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

using namespace std;

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

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

int main()
{
  ll a, b, c;
  cin >> a >> b >> c;
  ll res = 0;
  ll tmp1 = 0;
  ll tmp2 = 0;
  tmp1 = (a-1) / c + 1;
  tmp2 = b / c + 1;
  if(a == 0) tmp1 = 0;
  if(b == 0)tmp2 = 1;
  res = tmp2 - tmp1;
  cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a, b, ans;
 
    cin >> a >> b;
    if (b == 100) b++;
    
    if (a == 0) {
        cout << b << '\n';
        return 0;
    }
 
    cout << b;
    for (int i = 1; i <= a; i++) {
        cout << "00";
    }
    cout << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <string>

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

int main() {
	int n, r;

	cin >> n >> r;

	if (n < 10) {
		r += 100 * (10 - n);
	}

	cout << r;
	return 0;
}

Measured memory_bytes: 256
loop do
  line = gets

  break unless line

  a, b, c, d, e, f = line.split.map(&:to_f)

  det = a*e-b*d
  x = (e*c-b*f)/det ; y = (a*f-c*d)/det

  x = 0.0 if x == -0.0
  y = 0.0 if y == -0.0

  printf( "%.3f %.3f\n", x, y )
end

Measured memory_bytes: 8608
package main

import (
	"fmt"
	"sort"
)

func gcd(n, m int) int {
	if n%m == 0 {
		return m
	}
	return gcd(m, n%m)
}

func main() {
	var N, X int
	var x []int
	fmt.Scan(&N, &X)
	for i := 0; i < N; i++ {
		var tmp int
		fmt.Scan(&tmp)
		x = append(x, tmp)
	}
	x = append(x, X)
	sort.Ints(x)

	var diff []int
	for i := 1; i < N+1; i++ {
		diff = append(diff, x[i]-x[i-1])
	}
	if N == 1 {
		fmt.Println(diff[0])
	} else {
		res := gcd(diff[0], diff[1])
		for i := 2; i < N; i++ {
			res = gcd(res, diff[i])
		}
		fmt.Println(res)
	}
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
using pl = pair<ll,ll>;
signed main(){
	ll n,L; cin >> n >> L;
	ll sum=0;
	vl a(n); rep(i,0,n)cin >> a[i];
	rep(i,1,n){
		if(a[i]+a[i-1]>=L){
			cout<<"Possible"<<endl;
			rep(j,0,i-1)cout<<j+1<<endl;
			for(ll j = n-1; j>= i; --j)cout<<j<<endl;
			return 0;
		}
	}
	cout<<"Impossible"<<endl;



	return 0;
}

Measured memory_bytes: 3992
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<algorithm>

using namespace std;

int main() {
	int a, b, c, m, r;
	cin >> a >> b >> c;
	m = max(a, max(b, c));
	a = m - a;
	b = m - b;
	c = m - c;
	r = a % 2 + b % 2 + c % 2;
	cout << a / 2 + b / 2 + c / 2 + (!!r)*(3-r) << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

mod = 10**9 + 7
ans = 0
two = 1
for i in range(61):
    one = 0
    for j in range(n):
        if (a[j] >> i) & 1:
            one += 1
    ans = (ans + (one*(n-one))*two) % mod
    two = (two * 2) % mod
print(ans)

Measured memory_bytes: 124320
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, X);
    ll x = 100;
    ll i;
    for (i = 0; x < X; ++i)
    {
        x += x / 100;
    }
    OUT(i);
}

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

int main(){
 string a,b,c;
cin>>a>>b>>c;
a.at(0)=toupper(a.at(0));
  b.at(0)=toupper(b.at(0));
     c.at(0)=toupper(c.at(0));
 

    cout<<a.at(0)<<b.at(0)<<c.at(0)<<endl;

}


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

int main(){
    int n,b,f,r,v;
    int a[4][3][10];
    cin>>n;
    for(int i=0;i<4;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<10;k++){
                a[i][j][k]=0;
            }
        }
    }
    for(int i=0;i<n;i++){
        cin>>b>>f>>r>>v;
        a[b-1][f-1][r-1]+=v;
    }
    for(int i=0;i<4;i++){
        if(i>0)cout<<"####################"<<'\n';
        for(int j=0;j<3;j++){
            for(int k=0;k<10;k++){
                cout<<' '<<a[i][j][k];
            }
            cout<<'\n';
        }
    }
}


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

int main()
{
	string number;
	int i;
	int ans;

	while (1) {
		cin >> number;

		ans = 0;
		for (i = 0; i < number.size(); i++) {
			ans += number[i] - '0';
		}
		if (ans == 0)break;

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




Measured memory_bytes: 3164
#include "bits/stdc++.h"
#define double long double
#define int long long
#define low lower_bound
#define upp upper_bound
#define mod 1e9+7
#define inf 1e16
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define vsort(vec) sort(all(vec));
#define vrever(vec) reverse(all(vec));
#define vunsort(vec) vsort(vec); vrever(vec);
#define bisea binary_search
#define cend cout<<endl;
#define P pair<int,int>
#define prique priority_queue<p,vector<P>,greater<P>>
using namespace std;
signed main() {
	int n;
	cin>>n;
	int t=0,x=0,y=0;
	bool can=true;
	rep(i,n) {
		int a,b,c;
		cin>>a>>b>>c;
		if((abs(b-x)+abs(c-y))<=(a-t)&&(a-t)%2==(abs(b-x)+abs(c-y))%2) {
			x=b;
			y=c;
			t=a;
		}
		else {
			can=false;
			break;
		}
	}
	if(can) {
		cout<<"Yes"<<endl;
	}
	else {
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    static Scanner sc;
    static List<List<Integer>> t;
    static boolean[] visited;
    static boolean[] grey;
    static int[] prev;
    static List<Integer> shortestCycle;
    public static void main(String[] args) {
        sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        t = new ArrayList<List<Integer>>(N);
        for(int i = 0; i <= N; i++) {
            t.add(new ArrayList<Integer>());
        }

        for(int i = 0; i < M; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            t.get(a).add(b);
        }
        visited = new boolean[N+1];
        grey = new boolean[N+1];
        prev = new int[N+1];

        for(int i = 1; i <= N; i++) {
            dfs(i);

            visited = new boolean[N+1];
            grey = new boolean[N+1];
            prev = new int[N+1];
        }
        if(shortestCycle != null) {
            System.out.println(shortestCycle.size());
            for(int l: shortestCycle) {
                System.out.println(l);
            }
        } else {
            System.out.println("-1");
        }
    }

    static void dfs(int s) {
        grey[s] = true;
        for(int i : t.get(s)) {
            if(!visited[i]) {
                if(grey[i]) {
                    List<Integer> lst = new ArrayList<>();
                    int tmp = s;
                    while(tmp != i) {
                        lst.add(tmp);
                        tmp = prev[tmp];
                    }
                    lst.add(i);
                    if(shortestCycle == null || lst.size() < shortestCycle.size()) {
                        shortestCycle = lst;
                    }
                } else {
                    prev[i] = s;
                    dfs(i);
                }
            }
        }
        visited[s] = true;
    }
}

Measured memory_bytes: 272344
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>
#include <complex>
#include <iostream>
#include <iterator>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int n;
vi w, s;
int array[10];

int best;
int bestarray[10];

void solve(int g, int st, int k)
{
	if(g >= best)
		return;
	
	if(k == n){
		best = g;
		copy(array, array+n, bestarray);
		return;
	}
	
	reep(i, k, n){
		if(st >= w[array[i]]){
			swap(array[k], array[i]);
			solve(g+(k+1)*w[array[k]], min(st-w[array[k]], s[array[k]]), k+1);
			swap(array[k], array[i]);
		}
	}
}

int main()
{
	while(scanf("%d", &n), n){
		vector<string> f(n);
		w.resize(n);
		s.resize(n);
		rep(i, n){
			char name[32];
			scanf("%s%d%d", name, &w[i], &s[i]);
			f[i] = name;
		}
		
		best = 100000000;
		rep(i, n)
			array[i] = i;
		solve(0, 10000000, 0);
		rep(i, n){
			puts(f[bestarray[i]].c_str());
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;

long long gcd(long long a,long long b){
  if(a%b==0){
    return(b);
  }
  else{
    return gcd(b,a%b);
  }
}

int main(){
  long long N,A1,A2;
  cin>>N;
  cin>>A1;
  for(int i=1;i<N;++i){
    cin>>A2;
    A1=gcd(A1,A2);
  }
  cout<<A1<<"\n";
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int a[100005], check[100005];
int main() {
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	if ((n - k) % (k - 1) != 0) {
		cout << (n - k) / (k - 1) + 2 << endl;
	}
	else {
		cout << (n - k) / (k - 1) + 1 << endl;
	}
	return 0;
}




Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  string s;
  cin>>N>>s;
  for(int i=0;i<s.size();i++){
    s.at(i) = (s.at(i) -'A' + N)%26 + 'A';
  }
  cout<<s<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <cstdlib>

using namespace std;

typedef long long ll;

int main()	{
  ll n, m;
  cin >> n >> m;
  unordered_map<ll, vector<ll>> x;
  for (ll i = 1; i <= n; i++)	{
    x[i] = vector<ll>();
  }
  ll a, b;
  for (ll i = 0; i < m; i++)	{
    cin >> a >> b;
    x[a].push_back(b);
    x[b].push_back(a); //check this out
  }
  bool reached = false;
  for (ll i = 0; i < x[1].size(); i++)	{
    if (find(x[x[1][i]].begin(), x[x[1][i]].end(), n) == x[x[1][i]].end())	{
      continue;
    }
    else	{
      reached = true;
      break;
    }
  }
  if (reached)	{
    cout << "POSSIBLE" << endl;
  }
  else	{
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}

Measured memory_bytes: 22204
def c_flip(N, M):
    if N == 1 and M == 1:
        ans = 1  # 1枚のカードが1回裏返される
    elif min(N, M) == 1:  # カードは1列に並んでいる
        # 両端のカードは2回、その他のカードは3回裏返される
        ans = max(N, M) - 2
    else:
        # 四隅は4回、その他の周上は6回、それ以外は9回裏返される
        ans = (N - 2) * (M - 2)
    return ans

N,M = [int(i) for i in input().split()]
print(c_flip(N, M))

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cmath>

int main(void) {
    int N,K;
    double prob = 0.0;

    std::cin >> N >> K;
    double log2K = ::log2(K);

    // 各目について勝てる確率を計算して足す
    for(int i = 0; i < N; i++) {
        // x * 2^n >= K より
        // n >= log2(K) - log2(x)
        // よって prob += 0.5 ^ min(n) 
        int n = std::ceil(log2K - ::log2(i+1));
        if(n <= 0)
            prob+=1;
        else
            prob += ::pow(0.5, n);
    }

    // 重みで割る
    prob /= (double)N;
    std::cout << std::setprecision(12) << prob << std::endl;

    return 0;
}


Measured memory_bytes: 256
N,K = input().split()
D =list(map(int,input().split()))
ans = []
a = int(N[0])
x = 0
b = 0
while b in D:
    b += 1
c = 2
while c in D:
    c += 1
y = 0
while a == int(N[x]) and x <= len(N)-1:
    while a in D and a <= 9:
        a += 1
    if  a == 10:
        y = x
        if 0 in D:
            a += b
        if 1 in D:
            if b != 0:
                a += (b-1)*10
            else:
                a += (c-1)*10
    ans.append(str(a))
    if a != int(N[x]):
        for i in range(len(N)-1-x):
            ans.append(str(b))
    elif x <= len(N)-2:
        x += 1
        a = int(N[x])
    else:
        a = int(N[x])-1
while y > 0:
    s = ans[y][0]
    t = ans[y][1]
    r = ans[y]
    ans[y] = t
    ans[y-1] = str(int(ans[y-1]) + 1)
    if int(ans[y-1]) in D:
        u = int(ans[y-1])
        while u in D:
            u += 1
            ans[y-1] = str(u)
    if ans[y-1] != "10":
        y = 0
    else:
        y -= 1
        ans[y] = r
print("".join(ans))

Measured memory_bytes: 9176
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	char a,b;
	scanf("%c %c",&a,&b);
	if(a=='H'&&b=='H'){
		cout<<"H";
	}
	else if(a=='H'&&b=='D'){
		cout<<"D";
	}
	else if(a=='D'&&b=='H'){
		cout<<"D";
	}
	else if(a=='D'&&b=='D'){
		cout<<"H";
	}
	return 0;
} 

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

int main(){
    int n;cin >> n;
    cout << n / 2 + n % 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_macros)]

#[allow(unused_imports)]
use std::cmp::{max, min};

#[allow(unused_imports)]
use proconio::{fastout, input};

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Isize1, Usize1};

macro_rules! chmin {
    ($a:expr,$b:expr) => {
        $a = {
            let tmp = $b;
            if ($a > $b) {
                $b
            } else {
                $a
            }
        }
    };
}

macro_rules! chmax {
    ($a:expr,$b:expr) => {
        $a = {
            let tmp = $b;
            if ($a < $b) {
                $b
            } else {
                $a
            }
        }
    };
}

macro_rules! rep{
    ($i:ident,$n:expr,$b:block)=>{
        for $i in 0..$n $b
    }
}

const LIM: usize = 3;

#[allow(non_snake_case)]
#[allow(unused)]
#[fastout]
fn main() {
    input! {
        H:usize,
        W:usize,
        K:usize,
    }

    let mut fld = vec![vec![0; W]; H];
    let mut dp = vec![vec![[0i64; LIM + 1]; W]; H];
    rep!(i, K, {
        input! {
            y:Usize1,
            x:Usize1,
            v:i32,
        }
        fld[y][x] = v;
    });
    dp[0][0][1] = fld[0][0] as i64;

    rep!(i, H, {
        rep!(j, W, {
            rep!(k, LIM + 1, {
                for (dy, dx) in [(1, 0), (0, 1)].iter() {
                    let ny = i + dy;
                    let nx = j + dx;
                    if ny == H || nx == W {
                        continue;
                    }
                    let nk = if (dy == &1) { 0 } else { k };
                    chmax!(dp[ny][nx][nk], dp[i][j][k]);
                    if nk + 1 <= LIM {
                        chmax!(dp[ny][nx][nk + 1], dp[i][j][k] + (fld[ny][nx] as i64));
                    }
                }
            });
        });
    });

    let mut ans = 0;
    rep!(k, LIM + 1, {
        chmax!(ans, dp[H - 1][W - 1][k]);
    });
    println!("{}", ans);
}


Measured memory_bytes: 321736
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, x[213] = {}, y[213] = {}, p[213] = {1}, z = 0;
    bool b[213][213] = {};
    cin >> n;
    for (int i = 1; i <= n; i++) p[i] = p[i - 1] * 2 % 998244353;
    for (int i = 1; i <= n; i++) cin >> x[i] >> y[i];
    for (int i = 1; i <= n; i++) for (int j = i + 1; j <= n; j++) if (!b[i][j]) {
        vector<int> c = {i, j};
        int w = 2;
        for (int k = j + 1; k <= n; k++) if ((x[i] - x[j]) * (y[i] - y[k]) == (y[i] - y[j]) * (x[i] - x[k])) w++, c.push_back(k);
        for (int k : c) for (int l : c) b[k][l] = 1;
        z = (z + p[w] - 1 - w) % 998244353;
    }
    cout << (p[n] - z - n + 998244352) % 998244353;
}


Measured memory_bytes: 3660
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
using namespace std;
int main(){
    int N;
    scanf("%d", &N);
    vector<vector<int> > f(N, vector<int>(10));
    for(int i = 0; i < N; i++){
        for(int j = 0; j < 10; j++){
            scanf("%d", &f[i][j]);
        }
    }

    vector<vector<int> > p(N, vector<int>(11));
    for(int i = 0; i < N; i++){
        for(int j = 0; j < 11; j++){
            scanf("%d", &p[i][j]);
        }
    }

    int max_profit = -1e11;
    for(unsigned int i = 1; i < pow(2, 10); i++){
        int profit = 0;
        for(int j = 0; j < N; j++){
            int cnt = 0;
            for(int k = 0; k < 10; k++){
                if(i >> k & (unsigned int) 1)
                    cnt += f[j][k];
            }
            profit += p[j][cnt];
        }
        max_profit = max(max_profit, profit);
    }
    printf("%d\n", max_profit);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
const ll MOD = 998244353;
const ll INF = 1e18;
const ll MAXN = 1e6+10;

ll N;
deque<ll> F,S;
ll c = 1;

void solve(ll x){
	// cout<<"Do "<<x<<'\n';
	if (x<=0)return;
	if (x%2==0){
		// Basically u wanna minus
		solve(x-1);
		F.push_front(c);
		S.pb(c);
		++c;
	}else{
		solve((x-1)/2);
		S.push_front(c);F.push_front(c);++c;
	}

}

int main(){
	cin>>N;
	solve(N);
	cout<<SZ(F)*2<<'\n';
	for (auto i : F)cout<<i<<' ';
	for (auto i : S)cout<<i<<' ';
}

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

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define clr(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
typedef pair<ll, ll> pii;
typedef vector< ll > vl;
typedef vector< pii > vpii;
const ll N= 1e5+55,mod = 1e9+7;
int main() {
// 	freopen("Task.in","r",stdin);freopen("Task.out","w",stdout);
	ll x,a,b,ans,xx,yy;
	sc(x);sc(a);sc(b);
	xx=abs(x-a);
	yy=abs(x-b);
	ans=min(xx,yy);
	if(ans==xx)printf("A\n");
	else printf("B\n");	
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <cstdio>
#include <cstdint>
using namespace std;
typedef int_fast64_t ll;

ll c, sd = -1, sc = -1, A, M;
constexpr uint32_t buff_size = 1 << 17;
char buff[buff_size], *ci = buff + buff_size, *ce = ci, ct;

inline char readchar() {
    if (ci == ce) {fread_unlocked(buff, 1, buff_size, stdin); ci = buff;}
    return *ci++;
}

inline ll readint() {
	A = 0;
	if (ci + 16 > ce) while ((ct = readchar()) > 47) A = (A << 3) + (A << 1) + ct - 48;
    else while ((ct = *ci++) > 47) A = (A << 3) + (A << 1) + ct - 48;
    return A;
}

int main() {
    M = readint();
    while(M--) {
        sd += readint() * readint();
        sc += A;
    }
    printf("%lld\n", sc + sd / 9);
	return 0;
}


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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    set<int> s;
    int a,b,c;
    cin >> a >> b >> c;
    s.insert(a);
    s.insert(b);
    s.insert(c);

    if (s.size() == 2) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

m = 0
aa = [0] * n
b = []

for i in range(n-1, -1, -1):
    t = sum(aa[i::i+1]) % 2
    if t != a[i]:
        m += 1
        aa[i] += 1
        b.append(i+1)

print(m)
print(*b)

Measured memory_bytes: 73948
#include<bits/stdc++.h>
using namespace std;
int main(){
  long int n,a,b;
  cin>>n>>a>>b;
  if(a%n==0||b%n==0)cout<<"OK\n";
  else if(a/n==b/n)cout<<"NG\n";
  else cout<<"OK\n";
}


Measured memory_bytes: 3624
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <queue>
# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
long long int a = 0, b = 0, c = 0, ans = 0, x = 0, y = 0, z = 0, n = 0, m = 0, maxy = 0, mini = 9999, counter = 0, endp = 0, checker = 0;

std::vector <char> vec{}, vecsec{}, vecth{};
long long int iremono[100001], sec[100001];
long long int iremono2[100001], check[100001];
std::vector<long long int>kinds{}, kaku{};
char maze[1000][1000];
int sx, sy;
int gx, gy;

int d[1000][1000];
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
bool okada = false, okada2 = false;
std::string output, output2, input, input2;
char rev[100001];


int ctoi(const char c) {
	if ('0' <= c && c <= '9') return (c - '0');
	return -1;
}
unsigned long long int LCM(unsigned long long int a, unsigned long long int b) {
	unsigned long long int i, j;
	i = a; j = b;
	while (true) {

		c = i % j;
		i = j;
		if (c != 0) {

			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int kaizyo(int k) {
	int sum = 1;
	for (int i = 1; i <= k; ++i)
	{
		sum *= i;
	}
	return sum;
}

int H, W;//はんい

int main()
{
	cin >> H >> W;
	string s;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> maze[j][i];
		}
	}
	using pint = pair<int, int>;
	queue<pint> que;

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (maze[j][i] == '#') {
				que.push(pint(j, i));
			}
		}
	}

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			d[j][i] = 0;
		}
	}
	
	
	while (que.size()) {
		pair<int, int> p = que.front();
		que.pop();
		/*		if (p.first == gy && p.second == gx) {
					break;
				}*/
		for (int i = 0; i < 4; i++) {
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if (0 <= nx && nx < W && 0 <= ny && ny < H && maze[nx][ny] != '#'&&d[nx][ny] == 0) {
				que.push(pair<int, int>(nx, ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
	int res = 0;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			res = std::max(res, d[j][i]);
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 14480
#include	<bits/stdc++.h>
using	namespace	std;
main(){
	int N;
	string S;
	cin>>N>>S;
	int U=0;
	for (int i=2;i<N;i++) {
		int T=0;
		for (int j=0;i+j<N;j++)
			if (S[j]==S[j+i]) U=max(U,min(i, ++T));
			else T=0;
	}
	cout<<U;
}



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

int main(){
    long long n,x;
    cin>>n>>x;
    long long a[n],i,c=0;
    for(i=0;i<n;i++)    
        cin>>a[i];
    for(i=0;i<n-1;i++){
        if(a[i]+a[i+1]>x){
            long long del=a[i]+a[i+1]-x;
            c+=del;
            if(del<=a[i+1])
                a[i+1]-=del;
            else{
                a[i]=a[i]-(del-a[i+1]);
                a[i+1]=0;
            }
        }
    }
    if(c==0)
        cout<<0;
    else
        cout<<c;
}

Measured memory_bytes: 1024
n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))
l = [v[i]/c[i] for i in range(n)]
x,y=0,0
for k,i in enumerate(l):
    if i>=1:
        x+=v[k]
        y+=c[k]
print(x-y)

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,H,W; cin>>N>>H>>W;
    cout<<(N-H+1)*(N-W+1)<<"\n";
    return 0;
}


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

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> height(N);
  for (int i; i < N; i++) {
    cin >> height.at(i);
  }
  vector<bool> ok(N, true);
  for(int i;i<M;i++) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    if(height.at(a) > height.at(b)){
      ok.at(b) = false;
    } else if(height.at(a) < height.at(b)) {
      ok.at(a) = false;
    } else if(height.at(a) = height.at(b)) {
      ok.at(a) = false;
      ok.at(b) = false;
    }
  }
  int ans = 0;
  for(int i; i < N; i++) {
    if(ok.at(i)) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3788
#include<iostream>
#include<vector>
#include<functional>
#include<algorithm>
#include<cmath>
using namespace std;

int main()
{
	long long w;
	int n;
	cin>>n>>w;
	int v=0;
	long long dp[101][100001];//i,vを満たす最小重量100001
	dp[0][0]=0;
	long long item[2][101];
	for(int i=0;i<n;i++){
		cin>>item[0][i+1]>>item[1][i+1];
		v+=item[1][i+1];
	}
	for(int i=1;i<=v;i++)
	{
		dp[0][i]=99999999999999;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=v;j++)
		{
			dp[i][j]=min(dp[i-1][j],j-item[1][i]>=0?dp[i-1][j-item[1][i]]+item[0][i]:99999999999999);
		}
	}
	long long ans=0;
	for(int i=v;i>=0;i--)
	{
		if(w>=dp[n][i])
			{
				cout<<i<<endl;
				break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 79104
N = int(input())
P = [list(map(int, input().split())) for _ in range(N)]
ans = 0
c = 0

def dfs(i, dis, passed):
    if len(passed) == N:
        global c, ans
        c += 1
        ans += dis
        return
    x = P[i][0]
    y = P[i][1]
    for ii in range(N):
        if P[ii] in passed:
            continue
        xx = P[ii][0]
        yy = P[ii][1]
        passed.append([xx, yy])
        dfs(ii, dis + ((x - xx)**2 + (y - yy)**2)**0.5, passed)
        passed.pop(-1)

for i in range(N):
    dfs(i, 0, [P[i]])
print(ans / c)

Measured memory_bytes: 3188
def Main(X, Y, A, B, C, p, q, r):
    p.sort()
    q.sort()
    r.sort()
    ans = 0
    p = p[-X:]
    q = q[-Y:]
    wa = X+Y
    for i in range(wa):
        if(len(r) and len(p) and len(q)):
            if p[-1] < r[-1] and q[-1] < r[-1]:
                ans += r.pop()
            elif p[-1] < q[-1]:
                ans += q.pop()
            else:
                ans += p.pop()
        elif(len(r) == 0 and len(p) and len(q)):
            if p[-1] < q[-1]:
                ans += q.pop()
            else:
                ans += p.pop()
        elif(len(r) and len(p)==0 and len(q)):
            if q[-1] < r[-1]:
                ans += r.pop()
            else:
                ans += q.pop()
        elif(len(r) and len(p) and len(q)==0):
            if p[-1] < r[-1]:
                ans += r.pop()
            else:
                ans += p.pop()
        elif(len(r)==0 and len(p)==0 and len(q)):
            ans += q.pop()
        elif(len(r)==0 and len(p) and len(q)==0):
            ans += p.pop()
        elif(len(r) and len(p)==0 and len(q)==0):
            ans += r.pop()
    return ans
def main():
    X, Y, A, B, C = map(int, input().split())
    p = list(map(int, input().split()))
    q = list(map(int, input().split()))
    r = list(map(int, input().split()))
    print(Main(X, Y, A, B, C, p, q, r))

if __name__ == '__main__':
    main()

Measured memory_bytes: 23328
#include<stdio.h>
int main()
{
	int h,m,s,H,M,S,hr,mr,sr,g,gr,r;
	for(int i=0;i<3;i++){
		scanf("%d%d%d%d%d%d",&h,&m,&s,&H,&M,&S);
		g=h*3600+m*60+s;
		gr=H*3600+M*60+S;
		r=gr-g;
		hr=r/3600;
		mr=r%3600/60;
		sr=r%3600%60;
		printf("%d %d %d\n",hr,mr,sr);
	}
	return 0;
}

Measured memory_bytes: 2760
/*
ID: varunra2
LANG: C++
TASK: faceunhappy
*/
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits.h>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>

using namespace std;

#define EPS 1e-9
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert(B <= A && A <= C)
#define INF (int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))
#define MOD 1000000007
#define MP make_pair
#define PB push_back
#define PI 3.1415926535897932384626433832795
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()

typedef pair<int, int> PII;
typedef vector<int> VI;

const double pi = acos(-1.0);
typedef long int int32;
typedef long long int int64;
typedef map<int, int> MPII;
typedef multiset<int> MSETI;
typedef set<int> SETI;
typedef set<string> SETS;
typedef unsigned long int uint32;
typedef unsigned long long int uint64;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef vector<string> VS;

#define watch(x) cerr << (#x) << " is " << (x) << endl
#define printvii(v)                                    \
  cerr << (#v) << "=";                                 \
  for_each(v.begin(), v.end(), [](PII i) -> void {     \
    cerr << "(" << i.first << "," << i.second << "),"; \
  });                                                  \
  cerr << endl;
#define printvi(v)                                                       \
  cerr << (#v) << "=";                                                   \
  for_each(v.begin(), v.end(), [](int i) -> void { cerr << i << ","; }); \
  cerr << endl;

int main(int argc, char const *argv[]) {

  int n, k;
  cin >> n >> k;

  string s;
  cin >> s;

  int good = 0;

  for(int i = 1; i < n; i++) {
    if(s[i] == s[i - 1]) good++;
  }

  cout << min(n - 1, good + 2*k) << endl;

  return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

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

        int a = scan.nextInt();
        int b = scan.nextInt();

        int answer = a * b;
        if(answer % 2 == 0){
            System.out.println("Even");
        }else{
            System.out.println("Odd");
        }

	}

}


Measured memory_bytes: 21844
use std::io;
use std::collections::HashSet;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut s:Vec<char> = buf.trim().chars().collect();
	s.sort();
	
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut t:Vec<char> = buf.trim().chars().collect();
	t.sort();
	let t2 = t.clone();
	let iter = t2.iter().rev();
	t = Vec::new();
	for i in iter {
		t.push(*i);
	}
	
	let mut s1 = String::new();
	s1 = format!("{}", s[0]);
	for i in 1..s.len() {
		s1 = format!("{}{}", s1, s[i]);
	}
	let mut t1 = String::new();
	t1 = format!("{}", t[0]);
	for i in 1..t.len() {
		t1 = format!("{}{}", t1, t[i]);
	}
	
	if s1 < t1 {
		println!("Yes");
	}else{
		println!("No");
	}
	/*
	let mut sind = HashSet::new();
	let mut tind = HashSet::new();
	for i in 0..s.len() {
		for j in 0..t.len() {
			if s[i] == t[j] {
				if tind.insert(j) {
					sind.insert(i);
					break;
				}
			}
		}
	}
	
	let mut s2:Vec<char> = Vec::new();
	let mut t2:Vec<char> = Vec::new();
	for i in 0..s.len() {
		if sind.insert(i) {
			s2.push(s[i]);
		}
	}
	for i in 0..t.len() {
		if tind.insert(i) {
			t2.push(t[i]);
		}
	}
	
	if s2.len() == 0 && t2.len() > 0 {
		println!("Yes");
	}else if s2.len() > 0 && t2.len() == 0 {
		println!("No");
	}else if s2.len() == 0 && t2.len() == 0 {
		println!("No");
	}else{
		s2.sort();
		t2.sort();
		if s2[0] < t2[t2.len() - 1] {
			println!("Yes");
		}else{
			println!("No");
		}
	}
	*/
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(a) int((a).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

#define _deb(x) cout<<x;
void _print() {cerr << "]\n";} template <typename T, typename... V>void _print(T t, V... v) {_deb(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
template <class T, class U> void print_m(const map<T,U> &m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}
template<class T, class U>void debp(const pair<T, U> &pr, bool end_line=1){cout<<"{"<<pr.first<<" "<<pr.second<<"}"; cout<<(end_line ? "\n" : ", ");}
template <class T> void print_vp(const T &vp, int sep_line=0){if(vp.empty()){cout<<"Empty"<<endl; return;}if(!sep_line) cout<<"{ ";for(auto x: vp) debp(x,sep_line);if(!sep_line) cout<<"}\n";cout<<endl;}
template <typename T>void print(const T &v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<sz(v); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<endl;}
template <typename T>void print_vv(const T &vv){if(sz(vv)==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<sz(*vv.begin()); j++)cout<<setw(w)<<j<<" ";cout<<endl;int i = 0;for(auto &v: vv){cout<<i++<<" {";for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<"},\n";}cout<<endl;}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    while(cin>>n){
        vi a(n);
        int xr = 0;
        forn(i,n){
            cin>>a[i];
            xr^=a[i];
        }
        
        forn(i,n){
            cout<<(a[i]^xr)<<" ";
        }
        cout<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
long int sub(long int a){
  if(a<=1){
    return 1;
  }
  long int b=1,c=a;
	while(c){
      b=b*2;
      c=c/2;
    }
  return b/2+sub(a/2);
}
int main() {
 long int H,A,count,o=0;
  cin>>H;
	cout<<sub(H);
}

Measured memory_bytes: 256
#include<stdio.h>
const int MAX_V=1000000;
int main() {
	int i,k,n,mini=0,big=0,prime[MAX_V+1];
	for(i=2;i<=MAX_V;i++) {
		prime[i]=1;
	}
	for(i = 2; i*i <= MAX_V; i++) { 
		if(prime[i]) {
			for(k = 2 * i; k <= MAX_V; k += i) {
				prime[k] = 0;
			}
		}
	}
	while(1) {
		scanf("%d", &n);
		if(n==0) break;
		for(i=3;i<=n-2;i+=2) {
			if(prime[i]==1 && prime[i+2]==1) {
				if(i+2>big) {
					mini=i; big=i+2;
				}
			}
		}
		printf("%d %d\n",mini,big);
	}
	return 0; 
}

Measured memory_bytes: 5584
//2020-07-31
#include <bits/stdc++.h>
using namespace std;
#define loop(v, st, en) for (int v = st; v < en; v++)
#define loopdesc(v, st, en) for (int v = st; v >= en; v--)
#define INF 1E9
#define clr(v, d) memset(v, d, sizeof(v))
#define P(x) cout << #x << " = { " << x << " }\n"
#define PI acos(-1)

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
const int M = 2e5 + 5;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    loop(i, 0, k)
    {
        if (b <= a)
            b *= 2;
        else if (c <= b)
            c *= 2;
        
        // else a*=2;
    }
    if (c > b && b > a)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}

Measured memory_bytes: 3540
#include<string>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
using namespace std;
char n,m;//在外面设置，值为0
int main()
{
    cin>>n>>m;
    if(n<m)//如果情况是小于
    {
    	cout<<"<";//输出小于号
    	return 0;
    }
    if(n==m)//如果情况是等于
    {
    	cout<<"=";//输出等号
        return 0;
    }
    if(n>m)//如果情况是大于
    {
    	cout<<">";//输出大于号
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define mp make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define LLINF (1<<60)
#define MOD 1000000007
#define rep(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

ll gcm(ll n, ll m) {
    if (n < m)swap(n, m);
    ll r = n % m;
    while (r != 0) {
        n = m;
        m = r;
        r = n % m;
    }
    return m;
}

ll lcm(ll n, ll m) {
    ll x = n * m;
    ll t=gcm(n, m);
    return x / t;
}

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

    ll n, m;
    string s, t;
    cin >> n >> m >> s >> t;
    if (n < m) {
        swap(n, m);
        swap(s, t);
    }
    if (n == m) {
        if (s == t)cout << n << endl;
        else cout << "-1" << endl;
    }
    else if (n%m == 0) {
        bool flag = true;
        for (ll i = 0; i < m; i++) {
            if (s[0 + i * (n / m)] != t[0 + i]) {
                cout << "-1" << endl;
                flag = false;
                break;
            }
        }
        if(flag) cout << n << endl;
    }
    else {
        ll ncycle = lcm(n, m) / n;
        ll mcycle = lcm(n, m) / m;
        ll cyclelcm = lcm(ncycle, mcycle);
        ll LCM = lcm(n, m);
        bool flag = true;
        for (ll i = 0; i < LCM / cyclelcm; i++) {
            if (s[0 + i * mcycle] != t[0 + i * ncycle]) {
                cout << "-1" << endl;
                flag = false;
                break;
            }
        }
        if (flag) cout << LCM << endl;
    }
    return 0;
}


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

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

    int C, D;
    cin >> C >> D;

    if(A*B > C*D) cout << A*B << endl;
    else if(A*B == C*D) cout << A*B << endl;
    else cout << C*D << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int mod=1e9+7;
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    int n,m;
    cin>>n>>m;
    string s[n];
    for(int i=0;i<n;i++)
        cin>>s[i];
    int dp[n+1][m+1];
    for(int i=0;i<=n;i++)
        dp[i][0]=0;
    for(int j=0;j<=m;j++)
        dp[0][j]=0;
    int val;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            val=0;
            if(i!=1 && s[i-2][j-1]=='.')
                val+=dp[i-1][j];
            if(j!=1 && s[i-1][j-2]=='.')
                val+=dp[i][j-1];
            if(s[i-1][j-1]=='#')
                dp[i][j]=0;
            else if(i==1 && j==1)
                dp[i][j]=1;
            else
                dp[i][j]=val%mod;
            //cout<<dp[i][j]<<" ";
        }
        //cout<<endl;
    }
    cout<<dp[n][m];
    return 0;
}

/*
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
*/


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


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


N = int(input())
lst_T = [int(input()) for _ in range(N)]


ans = 1
for t in lst_T:
    ans = lcm(ans, t)


print(ans)

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int H,W,N;
    Scd3(H,W,N);
    H = max(H,W);

    printf ("%d\n", (N+H-1)/H );

    return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x1 = sc.nextInt();    
    int y1 = sc.nextInt();
    int x2 = sc.nextInt();
    int y2 = sc.nextInt();
    
    int x3 = x2 - (y2 - y1);
    int y3 = y2 + (x2 - x1);
    int x4 = x1 - (y2 - y1);
    int y4 = y1 + (x2 - x1);
    System.out.println(x3 + " " + y3 + " " + x4 + " " + y4);
  }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 1e9 + 7;

int main(){
	ll n,k;
	cin >> n >> k;
	ll m = (((k + 1) * k ) / 2 ) % N;
	ll p = ((k * (k-1)) / 2 ) % N;
	ll a[n];
	for(int i = 0;i < n;i++) scanf("%lld",&a[i]);
	ll cnt = 0;
	for(int i = 0;i < n;i++){
		ll sum = 0;
		ll ans = 0;
		for(int j = i+1;j < n;j++){
			if(a[i] > a[j]) sum++;
		}
		sum %= N;
		cnt += (sum * (m % N)) % N;
		for(int j = i-1;j >= 0;j--){
			if(a[i] > a[j]) ans++;
		}
		ans %= N;
		cnt += (ans * (p % N)) % N;
//		cout << cnt % N<< endl;
	}
	cout << cnt % N<< endl;
	return 0;
}

Measured memory_bytes: 256
import queue
import math


def warshall(graph, n):
    for i in range(n):
        graph[i][i] = 0

    for k in range(n):
        for i in range(n):
            for j in range(n):
                graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j])

    return graph


def main():
    n, m = map(int, input().split())
    graph = [[float('inf') for _ in range(n)] for _ in range(n)]

    for _ in range(m):
        data = list(map(int, input().split()))

        graph[data[0]][data[1]] = data[2]

    dist = warshall(graph, n)

    for i in range(n):
        if dist[i][i] < 0:
            print("NEGATIVE CYCLE")
            return

    for i in range(n):
        for j in range(n):

            if j == 0:
                print(dist[i][j] if dist[i][j] != float('inf') else 'INF', end="")
            else:
                print(' {}'.format(dist[i][j] if dist[i][j] != float('inf') else 'INF'), end="")

        print()

    return


if __name__ == '__main__':
    main()



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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define per(i,n) for(int i = n; i >= 0; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }

const ll mod = 998244353;


long long Modpow(long long a, int n){
  if(n == 0) return 1;
  if(n%2 == 0){
    long long res = Modpow(a, n/2);
    return res * res % mod;
  }
  return a * Modpow(a, n-1) % mod;
}

int inv(int n) { // 逆元
  return Modpow(n, mod-2);
}

struct Combination { 
  vector<long long> fact, ifact;
  Combination(int n):fact(n+1), ifact(n+1) {
    fact[0] = 1;
    for(long long i = 1; i <= n; i++) fact[i] = fact[i-1]*i % mod;
    ifact[n] = inv(fact[n]);
    for(long long i = n; i >= 1; i--) ifact[i-1] = ifact[i]*i % mod;
  }
  long long operator()(int n, int k) { // modcom (nCk % mod)
    if(k < 0 || k > n) return 0;
    return ((fact[n] * ifact[k]) % mod * ifact[n-k]) % mod;
  }
};



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

  ll n, m, k;
  cin >> n >> m >> k;
  ll ans = 0;
  Combination com(n);
  rep(i,k+1) {
    ll tmp = com(n-1,i);
    tmp = tmp * m % mod;
    tmp = tmp * Modpow(m-1, n-i-1) % mod;
    ans += tmp;
    ans %= mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 6352