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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int rsl = 0;
  rep(i, 0, s.size() / 2) {
      if(s[i] != s[s.size() - i - 1]) rsl++;
  }
  cout << rsl << endl;
}


Measured memory_bytes: 256
/*input
5
1 2 3 4 5
1000000000 1000000000 1000000000 1000000000 1000000000
*/
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int const N = 200001;
int dp[N];
int tree[4*N];
int V,ind;
void update(int TN,int S,int E){
	if(S == E){
		tree[TN]=V;
		return;
	}
	int mid = (S+E)/2;
	if(mid>=ind){
		update(2*TN,S,mid);
	}
	else{
		update(2*TN+1,mid+1,E);
	}
	tree[TN]=max(tree[2*TN],tree[2*TN+1]);
}
int L,R;
int query(int TN,int S,int E){
	if(S>R||E<L){
		return 0 ;
	}
	if(S>=L&&E<=R){
		return tree[TN];
	}
	int mid = (S+E)/2;
	return max(query(2*TN,S,mid),query(2*TN+1,mid+1,E));
}
signed main() {
	IOS;
	int n;
	cin>>n;
	int a[n+1];
	int h[n+1];
	for(int i=1;i<=n;i++){
		cin>>h[i];
	}
	for(int i=1;i<=n;i++){
		cin>>a[i];
		
	}
	h[0]=0;
	a[0]=0;
	for(int i=1;i<=n;i++){
		dp[h[i]]=a[i];
		V = a[i];
		ind = h[i];
		update(1,1,N);
		L = 0 ; R = h[i]-1;
		dp[h[i]]=max(dp[h[i]],a[i]+query(1,1,N));
		V = dp[h[i]];
		ind = h[i];
		update(1,1,N);
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		ans = max(ans,dp[h[i]]);
	}
	cout << ans << endl ; 
return 0;
}


Measured memory_bytes: 11136
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			String[] s = new String[3];
			s[0] = sc.next();
			if (s[0].equals("0")) {
				break;
			}
			for(int i=1;i<3;i++) {
				s[i] = sc.next();
			}
			char[][] map = new char[3][];
			for(int i=0;i<3;i++) {
				map[i] = s[i].toCharArray();
			}
			char c = win(map);
			System.out.println(c == '+' ? "NA" : c);
		}
	}

	public static char win(char[][] map) {
		for(int i=0;i<3;i++) {
			char c = win(map,i,0,0,1);
			if (c != '+') {
				return c;
			}
			c = win(map,0,i,1,0);
			if (c != '+') {
				return c;
			}
		}
		char c = win(map,0,0,1,1);
		if (c != '+') {
			return c;
		}
		return win(map,0,2,1,-1);
	}
	public static char win(char[][] map,int si,int sj,int di,int dj) {
		char c = map[si][sj];
		if (c == '+') {
			return '+';
		}
		for(int i=1;i<3;i++) {
			si += di;
			sj += dj;
			if (map[si][sj] != c) {
				return '+';
			}
		}
		return c;
	}

}

Measured memory_bytes: 17176
def m():
    A = []
    for _ in range(5):
        a = int(input())
        A.append(a)
    k = int(input())

    B = A.copy()
    for i in range(5):
        for j in range(i, 5):
            if B[j]-A[i] > k:
                return ':('
    return 'Yay!'

print(m())


Measured memory_bytes: 3060
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
at,bt=[0]*n,[0]*n
s=0
d=0
for i in range(n):
    s+=a[i]
    at[i]=(s)
    d+=b[-i-1]
    bt[-i-1]=d
print(max(sum(f) for f in zip(at,bt)))

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

using namespace std;

const int N = 1e5 + 10;

int n, a[ N ];

int main() {
  cin >> n;
  for ( int i = 0 ; i < n ; ++i )
    cin >> a[ i ];

  int cnt = 0;
  for ( int i = 0 ; i < n ; ++i )
    if ( a[ i ] & 1 )
      ++cnt;

  if ( cnt & 1 )
    cout << "NO" << endl;
  else 
    cout << "YES" << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  string S;
  cin >> S;
  if(S.size() == 2) cout << S << endl;
  else reverse(all(S)), cout << S << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long 
const int mod=998244353,N=3e5+5;
char s[N];int cnt[3];
int calc(char ch){
	if(ch=='R') return 0;
	if(ch=='G') return 1;
	return 2;
}
signed main(){
	int ans=1;
	int n;cin>>n>>(s+1);
	for(int i=1;i<=3*n;++i){
		int t=calc(s[i]),tmp=1e18;
		for(int j=0;j<3;++j)
			if(cnt[j]>cnt[t]) tmp=min(tmp,cnt[j]-cnt[t]);
		if(tmp!=1e18) ans=ans*tmp%mod;
		cnt[t]++;
		tmp=min(min(cnt[0],cnt[1]),cnt[2]);
		for(int j=0;j<3;++j)
			cnt[j]-=tmp;
	}
	for(int i=2;i<=n;++i) ans=ans*i%mod;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3916
#include <stdio.h>
#include <stdlib.h>
#define M 2000001
#define X 10001

int main() {
  unsigned short *A, *B;

  int C[X];
  int n, i, j;
  scanf("%d", &n);

  A = malloc(sizeof(short) * n + 1);
  B = malloc(sizeof(short) * n + 1);

  for(i = 0; i <= X; i++) C[i] = 0;

  for(i = 0; i < n; i++) {
    scanf("%hu",&A[i + 1]);
    C[A[i + 1]] += 1;
  }

  for(i = 1; i <= X; i++) C[i] = C[i] + C[i-1];

  for(j = 1; j <= n; j++) {
    B[C[A[j]]] = A[j];
    C[A[j]] -= 1;
  }

  for(i = 1; i<= n; i++) {
    if(i>1)printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 8464
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;

const int N = 1e5 + 5;
const int INF = 1e6 + 5;
const int mod = 1000000007;//786433;//998244353;
const double Pi = acos(-1);

 
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

long long a, b;

int main()
{
	cin >> a >> b;
	cout << a * b;	
}

Measured memory_bytes: 3636
from functools import lru_cache
@lru_cache(maxsize=None)
def b(n):
    if n<1:return 1
    return b(n-1)*2+3
@lru_cache(maxsize=None)
def p(n):
    if n<1:return 1
    return p(n-1)*2+1
def solve(n,x):
    if n<1:return int(x>0)
    if x-2<b(n-1):return(solve(n-1,x-1))
    return p(n-1)+solve(n-1,x-b(n-1)-2)+1
print(solve(*map(int,input().split())))

Measured memory_bytes: 38256
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

#define EPS 1e-9

double get_angle( double x1, double y1, double x2, double y2 )
{
	double angle;
	double m;
	if ( x1 == x2 ) angle = 90.0;
	else
	{
		m = ( y2 - y1 ) / ( x2 - x1 );
		angle = atan( m ) * 180.0 / M_PI;
	}
	return angle;
}

double get_radian( double x1, double y1, double x2, double y2 )
{
	if ( x1 == x2 ) return M_PI / 180.0;
	return atan( ( y2 - y1 ) / ( x2 - x1 ) );
}

double get_distance( double x1, double y1, double x2, double y2 )
{
	return sqrt( ( x2 - x1 ) * ( x2 - x1 ) + ( y2 - y1 ) * ( y2 - y1 ) );
}

int main( void )
{
	int n; cin >> n;
	
	double x1, y1, x2, y2, x3, y3;
	for ( int i = 0; i < n; i++ )
	{
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

		double x12 = ( x1 + x2 ) / 2.0;
		double y12 = ( y1 + y2 ) / 2.0;
		double a12 = get_angle( x1, y1, x2, y2 ) - 90.0;
		double x13 = ( x1 + x3 ) / 2.0;
		double y13 = ( y1 + y3 ) / 2.0;
		double a13 = get_angle( x1, y1, x3, y3 ) - 90.0;

		double t12 = tan( a12 * M_PI / 180.0 );
		double t13 = tan( a13 * M_PI / 180.0 );
		double x, y;
		if ( fabs( a12 - 90.0 ) <= EPS || fabs( a12 + 90.0 ) <= EPS )
		{
			y = t13 * ( x12 - x13 ) + y13;
			x = x12;
		}
		else if ( fabs( a13 - 90.0 ) <= EPS || fabs( a13 + 90.0 ) <= EPS )
		{
			y = t12 * ( x13 - x12 ) + y12;
			x = x13;
		}
		else
		{
			x = ( t12 * x12 - t13 * x13 + y13 - y12 ) / ( t12 - t13 );
			y = t12 * ( x - x12 ) + y12;
		}
		double r = get_distance( x1, y1, x, y );

		/*
		cout << "=== test ==============" << endl;
		cout << "a12 = " << a12 << endl;
		cout << "t12 = " << t12 << endl;
		cout << "x12 = " << x12 << endl;
		cout << "y12 = " << y12 << endl;
		cout << endl;
		cout << "a13 = " << a13 << endl;
		cout << "t13 = " << t13 << endl;
		cout << "x13 = " << x13 << endl;
		cout << "y13 = " << y13 << endl;
		cout << "=======================" << endl;
		*/

		cout.setf( ios::fixed );
		cout.precision( 3 );
		cout << x << " " << y << " " << r << endl;
	}

	return 0;
}

Measured memory_bytes: 0
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scanf("%s", &s)

	total := 0
	for i := 0 ; i< len(s) / 2; i++ {
		if s[i] != s[len(s) - 1 - i] {
			total ++
		}
	}

	fmt.Printf("%d", total)
}


Measured memory_bytes: 512
import sys

# from collections import Counter, deque, defaultdict
# from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
# from functools import reduce
# from math import ceil, floor, log10, log2, factorial

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7

# N = int(input())
# A = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]

N = int(input())
# XY = set()
XY = []
for _ in range(N):
    x, y = [int(x) for x in input().split()]
    # XY.add((x,y))
    XY.append((x, y))

XY.sort()
ans = float("INF")
for i in range(N):
    for j in range(N):
        if i == j:
            continue

        p = XY[i][0] - XY[j][0]
        q = XY[i][1] - XY[j][1]

        T = [0] * N
        for k in range(N):
            if T[k] != 0:
                continue
            T[k] = 1
            curXY = (XY[k][0], XY[k][1])

            for l in range(N):
                if (XY[l][0], XY[l][1]) == ((curXY[0] - p, curXY[1] - q)):
                    T[l] = 2
                    curXY = XY[l]

        # ans = min(T.count(1), ans)
        if ans > T.count(1):
            ans = T.count(1)
            ansP, ansQ = p, q
            # print("ans,p,q = {},{},{}".format(ans, p, q))

if N == 1:
    ans = 1

print(ans)


Measured memory_bytes: 45788
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll x, y;
map<ll, ll> score;
int main(){
    score[1]=300000;
    score[2]=200000;
    score[3]=100000;
    cin>>x>>y;

    if(x==1 && x==y) cout<<score[x]+score[y]+400000<<endl;
    else cout<<score[x]+score[y]<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Atcoderrrrrrr
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);int B = int.Parse(input[1]);

            string ans = "Impossible";
            if(A%3 ==0){
                ans ="Possible";
            }else if(B%3 ==0){
                ans = "Possible";
            }else if ((A+B) %3 ==0){
                ans = "Possible";
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

   ll r,x,d;
   cin>>r>>d>>x;
   ll a[10];
   a[0]=x*r-d;
   cout<<a[0]<<endl;
   for(int i=1;i<10;i++)
   {
       a[i]=r*a[i-1]-d;
       cout<<a[i]<<endl;
   }

}




Measured memory_bytes: 3596
for i in range(input()):
    s=raw_input()
    S=set()
    for j in range(1,len(s)):
        S.add(s[:j]+s[j:])
        S.add(s[:j][::-1]+s[j:])
        S.add(s[:j]+s[j:][::-1])
        S.add(s[:j][::-1]+s[j:][::-1])
        S.add(s[j:]+s[:j])
        S.add(s[j:][::-1]+s[:j])
        S.add(s[j:]+s[:j][::-1])
        S.add(s[j:][::-1]+s[:j][::-1])
    print len(S)

Measured memory_bytes: 4284
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
    int n;
    string s;
    cin >> n >>s;
    int cnt_tot=0;
    for(int i=0;i<n;i++){
        string l,r;
        l=s.substr(0,i);
        r=s.substr(i);
        int cnt_cut=0;
        for(int j=0;j<i;j++){
            bool flag =false;
            for(int k=0;k<j;k++){
                if(l.at(j)==l.at(k)){
                    flag =true;
                }
            }
            if(flag ==false){
                bool s_cnt=false;
                for(int k=0;k<n-i;k++){
                    if(l.at(j)==r.at(k)){
                        s_cnt =true;
                        break;
                    }
                }        
                if(s_cnt==true) cnt_cut++;
            }
        }
        if(cnt_tot <= cnt_cut) cnt_tot=cnt_cut;
    }
    cout <<cnt_tot <<endl;
}


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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);

    int n; cin >> n;
    vi v(n + 1), h(n);
    rep(i, 0, n + 1) cin >> v[i];
    rep(i, 0, n) cin >> h[i];
    ll ans = 0;
    rep(i, 0, n) {
        ll x = min(h[i], v[i]);
        h[i] -= x, v[i] -= x, ans += x;
        ll y = min(h[i], v[i + 1]);
        h[i] -= y, v[i + 1] -= y, ans += y;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

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

    cout << char('A' + (s1[0] - 'a'));
    cout << char('A' + (s2[0] - 'a'));
    cout << char('A' + (s3[0] - 'a'));
    cout << endl;
    return 0;
}

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

template <typename T>
class SegmentTree
{
private:
  using Fn = function<T(T, T)>;
  int N;
  vector<T> dat;
  T unit;
  Fn func;

public:
  SegmentTree() {}
  SegmentTree(int n_, Fn func_, T unit_) : func(func_), unit(unit_)
  {
    N = 1;
    while (N < n_)
      N *= 2;
    dat.assign(2 * N - 1, unit);
  }
  SegmentTree(vector<T> v, Fn func_, T unit_) : func(func_), unit(unit_)
  {
    N = 1;
    int sz = v.size();
    while (N < sz)
      N *= 2;
    dat.resize(2 * N - 1);
    for (int i = 0; i < N; ++i)
      dat[i + N - 1] = (i < sz ? v[i] : unit);
    for (int i = N - 2; i >= 0; --i)
      dat[i] = func(dat[i * 2 + 1], dat[i * 2 + 2]);
  }

  // k 番目の要素を a に変更
  void update(int k, T a)
  {
    k += N - 1;
    dat[k] = a;
    while (k > 0)
    {
      k = (k - 1) / 2;
      dat[k] = func(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
  }

  // k 番目の要素を取得
  T get(int k) { return dat[k + N - 1]; }

  // 区間 [l, r) のminを取得
  T query(int l, int r)
  {
    T vl = unit, vr = unit;
    for (l += (N - 1), r += (N - 1); l < r; l >>= 1, r >>= 1)
    {
      if ((l & 1) == 0)
        vl = func(vl, dat[l]);
      if ((r & 1) == 0)
        vr = func(vr, dat[--r]);
    }
    return func(vl, vr);
  }
};

int main(){
  int n,q;
  cin>>n>>q;
  auto f = [](int a, int b) {return min(a,b);};
  SegmentTree<int> sg(n,f,INT_MAX);
  rep(qi,q){
    int com, x, y;
    cin>>com>>x>>y;
    if(com==0)//change
      sg.update(x,y);
    else//min
      cout<<sg.query(x,y+1)<<endl;
  }
}


Measured memory_bytes: 3876
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use text_io::*;

fn main() {
    const U_INF: usize = 1 << 60;
    const I_INF: isize = 1 << 60;

    let n: usize = read!();
    let mut a = vec![0, 0, 0];
    for _ in 0..n {
        let ai: usize = read!();
        a[ai - 1] += 1;
    }

    let mut dp = vec![vec![vec![None; n + 10]; n + 10]; n + 10];
    dp[0][0][0] = Some(0.0);
    println!("{}", memo(n, a[0], a[1], a[2], &mut dp));
}

fn memo(n: usize, i: usize, j: usize, k: usize, dp: &mut Vec<Vec<Vec<Option<f64>>>>) -> f64 {
    match dp[i][j][k] {
        Some(ans) => ans,
        None => {
            let y = (i + j + k) as f64;
            let kk = if k == 0 {
                0.0
            } else {
                (k as f64 / y) * memo(n, i, j + 1, k - 1, dp)
            };
            let jj = if j == 0 {
                0.0
            } else {
                (j as f64 / y) * memo(n, i + 1, j - 1, k, dp)
            };
            let ii = if i == 0 {
                0.0
            } else {
                (i as f64 / y) * memo(n, i - 1, j, k, dp)
            };
            let ans = (n as f64) / y + ii + jj + kk;
            dp[i][j][k] = Some(ans);
            ans
        }
    }
}


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

int gcd(int x,int y){
  int r;
  while(y>0){
    r=x%y;
    x=y;
    y=r;
  }
  return x;
}

int main(){
  int N, K, A, g=0; cin >> N >> K;
  if(N==1){
    cin >> A;
    if(A==K){
      cout << "POSSIBLE" << endl;
    }else{
      cout << "IMPOSSIBLE" << endl;
    }
  }else{
    bool exist=false;
    bool bigger=false;
    for(int i=0; i<N; i++){
      cin >> A;
      if(A>K) bigger=true;
      else if(A==K) exist=true;
      g=gcd(A,g);
    }
    if(exist||(bigger&&(K%g==0))){
      cout << "POSSIBLE" << endl;
    }else{
      cout << "IMPOSSIBLE" << endl;
    }
  }
}

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

signed main(){
	string s;
	cin>>s;
	int ans=1e9;
	r(i,s.size()){
		int x=0,f=0;
		for(int j=0;j<3;j++){
			if(i+j<s.size())
				x=x*10+(s[i+j]-'0');
			else f++;
			if(!f&&j==2)ans=min(ans,abs(753-x));
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    forn (i, 0, n)
        cout << s[i] << t[i];
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	int i;
	int a, b;
	int count[100005];
	for (i = 0; i < n; i++)
		count[i] = 0;
	for (i = 0; i < m; i++)
	{
		scanf("%d %d", &a, &b);
		count[a - 1]++;
		count[b - 1]++;
	}
	for (i = 0; i < n; i++)
	{
		if (count[i] % 2 > 0)
		{
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second
using ld = long double;

int main(void) {
	ll a,b,c; cin >> a >> b >> c;
	if(c-a-b>0&&(c-a-b)*(c-a-b)>4*a*b) cout << "Yes" << endl;
	else cout << "No" << endl;
	
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>

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

using namespace std;
using ll = long long int;
using ull = unsigned long long;

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int main() {
	int n, k;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int tmp = -1;
	for (int j = 0; j < n; j++) {
		if (a[j] == 1) {
			tmp = j;
			break;
		}
	}
	if (tmp == -1) {
		cout << -1 << endl;
		return 0;
	}
	vector<int> b;
	b.push_back(1);
	k = 2;
	for (int i = tmp; a[i] != '\0'; i++) {
		if (a[i] == k) {
			b.push_back(k);
			k++;
		}
	}
	cout << (n - b.size()) << endl;
	return 0;
}

Measured memory_bytes: 2296
x = int(input())
for i in range(x):
    a , b , c = list(map(int,input().split()))
    if a**2 + b**2 == c**2:
        print("YES")
    elif a**2 + c**2 == b**2:
        print("YES")
    elif b**2 + c**2 == a**2:
        print("YES")
    else:
        print("NO")


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

class DisjointSet {
public:
  vector<int> rank, p;
  DisjointSet() {}
  DisjointSet(int size) {
    rank.resize(size,0);
    p.resize(size,0);
    for (int i=0; i<size; i++) {
      makeSet(i);
    }
  }
  void makeSet(int x) {
    p[x]=x;
    rank[x]=0;
  }
  bool same(int x,int y) {
    return findSet(x)==findSet(y);
  }
  void unite(int x,int y) {
    link(findSet(x),findSet(y));
  }
  void link(int x,int y) {
    if (rank[x]>=rank[y]) {
      p[y]=x;
    } else {
      p[x]=y;
      if (rank[x]==rank[y]) {
        rank[y]++;
      }
    }
  }
  int findSet(int x) {
    if (x!=p[x]) {
      p[x]=findSet(p[x]);
    }
    return p[x];
  }
};
int main() {
  int n, q;
  cin >> n >> q;
  DisjointSet ds=DisjointSet(n);
  int com, x, y;
  for (int i=0; i<q; i++) {
    cin >> com >> x >> y;
    if (com==0) {
      ds.unite(x,y);
    } else if (com==1) {
      cout << (ds.same(x,y)?1:0) << endl;
    }
  }
  return 0;
}



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

int main(){
  int n; cin >> n;
  vector<ll> v(n); rep(i,n) cin >> v.at(i);
  
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  cout << v.size() << endl;;
}


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


int solve(int value,int size,vector<int> digits , int N){
	
	if(value>=N) return value;
	
	
	int ans = 1000000;
	
	for(int i = 0 ; i < 10 ; i++){
		
		if(!digits[i]){
			int number  = solve(value*10+i,size,digits,N);
			
			if(number>=N){
				ans = min(ans,number);
			}
		}
		
	}
	
	return ans;
	
	
}

int main(){
	
	int N , K , val ;
	
	
	vector<int> digits(10,0);
	cin >> N >> K;
	for(int i = 0 ; i < K ; i ++){
		cin >> val ;
		
		digits[val]=1;
	}
	
	
	int size = log10(N)+1;
	
	int ans = 1000000;
	
	for(int i = 1;i<=9;i++){
		if(!digits[i]){
			int number = solve(i,size,digits,N); 
			if(number>=N){
				ans = min(ans,number);
			}
		}
	}
	
	cout << ans << endl;
	
	
		
	return 0;
}


Measured memory_bytes: 640
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 998244353
size = 2*10**5
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, size + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N, M, K = map(int,input().split())

ans = 0
power = pow(M-1, N-K-1, mod)
for i in range(K, -1, -1):
    ans += M * power * cmb(N-1, N-i-1, mod)
    ans %= mod
    power *= M - 1
    power %= mod

print(ans)

Measured memory_bytes: 32696
#include <iostream>
#include <numeric>
#include <vector>
#include <algorithm>
#include <map>
#include<queue>
#include <sstream>
#include <set>
typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}
using namespace std;
int main(){
    int N,M,C,ans=0,x,y=0;
    cin >> N >> M >>C;

    vector<int> vecA(M),vecX(M);

    REP(i,M) cin >> vecA[i];

    REP(i,N){
        y =0;
        REP(j,M){
            cin >> x;
            y += x*vecA[j];
        }
        if(y+C>0) ans ++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
char s[200005];
int dp[200005],pre[200005][28];
int main(){
	scanf("%s",s);
	int len=strlen(s);
	for(int i=0;i<=25;++i)	pre[len][i]=len;
	dp[len]=1;
	for(int i=len-1;~i;--i)
	{
		for(int j=0;j<=25;++j)	pre[i][j]=pre[i+1][j];
		pre[i][s[i]-'a']=i;
		dp[i]=len+1;
		for(int j=0;j<=25;++j)	dp[i]=min(dp[i],dp[pre[i][j]+1]+1);
	}
	int ans=dp[0],Last=0;
	for(int i=1;i<=ans;++i)
	{
		for(int j=0;j<=25;++j)
		{
			if(dp[pre[Last][j]+1]+1==dp[Last])
			{
				putchar('a'+j);
				Last=pre[Last][j]+1;
				break;
			}
		}
	}
	putchar('\n');
	return 0;
}

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

/*******  All Required define Pre-Processors and typedef Constants *******/
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define Dcout(a) cout << setprecision(20) << a << endl
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
using ll = long long;
using PAIR = pair<int, int>;
using Graph = vector<vector<int>>;
const int INF = 1 << 29;
const double pi=acos(-1.0);
#define debug cout << "line : " << __LINE__ << " debug" << endl
/****** Template of some basic operations *****/
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; }
/**************************************/

/******** User-defined Function *******/

/**************************************/

/********** Main()  function **********/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int a; cin >> a;

  cout << a + a*a + a*a*a << endl;

  return 0;
}
/********  Main() Ends Here *************/


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

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

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

void solve() {
    vector<int> v(1e4+1,0);
    FOR(x,1,101)FOR(y,1,101)FOR(z,1,101) {
        ll n = (x*x) + (y*y) + (z*z) + (x*y) + (y*z) + (z*x);
        if (n <= 1e4) v[n]++;
    }
    int N;
    cin >> N;
    REP(i,N) cout << v[i+1] << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 3652
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	static int[] C;
	static int[][] A;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int n=gi();
	    int m=gi();
	    int x=gi();
	    C=new int[n];
	    A = new int[n][m];
	    
	    int c=Integer.MAX_VALUE;
	    for (int i=0; i<n; i++) {
	    	C[i] = gi();
	    	for (int j=0; j<m;j++) {
	    		A[i][j]=gi();
	    	}
	    }
	    
	    for (int i=0; i<Math.pow(2, n); i++) {
	    	int t=f(n,m,x,i);
	    	if (t>=0 && t<c) {
	    		c=t;
	    	}
	    }
	    
	  if (c!=Integer.MAX_VALUE) {
	    System.out.println(c);
	  } else {
		  System.out.println(-1);
	  }
	    
        //System.out.println(Math.pow(l/3, 3));
//        if (a<b) {
//        	System.out.print(Math.max(b-a-w, 0));
//        }else {
//        	System.out.print(Math.max(a-b-w, 0));
//        }


	}

	public static int f(int n, int m, int x, int y) {
		int c=0;
		int[] e= new int[m];
	    for (int i=0; i<n; i++) {
	        if(((y & (int)Math.pow(2, i)) >> i) == 1) {
	        	c+=C[i];
	        	for (int j=0; j<m;j++) {
	        		e[j]+=A[i][j];
	        	}
	        }
	    }
	    for (int i=0;i<m;i++) {
	    	if (x>e[i]) {
	    		return -1;
	    	}
	    }
	    return c;
	}
	
	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 36720
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC121A
{
    class Program
    {
        static void Main(string[] args)
        {
            var H = ReadInt;
            var W = ReadInt;

            var h = ReadInt;
            var w = ReadInt;

            int ans = H * W - h*W - w*H + h * w;
            Console.WriteLine(ans);
        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] NextLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        static public void Draw2D(int[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            int[,] map2 = new int[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0;
                    else if (i == 0) map2[i, j] = j - 1;
                    else if (j == 0) map2[i, j] = i - 1;
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        static void Draw1D(int[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


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

int main()
{
    int n;
    int a[105];
    int ans = 0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n;i++)
    {
        int mini = i;
        int flag = 0;
        for(int j=i+1;j<n;j++)
        {
            if(a[j]<a[mini])
            {
                flag = 1;
                mini = j;
            }
        }
        swap(a[i], a[mini]);
        if(flag) ans++;

    }
    for(int i=0;i<n-1;i++)
    {
        cout<<a[i]<<" ";
    }
    cout<<a[n-1]<<endl;
    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 3104
def counter(x):
    if x == 0:
        return 0
    return counter(x >> 1) + (x & 1)


N = int(input())
A = [0 for i in range(20)]
x = [[0 for i in range(20)] for j in range(20)]
y = [[0 for i in range(20)] for j in range(20)]

for i in range(1, N + 1):
    A[i] = int(input())
    for j in range(1, A[i] + 1):
        x[i][j], y[i][j] = list(map(int, input().split()))

# 2^N 通りをbit全探索
# kが正直者 = 2進数表記のk-1桁目が1 (1 <= k <= N)
ans = 0
for bits in range(1, 1 << N):
    ok = True
    for i in range(1, N + 1):
        # 不親切な人の意見は無視
        if not ((bits >> (i - 1)) & 1):
            continue
        for j in range(1, A[i] + 1):
            # x_ij が正直者であることが偽であれば False
            if ((bits >> (x[i][j] - 1)) & 1) ^ y[i][j]:
                ok = False
    if ok:
        ans = max(ans, counter(bits))

print(ans)


Measured memory_bytes: 3064
import sys
from collections import defaultdict
array_8 = defaultdict(int)
N = int(input())
if not ( 1 <= N <= 200 ): sys.exit()

for A in range(2,N+1):
    if A % 2 == 1:
        for I in range(2,N // 2):
            if A % I == 0:
                array_8[A] += 1

result = 0
for J in array_8:
    if array_8[J] == 6:
        result += 1
print(result)

Measured memory_bytes: 9324
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
	int n,a[10000],i,j;
	long min,max,gou=0;
	cin>>n;
	for(i=0;i<n;i++){
	cin>>a[i];
	}
	sort(a,a+n);
	for(j=0;j<n;j++){
	min=a[j-(n-1)];
	max=a[j];
	gou=gou+=a[j];
	}
	cout<<min<<" "<<max<<" "<<gou<<endl;
return 0;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n;
    while(cin >> n) {
        if(n == 0) return 0;

        ll MAX = 24 * 3600 + 60 * 60 + 60 + 1;

        vll s(MAX, 0);

        rep(i, n) {
            int hs, ms, ss, he, me, se;
            scanf("%d:%d:%d", &hs, &ms, &ss);
            ll start = 3600 * hs + 60 * ms+ ss;
            scanf("%d:%d:%d", &he, &me, &se);
            ll end = 3600 * he + 60 * me + se;

            s[start]++;
            s[end]--;
        }

        rep(i, MAX) if(i > 0) s[i] += s[i-1];
        ll ans = 0;
        rep(i, MAX) chmax(ans, s[i]);
        cout << ans << endl;
    }

}



Measured memory_bytes: 3860
#include<stdio.h>
int R[200000];

int main(){
	int n,i,temp;
	int minnum,maxsub;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&R[i]);
	}
	
	minnum = R[0];
	maxsub = R[1]-minnum;
	if(minnum > R[1])minnum = R[1];
	for(i=2;i<n;i++){
		if(R[i] - minnum > maxsub )maxsub = R[i] - minnum;
		if(minnum > R[i])minnum = R[i];
	}
	
	printf("%d\n",maxsub);
	
	return 0;
}

Measured memory_bytes: 2632
N, K = map(int, input().split())
A = list(map(int, input().split()))
A = A + [0]

if K >= N - 1:
    ans = [N] * N
    print(*ans)

else:
    for i in range(K):
        tmp = [0] * (N + 1)
        
        for j in range(N):
            end_l = max(j - A[j], 0)
            end_r = min(j + A[j] + 1, N)
            
            tmp[end_l] += 1
            tmp[end_r] -= 1
        
        flg = tmp[0]
        
        for j in range(1, N):
            tmp[j] += tmp[j - 1]
            flg += tmp[0]
            A[j] = tmp[j]
        
        A[0] = tmp[0]
        
        if flg == N**2:
            break
            
    print(*A[:N])

Measured memory_bytes: 157632
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;
using ll = long long;

ll INF = 1LL << 60;

vector<vector<char>> vec;
vector<pair<int, int>> direct = {{1,0},{-1, 0}, {0,1}, {0, -1}};
int H, W;

int
bfs(int x, int y)
{
  vector<vector<int>> dist(H, vector<int>(W, -1));
  queue<pair<int, int>> que;

  int ans = 0;
  que.push({x, y});
  dist[x][y] = 0;
  while(!que.empty()){
    int x = que.front().first;
    int y = que.front().second;
    ans = max(ans, dist[x][y]);
    que.pop();
    rep(i, 0, 4){
      int dx = x + direct[i].first;
      int dy = y + direct[i].second;
      if(dx < 0 || dx >= H || dy < 0 || dy >= W) continue;
      if(vec[dx][dy] == '#') continue;
      if(dist[dx][dy] == -1){
        dist[dx][dy] = 1 + dist[x][y];
        que.push({dx, dy});
      }
    }
  }
  return ans;
}

int 
main() {

  cin >> H >> W;
  vec.resize(H);
  rep(i, 0, H){
    rep(k, 0, W){
      char c; cin >> c;
      vec[i].push_back(c);
    }
  }

  int ans = 0;
  rep(x, 0, H){
    rep(y, 0, W){
      if(vec[x][y] == '#') continue;
      ans = max(ans, bfs(x,y));
    }
  }

  cout << ans << endl;

}


Measured memory_bytes: 384
#include <stdio.h>

#define __max(a,b) (((a) > (b)) ? (a) : (b))

int main() {
	int a, b, i;

	scanf("%d %d", &a, &b);

	for (i = b - a + 1; i <= b + a - 1; ++i)
	{
		if (i < -1000000) {
			continue;
		}
		if (i > 1000000) {
			break;
		}
		printf("%d ", i);
	}

	printf("\n");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define prin(a) cout<<(a)<<endl
using ll=int64_t;
using namespace std;

//define gcd and lcm (using 64bit)
ll gcd(ll a,ll b){
    if (a < b) {
        //^はxor(bitwise operator)。以下三行でswap(a,b)を行っている。
        a ^= b;
        b ^= a;
        a ^= b;
    }
    //only when b==0,this program finds that b means false and returns a.
    return b ? gcd(b, a % b) : a;
}

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


int main(){
    vector<int> p(32);
    int k;
    cin>>k;
    p={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout<<p[k-1]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<utility>//swapでaとbの値を入れ替える
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define sort(s) sort(s.begin(),s.end())
#define r(s) reverse(s.begin(),s.end())
using namespace std;


int main() {
	int  a, b,c;
	int  ans = 0;
	cin >> a;
	vector<ll> s(a);
	rep(i, a)cin >> s[i];
	r(s);
	rep(i, a - 1) {
		if (s[i] >= s[i + 1]);
		else if (s[i]>= s[i + 1] - 1)s[i+1]-=1;
		else if(s[i]<s[i+1]-1)ans++;
	}
	if (ans == 0)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

mod = 10**9 + 7
X, Y = map(int, input().split())

g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] 

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod



if (X + Y) % 3 == 0:
    C = (X + Y) // 3
    x1 = C*2
    y1 = C*1

    x2 = C*1
    y2 = C*2

    if (x1-X) >= 0 and (y2-Y) >= 0:
        c1 = x1 - X
    
        for i in range(2, C+1):
            g1.append( ( g1[-1] * i ) % mod )
            inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
            g2.append( (g2[-1] * inverse[-1]) % mod )

        a = cmb(C,c1,mod)
        print(a)

    else:
        print(0)

else:
    print(0)

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> v(n);
  for(int i=0; i < n; i++) {int x, y; cin >> x >> y; v[i] = make_pair(x, y);}
  long double total = 0.0;
  long double count = 0;
  for(int i=0; i < n; i++) {
    for(int j=i+1; j < n; j++) {
      count++;
      total += sqrt(pow(v[i].first-v[j].first, 2) + pow(v[i].second-v[j].second, 2));
    }
  }
  printf("%.10f\n", (double)(total/count)*(n-1));
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

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

typedef long long ll;

void solve(long long A, long long B, long long C) {
  int ab = A - B;
  cout << max(C - ab, (ll)0) << endl;
}

int main() {
  long long A;
  scanf("%lld", &A);
  long long B;
  scanf("%lld", &B);
  long long C;
  scanf("%lld", &C);
  solve(A, B, C);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
#define endl '\n'
#define mod 1000000007
const int N=3005;
int dp[N][N];
int32_t main(){
  #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
  #endif
  
  ios_base::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);

  int n ;
  string s;
  cin>>n>>s;
  int l,r;
  vi pref(n+1,1);
  pref[0]=0;
  for(int i=2;i<=n;i++){
    vi p(n+1);
    for(int j=1;j<=i;j++){
      if(s[i-2]=='<')l=1,r=j-1;
      else l=j,r=i-1;
      dp[i][j]=(mod+pref[r]-pref[l-1])%mod;
      p[j]=(p[j-1]+dp[i][j])%mod;
    }
    pref=p;
  }
  cout<<pref[n];
}

Measured memory_bytes: 31168
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    int N, M;
    cin >> N >> M;
    int L[M], R[M];
    REP(i, M) cin >> L[i] >> R[i];

    int min = N;
    REP(i, M) if (min > R[i]) min = R[i];
    int max = 1;
    REP(i, M) if (max < L[i]) max = L[i];
    int c = min - max + 1;
    if (c < 0) c = 0;
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 1024
/**
  * @brief atcoder
  * @author yao
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#define ft first
#define sd second
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#   define NDEBUG
#endif //DBG
#include <cassert>

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

char ss[8][8];

int main()
{
    int n,m,k, ans=0;
    scanf("%d%d%d", &n ,&m, &k);
    for(int i=0;i<n;++i)scanf("%s", ss[i]);
    for(int rm=0;rm<1<<n;++rm)for(int cm=0;cm<1<<m;++cm)
    {
        int cnt = 0;
        for(int i=0;i<n;++i)if(rm&1<<i)for(int j=0;j<m;++j)if(cm&1<<j)
            cnt += ss[i][j] == '#';
        ans += cnt == k;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1732
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#define ll long long

using namespace std;
ll zerobp( int n , int weight , vector<int>& w , vector<int>& v ){
  vector<ll> dp( weight + 1 , 0 );
  dp[0] = 0;
  for( int i = 1 ; i <= n ; i++ ){
    for( int j = weight ; j >= 0 ; j-- ){
      if( j >= w[i] ){
          dp[j] = max( dp[j] , dp[j - w[i] ] + v[i] ) ;
        }
    }

//    for( int j = 0 ; j <= weight ; j++ ){
//      cout << dp[j] << " " ;
//    }
//    cout << endl ; 
  }
  return dp[weight]; 
}

int main(){
  int N,W;
  cin >> N >> W;//N <= 100 , W <= 1e5
  vector<int> w(N+ 1);
  vector<int> v(N + 1);

  for( int i = 1 ; i <= N ; i++ ){
    int wi,vi;
    cin >> wi >> vi ;
    w[i] = wi;
    v[i] = vi;//vi <= 1e9
  }
  ll ret = zerobp( N , W , w , v );

  cout << ret << endl;
  return 0;
}


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

pair<long long, long long> func(long long a, long long b, long long c, long long d) {
	pair<long long, long long> res;

	res.first = (a + c - 1) / c * c;
	res.second = res.first / c * d;
	return res;
}

void solve(long long N, vector<long long> T, vector<long long> A){
	long long a = 1, b = 1;

	for(int i = 0; i < N; ++i) {
		long long na = (long long)1e18 + 10, nb = (long long)1e18 + 10;
		pair<long long, long long> res = func(a, b, T[i], A[i]);

		if (res.first >= a && res.second >= b) {
			na = res.first;
			nb = res.second;
		}
		
		res = func(b, a, A[i], T[i]);

		if (res.second >= a && res.first >= b && res.second < na && res.first < nb) {
			na = res.second;
			nb = res.first;
		}
		a = na;
		b = nb;
		
		//cerr << a << "," << b << endl;
	}
	cout << a + b << endl;
}

int main(){	
	long long N;
	scanf("%lld",&N);
	vector<long long> T(N-1+1);
	vector<long long> A(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&T[i]);
		scanf("%lld",&A[i]);
	}
	solve(N, T, A);
	return 0;
}



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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int n, m;
  cin >> n >> m;
  if (n == m) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int main(){

	int x, y;
	cin>>x>>y;
	int c=2, t=4;
	int nt=x, nc=0;
	for(int i=0; i<x; i++){
		if(nt*4+nc*2==y){
			cout<<"Yes"<<endl;
			return 0;
		}
		nt--, nc++;
	}
	nt=0, nc=x;
	for(int i=0; i<x; i++){
		if(nt*4+nc*2==y){
			cout<<"Yes"<<endl;
			return 0;
		}
		nt++, nc--;
	}
	cout<<"No"<<endl;

return 0;

}

Measured memory_bytes: 3636
#![allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let c = read::<char>() as u8;
    println!("{}", if c >= b'A' && c <= b'Z' { "A" } else { "a" });
}

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

int main(){
  ll n, k; cin >> n >> k;
  vector<ll> h(n);
  for(ll i=0; i<n; ++i) cin >> h[i];
  
  if(n<=k){
    cout << 0 << endl;
    return 0;
  }
  
  sort(h.begin(), h.end());
  for(ll i=0; i<k; ++i) h.pop_back();
  ll res = 0;
  for(ll x : h) res += x;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1792