akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

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

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n, k := intScanner(), intScanner()
	x, y := intScanner(), intScanner()
	if n <= k {
		fmt.Println(n * x)
	} else {
		fmt.Println(k*x + (n-k)*y)
	}
}


Measured memory_bytes: 1776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

int main()
{
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    vector<ll> a(N);

    rep(i, N - 1)
    {
        ll c;
        cin >> c;
        --c;

        a[c]++;
    }

    rep(i, N)
    {
        cout << a[i] << endl;
    }
}


Measured memory_bytes: 4768
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];
    sort(all(h));
    ll ans = 0;
    rep(i, n - k) ans += h[i];
    cout << ans << endl;
}


Measured memory_bytes: 1792
import sys 
sys.setrecursionlimit(2147483647)

N,W = map(int,input().split())
A = [list(map(int, input().split())) for i in range(N)]
dp = [[0 for _ in range(W+1) ] for _ in range(N + 1)] 

for i in range(1,N + 1): 
    for j in range(W + 1): 
        if j - A[i-1][0] >= 0:
            res1 = dp[i - 1][j - A[i-1][0]] + A[i - 1][1]
            res2 = dp[i - 1][j]
            dp[i][j] = max(res1,res2)
        else:
            dp[i][j] = dp[i-1][j]
#print(dp)
print(max(dp[N]))          

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

#define MOD 1000000007LL

char ss[60]; // - or |
long long dp[60];

int main() {
    int N;
    cin >> N;
    string s1, s2;
    cin >> s1;
    cin >> s2;

    int k = 0;
    for (int i=0; i<N;) {
        if (s1[i] != s2[i]) {
            ss[k] = '-';
            i += 2;
        } else {
            ss[k] = '|';
            i++;
        }
        k++;
    }

    if (ss[0] == '|') {
        dp[0] = 3;
    } else {
        dp[0] = 6;
    }
    for (int i=1; i<k; i++) {
        if (ss[i-1] == '-' && ss[i] == '-') {
            dp[i] = dp[i-1] * 3LL;
        } else if (ss[i-1] == '-' && ss[i] == '|') {
            dp[i] = dp[i-1];
        } else if (ss[i-1] == '|' && ss[i] == '|') {
            dp[i] = dp[i-1] * 2LL;
        } else if (ss[i-1] == '|' && ss[i] == '-') { 
            dp[i] = dp[i-1] * 2LL;
        } else {
            return 1;
        }
        dp[i] %= MOD;
    }

    cout << dp[k-1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int a , b ;
	char op ;
	0 <= a , b <= 20000 ;
	b != 0 ;
	while( 1 ){
		cin >> a >> op >> b ;
		if ( op  == '?' ) break;
		else if( op == '+' )
		{
			cout << a + b << endl;
		}
		else if ( op == '*' )
		{
			cout << a * b << endl;
		}
		else if ( op == '-' )
		{
			cout << a - b << endl;
		}
		else if ( op == '/' )
		{
			cout << a / b << endl;
		}
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;	cin >> s;
  
  string t=s;
  reverse(t.begin(),t.end());
  if(s!=t){
    cout << "No";
    return 0;
  }
  
  t=s.substr(0,(s.size()-1)/2);
  string u=t;
  reverse(u.begin(),u.end());
  if(t!=u){
    cout << "No";
    return 0;
  }
  
  t=s.substr((s.size()+3)/2-1);
  u=t;
  reverse(u.begin(),u.end());
  if(t!=u){
    cout << "No";
    return 0;
  }
  cout << "Yes";
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include <string>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/



int main(void) {
  ll i, j, k;
  
  ll K, N;
  cin >> K >> N;
  ll a[111];
  ll s=0;
  
  for(i=0; i<N; i++) cin >> a[i];
  sort(a, a+N);
  for(i=0; i<N-1; i++) s+=a[i];
  
  pt(max(0LL, a[N-1]-s-1));
  
}



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

using namespace std;

int n, p;
string s;
long long ans = 0;
map<int, int> m;

long long fast_10(int e)
{
    long long t = 10;
    long long a = 1;
    while (e > 0)
    {
        if (e & 1 == 1)
            a = a * t % p;
        t *= t;
        e >>= 1;
        t %= p;
    }

    return a;
}

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

    cin >> n >> p;
	cin >> s;

    if (p == 2 || p == 5)
    {
        for (int i = 0; i < n; i++)
        {
            if ((s[i] - '0') % p == 0)
                ans += i + 1;
        }
    }
    else
    {
        long long curr = 0;
        for (int i = 0; i < n; i++)
        {
            curr += fast_10(n - 1 - i) * (s[i] - '0');
            curr %= p;
            m[curr]++;
        }
        for (auto a : m)
        {
            int c = a.second;
            ans += 1ll * c * (c - 1) / 2;
        }
        ans += m[0];
    }

    cout << ans;

	return 0;
}


Measured memory_bytes: 916
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, k, h[N], ans = 0;
int main () {
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; i++) scanf("%d", &h[i]);
	for (int i = 1; i <= n; i++) {
		if (h[i] >= k) ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
	int r,c;
	cin >> r >> c;
	int a[105][105]={0};
	for(int i=1;i<=r;i++){
		for(int j=1;j<=c;j++){
			int num;
			cin >> num;
			a[i][j]=num;
		}
		for(int j=1;j<=c;j++){
			a[i][c+1]+=a[i][j];
		}
	}
	for(int i=1;i<=c+1;i++){
		for(int j=1;j<=r;j++){
			a[r+1][i]+=a[j][i];
		}
	}
	for(int i=1;i<=r+1;i++){
		for(int j=1;j<=c+1;j++){
			if(j!=c+1) cout<<a[i][j]<<" ";
			else cout<<a[i][j]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3140
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
   ll k,a,b;
   cin >> k >> a >>b;
   ll ans;
   if(a+1>=b)ans=k+1;
   else{
     if(a-1>k)ans=1+k;
     else{
       ll lst=k-a+1;
       if(lst%2==0)ans=a+(lst/2)*(b-a);
       else ans=a+(lst/2)*(b-a)+1;
     }  
   }
   cout << ans << endl;
}

Measured memory_bytes: 3532
N, X, Y = map(int, input().split())
k_list = [0]*(N-1)
for i in range(1, N+1):
    for j in range(i+1, N+1):
        min_dst = min((j-i, abs(i-X)+1+abs(j-Y), abs(i-Y)+1+abs(j-X)))
        k_list[min_dst-1] += 1
for i in k_list:
    print(i)

Measured memory_bytes: 3444
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <string>
#include <random>
#include <map>
#include <math.h>
#pragma warning(disable : 4996)

int min(int a, int b) {
	if (a < b) return a;
	return b;
}
int abs(int a) {
	if (a < 0) a *= -1;
	return a;
}

int main(void) {
	int W, a, b;
	scanf("%d %d %d",&W, &a, &b);
	if (abs(b - a) < W) {
		printf("0");
	}
	else {
		printf("%d", min(abs(a + W - b), abs(b + W - a)));
	}
	return 0;
}


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

int main()
{
	int a, b, c;
	int max, min;
	int ans;

	max = min = ans = 0;

	cin >> a;
	max = a;

	cin >> b;
	if (a > b)
	{
		min = b;
	}
	else
	{
		min = a;
		max = b;
	}
	cin >> c;
	if (max > c)
	{
		if (min > c)
		min = c;	
	}
	else
	{
		max = c;
	}

	ans = max - min;

	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define SCAN(x) scanf("%lld",&x);
#define INF 5555555555555555555
#define MOD 1000000007
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool flag, ok;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111



int main(void) {
  cin >> n;
  MAP mp;
  FOR(i, 0, n) {
	cin >> tmp;
	mp[tmp]++;
  }

  for (auto it : mp) {
	if (it.second % 2 == 1) ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

int main(void) {
    ll n;
    cin >> n;
    ll a[n];
    ll s[n];
    ll c = 0;
    for(ll i = 0; i < n; i++){
        cin >> a[i];
        c+=a[i];
        if(i==0) s[i] = a[i];
        else s[i] = s[i-1] + a[i];
    }
    ll ans = 0;
    for(ll i = 0; i < n; i++){
        //if(s[i]*2==c) break:
        if(s[i]*2>c){
            ans = min(s[i]-(c-s[i]), (c-s[i-1])-s[i-1]);
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			int[] xs = new int[3];
			int[] ys = new int[3];
			for (int i = 0; i < 3; i++) {
				int a = scanner.next().charAt(0) - 'A';
				xs[i] = a % 3;
				ys[i] = a / 3;
			}
			double[][] cur = new double[3][3];
			cur[xs[0]][ys[0]] = 1;
			for (int i = 0; i < n; i++) {
				double[][] nxt = new double[3][3];
				for (int x = 0; x < 3; x++)
					for (int y = 0; y < 3; y++)
						for (int[] m : move) {
							int nx = x + m[0];
							int ny = y + m[1];
							if (nx == xs[2] && ny == ys[2] || nx < 0 || 2 < nx
									|| ny < 0 || 2 < ny)
								nxt[x][y] += cur[x][y] / 4;
							else
								nxt[nx][ny] += cur[x][y] / 4;
						}
				cur = nxt;
			}
			System.out.printf("%.8f\n", cur[xs[1]][ys[1]]);
		}
	}

	int[][] move = { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

}

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

#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define REP2(i,n) for(int i=0;i<(int)(n);i++)
#define REP3(i,m,n) for(int i=m;i<(int)(n);i++)
#define REP4(i,m,n,s) for(int i=m;(s>0 and i<(int)(n)) or (s<0 and i>(int)(n));i+=s)
#define REP(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)
#define REPIT(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define PIS(x) printf("%d ",x)
#define PN() putchar('\n')
#define MP make_pair
#define PB push_back
#define EB emplace_back

typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long ULL;

void RI() {}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}
void PI() {putchar('\n');}
template<typename... T>
void PI(const int head, T... tail ) {
    printf("%d ", head);
    PI(tail...);
}

const int MOD = 1000000007;
#define MAX_N 100005


int main()
{
    int n, m;
    RI(n, m);
    if(abs(n-m) > 1) {
        printf("0\n");
        return 0;
    }
    if(n > m) {
        swap(n, m);
    }
    LL ans = 1;
    REP(i, 1, n+1) {
        ans = (ans * i) % MOD;
    }
    ans = (ans * ans) % MOD;
    if(m > n) {
        ans = (ans * m) % MOD;
    } else {
        ans = (ans * 2) % MOD;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 384
while True:
    a=input().split()
    h=int(a[0])
    w=int(a[1])
    if h==0 and w==0:
        break
    count=0
    count2=0
    for i in range(h):
        count=1
        if count2%2==1:
            count=0
        count2+=1
        for i in range(w):
            if count%2==1:
                print("#",end="")
            else:
                print(".",end="")
            count+=1
        print()
    print()
        



Measured memory_bytes: 7008
#include <iostream>
#include<vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
typedef long long ll;
using namespace std;

const int MX = 100001;

int main() {
    int n;
    cin>>n;
    vector<ll>cnt(MX);
    rep(i,n){
        int a;
        cin >> a;
        cnt[a]++;
    }
    ll tot = 0;
    rep(i,MX)tot += i*cnt[i];
    int q;
    cin>>q;
    rep(i,q){
        int b,c;
        cin>>b>>c;
        tot += (c-b)*cnt[b];
        cnt[c] += cnt[b];
        cnt[b]=0;
        cout << tot <<endl;
    }
    return 0;
}

Measured memory_bytes: 4044
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
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; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int x;
    cin >> x;
    int ans = 0;
    cout << (x/500) * 1000 + (x%500) - (x%500)%5 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>


using namespace std;


int main() {
    long long int n;
    cin >> n;
    unsigned long long int min = 1000000000000000000;
    unsigned long long int t = 0;
    for(unsigned long long int i = 1; i <= sqrt(n); i++){
        t = (unsigned long long int)(n/i);
        if (t == (1.0 * n)/i){
            if((i-1 + t- 1) < min)
                min = i-1 + t- 1;
        }
    }
    cout << min;
}

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

int main(void) {
	int N;
	cin >> N;
	map<string, long> mp;
	long cnt = 0;
	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		cnt += mp[s];
		mp[s]++;
	}
	//for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
	//	cout << itr->first << ":" << itr->second << endl;
	//}
	cout << cnt << endl;

}

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


int pop(int*);
void push(int);

int* top;

int main(){
    int x;
    char s[100];
    int stack[1024];
    int a,b;
    top=stack;


    while( scanf("%s", s) != EOF ){
        if ( s[0] == '+' ){
            a=pop(stack);
            b=pop(stack);
            if(a*b==0)
                exit(-1);
            push(a+b);

        } else if ( s[0] == '-' ){
            a=pop(stack);
            b=pop(stack);
            if(a*b==0)
                exit(-2);
            push(b-a);

        } else if ( s[0] == '*' ){
            a=pop(stack);
            b=pop(stack);
            if(a*b==0)
                exit(-3);
            push(a*b);

        } else {
            x = atoi(s);
            push(x);
        }
    }

    printf("%d\n",pop(stack));

    return 0;
}

int pop(int* x){
    if(top==x)
        return 0;

    top--;
    return *(top);
}

void push(int x){
    *top=x;

    top++;
    return;
}



Measured memory_bytes: 2104
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int[][] c = new int[4][4];
		for(int i=1;i<=3;i++){
			for(int j=1;j<=3;j++) c[i][j] = sc.nextInt();
		}
		if(((c[1][2]-c[1][1])==(c[2][2]-c[2][1])) && ((c[1][2]-c[1][1])==(c[3][2]-c[3][1]))
				&& ((c[1][3]-c[1][2])==(c[2][3]-c[2][2])) && ((c[1][3]-c[1][2])==(c[3][3]-c[3][2]))
				&& ((c[2][1]-c[1][1])==(c[2][2]-c[1][2])) && ((c[2][1]-c[1][1])==(c[2][3]-c[1][3]))
				&& ((c[3][1]-c[2][1])==(c[3][2]-c[2][2])) && ((c[3][1]-c[2][1])==(c[3][3]-c[2][3]))){
			System.out.println("Yes");
		}else System.out.println("No");
		return;
	}
}

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

using namespace std;


void solve() {
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    for (auto& x: a) {
        cin >> x;
    }
    vector<vector<pair<int,int>>> g(n);
    vector<bool> root(n);
    for (int i = 0; i < m; i++) {
        int x,y;
        cin >> x >> y;
        x--;y--;
        if (a[x] <= a[y]) g[x].emplace_back(y,i);
        if (a[y] <= a[x]) g[y].emplace_back(x,i);
        if (a[x] == a[y]) root[x] = true;
    }
    vector<int> co(n, -1);
    vector<int> cost(m, 1e9);
    function<bool(int,int)> dfs = [&](int u, int c){
        if (co[u] != -1) return false;
        co[u] = c;
        for (auto& e: g[u]) {
            int v,i;
            tie(v,i) = e;
            if (dfs(v, c^1)) {
                cost[i] = a[v];
            }
        }
        return true;
    };
    for (int i = 0; i < n; i++) {
        if (root[i] && co[i]==-1) dfs(i, 0);
    }
    for (int i = 0; i < n; i++) {
        if (co[i]==-1) {
            cout << -1; return;
        }
    }
    for (int i = 0; i < n; i++) {
        cout << (co[i]?'B':'W');
    }cout << '\n';
    for (int x:cost) cout << x << '\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 11392
#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <sstream>
#include <climits>
#include <cmath>
#include <map>
#include <stack>
using namespace std;
#define M_PI 3.141592
#define toRad 2.0*M_PI/360.0
#define inin(x) int x;cin>>x;
#define all(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" "<<x<<endl;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define EPS 1e-12
#define pri_max 60000
typedef pair<double, double> pdd;
/*
bool memo[pri_max] = {};
vector<int> pri;
void calc()
{
	for (int i = 2; i < pri_max; i++)
	{
		if (memo[i] == false)
		{
			pri.push_back(i);
			for (int l = i; l < pri_max; l += i)
			{
				memo[l] = true;
			}
		}
	}
}*/
int main()
{
	double ax, ay, aX, aY, bx, by, bX, bY;
	while (cin >> ax >> ay >> aX >> aY >> bx >> by >> bX >> bY)
	{
		if (ax > bX || ay > bY || bx > aX || by > aY)cout << "NO" << endl;
		else cout << "YES" << endl;
	}
}

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

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int n=fsc.nextInt();
        int k=fsc.nextInt();
        int ans=0;
        for(int i=0;i<n;i++){
            int x=fsc.nextInt();
            ans+=2*Math.min(Math.abs(k-x), x);
        }
        fsc.close();
        System.out.println(ans);
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}


Measured memory_bytes: 21204
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

def test(a):
    while len(a) != 1:
        tmp = []
        for i in range(len(a) - 2):
            tmp.append(sorted([a[i], a[i + 1], a[i + 2]])[1])
        a = tmp[::1]
    return tmp[0]
#solve
def solve():
    n, x = LI()
    if 1 == x or 2 * n - 1 == x:
        print("No")
        return
    print("Yes")
    if x < n:
        for i in range(n, 0, -1):
            if i == x:
                continue
            print(i)
        print(x)
        for i in range(n + 1, 2 * n):
            print(i)
    elif x == n:
        for i in range(1, 2 * n):
            print(i)
    else:
        for i in range(1, n):
            print(i)
        print(x)
        for i in range(2 * n - 1, n - 1, -1):
            if i == x:
                continue
            print(i)



#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 48988
n=int(input())
A=list(map(int,input().split()) )
q=int(input())
B=[]
C=[]

a_sum = sum(A)
counter = [0]*10**5

for a in A:
    counter[a-1] += 1

for i in range(q):
    b,c = map(int,input().split()) 
       
    a_sum += (c-b) * counter[b-1]
      
    counter[c-1]+=counter[b-1]
    counter[b-1]=0
    
    print(a_sum)


Measured memory_bytes: 84792
X, Y = map(int, input().split())

MD = pow(10, 9) + 7

def choose(n, a):
    x, y = 1, 1
    for i in range(a):
        x = x * (n - i) % MD
        y = y * (i + 1) % MD
    return x * pow(y, MD - 2, MD) % MD


a = (2*Y-X)//3
b = (Y-2*X)//-3

if a < 0 or b < 0 or (X+Y) % 3 != 0:
    print(0)
    import sys
    sys.exit()

print(choose(a+b, min(a,b)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
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;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);
// priority_queue<ll, vector<ll>, greater<ll>> pq;


int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll ans = 0;
    vector<ll> s(n);
    s[0] = a[0];
    rep(i, n-1){
        s[i+1] = (s[i] + a[i+1]) % MOD;
    }
    rep(i, n-1){
        ll tmp = (((s[n-1]-s[i] + MOD) % MOD)*a[i]) % MOD;
        ADD(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6356
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }

void dfs(int N, const string& S, int dpt) {
    if (S.size() >= N) {
        cout << S << endl;
        return;
    }
    string newS = S;
    rep(i, dpt) {
        char add = 'a';
        auto SS = newS + char(add + i);
        unordered_set<int> kind;
        rep(j, SS.size()) {
            kind.insert(SS[j]);
        }

        dfs(N, newS + char(add + i), kind.size() + 1);

    }

}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    string S = "";
    dfs(N, S, 1);

    return 0;
}

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

bool wolf[1<<20];
int n;
string s, ans;

bool tri(bool a0, bool a1) {
    wolf[0] = a0;
    wolf[1] = a1;
    for (int i = 2; i < n; i++) {
        if (wolf[i-1]) {
            if (s[i-1] == 'x') wolf[i] = wolf[i-2];
            else wolf[i] = !wolf[i-2];
        } else {
            if (s[i-1] == 'o') wolf[i] = wolf[i-2];
            else wolf[i] = !wolf[i-2];
        }
    }
    if (wolf[n-1]) {
        if (s[n-1] == 'o' && wolf[0] == wolf[n-2]) return false;
        if (s[n-1] == 'x' && wolf[0] != wolf[n-2]) return false;
    } else {
        if (s[n-1] == 'x' && wolf[0] == wolf[n-2]) return false;
        if (s[n-1] == 'o' && wolf[0] != wolf[n-2]) return false;
    }
    if (wolf[0]) {
        if (s[0] == 'o' && wolf[1] == wolf[n-1]) return false;
        if (s[0] == 'x' && wolf[1] != wolf[n-1]) return false;
    } else {
        if (s[0] == 'x' && wolf[1] == wolf[n-1]) return false;
        if (s[0] == 'o' && wolf[1] != wolf[n-1]) return false;
    }
    if (ans == "") {
        for (int i = 0; i < n; i++) {
            if (wolf[i]) ans += "W";
            else ans += "S";
        }
    }
}

int main() {
    //freopen("in.txt","r",stdin);
    cin >> n;
    getline(cin,s);
    getline(cin,s);
    wolf[0] = 1;
    wolf[1] = 1;
    if (tri(1,1) || tri(1,0) || tri(0,1) || tri(0,0)) cout << ans;
    else cout << -1;
	return 0;
}


Measured memory_bytes: 768
#include <iostream>

using namespace std;

int main()
{
    int n, t,a, b, m=10000;
    cin>>n>>t;
    for(int i=0; i<n; i++){
        cin>>a>>b;
        if(b<=t){
            if(a<m)
                m=a;
        }
    }
    if(m==10000)
        cout<<"TLE";
    else
    cout<<m;

    return 0;
}


Measured memory_bytes: 256
using System;
namespace sample
{
	class Program
    {
    	static void Main()
        {
          	int time = 0;
          	int ans = 0;
        	string[] a = Console.ReadLine().Split(' ');
          	int A = int.Parse(a[0]);
          	int B = int.Parse(a[1]);
          	int T = int.Parse(a[2]);
            while(true)
            {
            	time++;
              	if(A * time <= T)
                {
                	for(int i =0;i<B;i++)ans++;
                }
              	else
                {
                	break;
                }
            }
          	Console.WriteLine(ans);
        }
    }
}

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

int main() {
  int H, W; cin >> H >> W;
  vector<string> A(H);
  for (int i = 0; i < H; i++) cin >> A.at(i);
  int INF = 1000000000;
  vector<vector<int>> G(H, vector<int>(W, INF));
  queue<pair<int, int>> q;
  for (int y = 0; y < H; y++) {
    for (int x = 0; x < W; x++) {
      if (A.at(y).at(x) == '#') {
        q.push(make_pair(y, x));
        G.at(y).at(x) = 0;
      }
    }
  }
  int ans = 0;
  vector<int> dx = { 0, 0, -1, 1 };
  vector<int> dy = { 1, -1, 0, 0 };
  while (!q.empty()) {
    int y = q.front().first;
    int x = q.front().second;
    q.pop();
    for (int i = 0; i < 4; i++) {
      int ny = y + dy.at(i);
      int nx = x + dx.at(i);
      if (ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
      if (G.at(ny).at(nx) != INF) continue;
      G.at(ny).at(nx) = G.at(y).at(x) + 1;
      ans = max(ans, G.at(ny).at(nx));
      q.push(make_pair(ny, nx));
    }
  }
  cout << ans << endl;
}

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

int main()
{
	long a[10000], i, max, min, sum = 0;
	cin >> i;

	for (int j = 0; j < i; j++) {
		cin >> a[j];
	}
	max = a[0];
	min = a[0];

	for (int j = 0; j < i; j++) {
		if (max < a[j]) { max = a[j]; }
		if (a[j] < min) { min = a[j]; }
		sum += a[j];
	}
	cout << min << ' ' << max << ' ' << sum << endl;
    return 0;
}

Measured memory_bytes: 1236
#include <stdio.h>

#define NUM 10

void bsort(int a[], int n){
	int i,j;
	
	for(i = 0; i < n - 1; i++){
		for(j = 0; j < n - 1 - i; j++){
			if(a[j + 1] > a[j]){
				int temp = a[j];
				a[j] = a[j + 1];
				a[j + 1] = temp;
			}
		}
	}	
}

int main(void){
	int hills[NUM];
	int i;
	
	
	for(i = 0; i < NUM; i++){
		scanf("%d", &hills[i]);
	}
	
	bsort(hills, NUM);
	
	for(i = 0; i < 3; i++){
		printf("%d\n", hills[i]);
	}
	
	return 0;
}

Measured memory_bytes: 600
N=int(input())
h=list(map(int,input().split()))

dp=[0 for i in range(N+1)]
for i in range(N):
    if i==0:
        dp[i]=0
    elif i==1:
        dp[i]=abs(h[i]-h[i-1])
    else:
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))

print(dp[N-1])

Measured memory_bytes: 13928
#include<bits/stdc++.h>
#include<atcoder/dsu>
using namespace std;
int main(){
	int n,q;cin>>n>>q;
	atcoder::dsu d(n);
	for(int i=0;i<q;i++){
		int t,u,v;cin>>t>>u>>v;
		if(t)cout<<d.same(u,v)<<endl;
		else d.merge(u,v);
	}
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll m,n; cin>>m>>n;
	ll ans=0;
	vector<pair<ll,int> > vec;
	for(int i=0;i<m;i++)
	{
		ll x; cin>>x;
		vec.pb(mp(x,0));
	}
	for(int i=0;i<n;i++)
	{
		ll x; cin>>x;
		vec.pb(mp(x,1));
	}
	sort(vec.begin(),vec.end());
	ll R = n + 1; ll C = m + 1;
	for(int i=0;i<vec.size();i++)
	{
		ll cost=vec[i].fi; ll ty=vec[i].se; 
		if(ty==0)
		{
			ans+=R*cost;
			C--;
		}
		else
		{
			ans+=C*cost;
			R--;
		}
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 6512
n = input()
s = n[-1]
if s == '2' or s == '4' or s == '5' or s == '7' or s == '9':
    print('hon')
elif s == '0' or s == '1' or s == '6' or s == '8':
    print('pon')
else:
    print('bon')
    

Measured memory_bytes: 9104
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
long long int N,f[100][10],p[100][11],ans=-1000000000,a[10];
void func(){
    bool flag=false;
    long long int score=0,count[100]={};
    for(int i=0;i<10;i++){
        if(a[i]==1) flag=true;
    }
    if(flag==true){
        for(int i=0;i<10;i++){
            for(int j=0;j<N;j++){
                if(a[i]==1&&f[j][i]==1)  count[j]++;
            }
        }
        for(int i=0;i<N;i++){
            score+=p[i][count[i]];
        }
        ans = max(ans,score);
    }
}
void dfs(int pos){
    if(pos==10){
        func();
        return;
    }
    a[pos]=1;
    dfs(pos+1);
    a[pos]=0;
    dfs(pos+1);
}

int main(){
    cin >> N;
    for(int i=0;i<N;i++){
        for(int j=0;j<10;j++)   cin >> f[i][j];
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<11;j++)   cin >> p[i][j];
    }
    dfs(0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P  = pair<int,int>;
using v  = vector<int>;
using vv = vector<v>;

int main(){
    int n;
    cin >> n;
    
    vv cost(n,v (n));
    vector<vector<bool>> seat(n,vector<bool> (n,true));
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            cost[i][j] = min(min(i,n-1-i), min(j,n-1-j));
        }
    }
    
    int ans = 0;
    
    v di={-1,0,1,0};
    v dj={0,-1,0,1};//四方
    
    for(int i=0; i<n*n; i++){
        int p;
        cin >> p;
        int pi = (p-1)/n;
        int pj = (p-1)%n;
        
        ans += cost[pi][pj];
        seat[pi][pj] = false;
        
        //幅優先で距離リストを更新
        queue<P> more;
        more.push({pi,pj});
        
        while(!more.empty()){
            
            int ni = more.front().first;
            int nj = more.front().second;
            
            for(int l=0; l<4; l++){
                if(ni+di.at(l)<n && ni+di.at(l)>=0 && nj+dj.at(l)<n && nj+dj.at(l)>=0){
                    
                    if(cost[ni+di[l]][nj+dj[l]]>cost[ni][nj]+seat[ni][nj]){
                        
                        cost[ni+di[l]][nj+dj[l]] = cost[ni][nj]+seat[ni][nj];
                        more.push({ni+di[l], nj+dj[l]});
                        
                    }
                }
            }
            more.pop();
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4660
#include "bits/stdc++.h"
using namespace std;
char S[3005] , T[3005] , Ans[3005];
pair<int,int> dp[3001][3001];

int LCS( int Ns , int Nt ){
    int i , j , which , Max;

    for( i = 1 ; i <= Nt ; ++i ){
        for( j = 1 ; j <= Ns ; ++j ){
            Max = which = 0;

            if( S[j] == T[i] ){ 
                Max = 1 + dp[i - 1][j - 1].first;
                which = 0;
            }
            if( dp[i][j - 1].first > Max ){
                Max = dp[i][j - 1].first;
                which = 1;
            }
            if( dp[i - 1][j].first > Max ){
                Max = dp[i - 1][j].first;
                which = 2;
            }

            dp[i][j].first = Max;
            dp[i][j].second = which;
        }
    }

    return dp[Nt][Ns].first;
}

void ConstructString( int Ns , int Nt , int length ){
    int i = Nt , j = Ns , which , i_Pre , j_Pre;
    Ans[length + 1] = '\0';

    while( true ){
        which = dp[i][j].second;

        if( which == 0 ){
            i_Pre = i - 1;
            j_Pre = j - 1;
        }   
        else if( which == 1 ){
            i_Pre = i;
            j_Pre = j - 1;
        }
        else{
            i_Pre = i - 1;
            j_Pre = j;
        }

        if( dp[i_Pre][j_Pre].first == dp[i][j].first - 1 ){
            Ans[length] = T[i];
            --length;
            if( length == 0 ) break;
        }   

        i = i_Pre;
        j = j_Pre;
    }
}

int main(){
    int Ns , Nt;
    scanf( "%s%s" , S + 1 , T + 1 );
    Ns = strlen( S + 1 );
    Nt = strlen( T + 1 );
    int length = LCS( Ns , Nt );
    if( length == 0 ) puts( "" );
    else{
        ConstructString( Ns , Nt , length );
        printf( "%s\n" , Ans + 1 );
    }
    return 0;
}

Measured memory_bytes: 70656
#include <cmath>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <cstdio>
#include <cctype>
#include <queue>
#include <complex>
#include <climits>

typedef long long ll;

using namespace std;

unsigned long long int dp[101][21];

int main(){
	int n, a[101];
	cin >> n;
	for(int i=1; i<=n; ++i){
		cin >> a[i];
	}

	dp[0][0] = 1;

	for(int i=1; i<n; ++i){
		for(int j=0; j<21; ++j){
			if(j-a[i] >= 0){
				dp[i][j] += dp[i-1][j-a[i]];
			}
			if(j+a[i] <= 20){
				dp[i][j] += dp[i-1][j+a[i]];
			}

			if(i == 1 && a[i] == 0) dp[i][j] = dp[i-1][j];
		}
	}

	cout << dp[n-1][a[n]] << endl;


    return 0;
}

Measured memory_bytes: 1172
#include<bits/stdc++.h>                                                   //---------------------------------------------------------------
                                                                    
# define ll long long   
# define ld long double                                               
# define mod 1000000007                                                   
# define MAX 100005
# define pi 3.141592653589793238                                                                                  //shortcut keys
                                                                                
# define pb push_back                                                                     
# define mp make_pair 
# define all(x) x.begin(),x.end()                                                      
                                                                  
# define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);        //---------------------------------------------------------------                                       
using namespace std;
int main()
{
	ll r;
	cin>>r;
	double ans=2.0*pi*r;
	cout<<fixed<<setprecision(9)<<ans<<'\n';
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  vector<char> vec(W + 2, '#');
  for (int i = 0; i < W + 2; i++){
    cout << vec.at(i);
  }
  cout << endl;
  for (int i = 0; i < H; i++){
    string a;
    cin >> a;
    cout << '#' << a << '#' << endl;
  }
  for (int i = 0; i < W + 2; i++){
    cout << vec.at(i);
  }
  cout << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define DEBUG
#ifdef DEBUG
#define dump(x) cout << "[*] " #x ": " << x << endl
#define debug(x) x
#else
#define dump(x)
#define debug(x)
#endif

typedef long long ll;
//#define int long long
#define stepn(i, s, e, n) decltype(e) i = (s); i < (e); i += (n)
#define step(i, s, e) decltype(e) i = (s); i < (e); ++i
#define range(i, n) step(i, 0, n)
constexpr int INF = 1e9;

decltype(1) main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(0, c + b - a) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N, X;
    cin >> N >> X;
    int S[N];
    rep(i, N) cin >> S[i];
    sort(S, S+N, greater<int>());
    ll dp[X+1];
    fill(dp, dp+X+1, 0);
    dp[X] = 1;
    rep(i, N-1){
        rep(j, X+1){
            if(S[i] > j){
                dp[j] *= (N-i), dp[j] %= MOD;
            }
            else{
                dp[j%S[i]] += dp[j], dp[j%S[i]] %= MOD;
                dp[j] *= (N-i-1), dp[j] %= MOD;
            }
        }
    }
    ll ans = 0;
    rep(j, X+1){
        ans += (j%S[N-1])*dp[j], ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <fstream>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

//#define _debug
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc(x) scanf("%d",&x)
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORd(i,a,b) for(int i=a;i>b;i--)
#define ff first
#define ss second
#define sz(x) x.size()
#define pb push_back
//#define _online_judge

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, //data type
        null_type, //
        less<int>, //
        rb_tree_tag, //red-black tree
        tree_order_statistics_node_update> new_data_set;

typedef pair<int,int> pii;
typedef vector<pii> vii;
const int con = static_cast<const int>(1e6 + 5);
const int MOD = 1000000007;


int main (){
	FASTIO
#ifdef _online_judge
	freopen("input.txt" , "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif

    int n;
    cin >> n;
    int arr[n];
    FOR(i,0,n) cin >> arr[i];
    int ans=0;
    FORd(i,n-1,-1){
        bool flag = true;
        FORd(j,i-1,-1){
            if(arr[j] > arr[i]){
                flag = false;
            }
        }
        if(flag) ans++;
    }
    cout << ans;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
a,b = map(int, raw_input().split())
tmp = a

if b == 1:
	print 0
elif a >= b:
	print 1
else:
	count = 1
	while True:
		count +=1
		tmp += (a - 1)
		if tmp >= b:
			print count
			break

Measured memory_bytes: 2568
#include <stdio.h>
#include <math.h>
int main()
{
  int s,n,i,count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&s);
    if(hantei(s)==1){
      count++;
    }
  }
  printf("%d\n",count);
    return 0;

}

int hantei(s)
{
  int i;
  if(s<2) return 0;
  else if(s==2) return 1;
  else if(s%2==0)return 0;
  for(i=3;i<=sqrt(s);i+=2){
    if(s%i==0){
      return 0;
    }
  }
  return 1;
}
  
  
  



Measured memory_bytes: 2144
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int i,a,b,c;
    scanf("%d",&i);
    a = i/3600;
    b = (i-(a*3600))/60;
    c = i%60;
    printf("%d:%d:%d\n",a,b,c);
    
    return 0;
}

Measured memory_bytes: 592
n = int(input())
ans = 0
ba = 0 # bで始まりaで終わる
a = 0 # 末尾がa
b = 0 # 先頭がb
sss = []
for i in range(n):
    s = input()
    for j in range(len(s)-1):
        if s[j:j+2] == 'AB':
            ans+=1
    if s[0] == 'B' and s[-1] == 'A': ba += 1
    else:
        if s[0] == 'B': b+=1
        if s[-1] == 'A': a+=1
"""
貪欲で解けると思う
まずbaを並べて、可能な限りその先頭にa、末尾にbをつける
a,bが残るようであれば、ペアにする
"""
if ba > 0:
    ans += ba-1
    if a>0:
        ans+=1
        a-=1
    if b>0:
        ans+=1
        b-=1
ans += min(a, b)
print(ans)
            

Measured memory_bytes: 9244