akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define pii pair<int,int>
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define td(v) v.begin(),v.end()
#define inf 1000000000 // 1e9
#define MAXN 1000101
using namespace std;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}

struct point{
	int x,y;
	point(){}
	point (int _x,int _y){
		x = _x;
		y = _y;
	}
	point operator+(const point & oth){
		return point(x+oth.x,y+oth.y);
	}
	point operator-(const point &oth){
		return point(x-oth.x,y-oth.y);
	}
};

int dot(point a,point b){
	return a.x*b.x + a.y*b.y;
}
int cross(point a,point b){
	return a.x*b.y - a.y*b.x;
}
int ccw(point a,point b,point c){
	int dir = cross(b-a,c-b);
	return dir<0;//convexo
}
int n,a,b,c;
int h[MAXN];
int dp[MAXN];
int pointer =0;
vector<int> M;
vector<int> B;

int bad(int l1,int l2,int l3){
	return (B[l3]-B[l1])*(M[l1]-M[l2])<(B[l2]-B[l1])*(M[l1]-M[l3]);
    // se a intersecao l1 e l3 for a esquerda da de l1 e l2;
}
void add(int m,int b){
	M.pb(m);
	B.pb(b);
	while(M.size()>=3 && bad(M.size()-3,M.size()-2,M.size()-1)){
		M.erase(M.end()-2);
		B.erase(B.end()-2);
	}
}

int query(int x){
	if(pointer>=M.size()){
		pointer = M.size()-1;
	}
	while(pointer<M.size()-1 && M[pointer+1]*x + B[pointer+1] < M[pointer]*x + B[pointer]){
		pointer++;
	}
	return M[pointer]*x+B[pointer];
}

int32_t main(){
	fastio;
	cin>>n>>c;
	for(int i=1;i<=n;i++){
		cin>>h[i];
	}
	dp[1]=0;
	add(-2*h[1], dp[1] + h[1]*h[1]);
	for(int i=2;i<=n;i++){
		dp[i] = c + h[i]*h[i];
		dp[i] = min(dp[i],(h[i]*h[i] + c) + query(h[i]));
		add(-2*h[i],dp[i] + h[i]*h[i]);
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 9316
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define all(x) (x).begin (),(x).end()
#define pb push_back
#define mp make_pair
#define vi vector<ll>
#define pii pair<ll,ll>
#define vii vector<pii>
#define mi map<ll,ll>
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define si set<ll>
#define rep(i,a,b) for(unsigned ll i=a;i<b;i++)
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define MOD 1000000007LL
#define pi 3.141592
ll binary_power(ll a, ll n) {
    if (n==0) return 1;
    ll k=binary_power(a,n/2);
    if (n%2==0) return (k*k)%MOD;
    else return (((k*k)%MOD)*a)%MOD;
}
bool isPrime(int num){
    bool flag=true;
    for(int i = 2; i*i <= num ; i++) {
       if(num % i == 0) {
          flag = false;
          break;
       }
    }
    return flag;
}

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
ll calc(ll n, ll r)
{
    ll k=1;
    while(r>0)
    {
        k = ((k%MOD)*((n/r)%MOD))%MOD;
        n--; r--;
    }
    return k%MOD;
}
void solve()
{
   ld r;
   cin>>r;
   r = 2.0*pi*r;
   cout<<setprecision(10)<<r;
}

int main()
{
    SPEED;
    ll t = 1;

  // cin>>t;

    while(t--) solve();

   return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
const ll inf = 1e18 + 5;
typedef pair<int, bool> pib;

int main() {
    int n; cin >> n;
    int answer = -1;
    for (int i = 1; i <=n+1; i++){
        if (int(i * 1.08) == n){
            answer = i;
        }
    }
    if (answer != -1){
        cout << answer;
    }
    else{
        cout << ":(";
    }
}



Measured memory_bytes: 384
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {

        String strCount = Console.ReadLine();
        int count = int.Parse(strCount);

        String[] str = Console.ReadLine().Split(' ');

        int max = int.Parse(str[0]);
        int min = int.Parse(str[0]);
        long sum = 0;

        for ( int i = 0 ; i < count; i++ )
        {
            if (max < int.Parse(str[i]))
            {

                max = int.Parse(str[i]);

            }

            if (min > int.Parse(str[i]))
            {

                min = int.Parse(str[i]);

            }

            sum += int.Parse(str[i]);
        }

        Console.WriteLine("{0} {1} {2}", min, max, sum);

    }
}

Measured memory_bytes: 9960
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t H, N;
  cin >> H >> N;
  // const int64_t L = static_cast<int64_t>(T.length());
  vector<int64_t> A(N + 1);
  vector<int64_t> B(N + 1);
  for (int64_t i = 1; i <= N; ++i) {
    cin >> A[i] >> B[i];
  }
  const int64_t max_damage = *max_element(A.begin(), A.end());
  vector<vector<int64_t>> mp(N + 1, vector<int64_t>(H + max_damage + 1, INT64_MAX));
  for (auto &a : mp) {
    a[0] = 0;
  }
  for (int64_t i = 1; i <= N; ++i) {
    for (int64_t d = 1; d <= H + max_damage - 1; ++d) {
      mp[i][d] = mp[i - 1][d];
      if (d - A[i] >= 0 && mp[i - 1][d - A[i]] != INT64_MAX) {
        mp[i][d] = min(mp[i][d], mp[i - 1][d - A[i]] + B[i]);
      }
      if (d - A[i] >= 0 && mp[i][d - A[i]] != INT64_MAX) {
        mp[i][d] = min(mp[i][d], mp[i][d - A[i]] + B[i]);
      }
    }
  }
  int64_t result = INT64_MAX;
  for (int64_t d = H; d < H + max_damage; ++d) {
    result = min(result, mp[N][d]);
  }
  cout << result << endl;
  return 0;
}


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

int main() {

  double N, K;
  cin >> N >> K;
  
  double ans;
  if (K <= N) { 
    ans = (N-K+1) / N;
  } else {
    ans = 0;
  } 
  
  for (int i = 1; i < min(N+1, K); i++) {
    int x = i;
    double sub_p = 1 / N;
    while (x < K) {
      x *= 2;
      sub_p *= 0.5;
    }
    
    ans += sub_p;
  }
  cout << fixed << setprecision(13) << ans << endl;
}

Measured memory_bytes: 256
n,m=gets.split.map &:to_i
h=gets.split.map &:to_i
z=[true]*n
m.times{|i|
a,b=gets.split.map &:to_i
a-=1
b-=1
z[a]=false if h[a]<=h[b]
z[b]=false if h[b]<=h[a]
}
p z.count{|a|a}

Measured memory_bytes: 22568
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

char s[11] = {'\0'};

void split(char *ptr, char* ptr2, int factor, int length){ /*ptrはコピー先、ptr2は切り取りコピーの素配列、factorは開始位置、lengthは切り出し個数。*/
	int num = 0;
	for(int a = factor; a < factor+length; a++) ptr[num++] = ptr2[a];
}

int check(char *ptr){ /*ptr配列での文字列の長さを返す。*/
	int length;
	for(length = 0; length < 11; length++){
		int checker = ptr[length] - '\0';
		if(!checker) break;
	}
	return length;
}

long long int add(char *ptr){
	long long int ans = atoll(ptr);
	int size = check(ptr);
	for(int a = 1; a < size; a++){
		char tmp[11] = {'\0'};
		char tmp2[11] = {'\0'};
		split(tmp,ptr,0,a);
		ans += atoll(tmp)*powl(2,size - a - 1);
		split(tmp2,ptr,a,size-a);
		//printf("tmp:%s tmp2:%s\n",tmp,tmp2);
		ans += add(tmp2);
		//printf("add fin : ans = %lld\n",ans);
	}
	return ans;
}

int main(void){
	long long int result = 0; /*factorは配列の長さとする。*/
	scanf("%s",s);
	result = add(s);
	printf("%lld\n",result);
	return 0;
}

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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}

int main(){
  ll n;
  cin >> n;
  vector<ll> v(n);
  rep(i,n) cin >> v[i];
  ll min = v[0];
  ll ans = 0;
  rep(i,n){
    if(v[i]<=min){
      min = v[i];
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}

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

int main() {
	short x, ans = 0;
  	for (short i = 1; i <= 5; i++) {
    	cin >> x;
      	if (x != i)
          ans = i;
    }
  	cout << ans;
  	return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define pq          priority_queue
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define inf         INT_MAX
#define vl          vector<ll>
#define vvl         vector<vector<ll>>
#define F           first
#define S           second
#define db          double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
const int N=3005;
ll n;
db p[N],dp[N][N];

void solve()
{
    fix(15);
   cin>>n;
   rep(i,1,n+1)cin>>p[i]; // dp[i][j]=j heads among i tosses
   dp[0][0]=1.0;
   rep(i,1,n+1){
       rep(j,0,i+1){
           if(j!=0) dp[i][j]=(1.0-p[i])*dp[i-1][j]+p[i]*dp[i-1][j-1];
           else dp[i][j]=(1-p[i])*dp[i-1][j];
       }
   }
   db ans=0.0;
   rep(i,1,n+1) if(i>n-i) ans+=dp[n][i];
   cout<<ans;
}

int main()
{
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
}


Measured memory_bytes: 68992
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		double r = sc.nextDouble();
		
		System.out.print(String.format("%.6f", r * r * Math.PI ));
		System.out.print(" ");
		System.out.println(String.format("%.6f",(r + r) * Math.PI));
		
		sc.close();
	}
}

Measured memory_bytes: 28136
//
//  header_useful.h
//  c++_acm
//
//  Created by 李弘辰 on 2019/7/23.
//  Copyright © 2019 李弘辰. All rights reserved.
//

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <utility> // pair
#include <map>
#include <iostream>
#include <sstream>
#include <algorithm> // sort
#include <string>
#include <stack>
#include <queue>
#include <fstream>

using namespace std;

#define ll long long
#define uchar unsigned char
#define ushort unsigned short
#define uint unsigned int
#define ulong unsigned long
#define ull unsigned long long

#define pi acos(-1)

#define mx(a,b) (a) > (b) ? (a) : (b)
#define mn(a,b) (a) < (b) ? (a) : (b)
#define mem(a,b) memset(a,b,sizeof(a))
#define fre(a) freopen(a,"r",stdin)
#define cio ios::sync_with_stdio(false);

#define itn int
#define nit int
#define inr int
#define mian main
#define ednl endl
#define fro for
#define fir for
#define reutrn return
#define retunr return
#define reutnr return


/* header_useful_h */


int a[200010];

int main()
{
    int n;
    scanf("%d",&n);
    for (int i = 0;i < n;i ++)
    {
        scanf("%d",a + i);
    }
    ll s[200010] = {0};
    for (int i = 0;i < n;i ++)
    {
        s[a[i]] ++;
    }
    ll sum = 0;
    for (int i = 0;i < 200010;i ++)
    {
        sum += (s[i] - 1) * s[i] / 2;
    }
    for (int k = 0;k < n;k ++)
    {
        int i = a[k];
        printf("%lld\n",sum - (s[i] - 1) * s[i] / 2 + (s[i] - 2) * (s[i] - 1) / 2);
    }
    return 0;
}


Measured memory_bytes: 5496
#include <iostream>
using namespace std;
const int INF = 1e9;

int main() {
    int N, M, X; cin >> N >> M >> X;
    int C[N], A[N][M];
    for (int i = 0; i < N; i++) {
        cin >> C[i];
        for (int j = 0; j < M; j++) {
            cin >> A[i][j];
        }
    }
    int ans = INF, cost = 0;
    for (int bit = 0; bit < (1<<N); bit++) {
        int cost = 0;
        int res[M] = {};
        for (int i = 0; i < N; i++) {
            if (bit & (1<<i)) {
                cost += C[i];
                for (int j = 0; j < M; j++) {
                    res[j] += A[i][j];
                }
            }
        }
        int flag = 1;
        for (int i = 0; i < M; i++) {
            if (res[i] < X) {
                flag = 0;
                break;
            }
        }
        if (flag) ans = min(ans, cost);
    }
    if (ans == INF) cout << "-1" << endl;
    else cout << ans << endl; 
}

Measured memory_bytes: 3640
N=int(input())
L=list(map(int,input().split()))
a=L[0]
for i in range(N-1):
  a=L[i+1]-a
R=[0]*N
R[0]=a
for i in range(N-1):
  R[i+1]=(L[i]-R[i]//2)*2
print(" ".join(list(map(str,R))))

Measured memory_bytes: 19180
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;

int main() {
    int n;  cin >> n;
    string c;   cin >> c;
    vector<ll> x(n+1, 0), y(n+1, 0);

    for (int i = 0; i < n; i++) {
        if (c[i] == 'R')
            y[0]++;
    }

    for (int i = 0; i < n; i++) {
        if (c[i] == 'W') {
            x[i+1] = x[i]+1;
            y[i+1] = y[i];
        }
        else {
            x[i+1] = x[i];
            y[i+1] = y[i]-1;
        }
    }

    ll ans = 999999;
    for (int i = 0; i <= n; i++) {
        ans = min(ans, max(x[i], y[i]));
    }

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

Measured memory_bytes: 6724
package main

import "fmt"

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)

	lcm := lcm(c, d)

	ans := f(b, c, d, lcm) - f(a-1, c, d, lcm)
	fmt.Println(ans)

}

//1~x
func f(x int, c, d, lcm int) int {
	return x - x/c - x/d + x/lcm
}
func lcm(i, j int) int {
	return i * j / gcd(i, j)
}
func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

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

int main()
{
  int N;
  int sum = 0;
  
  cin >> N;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < N; k++) {
        sum++;
      }
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdint>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <valarray>
#include <vector>


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

using namespace std;


void solution()
{
    int k;
    cin >> k;
    int a = 7 % k;
    int n = 1;
    unordered_set<int> used_num = {a};
    for(;;){
        if(a == 0){
            break;
        }
        int newa = (a * 10 + 7) % k;
        if(used_num.find(newa) != used_num.end()){
            cout << "-1\n";
            return;
        }
        a = newa;
        used_num.insert(newa);
        n += 1;
    }
    cout << n << '\n';
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    solution();
    return 0;
}


Measured memory_bytes: 42536
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
//#include <set>
//#include <map>
//#include <iostream>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000//10^12


int main(void)
{
	//変数の宣言
	int n,m;

	//よく使う変数
	int i,j,l;
	int flag=0;
	ll int ans=0;
	int count=0;
	int temp,temp1,temp2;
	int max,min;
	int len;
	int sum=0;


	//データの読み込み
	scanf("%d %d",&n,&m);
//	scanf_s("%d %d",&n,&m);

/*	fri(m){
		scanf("%d",x[i]);
		scanf_s("%d",&x[i]);
	}
*/

	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	if(n==m){
		ans=2;
	}else if(abs(n-m)==1){
		ans=1;
	}else{
		printf("0");
		return 0;
	}

	for(i=1;i<=n;i++){
		ans=ans*i;
		ans=ans%1000000007;
	}

	for(i=1;i<=m;i++){
		ans=ans*i;
		ans=ans%1000000007;
	}

	//	printf("計算部分終了\n");

	//出力

	printf("%lld",ans);

	//	printf("結果の出力終了\n");


	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
#define ALL(obj) (obj).begin(),(obj).end()

string getString(string s,int a,int b)
{
    string t;
    for(int i=a;i<a+b;i++){
        t+=s.at(i);
    }
    return t;
}

int main(){
    string s;
    cin >> s;
    int k;
    bool chk=false;
    cin >> k;
    set<string> st;
    vector<string> str;

    for(int i=0;i<s.size();i++){
        for(int j=0;j<=k;j++){
            if(s.size()-i<j)break;
            string t=s.substr(i,j);
            if(st.find(t)==st.end())str.push_back(t);
            st.insert(t);
        }
    }
    sort(ALL(str));
    cout << str.at(k) << endl;
    return 0;
}


Measured memory_bytes: 1792
n = gets.to_i
line = gets.split(' ').map(&:to_i)
total_trade = 0

n.times do |i|
  index = line[i..-1].index(line[i..-1].min) + i
  next if i == index

  tmp = line[i]
  line[i] = line[index]
  line[index] = tmp
  total_trade += 1
end

puts line.join(' ')
puts total_trade


Measured memory_bytes: 6944
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;

#define dbg(x) cerr << #x"=" << x << endl;
typedef long long LL;
const int MAX_N = 1e5+100;
const LL MOD = 1e9+7;
LL f[MAX_N][11][15];
char s[MAX_N];

inline int to(char c){
    return c - '0';
}

int main(){
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    memset(f, 0, sizeof f);
    cin >> (s+1);
    int n = strlen((s+1));
    if(s[n] == '?') {
        for(int i = 0; i <= 9; ++i){
            f[n][i][i] = 1;
        }
    } else f[n][to(s[n])][to(s[n])] = 1LL;
    LL base = 1LL;
    for(int k = n; k >= 2; --k){
        base = base * 10LL % 13;
        for(int i = 0; i <= 9; ++i){ // 当前位置的数字情况
            for(int j = 0; j <= 12; ++j){ // 余数情况
                if(f[k][i][j]){
                    char c = s[k-1];
                    int l = 0, r = 9;
                    if(c != '?'){
                        l = to(c);
                        r = to(c);
                    }
                    for(int nxt = l; nxt <= r; ++nxt){ // 下一个位置的数字情况
                        (f[k-1][nxt][(nxt*base + j)%13] += f[k][i][j]) %= MOD;
                    }
                }
            }
        }
    }
    LL ans = 0;
    for(int i = 0; i <= 9; ++i){
        (ans += f[1][i][5]) %= MOD;
    }
    cout << ans << endl;
    return 0;
}
/*
f[k][i][j] 表示s[k..n]%13=j的数字个数 其中s[k]=i
*/



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

void drop(int x, int y, int xy[][10]){
  if(x>=0 && x<10 && y>=0 && y<10)
    xy[x][y]++;
}

int main(){
  int xy[10][10]={{0}};
  int x,y,size,num=0,ans=0;
  const int small=5, medium=9, big=13;
  char c;

  int s[small][2]={{0,0},{-1,0},{1,0},{0,-1},{0,1}};
  int m[medium][2]={{0,0},{-1,0},{1,0},{0,-1},{0,1},{-1,-1},{-1,1},{1,-1},{1,1}};
  int b[big][2]={{0,0},{-1,0},{1,0},{0,-1},{0,1},{-1,-1},{-1,1},{1,-1},{1,1},{-2,0},{2,0},{0,-2},{0,2}};
  while(cin >> x >> c >> y >> c >> size){
    if(size==1) for(int i=0; i<small; i++) drop(x+s[i][0],y+s[i][1],xy);
    else if(size==2) for(int i=0; i<medium; i++) drop(x+m[i][0],y+m[i][1],xy);
    else for(int i=0; i<big; i++) drop(x+b[i][0],y+b[i][1],xy);
  }

  for(int i=0; i<10; i++)
    for(int j=0; j<10; j++){
      if(xy[i][j]==0) num++;
      if(xy[i][j]>ans) ans = xy[i][j];
    }

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

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrepi(i,a,b) for(int i=((int)(b)-1);i>=(a);--i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) rrepi(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define ZERO(x) memset(x,0,sizeof(x))
#define MINUS(x) memset(x,-1,sizeof(x))
#define UNIQUE(x) (x).erase(unique(ALL(x)), (x).end())
#define TOUPPER(x) transform(ALL(x), (x).begin(), ::toupper)
#define TOLOWER(x) transform(ALL(x), (x).begin(), ::tolower)
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void viewarr(T arr[], int n) { for(int i = 0; i < n; ++i) std::cout << arr[i] << " "; std::cout << std::endl; }
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; }
ll qp(ll a,ll b){ll ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
ll qp(ll a,ll b,ll mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const int INF = 1e9;
const ll INFL = 1e18;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5;

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


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;




bool dp[maxn];
int n, k;
vector<int> a;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    cin>>n>>k;
    a.resize(n);
    for (int i=0; i<n; i++) {
	cin>>a[i];
    }

    dp[0]=false;
    for (int i=1; i<=k; i++) {
	for (int x: a) {
	    if (i-x>=0) {
		if (!dp[i-x]) {
		    dp[i]=true;
		    break;
		}
	    }
	}
    }

    cout<<(dp[k]? "First\n": "Second\n");
  

    return 0;
}


Measured memory_bytes: 384
use std::cmp::max;
use std::fs;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let (mut x, mut y, a, b): (usize, usize, usize, usize) = parse!(it, 4);
    let c: usize = parse!(it);
    let mut p: Vec<usize> = parse!(it, a);
    let mut q: Vec<usize> = parse!(it, b);
    let mut r: Vec<usize> = parse!(it, c);
    p.sort();
    p.reverse();
    let mut p = (&p[..x]).to_vec();
    q.sort();
    q.reverse();
    let mut q = (&q[..y]).to_vec();
    r.append(&mut p);
    r.append(&mut q);
    r.sort();
    r.reverse();
    println!("{}", &r[..(x + y)].iter().sum::<usize>());
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 16748
s = gets.chomp
n = s.length

def check1(str,start1,end1)
 str_slice = str[start1-1 .. end1-1]
 if str_slice == str_slice.reverse
   return 1
 else
   return 0
 end
end
if check1(s,1,n)*check1(s,1,(n-1)/2)*check1(s,(n+3)/2,n) == 1
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 1788
N = int(input())
list=[]
list = (str(input()))
cnt = 0
R = 0
W = 0
ans = 0
for i in range (N):
    if list[i] == "R":
        R += 1

W = N-R

cnt = min(R, W)

if R > W:
    for i in range(0,cnt):
        if list[N-i-1]=="R":
            ans +=1

if R<=W:
    for j in range(0,cnt):
        if list[j] == "W":
            ans +=1


print(ans)






Measured memory_bytes: 9412
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1234576891234601LL;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	int N, M, a0, ad, b0, bd;
	cin >> N >> M >> a0 >> ad >> b0 >> bd;
	vector<int> a(N), b(M);
	a[0] = a0;
	for (int i = 1; i < N; i++)
		a[i] = (a[i - 1] * 58 + ad) % (M + 1);
	b[0] = b0;
	for (int j = 1; j < M; j++)
		b[j] = (b[j - 1] * 58 + bd) % (N + 1);
	vector<int> c(N + 1);
	for (int j = 0; j < M; j++)
		c[b[j]]++;
	for (int i = N - 1; i >= 0; i--)
		c[i] += c[i + 1];
	sort(a.begin(), a.end(), greater<int>());
	ll unko = 0, ans = 0;
	for (int i = 0; i < N; i++) {
		int k = min((ll)a[i], unko + c[i + 1]);
		ans += k;
		unko += c[i + 1] - k;
	}
	cout << ans << endl;
}

Measured memory_bytes: 32148
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args) {
        int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int n = s[0];
        int m = s[1];
        List<int> x = Console.ReadLine().Split().Select(int.Parse).ToList();
        x.Add(x.Min());
        x.Sort();
        int[] l = new int[m];
        for(int i = 0; i < m; i ++) {
            l[i] = Math.Abs(x[i+1]-x[i]);
        }
        Array.Sort(l);
        Array.Reverse(l);
        for(int i = 0; i < n-1; i ++) {
            l[i] = 0;
            if(i == m-1) break;
        }
        Console.WriteLine(l.Sum());
    }
}

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

using namespace std;

const int N = 3e3+100;

long long int dp[N][N][3], a[N];

int main () {
    long long int n;
    cin >> n;
    for(int i = 0 ; i < n ; i++ ) {
        cin >> a[i];
        dp[i][i][0]=a[i];
        dp[i][i][1]=0;
    }
    for(int d = 1 ; d < n ; d++ ) {
        for(int j = 0 ; j < n ; j++ ) {
            if(j+d>=n)break;
            int i = j+d;
            dp[j][i][0]=max(dp[j][i-1][1]+a[i],dp[j+1][i][1]+a[j]);
            dp[j][i][1]=min(dp[j][i-1][0],dp[j+1][i][0]);
        }
    }
    cout << dp[0][n-1][0]-dp[0][n-1][1];
}


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

/*
void swap(int *a, int *b) {
  int temp = *a;
  *a = *b;
  *b = temp;
}
*/

int main() {
  int n;  cin >> n;
  
  int card[n];
  for (int i = 0; i < n; i++) 
    cin >> card[i];
  
  sort(card, card + n, greater<int>());
  
  /*
  int max;
  for (int i = 0; i < n; i++) {
    max = i;
    for (int j = i + 1; j < n; j++) {
      if (card[max] < card[j])
        max = j;
    }
    swap(card[i], card[max]);
  }
  */
  
  int alice = 0, bob = 0;
  for (int i = 0; i < n; i += 2) {
    alice += card[i];
    if (i + 1 < n)
      bob += card[i + 1];
  }
  cout << alice - bob << endl;
}


Measured memory_bytes: 256
import sys, heapq, bisect, math, fractions
from collections import deque

N = int(input())
P = list(map(int, sys.stdin.readline().rsplit()))

def ok():
    for i in range(N - 1):
        if P[i + 1] < P[i]:
            return False
    return True

if ok():
    print("YES")
else:
    for i in range(N - 1):
        for j in range(i + 1, N):
            P[i], P[j] = P[j], P[i]
            if ok():
                print("YES")
                exit()
            else:
                P[i], P[j] = P[j], P[i]

    print("NO")

Measured memory_bytes: 5076
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
          Copyright                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz(a) int((a).size())
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,y) for(int i=(x);i<=(y);i++)
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 400010;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return (pwur * pwur) % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------


int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));
    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);
    int n,k;
    cin>>n>>k;
    map<int,int>mp;
    rep(i,n){
        int a,b;
        cin>>a>>b;
        mp[a]+=b;
    }
    int ans=0;
    for(auto p:mp){
        if(p.s>=k){
            cout<<p.f;
            return 0;
        }
        else k-=p.s;
    }



    return 0;
}


Measured memory_bytes: 7596
#include<stdio.h>

int main(){
    int i,loop,h,w,s;
    scanf("%d",&loop);
    for(i=0;i<loop;i++){
    scanf("%d %d %d",&h,&w,&s);
    if((h*h==w*w+s*s||w*w==h*h+s*s||s*s==w*w+h*h))printf("YES\n");
    else printf("NO\n");
    }
    return 0;
}

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

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


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

  vector<pair<int, int>> A(N);
  REP(i, N){
    cin >> A[i].first;
    A[i].second = i;
  }

  sort(ALL(A),   // dai -> syou
      [](pair<int, int> const & l, pair<int, int> const &  r){
      if(l.first == r.first) return l.second < r.second;
      return l.first > r.first;
      });

  vector<int> ans(N, 0);

  int MIN = INF;
  REP(i, N){
    chmin(MIN, A[i].second);
    ans[MIN] += (i+1)*(A[i].first-A[i+1].first);
  }

  REP(i, N){
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 3456
/*
                   ,.ood888888888888boo.,
              .od888P^""            ""^Y888bo.
          .od8P''   ..oood88888888booo.    ``Y8bo.
       .odP'"  .ood8888888888888888888888boo.  "`Ybo.
     .d8'   od8'd888888888f`8888't888888888b`8bo   `Yb.
    d8'  od8^   8888888888[  `'  ]8888888888   ^8bo  `8b
  .8P  d88'     8888888888P      Y8888888888     `88b  Y8.
 d8' .d8'       `Y88888888'      `88888888P'       `8b. `8b
.8P .88P            """"            """"            Y88. Y8.
88  888                                              888  88
88  888                                              888  88
88  888.        ..                        ..        .888  88
`8b `88b,     d8888b.od8bo.      .od8bo.d8888b     ,d88' d8'
 Y8. `Y88.    8888888888888b    d8888888888888    .88P' .8P
  `8b  Y88b.  `88888888888888  88888888888888'  .d88P  d8'
    Y8.  ^Y88bod8888888888888..8888888888888bod88P^  .8P
     `Y8.   ^Y888888888888888LS888888888888888P^   .8P'
       `^Yb.,  `^^Y8888888888888888888888P^^'  ,.dP^'
          `^Y8b..   ``^^^Y88888888P^^^'    ..d8P^'
              `^Y888bo.,            ,.od888P^'
                   "`^^Y888888888888P^^'"
*/

#include<bits/stdc++.h>
#define forn(i, n) for(int i=0;i<(int)(n);i++)
#define for1(i, n) for(int i=1;i<=(int)(n);i++)
#define ford(i, n) for(int i=(int)(n)-1;i>=0;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl "\n"
#define MAX 1e9+7
using namespace std;
typedef int64_t ll;
typedef vector<int> vi;
typedef vector<int64_t> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

int main(int argc, char *argv[]){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	
	ll a,b,c;
	cin >> a >> b >> c;
	if((a==b && a!=c) || (a==c && a!=b) || (b==c && b!=a))
		cout << "Yes\n";
	else
		cout << "No\n";

	return 0;
	// you should actually read the stuff at the bottom
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases ( n=0, 1, negatives ? )
	* do smth instead of nothing and stay organized
*/



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int a[N], b[N];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++ i) scanf("%d%d", &a[i], &b[i]);
	long long tmp = 0;
	for (int i = n - 1; i >= 0; -- i) {
		tmp += (tmp + a[i] + b[i] - 1) / b[i] * b[i] - (tmp + a[i]);
	}
	cout << tmp << endl;
}



Measured memory_bytes: 1024
#include <iostream> //cin,cout
#include <fstream> //input.txtの入力
#include <vector> //vector
using namespace std;

int main(){
  //ifstream in("input.txt");
  //cin.rdbuf(in.rdbuf());

  int N,M;
  cin>>N>>M;

  int ac,wa;
  ac=0;wa=0;

  vector<long> iswa(N), isac(N);

  for(int i=0;i<M;i++){
    int x;
    string s;
    cin>>x>>s;
    x--;
    if(s=="AC"){
      if(!isac.at(x)){
        isac.at(x)++;
        ac++;
        wa+=iswa.at(x);
      }
    }
    else iswa.at(x)++;
  } 
  cout<<ac<<' '<<wa<<endl;
}


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

int main() {
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    vector<int> n(5);
    n[0] = a;
    n[1] = b;
    n[2] = c;
    n[3] = d;
    n[4] = e;
    sort(n.begin(), n.end());
    int max_distance = n[4] - n[0];
    if (max_distance <= k) {
        cout << "Yay!" << endl;
    } else {
        cout << ":(" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAX 5000001
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 10010010010001;

int main(){
    ll N,M;
    cin >> N >> M;
    ll ans = 0;
    if(N == 1 && M == 1){
        ans = 1;
    }
    else if(N == 1 && M != 1){
        ans = M-2;
    }
    else if(N != 1 && M == 1){
        ans = N-2;
    }
    else{
        ans = (N-2)*(M-2);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int main()
{
  string s,t;
  cin>>s>>t;
  int ans=0;

  for(int i=0; i<s.size(); i++)
  {
      if(s[i]!=t[i])
        ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3916
#include <cstdio>
#include <iostream>
#include <utility>
using namespace std;

int main(){
  long long m, n;
  scanf("%lld %lld", &m, &n);

  if (m > n) swap(m, n);

  if (m == 1) {
    if (n == 1) printf("1\n");
    else if (n == 2) printf("0\n");
    else printf("%lld\n", n - 2);
  } else if (m == 2) {
    printf("0\n");
  } else printf("%lld\n", (n - 2) * (m - 2));

  return 0;
}

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

#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

int N;

string S[100];

int dfs(int &n,int r){
    if(isdigit(S[n][r])){
        return S[n++][r]-'0';
    }
    int ret;
    if(S[n][r]=='+'){
        n++;
        ret=0;
        while(n<N&&S[n].size()>r+1&&S[n][r+1]!='.'){
            ret+=dfs(n,r+1);
        }
    }
    else{
        n++;
        ret=1;
        while(n<N&&S[n].size()>r+1&&S[n][r+1]!='.'){
            ret*=dfs(n,r+1);
        }
    }
    return ret;
}

signed main(){
    while(cin>>N,N){
        rep(i,N)cin>>S[i];
        int n=0;
        cout<<dfs(n,0)<<endl;
    }
    return 0;
}

Measured memory_bytes: 3168
l = list(input())

ab = l[0] + l[1]
cd = l[2] + l[3]

if ab[0] == "0":
    ab = ab[1]
if cd[0] == "0":
    cd = cd[1]

ab = int(ab)
cd = int(cd)
if ab < 13 and cd < 13 and ab != 0 and cd != 0:
    print("AMBIGUOUS")
elif ab >= 13 and cd < 13 and ab != 0 and cd != 0:
    print("YYMM")
elif cd >= 13 and ab < 13 and ab != 0 and cd != 0:
    print("MMYY")
elif ab == 0 and cd == 0:
    print("NA")
elif ab >= 13 and cd >= 13:
    print("NA")
elif ab == 0 and cd < 13 and cd != 0:
    print("YYMM")
elif cd == 0 and ab < 13 and ab != 0:
    print("MMYY")
elif ab == 0 and cd >= 13 and cd != 0:
    print("NA")
elif cd == 0 and ab >= 13 and ab != 0:
    print("NA")


Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<vector>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
const int N=1e5+5;
template<class T>inline void read(T &res)
{
char c;T flag=1;
while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
int main(){
	int n,m;
	read(n),read(m);
	if(n==m)puts("Yes");
	else puts("No");
	return 0;
}


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

const ll mod=1e9+7;
map<pair<ll,ll>,pair<ll,ll>> m;
ll dp[3003][3003];
string a,b;
string solve(){
    // Base Case
    for(ll i=1;a[i-1];i++){
        dp[i][0]=0;
    }
    for(ll i=1;b[i-1];i++){
        dp[0][i]=0;
    }
    dp[0][0]=0;
    for(ll i=1;a[i-1];i++){
        for(ll j=1;b[j-1];j++){
            if(a[i-1]==b[j-1]){
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);;
            }
        }
    }
    ll i=a.length(),j=b.length();
    string s;
    while(i>0 && j>0){
        if(a[i-1]==b[j-1]){
            s.push_back(a[i-1]);
            i--;
            j--;
        }
        else{
            if(dp[i-1][j]>dp[i][j-1])i--;
            else j--;
        }
    }
    i=0,j=s.length()-1;
    while(i<=j){
        swap(s[i],s[j]);
        i++;
        j--;
    }
    return s;
}


int main() {
    
    cin>>a>>b;
    memset(dp,-1,sizeof(dp));
    string ans=solve();
    ll i=0,j=0;
    cout<<ans<<endl;
}


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

void chss(int H, int W){
  for (int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
     if((i + j) % 2 == 0){
       cout << "#";
     }else{
       cout << ".";
     }
    } 
    cout << endl;     
  }
}

int main(){
  int H,W;

  while(1){
    cin >> H >> W;
    if(H == 0 && W == 0) return 0;
    
    chss(H, W);
    cout << endl;
  }
}

Measured memory_bytes: 1152
// --https://kenkoooo.com/atcoder/#/table/soma62jp
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>

using namespace std;

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

	int N;
	int ans = 1;
	string wrk;

	cin >> N;

	vector<string> W(N,"");

	for(int i=0 ; i<N ; i++){
		cin >> W[i];
	}

	for(int i=0 ; i < N-1 ; i++){
		if(W[i][W[i].size() - 1] != W[i+1][0]){
			ans=0;
		}
	}

	sort(W.begin(),W.end());

	wrk = "";
	for(int i=0 ; i<N ; i++){
		if(wrk==W[i]){
			ans=0;
		}
		wrk=W[i];
	}

	if(ans){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;

}



Measured memory_bytes: 256
from collections import deque
N, M = map(int, input().split())
G = [deque() for _ in range(N+1)]
ans = [0]*(N+1)
for _ in range(M):
  a, b = map(int, input().split())
  G[a].append(b)
  G[b].append(a)
memo = [False]*(N+1)
q = deque()
q.append(1)
while q:
  x = q.popleft()
  if not memo[x]:
    memo[x] = True
    for y in G[x]:
      if ans[y] == 0:
        ans[y] = x
        q.append(y)
print("Yes")
print("\n".join([str(x) for x in ans[2:]]))


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

int main() {
  int N;
  cin >> N;
  int p=0,i=0,a=0,b=0;
  
  for(i=0;i<N;i++){
    cin >> a >> b;
    p+=b-a+1;
  }
cout<<p<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
     int a,b,temp;

    while(1)
    {
        scanf("%d%d",&a,&b);
        if(a==0&&b==0)
        break;
        if(a>b)
    {
        temp=b;
         b=a;
         a=temp;
    }
    printf("%d %d\n",a,b);
    }
    return 0;
}



Measured memory_bytes: 2036
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String [][] nArray = new String [n][];
		for(int i = 0; i < n; i++) {
			String num = sc.next();
			nArray[i] = num.split("");
		}
		boolean judge = true;
		out: for(int i = 1; i < n; i++) {
			for(int k = 0; k < i; k++) {
				if(Arrays.equals(nArray[i], nArray[k])) {
					judge = false;
					break out;
				}
			}
		}
		for(int i = 0; i < n-1; i++) {
			if(nArray[i][nArray[i].length-1].equals(nArray[i+1][0])) {
			}else {
				judge = false;
				break;
			}
		}

		if(judge) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 21716
#include <iostream>
#include <math.h>
using namespace std;

int main() {
	int D, N, result;
	cin >> D;
	cin >> N;

	if (N == 100) {
		N = 101 ;
	} 

	result = N * pow(10, 2 * D);
	cout << result;

	return 0;
}

Measured memory_bytes: 256
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
a = [list(map(int,input().split())) for i in range(n)]
cnt = 0
for j in range (n):
  ans = 0
  for k in range (m):
    ans += a[j][k]*b[k]
  if ans+c > 0:
    cnt += 1
print(cnt)

Measured memory_bytes: 9136
#include <stdio.h>
#include <string.h>
#include <ctype.h>

void StrToLower(char *str);

int main( void )
{
	char w[11];
	char t[1001];
	int cnt = 0;
	
	scanf("%s", w);
	StrToLower(w);
	
	while( 1 ){
		scanf("%s", t);
		
		if(!strcmp(t, "END_OF_TEXT")) break;
		
		StrToLower(t);
		
		if(!strcmp(t, w)) cnt++;
	}
	
	printf("%d\n", cnt);
	
	return 0;
}

void StrToLower(char *str)
{
	char *ch;
	
	for(ch = str; *ch != '\0'; ch++){
		*ch = tolower(*ch);
	}
}

Measured memory_bytes: 552
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[1000001];
int main(void){
	ll n,m,i,p,f,cnt;
	char s[1000001];
	while(1){
		cin>>n;
		if(n==0)break;
		cin>>m>>s;
		for(i=0;i<m;i++) a[i]=0;
		for(i=1;i<m-1;i++){
			if(s[i]=='O'&&s[i-1]=='I'&&s[i+1]=='I') a[i]=1;
		}
		for(i=2;i<m;i++){
			if(a[i]!=0&&a[i-2]!=0){
				a[i]+=a[i-2];
				a[i-2]=0;
			}
		}
		cnt=0;
		for(i=0;i<m;i++){
			if(a[i]>=n)	cnt+=1+a[i]-n;
		}
		cout<<cnt<<endl;
	}
	return 0;
}


Measured memory_bytes: 11872
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();

		StringBuffer sb = new StringBuffer();
		for(int i = S.length(); i > 0; i--) {
			sb.append(S.charAt(i - 1));
		}
		String R = sb.toString();

		int count = 0;
		for(int i = 0; i < S.length(); i++) {
			if(S.charAt(i) != R.charAt(i)) {
				count++;
			}else {
				continue;
			}
		}
		System.out.println(count / 2);
	}

}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define ios ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
int a[16],b[16],c[16];
int main()
{
	ios;
	int n;
	cin>>n;
	for(int i=1;i<=n;++i)cin>>a[i];
	for(int i=1;i<=n;++i)cin>>b[i];
	for(int i=1;i<=n;++i)c[i]=i;
	int num1=0,num2=0;
	int flag1=0,flag2=0,t=0;
	do
	{
		t++;
		if(!flag1)
		{
			int flag=1;
			for(int i=1;i<=n;++i)
			{
				if(c[i]!=a[i]){flag=0;break;}
			}
			if(flag)
			{
				flag1=1;
				num1=t;
			}
		}
		if(!flag2)
		{
			int flag=1;
			for(int i=1;i<=n;++i)
			{
				if(c[i]!=b[i]){flag=0;break;}
			}
			if(flag)
			{
				flag2=1;
				num2=t;
			}
		}
	}while(next_permutation(c+1,c+1+n));
	cout<<abs(num1-num2)<<'\n';
}

Measured memory_bytes: 3640
n,a,b = map(int,input().split())

if (a - b) % 2 == 0:
    print(min(abs(a-b) // 2, max(a-1, b-1), max(n-a, n-b)))
else:
    print(min(max(a-1, b-1), max(n-a, n-b), (a+b-1)//2, (2 * n - a - b + 1)//2))


Measured memory_bytes: 9104
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define sz(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
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;
}
int main() {
    string s;cin>>s;
    int lo=sz(s);
    int b=0;
    ll ans=0;
    rep(i,lo){
        if(s[i]=='B'){
            b++;
        }else{
            ans+=b;
        }
    }
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640