akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <set>
#include <deque>
#include <map>
#include <iomanip>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <utility>
using namespace std;
int ky[8] = {-1,1,-2,2,-2,2,-1,1}; 
int kx[8] = {-2,-2,-1,-1,1,1,2,2};
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int ddy[8] = {-1,0,1,-1,1,-1,0,1};
int ddx[8] = {-1,-1,-1,0,0,1,1,1};
typedef long long ll;
#define pi pair
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define rep1(i,a,b) for(int i = a; i < b; i++)
#define rep2(i,a,b) for(int i = a; i <= b; i++) 
#define INF 99999999999999999
const double PI = acos(-1.0);
int N,M;
vector<int> adj[100001];
int d[100001];
int a,b;
queue<int> q;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> N >> M;
    rep1(i,0,M){
        cin >> a >> b;
        adj[a].PB(b);
        adj[b].PB(a);
    }

    rep2(i,1,N) d[i] = -1;
    q.push(1);
    
    while(!q.empty()){
        int here = q.front(); q.pop();
        
        rep1(i,0,(int)adj[here].size()){
            int next = adj[here][i];
            if(d[next] != -1) continue;
            d[next] = here;
            q.push(next);
        }
    }

    rep2(i,2,N) if(d[i] == -1){
        cout << "No";
        return 0;
    }

    cout << "Yes\n";
    rep2(i,2,N) cout << d[i] << '\n';
    return 0;
}

Measured memory_bytes: 10528
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;$n:expr) => {
        (0..$n).map(|_| scan!()).collect::<Vec<_>>()
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (n, _) = scan!(usize, i64);
    let mut num = n;
    let mut v = scan!(usize;;);
    v.sort();
    v.reverse();
    let matches = vec![2usize, 5, 5, 4, 5, 6, 3, 7, 6];
    let mut dp = vec![-1i64 << 60; n + 1];

    dp[0] = 0;
    for i in 1..dp.len() {
        dp[i] = v
            .iter()
            .map(|&m| {
                if i >= matches[m - 1] {
                    dp[(i - matches[m - 1]) as usize] + 1
                } else {
                    -1i64 << 60
                }
            })
            .max()
            .unwrap()
    }

    let mut ans = String::new();
    while num != 0 {
        for &m in v.iter() {
            if num >= matches[m - 1] && dp[(num - matches[m - 1]) as usize] == dp[num] - 1 {
                ans.push_str(&m.to_string());
                num -= matches[m - 1];
                break;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
 using namespace std;
 int main() 
{
  ios_base::sync_with_stdio(0);
   cin.tie(NULL);
   
   int n,a,b;
   cin>>n>>a>>b;
   cout<<min(n*a,b)<<"\n";
   return 0;
}
 
 

Measured memory_bytes: 256
card = [list(input()) for i in range(3)]
main = card[0]
target = "A"
while len(main) != 0:
    if main[0]=="a":
        main.remove(main[0])
        main = card[0]
        target = "A"
    elif main[0]=="b":
        main.remove(main[0])
        main = card[1]
        target = "B"
    else:
        main.remove(main[0])
        main = card[2]
        target = "C"

print(target)

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a[55];
int main()
{
	int n,i,j;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int sum=0;
	for(i=1;i<n;i++)
		for(j=i+1;j<=n;j++)
			sum+=a[i]*a[j];
	printf("%d",sum);
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void){
    int c, i, l, k;
    int H[1000],W[1000];
    for(c = 1; ; c++ ){
        scanf("%d %d", &H[c], &W[c]);
        if(H[c] == 0)   break;
    }
    c--;
    for(k = 1; k <= c; k++ ){
        for(i = 1; i <= H[k]; i++ ){
            if(i % 2 == 0){
                for(l = 1; l <= W[k]; l++ ){
                    if(l % 2 == 0){
                        printf("#");
                    } else {
                        printf(".");
                    }
                }
            } else {
                for(l = 1; l <= W[k]; l++ ){
                    if(l % 2 == 0){
                        printf(".");
                    } else {
                        printf("#");
                    }
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2044
import os
import sys
import math
import heapq
from decimal import *
from io import BytesIO, IOBase
from collections import defaultdict, deque

def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))

a,b,c=rm()
k=r()
while b<=a:
    b*=2
    k-=1
while c<=b:
    c*=2
    k-=1
if k>=0:
    print("Yes")
else:
    print("No")

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

int main(){
	int a,b,c,d,ans;
	cin >> a >> b >> c >> d;
	ans = abs(c-a) + abs(d-b) - __gcd(abs(c-a),abs(d-b));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
function main(input) {
    var ans = 0;
    input = input.split("\n");
    var n = input[0];
    var skewers = input[1].split(" "); 
    for (var i = 0; i < skewers.length; i++) {
        skewers[i] = parseInt(skewers[i]);
    }
    skewers.sort(function(a, b){return a-b});
    for (var i = 0; i < n; i++) {
        ans += skewers[2*i];
    }
    console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 6904
#include <cstdio>
#include <vector>

#define X first
#define Y second
#define PB push_back

using namespace std;

typedef long long ll;
typedef pair < int, int > pii;

const int N = 2e5 + 500;
const int OFF = (1 << 18);

ll dp[N];
int n, l[N], r[N], a[N], m;
vector < pii > v[N];

ll tour[2 * OFF],prop[2 * OFF];

void update(int i,int a,int b,int lo,int hi, ll x){
    if(lo <= a && b <= hi){
        tour[i] += x;
        prop[i] += x;
        return;
    }
    if(a > hi || b < lo) return;
    update(2 * i, a, (a + b) / 2, lo, hi, x);
    update(2 * i + 1, (a + b + 2) / 2, b, lo, hi, x);
    tour[i] = max(tour[2 * i], tour[2 * i + 1]) + prop[i];
}


int main(){
    scanf("%d%d", &n, &m);
    for(int i = 0;i<m;i++){
        scanf("%d%d%d", l + i, r + i, a + i);
        v[r[i] - 1].PB({l[i] - 1, a[i]});
    }
    for(int i = 0;i<n;i++){
        dp[i] = tour[1];
        update(1, 0, OFF - 1, i, i, dp[i]);
        for(int j = 0;j<v[i].size();j++){
            update(1, 0, OFF - 1, v[i][j].X, i, v[i][j].Y);
        }

    }
    printf("%lld\n", tour[1]);
}


Measured memory_bytes: 21248
import java.util.List;
import java.util.Scanner;
import java.util.Vector;

public class Main {
	static Vector<Integer> a[];
	static long dp[][];
	static int n;
	static long mod = 1000000007;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		a = new Vector[n];
		dp = new long[n][2];
		for (int i = 0; i < n; i++)
			a[i] = new Vector<>();
		for (int i = 0; i < n - 1; i++) {
			int x = sc.nextInt()-1;
			int y = sc.nextInt()-1;
			a[x].add(y);
			a[y].add(x);
		}
		int root = 0;
		for (int i = 0; i < n; i++)
			if (a[root].size()<a[i].size()) root = i;

		f(root,-1);
		System.out.println((dp[root][0]+dp[root][1])%mod);
	}

	private static void f(int r,int f) {
			dp[r][0] = dp[r][1] = 1;
		
		for (int i=0;i<a[r].size();i++) {
			int c = a[r].get(i);
			if (c==f) continue;
			f(c,r);
			dp[r][0] = (dp[r][0] * (dp[c][0]+dp[c][1])%mod)%mod;
			dp[r][1] = (dp[r][1] * dp[c][0])%mod;
		}
	}
}


Measured memory_bytes: 123496
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<queue>
#include<cstdio>
#include <iomanip>
#include <limits>
#include<vector>
using namespace std;

int main()
{
	int N,i,j,k,l,m,n,o,p;
	long long int sum, flag,cc,cnt;
	sum = 0;
	flag = 1;
	cc = 0;
	cnt = 0;
	char S[101];
	char T[101];
	cin >> S;
	cin >> T;
	n = strlen(S);
	for (i = 0; i < n; i++) {
		flag = 1;
		for (j = 0; j < n; j++) {
			if (S[(i + j)%n] != T[j]) {
				flag = 0;
				break;
			}
		}
		if (flag == 0) {
			continue;
		}
		else
			break;
	}
	if (flag)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;                                                                                   
#define FOR(v1, v2) for (v1 = 0; v1 < v2; ++v1)
int main () {
  int n, m;
  cin >> n >> m;
  cout << ((n == m)? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
lc=[]
ls=[]
lf=[]
for _ in range(N-1):
    C,S,F = map(int,input().split())
    lc.append(C)
    ls.append(S)
    lf.append(F)

for i in range(N-1):
    j = i
    ct = 0
    while j < N-1:
        if ct <= ls[j]:ct = ls[j] + lc[j]
        else:
            os = ct - ls[j]
            rm = os - lf[j] * (os//lf[j])
            if rm == 0:ct += lc[j]
            else:ct += (lf[j]-rm) + lc[j]
        if j == N-2:print(ct)
        j += 1
else:print(0)

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

int main() {
    string A[7] =  {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string s;
    cin >> s;
    int i = 0;
    while (s != A[i]) i++;
    cout << 7-i << endl;
    return 0;
}

Measured memory_bytes: 256
/**
 *  author:   TakeruOkuyama
 *  created:  2020-04-14 20:18:35
**/
#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>;

const int MOD = 1000000007;
const int INF = 999999999;

int main(){
    ll A, B, K;
    cin >> A >> B >> K;
    if(A > 0){
        if(A >= K){
            A = A - K;
            K = 0;
            cout << A << " " << B << endl;
            return 0;
        }else{
            K = K - A;
            A = 0;
        }
    }
    if(B > 0){
        if(B >= K){
            B = B - K;
            K = 0;
            cout << A << " " << B << endl;
            return 0;
        }else{
            K = K - B;
            B = 0;
        }
    }
    cout << A << " " << B << endl;
return 0;}

/**
 * g++ code.cpp
 * ./a.out
 * shift + ctrl + i
**/ 

Measured memory_bytes: 256
N, M = list(map(int,input().split()))
 
d = int(M/N)

def solve():
    ans = 1
    for i in range(M//N+1, 0, -1):
        if M % i == 0:
            if (M // i) >= N:
                print(i)
                break
	# i = 0
	# while True:
	# 	if M%(N+i+1) == 0:
	# 		print(int(M/(N+i+1)))
	# 		break
	# 	i += 1

if M%N == 0:
	print(d)
else:
	solve()

Measured memory_bytes: 2940
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<vector>
using namespace std;
#define ll long long
#define db double
ll gcd(ll a,ll b)
{
    return b>0?gcd(b,a%b):a;
}
int main()
{

    ll a,b;
    scanf("%lld %lld",&a,&b);
    ll k=gcd(a,b);
    ll ans=1;
    for(ll i=2;i*i<=k;i++)
    {
        if(k%i==0)
        {
            ans++;
            while(k%i==0)
            {
                k=k/i;
            }
        }
    }
    if(k>1)ans++;
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 3764
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {
	ll N,D=0;
	cin >> N ;
	vector<ll> A(N);
	vector<ll> B(N);
	vector<ll> W(N);
	for (int i = 0; i < N; i++) {
		cin >> A.at(i)>>B.at(i);
		W.at(i)= A.at(i) + B.at(i);
		D -= (B.at(i));
	}
	sort(W.begin(), W.end());
	reverse(W.begin(), W.end());
	rep(i, (N+1)/2) {
		D += W.at(i*2);
	}

	cout << D << endl;

	
	
}

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

int main(){
  string a, b;
  cin >> a >> b;
  int ans = 0;
  for(int i = 0; i < (int)a.size(); ++i)
    if(a[i]!=b[i])
      ans++;
  cout << ans << '\n';
  return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> segments = {0b0111111, 0b0000110, 0b1011011, 0b1001111,
                          0b1100110, 0b1101101, 0b1111101, 0b0100111,
                          0b1111111, 0b1101111};

  while(1) {
    int n;
    cin >> n;
    if(n == -1) { break; }
    int bef, aft;
    cin >> bef;
    cout << bitset<7>(segments[bef]) << endl;
    for(int i = 0; i < n - 1; i++) {
      cin >> aft;
      cout << bitset<7>(segments[bef] ^ segments[aft]) << endl;
      bef = aft;
    }
  }
  return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define EPS (1e-10)
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;
	rep(i, s.size() - 1) {
		if (s.at(i) == s.at(i + 1)) {
			cout << i +1<< " " << i + 2 << endl; return 0;
		}
	}
	rep(i, s.size() - 2)
	{
		if (s.at(i) == s.at(i + 2)) {
			cout << i +1<< " " << i + 3 << endl; return 0;
		}
	}
	cout << -1 << " " << -1 << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <limits>

using namespace std;
typedef long long ll;

int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> a(m), b(m);
    vector<vector<ll>> c(m);
    for(int i = 0; i < m; ++i){
        cin >> a.at(i) >> b.at(i);
        c.at(i).resize(b.at(i));
        for(int j = 0; j < b.at(i); ++j){
            cin >> c.at(i).at(j);
            c.at(i).at(j)--;
        }
    }

    vector<ll> price(1 << n, numeric_limits<ll>::max());
    price.at(0) = 0;
    for(ll i = 0; i < price.size(); ++i){
        if(price.at(i) == numeric_limits<ll>::max()){
            continue;
        }
        for(ll j = 0; j < m; ++j){
            ll k = i;
            for(ll ci : c.at(j)){
                k |= (1 << ci);
            }
            price.at(k) = min(
                price.at(k),
                price.at(i) + a.at(j)
            );
        }
    }

    if(price.back() != numeric_limits<ll>::max()){
        cout << price.back() << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll X;
    cin >> X;

    if(X<=3){
        cout << 1 << endl;
        return 0;
    }
    ll ans = 0;
    for(ll i=2; i<=X; i++){
        ll temp = i;
        temp *= temp;
        if(temp > X) continue;
        while(temp*i <= X){
         temp = temp*i;   
        }
        ans = max(ans, temp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
using namespace std;

int main(){
  string ans;
  int a, b;
  cin >> a >> b;
  vector<int> ac(a + 1);
  vector<int> bc(b + 1);
  cin >> ac[0];
  cin >> bc[0];
  rep(i, a) cin >> ac[i + 1];
  rep(i, b) cin >> bc[i + 1];
  if (*max_element(all(ac)) >= *min_element(all(bc))) ans = "War";
  else ans = "No War";
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

#define N 8
#define FREE -1
#define NOTFREE 1

int row[N], col[N], dpos[2 * N - 1], dneg[2 * N - 1];

int X[N][N];

void initialize(){
  int i, j;
  for(i = 0; i < N; i++) {
    row[i] = FREE;
    col[i] = FREE;
  } 
  for(i = 0; i < 2 * N - 1; i++){
    dpos[i] = FREE; // 右から左にかけての斜め
    dneg[i] = FREE; // 左から右にかけての斜め
  }
}

void print(){
  int i, j;
  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      if(X[i][j]){
	if(row[i] != j) return;
      }
    }
  }

  for(i = 0; i < N; i++){
     for(j = 0; j < N; j++){
       if(row[i] == j) printf("Q");
       else printf(".");
     }
     printf("\n");
  }
}

void put_queen(int i){
  if(i == N){
    print();
    return;
  }

  int j;

  for(j = 0; j < N; j++){
    if(NOTFREE == col[j] || NOTFREE == dpos[i + j] || NOTFREE == dneg[i - j + N - 1])
      continue;

    row[i] = j;
    col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOTFREE;
    put_queen(i + 1);
    row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
  }

}

int main(){
  initialize();
  int i, j, k, r, c;

  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      X[i][j] = 0;
    }
  }
     
  scanf("%d", &k);

  for(i = 0; i < k; i++){
    scanf("%d %d", &r, &c);
    X[r][c] = 1;
  }

  put_queen(0);
  
  return 0;
}



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

int a[1010];

int main(){
	int n,min;
	while(1){
		cin>>n;
		if(n==0) break;
		min=10000000;
		for(int i=0;i<n;i++) cin>>a[i];
		int f=1;
		while(f!=0){
			f=0;
			for(int j=0;j<n-1;j++){
				if(a[j]>a[j+1]){
					swap(a[j],a[j+1]);
					f++;
				}
			}
		}
		for(int i=n-1;i>0;i--){
			if(min>a[i]-a[i-1]) min=a[i]-a[i-1];
		}
		cout<<min<<endl;
	}
	return 0;
}


Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main(){
  int n;
  while(cin>>n,n){
    char c[n],i,j,k;
    int a[26]={};
    for(i=0;i<n;i++) cin>>c[i],c[i]-='A';
    priority_queue<P> q;
    P x,y;
    for(i=0;i<n;i++){
      a[c[i]]++;
      q.push(P(a[c[i]],c[i]));
      x=q.top();
      if(x.first>n/2) break;
      while(!q.empty()&&q.top().second==x.second) q.pop();
      if(!q.empty()){
	y=q.top();q.pop();
	if(y.first+(n-i-1)<x.first) break;
	q.push(y);
      }
      q.push(x);
    }
    if(i<n) cout << (char)('A'+x.second) << " " << i+1 << endl;
    else cout << "TIE" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3072
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

int f(int m, int e, int j) {
  if (m == 100 || e == 100 || j == 100) return 0;
  if (m + e >= 90 * 2) return 0;
  if (m + e + j >= 80 * 3) return 0;
  if (m + e + j >= 70 * 3) return 1;
  if (m + e + j >= 50 * 3 && (m >= 80 || e >= 80)) return 1;
  return 2;
}

void solve() {
  int n, m;
  while (cin >> n, n) {
    while (n--) {
      int m, e, j;
      cin >> m >> e >> j;
      cout << char('A' + f(m, e, j)) << endl;
    }
  }
}

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

public class Main{
	static void main() throws Exception{
		pw.println(sc.nextInt()^1);
	}
	public static void main(String[] args) throws Exception{
		sc=new MScanner(System.in);
		pw = new PrintWriter(System.out);
		int tc=1;
//		tc=sc.nextInt();
		while(tc-->0)
			main();
		pw.flush();
	}
	static PrintWriter pw;
	static MScanner  sc;
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void shuffle(int[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*(i+1));
			int tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
	static void shuffle(long[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*(i+1));
			long tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
}

Measured memory_bytes: 25420
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define RREP(i,a) for(int (i)=(a)-1;(i)>=0;(i)--)
#define FORR(i,a,b) for(int (i)=(a)-1;(i)>=(b);(i)--)
#define PI acos(-1.0)
#define DEBUG(C) cout<<C<<endl;
#define VI vector<int>
#define VII vector<VI>
#define VL vector<LL>
#define VLL vector<VL>
#define VD vector<double>
#define VDD vector<VD>
#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<LL,LL>
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define REVERSE(a) reverse(ALL(a))
#define MP make_pair
#define EP emplace_back
#define FORE(a,b) for(auto &&a:b)

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int INF=1e9;
const int MOD=INF+7;

VI ans;
VL a;
LL N,L;
int p=-1;
int main (void){
    cin>>N>>L;
    a=VL(N+1,0);
    REP(i,N){
        scanf("%d",&a[i+1]);
        if(i && p==-1){
            if(a[i]+a[i+1]>=L) p=i;
        }
    }
    if(p==-1){
        printf("Impossible\n");
        return 0;
    }
    FOR(i,1,p) ans.emplace_back(i);
    FORR(i,N,p) ans.emplace_back(i);
    printf("Possible\n");
    REP(i,ans.size()){
        printf("%d\n",ans[i]);
    }
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
#include <stdint.h>
#include <algorithm>
#include <vector>


using namespace std;

int main() {
	int n;
	cin >> n;
	
	vector<int> a(n,0);
	
	int max = 0;
	int second = 0;
	int maxint = 0;
	
	for (int i = 0; i < n; i++) {
		cin >> a.at(i);
		if (a.at(i) > max) {
			second = max;
			max = a.at(i);
			maxint = i;
		} else if(a.at(i) > second) {
			second = a.at(i);
		}
	}
	
	for (int i = 0; i < n; i++) {
		if (i == maxint) {
			cout <<second<<endl;
		} else {
			cout << max << endl;
		}
	}
	
	return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define ll long long
#define int long long
#define MOD 1000000007
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define vvi vector<vi>
#define endl "\n"
using namespace std;
void solve1();
void solve()
{
    int t;cin>>t;
    while(t--)
    {
        solve1();
    }
}
signed main()
{
    solve1();
}
void solve1()
{
    char x;
    cin>>x;
    if(x-'A'>=0&&x-'A'<26)cout<< 'A'<<endl;
    else cout<< 'a'<<endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mx2 102
#define mx3 1003
#define mx4 10004
#define mx5 100005
#define mx6 1000006
#define mod 1000000007
#define PI 3.14159265
#define fo(i,n) for(int i=0 ; i<n ; i++)
#define Fo(i,k,n) for(int i=k ; i<n ; i++)
 
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pair<int,int>,int> piii;

int n , m,a , b , cost[mx3],dp[mx3][(1<<12)];
const int inf =0x3f3f3f3f;
vector<int> v(mx3);

int solve(int i , int bit)
{
	if(i==m)
	{
		if(bit!=((1<<n)-1))
		{
			return inf;
		}
		return 0;
	}
	if(dp[i][bit]!=-1)
	{
		return dp[i][bit];
	}
	
	int ans1,ans2;
	ans1=solve(i+1,bit);
	int tmp=(bit|v[i]);
	ans2=solve(i+1,tmp)+cost[i];
	return dp[i][bit]=min(ans1,ans2);
}
 
int main() {
	ios::sync_with_stdio(false);
	//int t;cin>>t;while(t--)
	{
		cin>>n>>m;
		memset(dp,-1,sizeof(dp));
		fo(i,m)
		{
			cin>>cost[i]>>b;
			int tmp=0;
			fo(j,b)
			{
				cin>>a;
				tmp|=(1<<(a-1));
			}
			// cout<< tmp << " ";
			v[i]=tmp;
		}
		
		int ans=solve(0,0);
		if(ans<inf)
		{
			cout<<ans;
		}
		else
		{
			cout<<"-1";
		}
		
	}
	return 0;
}


Measured memory_bytes: 16384
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <sstream>
#include <string>
#include <utility>
#include <map>
#include <memory>
#include <set>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <array>

using namespace std;

const double eps = 1e-10;

class Vector
{
public:
  double x;
  double y;

  Vector(){}
  Vector( double x, double y ) : x(x), y(y) {}

  Vector operator + ( const Vector v ) { return Vector( x + v.x, y + v.y ); }
  Vector operator - ( const Vector v ) { return Vector( x - v.x, y - v.y ); }
  Vector operator * ( const double k ) { return Vector( x * k, y * k ); }
  Vector operator / ( const double k ) { return Vector( x / k, y / k ); }
  bool operator < ( const Vector &v ) const { return x * x + y * y < v.x * v.x + v.y * v.y; }

  double abs() { return sqrt( norm() ); }
  double norm() { return x * x + y * y; }

  static double dot( Vector v1, Vector v2 ) { return v1.x * v2.x + v1.y * v2.y; }
  static double cross( Vector v1, Vector v2 ) { return v1.x * v2.y - v1.y * v2.x; }

  void print() { cout << fixed << setprecision(10) << x << " " << y << endl; }
  static Vector projection( Vector ps, Vector pt, Vector p );
};

Vector Vector::projection( Vector ps, Vector pt, Vector p )
{
  Vector a = pt - ps;
  Vector b = p - ps;

  return ps + a * dot( a, b ) / a.norm();
}

class Circle
{
public:
  Vector cp;
  double r;
  Circle(){}
  Circle( Vector cp, double r ) : cp(cp), r(r) {}
};
  
class CPCircleLine
{
public:
  Circle c;
  CPCircleLine(){}
  CPCircleLine( Circle c ) : c(c) {}
  int solve( Vector p0, Vector p1 );
  void print( Vector p0, Vector p1 );
};

int CPCircleLine::solve( Vector p0, Vector p1 )
{
  Vector pr = Vector::projection( p0, p1, c.cp );
  Vector a = pr - c.cp;
  double t = sqrt( c.r * c.r - a.norm() );
  Vector p10 = p1 - p0;
  Vector e = p10 / p10.abs();
  print( pr + e * t, pr - e * t );
  
  return 0;
}

void CPCircleLine::print( Vector p0, Vector p1 )
{
  if ( p0.x < p1.x )
    cout << fixed << setprecision(10) << p0.x << " " << p0.y << " " << p1.x << " " << p1.y << endl;
  else if ( p0.x > p1.x )
    cout << fixed << setprecision(10) << p1.x << " " << p1.y << " " << p0.x << " " << p0.y << endl;
  else if ( p0.y < p1.y )
    cout << fixed << setprecision(10) << p0.x << " " << p0.y << " " << p1.x << " " << p1.y << endl;
  else
    cout << fixed << setprecision(10) << p1.x << " " << p1.y << " " << p0.x << " " << p0.y << endl;
}

int main()
{
  double cx, cy, r;
  cin >> cx >> cy >> r;
  
  CPCircleLine cpcl( Circle( Vector(cx, cy), r ));
  
  int q;
  cin >> q;

  for ( auto i = 0; i < q; ++i )
    {
      double x0, y0, x1, y1;
      cin >> x0 >> y0 >> x1 >> y1;
      
      cpcl.solve( Vector(x0, y0), Vector(x1, y1) );
    }

  return 0;
}

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

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void()
#endif

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ans = (int)1e9;
  for (int c = -100; c <= 100; c++) {
    int cost = 0;
    for (int i = 0; i < n; i++) {
      cost += (a[i] - c) * (a[i] - c);
    }
    ans = min(ans, cost);
  }
  cout << ans << '\n';
  return 0;
}

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

#define BUF_SIZE 20

struct uni {
  struct uni *parent;
  int depth;
};

struct uni *find_root(struct uni *u) {
  while(u->parent != u) {
    u = u->parent;
  }
  return u;
}

int check_group(struct uni *u1, struct uni *u2) {
  struct uni *root1 = find_root(u1);
  struct uni *root2 = find_root(u2);
  return root1 == root2;
}

void unite(struct uni *u1, struct uni *u2) {
  if(check_group(u1, u2)) return;
  struct uni *root1 = find_root(u1);
  struct uni *root2 = find_root(u2);
  if(root1->depth > root2->depth) {
    root2->parent = root1;
  } else {
    root1->parent = root2;
    if(root1->depth == root2->depth) {
      root2->depth++;
    }
  }
}

int main(void) {
  FILE *fp = stdin;
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, fp)) return 0;

  int num, conns;
  sscanf(line, "%d %d", &num, &conns);

  int i, j;
  struct uni *graphs = malloc(sizeof(struct uni)*num);
  for(i = 0; i < num; i++) {
    graphs[i].parent = &graphs[i];
    graphs[i].depth = 0;
  }

  for(i = 0; i < conns; i++) {
    if(!fgets(line, BUF_SIZE, fp)) return 0;
    int s1, s2;
    sscanf(line, "%d %d", &s1, &s2);
    unite(&graphs[s1], &graphs[s2]);
  }


  if(!fgets(line, BUF_SIZE, fp)) return 0;
  int queries;
  sscanf(line, "%d", &queries);

  for(i = 0; i < queries; i++) {
    int s1, s2;
    if(!fgets(line, BUF_SIZE, fp)) return 0;
    sscanf(line, "%d %d", &s1, &s2);
    int flag = check_group(&graphs[s1], &graphs[s2]);
    printf("%s\n", flag ? "yes" : "no");
  }
  return 0;
}


Measured memory_bytes: 3184
#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>;
 
int main(){
  string lr;
  cin >> lr;
  int n = lr.size();
  vector<int> ans(n);
  rep(i, n) ans.at(i) = 0;
  char s0 = lr.at(0);
  int ki = 0;
  int gu = 0;
  int cou = 0;
  if(s0 == 'R'){
    ki++;
    cou++;
  }
  for(int i=1; i<n; i++){
    if(lr.at(i) == 'R'){
      cou++;
      if(cou%2 == 1){
        ki++;
      }else{
        gu++;
      }
    }
    if(s0 == 'R' && lr.at(i) == 'L'){
      ans.at(i) += gu;
      ans.at(i-1) += ki;
      cou = 0;
      ki = 0;
      gu = 0;
    }
    s0 = lr.at(i);
  }
  s0 = lr.at(n-1);
  ki = 0;
  gu = 0;
  cou = 0;
  if(s0 == 'L'){
    ki++;
    cou++;
  }
  for(int i=n-2; i>=0; i--){
    if(lr.at(i) == 'L'){
      cou++;
      if(cou%2 == 1){
        ki++;
      }else{
        gu++;
      }
    }
    if(s0 == 'L' && lr.at(i) == 'R'){
      ans.at(i) += gu;
      ans.at(i+1) += ki;
      cou = 0;
      ki = 0;
      gu = 0;
    }
    s0 = lr.at(i);
  }
  rep(i, n) cout << ans.at(i) << ' ';
  cout << endl;
}

Measured memory_bytes: 1152
n1,t1 = map(int, input().split())
n2,t2 = map(int, input().split())
n3,t3 = map(int, input().split())
n4,t4 = map(int, input().split())
n5,t5 = map(int, input().split())
n6,t6 = map(int, input().split())
n7,t7 = map(int, input().split()) 

s1=abs(n1-t1)
s2=abs(n2-t2)
s3=abs(n3-t3)
s4=abs(n4-t4)
s5=abs(n5-t5)
s6=abs(n6-t6)
s7=abs(n7-t7)

print(s1)
print(s2)
print(s3)
print(s4)
print(s5)
print(s6)
print(s7)


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

int dp[59][3001];
 
int main(void)
{
	while(1)
	{
		int num,max,sum;
		cin >> num >> max >> sum;
		if(num+max+sum == 0)
			return 0;
		memset(dp,0,sizeof(dp));
		dp[0][0] = 1;

		for(int m=1;m<=max;++m)//その数を使ッた時のあれ
		{
			for(int n=num*num;n>=1;--n)//どの数が使う？(num
			{
				for(int i=m;i<=sum;++i){//どの数が使う？(sum
					dp[n][i] += dp[n-1][i-m];//mを使った時の通り数を足す
					dp[n][i] %= 100000;
				}
			}
		}

		cout << dp[num*num][sum] << endl;
	}
		return 0;
}

Measured memory_bytes: 1860
#include<bits/stdc++.h>
using namespace std;
#define loop(i,a,b) for(int i=a;i<(int)b;i++)
int main() 
{
    char ch1,ch2;
    cin>>ch1>>ch2;
    if(ch1=='H')
     cout<<ch2;
    else
    {
        if(ch2=='H')
         cout<<'D';
        else
         cout<<'H';
    }
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    int a[N];
    ll m = inf, M = -inf;
    int mi, Mi;
    REP(i, N) {
        cin >> a[i];
        if (m > a[i]) {
            m = a[i];
            mi = i;
        }

        if (M < a[i]) {
            M = a[i];
            Mi = i;
        }
    }

    ++mi; ++Mi;

    if (m * M < 0) {
        cout << 2 * N - 1 << endl;
        if (abs(m) > abs(M)) {
            REP(i, N) {
                cout << mi << " " << i+1 << endl;
            }
            m += m;
            M += m;
        } else {
            REP(i, N){
                cout << Mi << " " << i+1 << endl;
            }
            m += M;
            M += M;
        }
    } else {
        cout << N - 1 << endl;
    }


    if (m >= 0) {
        REP(i, N - 1) {
            cout << i + 1 << " " << i + 2 << endl;
        }
    } else {
        REP(i, N - 1) {
            cout << N - i << " " << N - i - 1 << endl;
        }
    }

}


Measured memory_bytes: 256
#include<stdio.h>

int LinearSearch(int *, int);

int n;

int main(void){

  int q,s[10000],t,count=0,i;


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


  scanf("%d",&q);
  for(i = 0 ; i < q ; i++){
    scanf("%d",&t);

    if(LinearSearch(s,t)==1) count++;

  }

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

  return 0;

}


int LinearSearch(int *s, int key){

  int i = 0;

  s[n] = key;

  while(s[i]!=key){
    i++;
  }
  
  if(i == n) return 0;
  
  return 1;
  
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iterator>

#define ll long long int
#define mod 1000000007

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    string s,t;
    cin >> s >> t;
    int m = s.length();
    int n = t.length();
    
    vector<vector<int>> dp(m+1,vector<int>(n+1,0));
    for(int i = 1;i<m+1;i++){
        for(int j = 1;j<n+1;j++){
            if(s[i-1] == t[j-1]){
            dp[i][j] = dp[i-1][j-1]+1 ;
            }
            else
            dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }
    
    
    string res;
    
    int i = m,j = n;
    while(i>0 && j>0){
        if(dp[i][j] == dp[i-1][j]){
            i--;
        }
        else if(dp[i][j] == dp[i][j-1])
        j--;
        else{
        res += t[j-1];
            i--;
            j--;
        }
    }
    reverse(res.begin(),res.end());
    cout << res;
}









Measured memory_bytes: 37720
#include <bits/stdc++.h>
typedef long long ll;
#define fr first
#define sc second

using namespace std;
const int MN = 1e2+7;
const int MA = 1e5+7;

int a[MN], cnt[5];
int dp[MA];

signed main(){
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++)cin >> a[i];
    for(int i = 0; i <= k; i++){
        int sw = 0;
        for(int j = 0; j < n; j++){
            if(a[j] <= i && (!dp[i-a[j]]))sw = 1;
        }
        dp[i] = sw;
    }
    cout << (dp[k]?"First":"Second");
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  ll a;
  string s;
  cin >> a >> s;
  ll b = s[0]-'0';
  b *= 10;
  b += s[2]-'0';
  b *= 10;
  b += s[3]-'0';
  ll ans = a*b/100;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3660
/*  TAHMID RAHMAN
    DAMIAN FOREVER
     MATH LOVER
    NEVER GIVE UP
*/
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define pb push_back
#define fi first
#define se second
#define in insert
#define mp make_pair
#define GCD(a,b) __gcd(a,b);
#define endl "\n"
#define FRU freopen("out.txt","w",stdout)
#define FRO freopen("in.txt","r",stdin)
#define INFLL 9223372036854775807
#define debug 0
#define MAXN   100001
//Don't hesitate to ask me if you don't understand my code.......Happy coding,Tahmid...;
int main()
{
    fastio;
    ll a,b;
    cin>>a>>b;
    cout<<a*b<<endl;


}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define inf 100000000
using namespace std;

typedef struct {
  int a;
  int b;
  int c;
} data;

int d, n, ans = 0;
int maxmin[2][65] = {0};
int t[205] = {0};
data ls[205];
// j日にiの服を着るときのそれまでの最大値
int dp[2][205] = {0};

void solve();

int main() {
  int i, j;
  cin >> d >> n;
  for(i = 0; i < d; ++i) cin >> t[i];
  for(i = 0; i < 65; ++i) maxmin[1][i] = inf;
  //その温度のときの派手さの最大値と最小値も記録する。
  for(i = 0; i < n; ++i) {
    cin >> ls[i].a >> ls[i].b >> ls[i].c;
    for(j = ls[i].a; j <= ls[i].b; ++j) {
      maxmin[0][j] = max(maxmin[0][j], ls[i].c);
      maxmin[1][j] = min(maxmin[1][j], ls[i].c);
    }
  }
  solve();
  cout << max(dp[0][d - 1], dp[1][d - 1]) << endl;
  return 0;
}

void solve() {
  int i, j, k;
  for(i = 1; i < d; ++i) {
    for(j = 0; j < 2; ++j) {
      for(k = 0; k < 2; ++k) {
        int bf = maxmin[k][t[i - 1]], now = maxmin[j][t[i]];
        now = max(now - bf, bf - now);
        dp[j][i] = max(dp[j][i], dp[k][i - 1] + now);
      }
    }
  }
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int r, D, x;
  cin >> r >> D >> x;

  int A[10];
  A[0] = x;
  
  for(int i=0 ;i < 10 ;i++){
    A[i+1] = r*A[i]-D;
  }
  

    cout << A[1] <<endl;
    cout << A[2] <<endl;
      cout << A[3] <<endl;
      cout << A[4] <<endl;
      cout << A[5] <<endl;
      cout << A[6] <<endl;
        cout << A[7] <<endl;
        cout << A[8] <<endl;
        cout << A[9] <<endl;
        cout << A[10] <<endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
char s[100010];
char s1[100010];
int len;
int main(){
	cin >> s;
	len = strlen(s);
	for(int i = len - 1, j = 0; i >= 0; i--, j++){
		if(s[i] == 'd') s1[j] = 'b';
		else if(s[i] == 'b') s1[j] = 'd';
		else if(s[i] == 'p') s1[j] = 'q';
		else if(s[i] == 'q') s1[j] = 'p';
	}
	for(int i = 0; i <= len; i++)
		if(s[i] != s1[i]){
			printf("No");
			return 0;
		}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
typedef long long ll;
const ll INF = 1ll << 60;

int main()
{

    int n;
    cin >> n;
    map<string, int> mp;

    vector<string> s(n);
    REP(i, n)
    {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }

    ll ans = 0;
    for (auto &p : mp)
    {
        int s = p.second;
        ans += (ll)s * (s - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}

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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

int main() {
    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    for (int i = 0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());
    bool can = true;
    for (int i = 0; i < S.size();) {
        bool can2 = false; 
        for (int j = 0; j < 4; ++j) {
            string d = divide[j];
            if (S.substr(i, d.size()) == d) { 
                can2 = true;
                i += d.size(); 
            }
        }
        if (!can2) { 
            can = false;
            break;
        }
    }

    if (can) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
int main()
{
    int N;
    scanf("%d",&N);
    if(N>=1&&N<=999)
    {
        while( N>10)
        {
            N=N%10;
        }
        if(N==2||N==4||N==5||N==7||N==9)
        {
            printf("hon");
        }
        if(N==0||N==1||N==6||N==8)
        {
            printf("pon");
        }
        if(N==3)
        {
            printf("bon");
        }
    }

}


Measured memory_bytes: 2156
n = int(input())
p = list(map(int, input().split()))

cnt = 0
for i in range(1, n-1):
  if p[i-1] > p[i] and p[i] > p[i+1]:
    cnt += 1
  elif p[i-1] < p[i] and p[i] < p[i+1]:
    cnt += 1

print(cnt)

Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;
int a,b,num;
int main() {
	cin >> a >> b;
  for (int i = a-1; i > 0; i--) {
    cout << b - i << " ";
  }

  if (a != 1)
    cout << b << " ";

  for (int i = 1; a > i + 1; i++) {
    cout << b + i << " ";
  }
  cout << b + a - 1 << endl;
}


Measured memory_bytes: 256