akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <utility>

using namespace std;

int main()
{
//    freopen("1.txt","r",stdin);

    long long a,b,n;
    while(~scanf("%lld",&n))
    {
        bool vis = true;
        long long minn = 0x3f3f3f3f;
        long long ans = 0;
        for(int i=0; i<n; i++)
        {
            scanf("%lld%lld",&a,&b);
            if (a != b)
            {
                vis = false;
            }
            if (b < a)
                minn = min(minn,b);
                ans += b;
        }
        if (vis)
            puts("0");
        else
            printf("%lld\n",ans-minn);
    }



//    fclose(stdin);
    return 0;
}



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

A = []
total = 0
for i in range(N):
    n = a[i]
    total = bin(total ^ n)
    total = int(total, 0)
    A.append(n)

result = []

for i in range(N):
    tmp = bin(total ^ A[i])
    m = int(tmp, 0)
    result.append(m)

print(*result)

Measured memory_bytes: 114836
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; i++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N,ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	ll N; cin >> N;
	vector<ll> X(N);
	rep(i, N)cin >> X[i];

	sort(ALL(X));

	ll mi = 100000000000;
	for (int P = X[0]; P <= X[N - 1]; P++) {
		ll tmp = 0;
		for (int j = 0; j < N; j++) {
			tmp += pow(X[j] - P, 2);
		}
		mi = min(tmp, mi);
	}

	cout << mi << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7,INF=1e18;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    // cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        vector<vector<double> > dp(n+1);
        vector<double> a(n+1);
        dp[0].resize(n+1,0);
        dp[0][0]=1;
        for(int i=1;i<=n;i++)
        {
            dp[i].resize(n+1,0);
            cin>>a[i];
        }
        for(int i=1;i<=n;i++)
        {
            for(int j=0;j<i;j++)
            {
                dp[i][j+1]+=dp[i-1][j]*a[i];
                dp[i][j]+=dp[i-1][j]*(1-a[i]);
            }
        }
        double ans=0;
        for(int i=n/2+1;i<=n;i++)
        ans+=dp[n][i];
        cout<<setprecision(18)<<fixed<<ans<<"\n";
    }
    return 0;
}

Measured memory_bytes: 73684
import java.io.*;
import java.util.*;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        long l = 1;
        for (int i = 0; i < N; i++) {
            l = lcm(l, in.l());
        }
        System.out.println(l);
    }

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

    static long gcd(long a, long b) {
        long r;
        while ((r = a % b) != 0) {
            a = b;
            b = r;
        }
        return b;
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    int i() {
        int k = next() - '0';
        boolean minus = k == -3;
        int n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        int k = next() - '0';
        boolean minus = k == -3;
        long n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    char[] s(final int N) {
        char[] s = new char[N];
        for (int i = 0; i < N; i++) {
            s[i] = next();
        }
        next();
        return s;
    }

    public int read(char[] cbuf) {
        int i;
        char c;
        for (i = 0; (c = next()) != ' ' && c != '\n'; i++) cbuf[i] = c;
        return i;
    }

    public String readLine() {
        try {
            return super.readLine();
        } catch (IOException e) {
            return null;
        }
    }
}


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

int main(){
   string s;
   int a[30]={};
   cin>>s;
   for(int i=0;i<s.size();i++){
       a[s[i]-'a']++;
   }
   int i=0;
   while(a[i]>=1){
       i++;
   }
   if(i>=26){
       cout<<"None"<<endl;
   }else{
       cout << char('a' + i) << endl;
   }
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>

typedef long long ll;

using namespace std;

int main() {
    int cnt = 0;
    int size;
    string str;
    cin >> str;

    size = str.length();

    for (int i = 0; i < size; i++) {
        if (((i+1) % 2) == 0) {
            if (str[i] == 'L' || str[i] == 'D' || str[i] == 'U') {
                cnt++;
            } 
        } else {
            if (str[i] == 'R' || str[i] == 'D' || str[i] == 'U') {
                cnt++;
            }
        }
    }

    if (cnt == size) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<vector>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*
h w
a11 .. a1w
..
ah1 .. ahw
 */

int h,w;
char a[100][100];

int main(){
  cin>>h>>w;
  REP(i,h){
    REP(j,w){
      cin>>a[i][j];
    }
  }

  set<int> white_row, white_col;
  
  REP(i,h){
    bool all_white = true;
    REP(j,w){
      all_white = all_white && (a[i][j] == '.');
    }
    if(all_white) white_row.insert(i);
  }

  REP(j,w){
    bool all_white = true;
    REP(i,h){
      all_white = all_white && (a[i][j] == '.');
    }
    if(all_white) white_col.insert(j);
  }

  REP(i,h){
    REP(j,w){
      if(white_row.count(i) == 0 && white_col.count(j) == 0)
        cout<< a[i][j];
    }
    cout<<endl;
  }
  

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for(int i = (s); i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
typedef long long ll;
const int INF = 1001001001;
const int mod = 1000000007;

int main() {
    int N;
    cin >> N;
    vector<int> v(N);
    rep(i, N) cin >> v[i];
    sort(v.begin(), v.end());
    cout << v[N / 2] - v[N / 2 - 1] << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define cs const
#define pb push_back
using namespace std;
cs int Mod = 998244353;
int add(int a, int b){ return a + b >= Mod ? a + b - Mod : a + b; }
int dec(int a, int b){ return a - b < 0 ? a - b + Mod : a - b; }
int mul(int a, int b){ return 1ll * a * b % Mod; }
void Add(int &a, int b){ a = add(a,b); }
void Dec(int &a, int b){ a = dec(a,b); }
void Mul(int &a, int b){ a = mul(a,b); }
int ksm(int a, int b){
	int ans = 1; for(;b;b>>=1, Mul(a,a))
	if(b&1) Mul(ans, a); return ans;
}
cs int N = 2e7 + 5;
int n, a, b, fc[N], ifc[N];
void fc_init(int n){
	fc[0] = fc[1] = ifc[0] = ifc[1] = 1; 
	for(int i = 2; i <= n; i++) fc[i] = mul(fc[i-1], i);
	ifc[n] = ksm(fc[n], Mod - 2);
	for(int i = n-1; i >= 2; i--) ifc[i] = mul(ifc[i+1], i+1);
}
int C(int n, int m){
	if(n < 0 || m < 0 || n < m) return 0;
	return mul(fc[n], mul(ifc[n-m], ifc[m]));
} int cat(int b, int c){ return dec(C(b + c, b), C(b + c, b + 1)); }
int main(){
	#ifdef FSYolanda
	freopen("1.in","r",stdin);
	#endif
	scanf("%d%d%d",&n,&a,&b);
	if(!a && !b) return puts("1"), 0;
	fc_init(n); int ans = 0;
	for(int c = 0,coe; c <= n-b; c++){
		coe=cat(b-1, c);
		if(n - b - c == 0){
			if(a == c) Add(ans, coe);
		} else{
			int x = n - b - c - 1;
			int y = a - c + 1;
			Add(ans, mul(coe, C(x + y - 1, y - 1)));
		}
	} cout << ans; return 0;
}

Measured memory_bytes: 81896
#include<iostream>
#include<string.h>

int main()
{
	char ring[11], str[11];
	int n;
	int ans = 0;
	std::cin >> ring >> n;
	
	while( n-- ){
		std::cin >> str;
		
		int i = 0, c = 0;
		
		while( i != 10 ){
			while( c != 10 && str[i] == ring[c] ){
				i = ( i + 1 ) % 10; 
				c++;
			}
			
			if( c == strlen( ring ) ){
				ans++;
				break;
			}
				
			i++;
		}
	}
	
	std::cout << ans << std::endl;

 	return 0;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#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 MOD = 1e9+7;

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; }
//C++17以上
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) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main() {
    ll a,b;cin >> a >> b;
    for(ll i=0;i<=1e9;i++){
        if(abs(a-i)==abs(b-i)){
            cout << i << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define MuhammedAly ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define popc(x) __builtin_popcount(x)
#define LLMX 1e18
#define NotinRange(n,m) i<0||i>=(n)||j<0||j>=(m)
#define mem(x,y) memset((x),(y),sizeof (x));
#define sz(a) (int)(a).size()
#define inFile(s) freopen((s),"r",stdin)
#define	outFile(s) freopen((s),"w",stdout)
#define biEdge(v, a, b) (v)[(a)].pb((b)), (v)[(b)].pb((a))
#define pi (2 * acos(0))
#define X real()
#define Y imag()
#define cross(a, b) ((conj(a) * (b)).Y)
#define dot(a, b) ((conj(a) * (b)).X)
#define vec(a,b) ((b) - (a))
#define ll long long
typedef long double ld;
typedef complex<double>point;
typedef tuple<int, int, int> line;
typedef pair<point, point>segment;
typedef vector<point>polygon;
const int N = 1e5 + 5, M = 50 + 5, OO = 0x3f3f3f3f, mod = 1e9 + 7, base = 131, mod2 = 1000136437, mod3 = 998244353;
const double EPS = 1e-9;
int n, a[N], b[N], c[N], memo[N][4];
int solve(int i, int lst)
{
    if(i == n)
        return 0;
    int &ret= memo[i][lst];
    if(~ret)
        return ret;
    ret = 0;
    if(lst != 0)
        ret = solve(i + 1, 0) + a[i];
    if(lst != 1)
        ret = max(ret, solve(i + 1, 1) + b[i]);
    if(lst != 2)
        ret = max(ret, solve(i + 1, 2) + c[i]);
    return ret;
}
int main()
{
    MuhammedAly
    mem(memo, -1);
    cin >> n;
    for(int i = 0 ; i < n ; i++)
        cin >> a[i] >> b[i] >> c[i];
    cout << solve(0, 3);
    return 0;
}

Measured memory_bytes: 6912
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

fn calc (v: usize, g: &Vec<Vec<usize>>, mut dp: &mut Vec<i32>) -> i32 {
    if dp[v] >= 0 {
        return dp[v];
    }
    let mut d = 0;
    for &u in &g[v] {
        let t = calc (u, &g, &mut dp) + 1;
        d = std::cmp::max (d, t);
    }
    dp[v] = d;
    d
}

fn run() {
    input! {
        n: usize,
        m: usize,
        e: [(usize, usize); m],
    }
    let mut g = vec![vec![]; n + 1];
    for (x, y) in e {
        g[x].push (y);
    }
    for i in 1..(n + 1) {
        g[0].push (i);
    }
    let mut dp = vec![-1; n + 1];
    let ans = calc (0, &g, &mut dp) - 1;
    println! ("{}", ans);
}

fn main() {
    run();
}


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

int main() {
  int n = 0, k = 0, temp = 0, ans = 1000000000;
  std::cin >> n >> k;
  
  std::vector<int> trees(n, 0);
  
  for (int i = 0; i < n; i++) {
    std::cin >> trees.at(i);
  }
  
  std::sort(trees.begin(), trees.end());
  
  for (int i = 0; i + k < n + 1; i++) {
    ans = std::min(ans, (trees.at(i + k - 1) - trees.at(i)));
    if(ans == 0) {
      std::cout << ans << std::endl;
      return 0;
    }
  }
  
  std::cout << ans << std::endl;
  
  return 0;
}


Measured memory_bytes: 640
string = input()
n = int(input())
for ser in range(n):
    order = list(input().split())
    op1 = int(order[1])
    op2 = int(order[2])
    if order[0] == 'print':
        print(string[op1: op2+1])
    elif order[0] == 'reverse':
        if op1 == 0:
            op11 = None
        else:
            op11 = op1-1
        string = string[:op1] + string[op2:op11:-1] + string[op2+1:]
#        print(string)
    elif order[0] =='replace':
        string = string[:op1] + order[3] +string[op2+1:]
#        print(string)
    

Measured memory_bytes: 7700
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
  int N, Y;
  cin >> N >> Y;
  int N10 = min((int)(Y / 10000), N);
  int N5 = min((int)(Y / 5000), N);
  for (int i = 0; i <= N10; ++i) {
    for (int j = 0; j <= N5; ++j) {
      int t = 10000 * i + 5000 * j + 1000 * (N - i - j);
      if (t == Y && N - i - j >= 0) {
        printf("%d %d %d\n", i, j, N - i - j);
        return 0;
      }
    }
  }
  printf("-1 -1 -1\n");
}

Measured memory_bytes: 3252
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, D;
  cin >> N >> D;
  
  int E = 2 * D + 1;
  
  if(N % E == 0){
    cout << N / E << endl;
  }else{
    cout << N/E + 1 << endl;
  }
  
}

Measured memory_bytes: 256
# 63 B - すぬけ君の塗り絵 2 イージー
W,H,N = map(int,input().split())

X = []
Y = []
A = []
for _ in range(N):
    x,y,a = map(int,input().split())
    x -= 1;y -= 1
    X.append(x)
    Y.append(y)
    A.append(a)

mtrx = [['.']*W for _ in range(H)]

for a,(x,y) in zip(A,zip(X,Y)):
    if a == 1:
        for i in range(H):
            for j in range(x+1):
                mtrx[i][j] = '#'
    if a == 2:
        for i in range(H):
            for j in range(x+1,W):
                mtrx[i][j] = '#'
    if a == 3:
        for i in range(y+1):
            mtrx[i] = ['#']*W
    if a == 4:
        for i in range(y+1,H):
            mtrx[i] = ['#']*W

ans = 0
for i in range(H):
    for j in range(W):
        if mtrx[i][j] == '.':
            ans += 1
print(ans)

Measured memory_bytes: 73832
'''
研究室PCでの解答
'''
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7

def main():
    x,y = map(int,ipt().split())

    #nCrをmodで割った余りを求める。Nに最大値を入れて使用。
    N = 7*10**5
    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] #逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル
    def cmb(n,r,mod=(10**9+7)):
        if r<0 or r>n :
            return 0
        r = min(r,n-r)
        return g1[n]*g2[r]*g2[n-r]%mod
    for i in range(2,N+1):
        g1.append((g1[-1]*i)%mod)
        inverse.append((-inverse[mod % i]*(mod//i))%mod)
        g2.append((g2[-1]*inverse[-1])%mod)


    if (2*x-y)%3 == 0 and 2*x-y >= 0 and (2*y-x)%3 == 0 and 2*y-x >= 0:
        print(cmb((x+y)//3,(2*x-y)//3))
    else:
        print(0)



    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 212400
open System.Linq

let n, d =
    stdin.ReadLine().Split()
    |> fun ary -> int64 ary.[0], int64 ary.[1]

seq {
    for _ in 1L .. n do
        stdin.ReadLine().Split()
        |> Array.map int64
        |> fun ary -> ary.[0], ary.[1]
}
|> fun sq -> sq.Count(fun (x, y) -> (pown x 2 + pown y 2) <= pown d 2)
|> printfn "%d"


Measured memory_bytes: 49252
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	ll x, y;
	cin >> x >> y;

	ll res = 0;
	ll v = x;
	while (x <= y) {
		x *= 2;
		res++;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
require 'prime'

# util functions
def gcd(arr) # arr: Array of non-negative integers
  if arr.size < 2
    raise "array (#{arr}) size is less than 2."
  end
  
  def gcd_two(a, b) # assume b <= a
    return a if b % a == 0
    return gcd_two(b % a, a)
  end

  g = arr[0]
  for i in 1..arr.size - 1 do
    g = gcd_two([g, arr[i]].min, [g, arr[i]].max)
  end
  return g
end


# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

aa = inputs[0][0]
bb = inputs[0][1]

gg = gcd([aa, bb])

# body
if $debugFlag
  p gg
end

gglst = gg.prime_division
puts gglst.size + 1


Measured memory_bytes: 2300
import Data.List

main = do
    -- r <- readLn -- 入力が一行に一文字の場合
    a <- map read . words <$> getLine -- 一行に入力が複数ある場合
    -- putStrLn $ show $ solve a b -- showの返り値がString型の場合
    -- putStrLn $ solve a b

    putStrLn $ show $ solve $ sort a -- showの返り値がString型の場合

solve :: [Int] -> Int
solve [a, b, _] = a + b


{-- その他 備忘録
    {{{ 型変換
       int 2 float: fromIntegral
       float 2 int: round
       int 2 string: show
    }}}

    {{{ モジュール
    Data.List: sort
    }}}
--}


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

signed main() {
  int n; cin >> n;
  int sum = 0;
  int a[n], sumA[110];
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
    sumA[i] = sum;
  }
  sum = 0;
  int b[n], sumB[110];
  for(int i = 0; i < n; i++) {
    cin >> b[i];
    sum += b[i];
    sumB[i] = sum;
  }

  int maxS = 0;
  for(int i = 0; i < n; i++) {
    maxS = max(maxS, sumA[i] + (i==0 ? sumB[n-1] : sumB[n-1]-sumB[i-1]));
  }
  cout << maxS << endl;
  return 0;
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
// #define M_PI 3.14159265358979323846 // CFでは定義しておく必要あり
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << "\n";
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"
// gcj print用
#define Case(x) printf("Case #%d: ", x);

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

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

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

void print() {
  cout << endl;
};

template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
};

template <class T>
void print(vector<T> &vec, ll k){
   ll n = vec.size();
   k = min(k, n);
   rep(i, 0, k-1) cout << vec[i] << " ";
   cout << vec[k-1] << endl;
};

template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
    print(vec);
  }
};

template<class T, class U>
void print(pair<T,U> &p){
  cout << p.first << " " << p.second << "\n";
};

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

  int a, b; cin >> a >> b;
  cout << (a+b) % 24 << endl;

  return 0;
};


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

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

    int ans = -1;
    rep(i, 0, s.size() + 1)
    {
        rrep(k, s.size(), s.size() - i - 1)
        {
            char c = s[k];
            bool is_ok = true;
            int cnt = i;

            rrep(j, k + 1, 0)
            {
                if (s[j] == c)
                    cnt = i;
                else
                    --cnt;
                
                if (cnt < 0)
                {
                    is_ok = false;
                    break;
                }
            }
            if (is_ok)
            {
                ans = i;
                break;
            }
        }
        if (ans >= 0) break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, a, b = map(int, readline().split())

    if (b - a - 1) % 2 == 0:
        print("Borys")
    else:
        print("Alice")


if __name__ == '__main__':
    main()


Measured memory_bytes: 61696
#include<bits/stdc++.h>
#define LLD long long int
#define For(a,b) for(int a=0;a<b;a++)
#define Str string
#define Pb push_buck

using namespace std;
typedef pair<int ,int> Pair;
int n,m,fin=0,f,f1;
LLD co[500],se[2000],co1[500],se1[2000];
LLD dif[500],dif1[500],dif2[2000][2000],dif21[2000][2000];
int main(){
    while(1){
    cin >> m;
    if(m==0)break;
    For(a,m)cin >> co[a] >> co1[a];
    cin >> n;
    For(a,n)cin >> se[a] >> se1[a];
    for(int a=1;a<m;a++){
    dif[a]=co[a]-co[0];
    dif1[a]=co1[a]-co1[0];
    //cout << dif[a]<< 'b';
    }
    For(a,n){
        For(x,m){
            For(b,n){
                if(se[a]+dif[x]==se[b]&&se1[a]+dif1[x]==se1[b])fin++;
                //else if(dif2[b][a]==dif[c]&&dif21[a][b]==dif1[c])fin++;
            }
        }if(fin>=m){
        f=se[a]-co[0];
        f1=se1[a]-co1[0];
        }//cout << fin << 'a';
        fin=0;
    }
    cout << f << ' ' << f1 << endl;
    }
return 0;
}

Measured memory_bytes: 1216
#include <stdio.h>

int main(){
  int n, p[100] = {0}, i, max, maxi;
  int sum;

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &p[i]);
  }

  max = p[0];
  maxi = 0;
  for (i = 0; i < n; i++) {
    if (max < p[i]) {
      max = p[i];
      maxi = i;
    }
  }

  sum = 0;
  for (i = 0; i < n; i++) {
    if (maxi == i) {
      sum += p[i] / 2;
    }
    else {
      sum += p[i];
    }
  }

  printf("%d\n", sum);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
	int n, a;
	cin >> n;
	vector<int> colors(9, 0);
	for (int i = 0; i < n; ++i) {
		cin >> a;
		if      (a <  400) ++colors[0];
		else if (a <  800) ++colors[1];
		else if (a < 1200) ++colors[2];
		else if (a < 1600) ++colors[3];
		else if (a < 2000) ++colors[4];
		else if (a < 2400) ++colors[5];
		else if (a < 2800) ++colors[6];
		else if (a < 3200) ++colors[7];
		else               ++colors[8];
	}
	int types = 0;
	//3200overを除いた種類数を求める
	for (int i = 0; i < 8; ++i) {
		if (colors[i] > 0) ++types;
	}
	//3200overは他の人に色を合わせられるため入っても種類数は増えない
	//ただし元の種類がゼロのときは何か一つ色を選ばざるをえないため１
	if (colors[8] > 0) {
		int min_types = (types > 0 ? types : 1);
		int max_types = types + colors[8];
		cout << min_types << " " << max_types << endl;
	}
	else {
		cout << types << " " << types << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
typedef priority_queue<int> p_queue;
typedef long long ll;
ll a,b;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>a>>b;
	if(a>b){
		for(int i=0;i<a;i++)cout<<b;
	}
	else for(int i=0;i<b;i++)cout<<a;
	return 0;
}


Measured memory_bytes: 256
fn main(){
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).unwrap();
	let vec: Vec<&str> = s.trim().split(' ').collect();
	let x: i32 = vec[0].parse().unwrap();
	let y: i32 = vec[1].parse().unwrap();
	let z: i32 = vec[2].parse().unwrap();
	if x % (y + z) == 0 || x % (y + z) < z {
		println!("{}", x / (y + z) - 1);
	} else {
		println!("{}", x / (y + z));
	}
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);

  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] = (a[i] + k - 1) % k;
  }

  vector<int> sum(n + 1);
  for (int i = 0; i < n; i++) {
    sum[i + 1] = (sum[i] + a[i]) % k;
  }

  map<int,int> cnt;
  long long ans = 0;
  for (int i = 0; i < n + 1; i++) {
    if (i - k >= 0) {
      cnt[sum[i - k]]--;
    }
    ans += cnt[sum[i]];
    cnt[sum[i]]++;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 11264
//
// Created by kuroneko on 2019-09-01.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>

using namespace std;

typedef long long ll;

#define INF 1000000000000009LL
#define MOD 1000000007LL

typedef int Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src, int dst, Weight weight):src(src), dst(dst), weight(weight) {}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

int main() {
    int N; cin >> N;
    vector<int> v(N);
    for (int i = 0; i < N; i++) cin >> v[i];

    int dp[N];
    for (int i = 0; i < N; i++) dp[i] = 0;

    for (int i = N-2; i >= 0; i--) {
        if (v[i] >= v[i+1]) dp[i] = dp[i+1] + 1;
    }
    
    int res = 0;
    for (int i = 0; i < N; i++) {
        if (dp[i] > res) res = dp[i];
    }
    
    cout << res << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef double db; 
typedef string str;
 
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
 
typedef vector<int> vi; 
typedef vector<bool> vb; 
typedef vector<ll> vl; 
typedef vector<db> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
 
#define sz(x) (int)(x).size()
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define sor(x) sort(all(x))
#define ins insert 
#define ft front() 
#define bk back()
#define pf push_front 
#define pb push_back
#define endl '\n'
 
const ll MOD = 1e9+7; // 998244353;
const ll INF = 1e18;
 
int main() {
   ios_base::sync_with_stdio(false); cin.tie(nullptr);
   str s; cin >> s;
   cout << (s.bk == 's' ? s + "es" : s + 's');
   return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define BOOST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ll long long
#define test(t) int t ; cin>>t ; while(t--)
ll mulmod(ll a, ll b, ll mod){ll res = 0;a = a % mod;while (b > 0){if (b % 2 == 1)res = (res + a) % mod;a = (a * 2) % mod;b /= 2;}return res % mod;}
ll n;
int main(){
    BOOST;
    cin >> n;
    ll ans = 0 ;
    ll arr[n];
    // ll sum = 0;
    for(int i = 0 ; i < n ; ++i){
        cin >> arr[i];
        // sum += arr[i];
    }
    for(int i = 0 ; i < n ; ++i){
        arr[i] = arr[i] - (i+1);
        // cout << arr[i] << " ";
    }
    sort(arr,arr+n);
    
    // cout << endl;
    int b = arr[n/2];
    // cout << b;
    for(int i = 0 ; i < n ; ++i){
        ans += abs(arr[i]-b);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1792
// atcoder/m-solutions2020/D/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int n;
  while (cin >> n) {
    vec<lli> a(n);
    cin >> a;

    const int N = 80 + 2;
    static lli dp[N];
    fill(dp, dp + N, -(1LL << 60));
    dp[0] = 1000;

    for (int i = 0; i < n; ++i) {
      if (dp[i] < 0) continue;
      for (int j = i; j < n; ++j) {
        // i日目の所持金dp[i]
        // j日目に全て株に変える
        lli t = dp[i] / a[j];
        for (int k = j + 1; k < n; ++k) {
          // k日目に全て金に変える
          setmax(dp[k + 1], a[k] * t + (dp[i] % a[j]));
        }
      }
    }
    lli mx = *max_element(dp, dp + N);
    cout << mx << endl;
  }

  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define nl "\n"
#define pb push_back
#define sp " "
typedef long long ll;

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a , b , c;
    cin >> a >> b >>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<sp<<b<<sp<<c<<nl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int N = sc.nextInt();
			int R[] = new int[N];
			int sum = 0;
			for (int i = 0; i < N; i++) {
				int temp = sc.nextInt();
				R[i] = temp;
				sum += temp;
			}
			int av = sum / N;
			long ans = 0;
			long ano = 0;
			for (int i = 0; i < N; i++) {
				ans += (R[i] - av) * (R[i] - av);
				ano += (R[i] - av - 1) * (R[i] - av - 1);
			}
			System.out.print(Math.min(ano, ans));
		}
	}
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
int main()	{
  int n,l;
  cin>>n>>l;
  vector<string>str(n);
  rep(i,n){
    cin>>str[i];
  }
  sort(str.begin(),str.end());
  string s;
  rep(i,n){
    s+=str[i];
  }
  cout<<s<<endl;
}

Measured memory_bytes: 256
N=int(input())
S=input()
if N%2!=0:
  print("No")
else:
  half=N//2-1
  T1=[]
  T2=[]
  for i in range(half+1):
    T1.append(S[i])
  for j in range(half+1,len(S)):
    T2.append(S[j])
  if T1==T2:
      print("Yes")
  else:
      print("No")


Measured memory_bytes: 3060
#include<stdio.h>

int main(void){
  int a,b,c;
  scanf("%d %d %d", &a, &b, &c);
  
  if ((a < c && c < b) || (b < c && c < a)){
    printf("%s", "Yes");
  }else{
    printf("%s", "No");
  }
  return 0; 
}

Measured memory_bytes: 128
import java.io.*;
import java.util.*;

class Main {
    public static void main(String args[]) {
        FastReader sc = new FastReader();
        StringBuilder sb = new StringBuilder();
        String odd = sc.next();
        String even = sc.next();
        String ans = "";
        int total = odd.length() + even.length();
        int oc = 0, ec = 0;
        int i = 0;
        while (i < total) {
            if (i%2 == 0) {
                ans += odd.charAt(oc++);
            }
            else {
                ans += even.charAt(ec++);
            }
            i++;
        }
        System.out.println(ans);
    }

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=5005;
int n,k,p[N],c[N],cir[N];
int cal(int st)
{
	int now=p[st],j=0;
	while(now!=st)
	{
		cir[++j]=c[now];
		now=p[now];
	}
	cir[++j]=c[now];
	for(int i=1;i<=j;i++) 
		cir[i]+=cir[i-1];
	if(k<=j)
	{
		int ans=cir[1];
		for(int i=1;i<=k;i++) 
			ans=max(ans,cir[i]);
		return ans;
	}
	else
	{
		int ans=cir[1];
		for(int i=1;i<=j;i++) 
			ans=max(ans,cir[i]);
		int macir=ans,qu=k%j,maqu=0;
		for(int i=1;i<=qu;i++) 
			maqu=max(maqu,cir[i]);
		ans=max(ans,k/j*cir[j]+maqu);
		if(k/j>0)
			ans=max(ans,(k/j-1)*cir[j]+macir);
		return ans;
	}
}
signed main()
{
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;i++) 
		scanf("%lld",&p[i]);
	for(int i=1;i<=n;i++) 
		scanf("%lld",&c[i]);
	int ans=-1e17;
	for(int i=1;i<=n;i++)
		ans=max(cal(i),ans);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3928
for i in range(1000):
    x,y=map(int,input().split())
    if x==0 and y==0:
        break
    if y > x:
        x,y=y,x
    else:
        x,y=x,y


    count=0
    for i in range (1000):
        
        if y==0:
            break
        x=x%y
        x,y=y,x
        count+=1
        
        
    print("{} {}".format(x,count))


Measured memory_bytes: 5604
/*
 * Code be weshen zyk :'(
 */
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include "bits/stdc++.h"

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define F first
#define S second

using ll = long long;
using ii = pair<int, int>;
using db = long double;

#ifdef ONLINE_JUDGE
#define cerr if(0)cerr
#endif

template<class C> void amin(C &a4, C b4) {
	a4 = min(a4, b4);
}
template<class C> void amax(C &a4, C b4) {
	a4 = max(a4, b4);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
	os << "[";
	for (auto vv : V)
		os << vv << ",";
	return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L, R> P) {
	return os << "(" << P.first << "," << P.second << ")";
}

const int N = 1e5 + 5;
int n, m;
ll dp[3005][3005];
ii par[3005][3005];
int main() {
#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#endif

	string s, t;
	cin >> s >> t;
	for (int i = 1; i <= s.size(); i++) {
		for (int j = 1; j <= t.size(); j++) {
			if (dp[i - 1][j] > dp[i][j - 1]) {
				dp[i][j] = dp[i - 1][j];
				par[i][j] = ii(i - 1, j);
			} else {
				dp[i][j] = dp[i][j - 1];
				par[i][j] = ii(i, j - 1);
			}
			if (s[i - 1] == t[j - 1]) {
				if (dp[i - 1][j - 1] + 1 > dp[i][j]) {
					dp[i][j] = dp[i - 1][j - 1] + 1;
					par[i][j] = ii(i - 1, j - 1);
				}
			}
		}
	}

	ii cur = ii(s.size(), t.size());
	string ans = "";
	while (cur.first || cur.second) {
		if (par[cur.first][cur.second] == ii(cur.first - 1, cur.second - 1)) {
			ans.push_back(s[cur.first - 1]);
		}
		cur = par[cur.first][cur.second];
	}
	reverse(ans.begin(), ans.end());
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 141312
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

int main()
{
    int N;
    string S;
    cin >> N >> S;

    int ans = 1;
    for(int i=1; i<N; i++){
        if(S[i-1] != S[i]) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>

#define LP(i,n) for(int i=0;i<n;i++)
#define Mset(x,v) memset(x,v,sizeof(x))
#define INF INT_MAX

using namespace std;
using LL=long long;

int main(){
    int jc=0,jl=0,jn=0;
    string s;
    cin>>s;
    if(s.size()>=6){
        for(int i=0;i<s.size();i++){
            if(s[i]>='a'&&s[i]<='z') jl=1;
            else if(s[i]>='A'&&s[i]<='Z') jc=1;
            else if(s[i]>='0'&&s[i]<='9') jn=1;
        }
        if(jl&&jc&&jn) cout<<"VALID"<<endl;
        else cout<<"INVALID"<<endl;
    }
    else cout<<"INVALID"<<endl;
    return 0;
}



Measured memory_bytes: 3216
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import math
from functools import lru_cache

#############
# Constants #
#############

MOD = 10**9 +7
INF = float('inf')

#############
# Functions #
#############

kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#############
# Main Code #
#############

A,B,M = map(int,input().split())

a = list(map(int,input().split()))
b = list(map(int,input().split()))

m = []

for _ in range(M):
  m.append(list(map(int,input().split())))

  
mini = min(a) + min(b)

for q in m:
  if a[q[0]-1] + b[q[1]-1] - q[2] < mini:
    mini = a[q[0]-1] + b[q[1]-1] - q[2]
    
print(mini)

Measured memory_bytes: 81900
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int solve(){
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  rep(i,n){
    if(k - 1 == i){
      char tmp = s[i];
      tmp = tolower(tmp);
      s[i] = tmp;
    }
  }
  cout << s << endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16) << endl; 
  solve();
  return 0;
} 

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)

class UnionFind():
	def __init__(self, size):
		self.table = [-1 for _ in range(size)]

	def find(self, x):
		if self.table[x] < 0:
			return x
		else:
			self.table[x] = self.find(self.table[x])
			return self.table[x]

	def union(self, x, y):
		s1 = self.find(x)
		s2 = self.find(y)
		if s1 != s2:
			if self.table[s1] > self.table[s2]:
				self.table[s2] = s1
			elif self.table[s1] < self.table[s2]:
				self.table[s1] = s2
			else:
				self.table[s1] = s2
				self.table[s2] -= 1
		return

n, m = map(int, input().split())
lang = [[] for _ in range(m)]
for i in range(n):
	kl = list(map(int, input().split()))
	for j in range(1, kl[0] + 1):
		lang[kl[j] - 1].append(i)

uf = UnionFind(n)
for i in range(m):
	if len(lang[i]) <= 1:
		continue
	else:
		for j in range(len(lang[i]) - 1):
			uf.union(lang[i][j], lang[i][j + 1])

root_count = 0
for i in range(n):
	if uf.table[i] < 0:
		root_count += 1

if root_count == 1:
	print("YES")
else:
	print("NO")

Measured memory_bytes: 16092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
typedef long long int ll;
typedef pair<int, int> P;

int main(){
  string S,T;cin>>S>>T;
  int a,b; cin>>a>>b;
  string s;cin>>s;
  if(s==S){
    cout<<a-1<<' '<<b<<endl;
  }
  if(s==T){
    cout<<a<<' '<<b-1<<endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

const int MAX_N = 100050;
vvi nx(MAX_N);
vi ans(MAX_N, 0);



void dfs(int s) {

    //新たな頂点なので、色番号をリセットする
    int cnt = 0;

    //頂点sからのびる全ての辺に色を付けていく。
    //ただし、色番号は幅優先で付けられるが、頂点sのたどり方は深さ優先である。
    //すると、頂点sにたどり着くときに通った直前の辺の色がans[s]となり、
    //新たな辺に色を付ける際は、ans[s]だけをスキップすればよい。
    rep(i, nx[s].size()) {

        //頂点sからのびる辺に、1から順に数えて色番号を付けていく
        cnt++;

        //直前の辺の色番号はスキップ
        if(cnt == ans[s]) cnt++;

        //確定した色番号を保存
        ans[nx[s][i]] = cnt;

        //色が確定したら、その辺をたどった先の頂点について同様の操作を始める
        dfs(nx[s][i]);
    }

}

signed main() {
    int N;
    cin >> N;

    vi a(N), b(N);
    rep(i, N-1) {
        cin >> a[i] >> b[i];
        nx[a[i]].pb(b[i]);
    }

    ans[1] = 0;
    dfs(1);

    int mx = 0;
    rep(i, N) {
        mx = max(mx, ans[i+1]);
    }

    cout << mx << endl;
    rep(i, N-1) {
        cout << ans[b[i]] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 8960
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef long long ll;
int max_cal(int a,int b)
{
  if(a>=b) return a;
  else return b;
}
int com(const void *a,const void *b)
{
  return (*(int *)a-*(int *)b);
}
void main(void)
{
  ll n,m,ans=0;
  scanf("%lld",&n);
  ll *a,*L,*R,*d;
  a=malloc(sizeof(ll)*n);
  L=malloc(sizeof(ll)*n);
  R=malloc(sizeof(ll)*n);
  d=malloc(sizeof(ll)*n);
  for(ll i=0;i<n;i++) d[i]=0;
  for(ll i=0;i<n;i++){
    scanf("%lld",&a[i]);
    R[i]=i+1-a[i];
    L[i]=i+1+a[i];
    if(L[i]<=(n-1)) d[L[i]]++;
    if(R[i]>=2)
      if(d[R[i]]>0) ans+=d[R[i]];
  }
  //qsort(R,n,sizeof(int),com);
  //qsort(L,n,sizeof(int),com);

  printf("%lld",ans);
}

Measured memory_bytes: 7980