akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = 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::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}

fn solve(ss: Vec<char>) -> u64 {
    let n = ss.len();

    let md = 1000000007;
    let mut pos = 0;
    let mut state = 0;
    let mut ret = 1;

    if n == 1 {
        return 3
    }

    if ss[0] == ss[1] {
        ret = 6;
        state = 2;
        pos += 2;
    } else {
        ret = 3;
        state = 1;
        pos += 1;
    }

    while pos < n {
        if pos < n-1 && ss[pos] == ss[pos+1] {
            if state == 1 {
                ret = (ret * 2) % md;
                state = 2;
            } else {
                ret = (ret * 3) % md;
            }
            pos += 2;
        } else {
            if state == 1 {
                ret = (ret * 2) % md;
            } else {
                state = 1;
            }
            pos += 1;
        }
    }

    ret
}

fn main() {
    read_line!();

    let ss = read_line!();
    println!("{}", solve(ss.chars().collect()));
}

#[test]
fn solve_test() {
    assert_eq!(solve(vec!['a','a','b']), 6);
    assert_eq!(solve("RvvttdWIyyPPQFFZZssffEEkkaSSDKqcibbeYrhAljCCGGJppHHn".chars().collect()), 958681902);
}


Measured memory_bytes: 4476
#include<bits/stdc++.h>
#define ll long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl '\n'
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define fo(i, x, y)   for (__typeof(x) i = x; i < y; ++i)
#define fr(i, x, y)   for (__typeof(x) i = x; i > y; i--)
#define vdp(n,x) vector<vector<ll>>dp(n+1,vector<ll>(x+1,0));
const ll mod=1000000007;
const ll AM=2e5+5;
using namespace std;
int main()
{
    fast;
   	ll n,k; cin>>n>>k;
   	ll val[n+1],wt[n+1];
   	fo(i,1,n+1) cin>>wt[i]>>val[i];
   	vdp(n,k)
   	fo(i,1,n+1)
   	{
   		fo(j,1,k+1)
   		{
   			if(j>=wt[i])
   				dp[i][j]=max(val[i]+dp[i-1][j-wt[i]],max(dp[i-1][j],dp[i][j-1]));
   			else
   				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
   			//cout<<dp[i][j]<<" ";
   		}
   		//cout<<endl;
   	}
   	cout<<dp[n][k];

}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "debug" << endl;
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    cin.tie(0);    
	ios::sync_with_stdio(false);
    int N,L;
    cin >> N >> L;
    vector<int> V;
    REP(i,N){
        V.pb(L+i);
    }
    sort ALL(V);
    int sum = 0;
    int minv = INF;
    REP(i,V.size()){
        sum += V[i];
        if(abs(V[i]) <= abs(minv) || V[i] == 0){
            minv = V[i];
        }
    }
    if(minv < 0 && sum < 0){
    cout << sum - minv << endl;
    }
    else if(minv < 0 && sum >= 0){
        cout << sum + minv << endl;
    }
    else if(minv >= 0 && sum < 0){
        cout << sum + minv << endl;
    }
    else cout << sum - minv << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
#define f2(i,j,k) for(int i=j;i>k;i--)
using namespace std;
int main(){
    long long n,ans=0,d;
    cin>>n;
    vector<long long> a(9,0);
    f(i,0,n){
        cin>>d;
        if(d>=3200){
            a[8]++;
        }
        else{
            a[d/400]++;
        }
    }
    f(i,0,8){
        if(a[i]>0){
            ans++;
        }
    }
    if(ans==0){
        cout<<1<<" "<<a[8]<<endl;
    }
    else{
        cout<<ans<<" "<<ans+a[8]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

string s;

void solve(){
    cin >> s;
    int n=s.length();
    rep(i,n){
        cout << "x";
    }
    cout << "" << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
// clang-format on

int N, T, A;
int H[MAX_N];

void solve()
{
  int minindex = 0;
  double mi = INT_MAX;
  for (int i = 1; i <= N; i++) {
    double diff = abs((double)A - ((double)T - (double)H[i] * 0.006));
    if (diff < mi) {
      mi = diff, minindex = i;
    }
  }
  cout << minindex << endl;
}

int main(void)
{
  cin >> N >> T >> A;
  for (int i = 1; i <= N; i++) cin >> H[i];
  solve();
  return 0;
}


Measured memory_bytes: 256
// @Author :- Gaurav Bharti
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define empb emplace_back
#define mp make_pair
#define F first
#define S second
#define vii vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vpii vector<pii>
#define mapii map<int,int> 
#define mapll map<ll,ll>
#define all(a) a.begin(),a.end()
#define test int t; cin>>t; while(t--)
#define prec(n) fixed<<setprecision(n)
#define ItsFUN ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007

bool comp(const pair<ll,ll> &a, const pair<ll,ll> &b) {
	return (a.second < b.second) ;
}

ll binpow(ll a, ll b) {
	ll res = 1;
	while(b) {
		if(b&1) res = res * a;
		a = a*a;
		b = b >> 1;
	}

	return res;
}


/*
BHAI EFFORT DAAL
*/


int main(){
	ItsFUN;

	ll n; cin >> n;
	ll ans = 0;


	for(ll i = 1 ; i <= n; ++i) {
		if(n%i==0) {
			ans += n/i -1;
		}
		else {
			ans += n/i;
		}
	}


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



Measured memory_bytes: 3636
a, b, c, x, y = map(int, input().split())
 
ans_min = x * a + y * b
for i in range(100001):
    ans = i * 2 * c + max(0, x - i) * a + max(0, y - i) * b
    if ans < ans_min:
        ans_min = ans
 
print(ans_min)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define PI acos(-1.0)
#define N 200005
#define eps 1e-8
int  n,i,a[N];
int main()
{
    scanf("%d",&n);
    for(i=1;i<=n;i++)scanf("%d",&a[i]);
    if(n%2==0){
    for(i=n;i>0;i-=2)
        printf("%d ",a[i]);
    for(i=1;i<=n;i+=2)
        printf("%d ",a[i]);
    }
    else{
        for(i=n;i>0;i-=2)
        printf("%d ",a[i]);
    for(i=2;i<=n;i+=2)
        printf("%d ",a[i]);
    }
    return 0;
}


Measured memory_bytes: 2944
#include <cstdio>
#include <cstring>

const int MaxN = 10;

int g[MaxN][MaxN];
int u[MaxN];
int n, m, res;

void go( int len, int last)
{
  
  if (len == n)
    return (void) res++;
    
  for (int i = 1; i < n; i++)
    if (u[i] == 0 && g[last][i])
    {
      u[i] = 1;
      go(len + 1, i);
      u[i] = 0;
    }
}


int main( void )
{
  while (scanf("%d %d", &n, &m) != EOF)
  {
    int a, b, i;
    memset (g, 0, sizeof g);
    for (i = 0; i < m; i++)
    {
      scanf("%d %d", &a, &b);
      g[a-1][b-1] = 1;
      g[b-1][a-1] = 1;
    }
    res = 0;
    memset (u, 0, sizeof u);
    u[0] = 1;
    go(1, 0);
    printf("%d\n", res);
  }
  return 0;
}

Measured memory_bytes: 128
package main

import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
  "math"
  "sort"
)

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n, _ := strconv.Atoi(NextLine())
  return n
}
func NextFloatVec() []float64 {
  L := strings.Split(NextLine(), " ")
  N := make([]float64, len(L))
  for i := range N {
    N[i], _ = strconv.ParseFloat(L[i], 64)
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

func MaxFloat(x, y float64) float64 {
  if x < y { return y }
  return x
}
func Dist02(A *[]float64) float64 {
  x, y := (*A)[0], (*A)[1]
  return x * x + y * y
}
func InnerProduct(A, B *[]float64) float64 {
  return (*A)[0] * (*B)[0] + (*A)[1] * (*B)[1]
}
func Angle(A, B *[]float64) float64 {
  acos := math.Acos(InnerProduct(A, B) / math.Sqrt(Dist02(A)) / math.Sqrt(Dist02(B)))
  return acos / math.Pi * 180.0
}

type Engines [][]float64
func (E Engines) Len() int { return len(E) }
func (E Engines) Less(i, j int) bool { return E[i][2] < E[j][2] }
func (E Engines) Swap(i, j int) { E[i], E[j] = E[j], E[i] }

func main() {
  N := NextInt()
  E := make([][]float64, 0)
  X := []float64{1.0, 0.0}
  C := 0
  for i := 0; i < N; i++ {
    XY := NextFloatVec()
    if XY[0] != 0.0 || XY[1] != 0.0 {
      angle := Angle(&X, &XY)
      if XY[1] < 0 { angle = 360.0 - angle }
      XY = append(XY, angle)
      E = append(E, XY)
      E = append(E, []float64{0.0, 0.0, angle - 180.0})
      E = append(E, []float64{0.0, 0.0, angle + 180.0})
      E = append(E, []float64{XY[0], XY[1], angle + 360.0})
      C++
    }
  }
  sort.Sort(Engines(E))
  ans := 0.0
  t := 0
  D := []float64{0.0, 0.0}
  cnt := 0
  for _, e := range E {
    for E[t][2] - e[2] < 180.0 {
      D[0] += E[t][0]
      D[1] += E[t][1]
      t++
    }
    ans = MaxFloat(math.Sqrt(Dist02(&D)), ans)
    D[0] -= e[0]
    D[1] -= e[1]
    if e[0] != 0.0 || e[1] != 0.0 { cnt++ }
    if cnt == C { break }
  }
  Write(ans)
  Output()
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define lli long long int
#define d double
#define mod 1000000007
#define mx 200001
using namespace std;
lli st[4*mx],dp[mx];
lli query(lli index,lli s,lli e,lli l,lli r){
	if(l>e || r<s) return INT_MIN;
	if(l<=s && r>=e) return st[index];
	lli mid=s+(e-s)/2;
	lli ql=query(2*index,s,mid,l,r);
	lli qr=query(2*index+1,mid+1,e,l,r);
	return max(ql,qr);
}
void update(lli index,lli s,lli e,lli i,lli val){
	if(i<s || i>e) return;
	if(s==e){
		st[index]=val;
		return;
	}
	lli mid=s+(e-s)/2;
	update(2*index,s,mid,i,val);
	update(2*index+1,mid+1,e,i,val);
	st[index]=max(st[2*index],st[2*index+1]);
}
int main() {
	FIO;
	lli n;
	cin>>n;
	vector<lli> H(n),B(n);
	for(lli i=0;i<n;i++) cin>>H[i];
	for(lli i=0;i<n;i++) cin>>B[i];
	vector<lli> dp(n+1);//dp[i]->max total beauty so far with i height....
	for(lli i=0;i<n;i++){
		// for(lli h=0;h<H[i];h++){
		// 	dp[H[i]]=max(dp[H[i]],dp[h]+B[i]);
		// }
		dp[H[i]]=query(1,0,n,0,H[i]-1)+B[i];
		update(1,0,n,H[i],dp[H[i]]);
	}
	lli ans=INT_MIN;
	for(lli i=0;i<=n;i++) ans=max(ans,dp[i]);
	cout<<ans<<endl;
}

Measured memory_bytes: 9472
package main

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

var sc = bufio.NewScanner(os.Stdin)
func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

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

func main() {
	sc.Split(bufio.ScanWords)
	
	n := scanInt()

	fmt.Println(n*n*n)
}


Measured memory_bytes: 640
#include <iostream>
#include<cstdio>

using namespace std;

int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    int ans=0;
    while(a--)
    {
        int x;
        scanf("%d",&x);
        if(x>=b)
            ans++;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<vector>
#include <iostream>
#include<string>
#include <complex>
#include <algorithm>
#include<string>
#include <map>
#include <utility>

using namespace std;

int main(){
    int_least64_t n;
    cin >> n;
    float t, a;
    cin >> t;
    cin >> a;
    float h[n];
    float ans[n];
    float c = 0.006;
    for(int i = 0; i < n; i++){
        cin >> h[i];
        ans[i] = abs(a - (t - (h[i]*c)));
        //cout << ans[i] << endl;
    }

    int min = 0;

    for(int i = 0; i < n; i++){
        if(ans[i] < ans[min]){
            min = i;
        }
    }

    cout << min + 1 << endl;

}

Measured memory_bytes: 3668
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = (lambda: (sys.stdin.readline()).rstrip())
    input_list = (lambda: input().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    a = input_number()
    print(a + a ** 2 + a ** 3)


if __name__ == '__main__':
    main()


Measured memory_bytes: 8860
#include <iostream>

using namespace std;

int main()
{
	long long n, m;
	cin >> n >> m;

	if (n * 2 <= m) {
		cout << (2 * n + m) / 4 << endl;
	}
	else {
		cout << m / 2 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define MOD 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(var) (var).begin(), (var).end()
#define MAXX 9000000000000000000
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> > 
#define vvpi vector<vector<pair<int,int> > >

int ans[10005];

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	int n,i,j,k,x,y;
	cin >> n;
	for(i=1;i<=100;i++)
	{
		for(j=1;j<=100;j++)
		{
			for(k=1;k<=100;k++)
			{
				x = i*i + j*j + k*k + i*j + j*k + k*i;
				if(x <= n)
				{
					ans[x] ++;
				}
			}	
		}
	}
	for(i=1;i<=n;i++)
	{
		cout << ans[i] << endl;
	}


	return 0;
}

Measured memory_bytes: 3612
//xtwakioi! xtwddYnoi(双重含义)!
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=200010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
signed main()
{
    char a,b;
    cin>>a>>b;
    if(a==b) puts("H");
    else puts("D");
    return 0;
}

Measured memory_bytes: 3564
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;

int main(){
   int n;
   cin>>n;
   vector<int> a(n);
   for(int i=0;i<n;i++)cin>>a[i];
   sort(a.begin(),a.end());
   cout<<a[n-1]-a[0]<<endl;
}

Measured memory_bytes: 256
class UnionFind(object):
    def __init__(self, N):
        self.parent = [-1] * N #parent[i] は(i+1)番目の要素が含まれる要素数の(-1)倍
    #要素が負-->その数を親とするグループに属する要素の数×(-1)
    #要素が正-->親のindex

    #Aがどのグループに属しているかを調べる
    def root(self, A):
        if self.parent[A-1] < 0: #負の数-->その数は親
            return A
        self.parent[A-1] = self.root(self.parent[A-1]) #負では無い時、親の場所が入っているから、親が属しているグループを、自分自身に入れる(一度確認したところは直接親を見れるようにする)
        return self.parent[A-1] #親の位置を返す

    #Aが含まれているグループに属している数を返す
    def size(self, A):
        return -1 * self.parent[self.root(A)-1]

    #AとBをくっ付ける
    def connect(self, A, B):
        A = self.root(A) #Aを含むグループの親を返す
        B = self.root(B) #Bを含むグループの親を返す
        if A == B: #親が同じならなにもしない
            return False
        
        #大きい方(A)に小さい方(B)をつなぎたい
        if self.size(A) < self.size(B): #大小関係が逆の時は入れ替える
            A, B = B, A
        
        self.parent[A-1] += self.parent[B-1] #大きい方に小さい方を加える　（負の数＋負の数 = 新しいグループに含まれる数×(-1)）
        self.parent[B-1] = A #加えられた親の値を、加えた先の親の位置に書き変える
        return True
    
    def same(self, A, B):
        if self.root(A) == self.root(B):
            return True
        else:
            return False

N = int(input())

lst = []
for i in range(N):
    x, y = map(int, input().split())
    lst.append([x, y, i])
# print (lst)
edge = []
lst.sort(key = lambda x: x[0])
for i in range(1, N):
    edge.append([lst[i-1][2], lst[i][2], min(abs(lst[i-1][0]-lst[i][0]), abs(lst[i-1][1]-lst[i][1]))])
# print (edge)
lst.sort(key = lambda x: x[1])
for i in range(1, N):
    edge.append([lst[i-1][2], lst[i][2], min(abs(lst[i-1][0]-lst[i][0]), abs(lst[i-1][1]-lst[i][1]))])
# print (edge)
edge.sort(key = lambda x: x[2])

uni = UnionFind(N)
ans = 0
for i in edge:
    if not uni.same(i[0], i[1]): #違うグループのとき
        uni.connect(i[0], i[1])
        ans += i[2]
print (ans)

Measured memory_bytes: 53416
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

struct UnionFind {
  vector<int> p;
  void init(int n) { p.assign(n, -1); }
  int find(int a) { return p[a] < 0 ? a : p[a] = find(p[a]); }
  bool merge(int a, int b) {
    a = find(a);
    b = find(b);
    if (a == b) return 0;
    if (p[a] > p[b]) swap(a, b);
    p[a] += p[b];
    p[b] = a;
    return 1;
  }
} uf_tree;

ll d[100005];

int main() {
  ll N, M, K;
  cin >> N >> M >> K;
  ll a, b;
  uf_tree.init(N);
  for (int i = 0; i < M; i++) {
    cin >> a >> b;
    a--, b--;
    uf_tree.merge(a, b);
    d[a]++;
    d[b]++;
  }
  for (int i = 0; i < K; i++) {
    cin >> a >> b;
    a--, b--;
    if (uf_tree.find(a) == uf_tree.find(b)) {
      d[a]++;
      d[b]++;
    }
  }
  for (int i = 0; i < N; i++) {
    cout << -uf_tree.p[uf_tree.find(i)] - d[i] - 1 << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 4288
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}

auto great(vector<int>&v,int x){
    int idx = (int)(lower_bound(all(v),x) - v.begin());
    //cout << (idx < v.size() ? v[idx] - x : INF) << endl;
    return (idx < v.size() ? v[idx] : INF);
}
auto smaller(vector<int>&v,int x){
    int idx = (int)(lower_bound(all(v),x) - v.begin());
    //cout << (idx-1 >= 0 ? x - v[idx-1] : INF) << endl;
    return (idx-1 >= 0 ? v[idx-1] : -INF);
}
signed main(){
    int a,b,Q;
    cin >> a >> b >> Q;
    vector<int>s(a),t(b);
    for(auto & e : s) cin >> e;
    for(auto & e : t) cin >> e;
    rep(_,Q){
        int x; cin >> x;
        int tans = INF;
        // -----t---x------------s
        cmin(tans, great(s,x) - smaller(t,x) + min(great(s,x) - x, x - smaller(t,x)));
        // -----s---x------------t
        cmin(tans, great(t,x) - smaller(s,x) + min(great(t,x) - x , x - smaller(s,x)));
        
        cmin(tans,max(great(t, x),great(s, x)) - x);
        cmin(tans,x - min(smaller(t, x), smaller(s, x)));
        
        cout << tans << endl;
    }
}



Measured memory_bytes: 2944
def gcd(a,b):
    if a < b:
        t = b
        b = a
        a = t
    if a % b == 0:
        return b
    else:
        return gcd(b, a%b)

n,k = map(int, raw_input().split())
l = map(int, raw_input().split())
g = l[0]
idx = 1
while idx < n:
    g = gcd(g,l[idx])
    idx += 1
if k <= max(l) and k % g == 0:
    print 'POSSIBLE'
else:
    print 'IMPOSSIBLE'


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

int main(){
    int n,aux;
    unsigned long long int total = 0;
    vector<int> v;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> aux;
        v.push_back(aux);
    }

    sort(v.begin(),v.end(),greater<int>());

    for(int i=0;i<n;i++){
        if(i%2==0){
            total+=v[i];
        }else
        {
            total-=v[i];
        }
        
    }

    cout<<total<<endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = [0 for i in range(n+1)]
a.reverse()
a.insert(0,0)
counter = 0
for i in range(1,n+1): #a[i]を見ている
    temp = 0
    t = 1
    while (n+1-i)*t <= n:
        temp += b[(n+1-i)*t]
        t += 1
    if temp%2 != a[i]:
        b[n+1-i] = 1
        counter += 1
print(counter)
for i in range(1,n+1):
    if b[i] == 1:
        if counter != 1:
            print(i,end= " ")
        else:
            print(i)
        counter -= 1


Measured memory_bytes: 7276
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(x) x.begin(), x.end()

#define mp make_pair
#define in insert
#define er erase
#define con continue
#define pb push_back
#define sc scanf
#define pr printf
#define ub upper_bound
#define lb lower_bound
#define s second
#define f first
#define int long long

const long long infl = 1e18; 
const int N = 3e5 + 300, N2 = 2e3, inf = 1e9 + 200, mod = 1e9 + 7;

int n;
string s;
int p[3002][3002], d[3002][3002];

int get(int l, int r, int i){
//	cout << l << " " << r << endl;
	if (l > r) return 0;
	return (p[i][r] - p[i][l - 1] + mod) % mod;
}

main (){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> s;
	for (int i = 1; i <= n; i++){
		if (i == 1){
			/*d[1][1] = 1;
			p[1][1] = 1;*/
			for (int j = 1; j <= n; j++){
				d[i][j] = 1;
			}
			for (int j = 1; j <= n; j++){
				(p[i][j] = p[i][j - 1] + d[i][j]) %= mod;
			}
		}
		else{
			for (int j = 1; j <= n; j++){
				if (s[i - 2] == '<'){
					d[i][j] = get(1, j - 1, i - 1);
					
			 	}
			 	else{
			 		d[i][j] = get(j, i - 1, i - 1);
			 	}
			}
			for (int j = 1; j <= n; j++){
				(p[i][j] = p[i][j - 1] + d[i][j]) %= mod;
			}
		}
		//if (i == 2)return 0;
	}
	int ans = 0;
	for (int i = 1; i <= n; i++){
		(ans += d[n][i]) %= mod;
	}
	cout << ans;
	return 0;
}












Measured memory_bytes: 141056
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define ld double
#define llu unsigned long long
#define rep(i,x,y)  for(ll i=int(x);i<int(y);++i)
#define For(i,x,y)  for(ll i=int(x);i<=int(y);++i)
#define FOr(i,x,y)  for(ll i=int(x);i>=int(y);--i)
#define pi acos(-1)
#define mk make_pair
#define pa pair<ll,ll>
#define lf else if
#define IL inline
#define sqr(x)      ((x)*(x))
#define Mul(x,y)    ((x)=1LL*(x)*(y)%mod)
#define Add(x,y)    ((x)=((x)+(y))%mod)
#define E(x)        return writeln(x),0
#define LL          (long long)
#define p(x)        printf("~%lld~\n",LL(x))
#define pp(x,y)     printf("~~%lld %lld~~\n",LL(x),LL(y))
#define ppp(x,y,z)  printf("~~~%lld %lld %lld~~~\n",LL(x),LL(y),LL(z))
#define pppp(a,b,c,d)   printf("~~~%lld %lld %lld %lld\n",LL(a),LL(b),LL(c),LL(d))
#define f_in(x)     freopen(x".in","r",stdin)
#define f_out(x)    freopen(x".out","w",stdout)
#define open(x)     f_in(x),f_out(x)
#define fi first
#define se second
#define GuYue       puts("\nGuYueNa________________________________________________________________________________")
#define y1          fafa____
typedef complex<double> E;
namespace SHENZHEBEI{
#ifdef LOCAL
    struct _{_(){freopen("cf.in","r",stdin);}}_;
#endif
#define NEG 1
    static const int GYN=2333333;
    char SZB[GYN],*SSS=SZB,*TTT=SZB;
    inline char gc(){   if (SSS==TTT){  TTT=(SSS=SZB)+fread(SZB,1,GYN,stdin); if (SSS==TTT) return '\n';  }   return *SSS++;    }
#define gc getchar
#if NEG
    inline ll read(){    ll x=0,g=1; char ch=gc();   for (;!isdigit(ch);ch=gc()) if (ch=='-') g=-1;  for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x*g; }
    inline void write(ll x){    if (x<0) putchar('-'),x=-x;  if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#else
    inline ll read(){    ll x=0; char ch=gc();   for (;!isdigit(ch);ch=gc());    for (;isdigit(ch);ch=gc())  x=x*10-48+ch;   return x;   }
    inline void write(ll x){    if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#endif
    inline char readchar(){ char ch=gc();   for(;isspace(ch);ch=gc());  return ch;  }
    inline ll readstr(char *s){ char ch=gc();   int cur=0;  for(;isspace(ch);ch=gc());      for(;!isspace(ch);ch=gc())  s[cur++]=ch;    s[cur]='\0';    return cur; }
    void Print(long long *a,int s,int t){For(i,s,t)printf("%lld ",a[i]);puts("");}
    void Print(int *a,int s,int t){For(i,s,t)printf("%d ",a[i]);puts("");}
    void Print(char *a,int s,int t){For(i,s,t)putchar(a[i]);puts("");}
    void writeln(ll x){write(x),puts("");}
    void Max(ll &x,ll y){x=x<y?y:x;}
    ll max(ll x,ll y){return x<y?y:x;}
}using namespace SHENZHEBEI;
const ll N=3010;
vector<ll>g[N];
ll a[N],sg[N],n;
void dfs(ll x){
	sg[x]=0;
	rep(i,0,g[x].size()){
		if (sg[g[x][i]]!=-1)continue;
		dfs(g[x][i]);
		if (a[x]>a[g[x][i]]&&sg[g[x][i]]==0){
			sg[x]=1;
			break;
		}
	}
}
int main(){
	n=read();
	For(i,1,n)a[i]=read();
	rep(i,1,n){
		ll x=read(),y=read();
		g[y].push_back(x);
		g[x].push_back(y);
	}
	For(i,1,n){
		memset(sg,-1,sizeof sg);
		dfs(i);if (sg[i])write(i),putchar(' ');
//		For(j,1,n)write(sg[j]),putchar(' ');puts("");
	}
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

struct UnionFind {
    vector<int> node;
    int N;

    UnionFind(){}
    UnionFind(int N) : N(N), node(N,-1) {}

    void init(int x) {
        node.assign(x,-1);
        N = x;
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (node[x] > node[y]) swap(x,y);
        node[x] += node[y];
        node[y] = x;
        N--;
        return true; 
    }

    bool same(int x, int y) {return root(x) == root(y);}

    int root(int x) {
        if (node[x] < 0) return x;
        return node[x] = root(node[x]);
    }

    int size(int x) {return -node[root(x)];}

    int count() const {return N;}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll N,D; cin >> N >> D;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    priority_queue<pll, vector<pll>, greater<pll>> pq;
    UnionFind uf(N);
    rep(i,N) pq.emplace(A[i],i);

    ll ans = 0;
    while (!pq.empty()) {
        ll val,v;
        tie(val,v) = pq.top(); pq.pop();
        if (val > A[v]) continue;
        if (v > 0 and uf.merge(v,v-1)) {
            ans += val + A[v-1] + D;
            chmin(A[v-1],val+D);
            pq.emplace(A[v-1],v-1);
        }
        if (v < N-1 and uf.merge(v,v+1)) {
            ans += val + A[v+1] + D;
            chmin(A[v+1],val+D);
            pq.emplace(A[v+1],v+1);
        }
    }

    cout << ans << ln;
}

Measured memory_bytes: 8816
#include<bits/stdc++.h>
using namespace std;
int main(){
long long A,B,s;
char op;
cin>>A>>op>>B;

			if(op== '+'){
				s=A+B;
				printf("%lld",s);
			}
			else if(op== '-'){
				s=A-B;
				printf("%lld",s);
			}
			return 0;
		}
		
	
	
	
	
	
	
	
	

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

int main(){
  long long N, P;
  cin >> N >> P;
  if (N==1){
    cout << P << endl;
    return 0;
  }
  long long sqP = sqrt(P);
  map<long long, long long> mp;
  for (long long i=2; i<sqP; i++){
    if (P%i==0){
      while(P%i==0){
        mp[i]++;
        P/=i;
      }
    }
  }
  long long ans = 1;
  for (auto k: mp){
    for (int i=0; i<k.second/N; i++){
      ans *= k.first;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) < (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pii Dir[8] = { //移動
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define int ll
signed main(void) {
	int n;
	cin >> n;
	vector<int> a(n), b(n), need, amari;

	int asum = 0, bsum = 0;

	REP(i, n) {
		cin >> a[i];
		asum += a[i];
	}
	int ans = 0, needsum = 0;

	REP(i, n) {
		cin >> b[i];
		bsum += b[i];
		if (a[i] < b[i]) {
			need.push_back(b[i] - a[i]);
			needsum += b[i] - a[i];
		}
		else if(a[i] > b[i])
			amari.push_back(a[i] - b[i]);
	}

	sort(ALL(amari), greater<int>());
	ans += need.size();

	REP(i, amari.size()) {
		if (needsum > 0) {
			ans++;
			needsum -= amari[i];

		}
		else
		{	
			break;
		}
	}

	if (needsum > 0) {
		cout << -1 << endl;
	}
	else {
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 2812
#include<cstdio>
int a[100001],ans;
void div(int l,int r)
{
	if(l>=r){
		ans++;
		return;
	}
	if(a[l]<a[l+1]){
		ans++;
		int i,pd=0;
		for(i=l+1;i<=r;i++){
			if(a[i]<a[i-1]){
				pd=1;
				break;
			}
		}
		if(pd){
			div(i,r);
		}
	}else if(a[l]>a[l+1]){
		ans++;
		int i,pd=0;
		for(i=l+1;i<=r;i++){
			if(a[i]>a[i-1]){
				pd=1;
				break;
			}
		}
		if(pd){
			div(i,r);
		}
	}else if(a[l]==a[l+1]){
		div(l+1,r);
	}
	return;
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	div(1,n);
	printf("%d\n",ans);
	return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
		int A, B;
	cin >> A >> B;

	fx(1000000) {
		double y = x;
		int a = y * 0.08;
		int b = y * 0.1;
		if (a==A&&b==B) {
			ce(x);
			return 0;
		}
	}
	ce(-1)
    return 0;
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String args[]){

		Scanner cin = new Scanner(System.in);
		int N = cin.nextInt();
		long K = cin.nextLong();
		long sum = 0L;
		int result=0;
		Map<Integer,Long> mapv = new HashMap<>();
		for(int i=0;i<N;i++){
			int tmp1 = cin.nextInt();
			long tmp2 = cin.nextLong();
			if(mapv.containsKey(tmp1)){
				mapv.put(tmp1, mapv.get(tmp1)+tmp2);
			}else{
				mapv.put(tmp1, tmp2);
			}
		}
		cin.close();
		int value[] = new int [mapv.size()];
		int count =0;
		for(Integer n : mapv.keySet()){
			value[count] = n;
			count++;
		}
		Arrays.sort(value);

		for(int j=0;j<value.length;j++){
			sum += mapv.get(value[j]);
			if(K<=sum){
				result = value[j];
				break;
			}
		}
		System.out.println(result);
	}
}


Measured memory_bytes: 96476
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        ll h;
        cin >> h;
        if (h >= K) {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#define pai 3.1415926535


int main(void)
{
	char S[6];
	scanf("%s", S);
	int flag = 0;
	for (int i = 0; i < strlen(S)-1; i++) {
		if (S[i] == 'A'&&S[i + 1] == 'C') {
			flag = 1;
		}
	}
	if (flag == 1) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}

	return 0;


}

Measured memory_bytes: 128
fun main(args : Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val hh = IntArray(n){ Integer.parseInt(readLine()!!) }
    hh.sort()

    var min = Int.MAX_VALUE

    for (i in 0..n-k) {
        val diff = hh[i+k-1] - hh[i]
        if (diff < min) min = diff
    }

    println(min)
}

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    string t;
    t = s.substr(n/2);
    if(t + t == s){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
const int N = 101;
int a[N];
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> a[i];
    int c = 1;
    int ans = 0;
    for (int i = 1; i < n; ++i) {
        if (a[i] == a[i - 1]) {
            ++c;
        }   
        else {
            ans += c >> 1;
            c = 1;
        }   
    }   
    ans += c >> 1;
    cout << ans << '\n';
}   

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <complex>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define EPS 1e-8
#define DEB 1


int main(){
	char in1[5],in2[5];
	while(scanf("%s %s",in1,in2),strcmp(in1,"0")|strcmp(in2,"0")){
		int hit = 0;
		int brow = 0;
		rep(i,4)if( in1[i]==in2[i] )hit++;
		rep(i,4)rep(j,4)if( i!=j )if( in1[i]==in2[j] )brow++;
		printf("%d %d\n",hit,brow);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h> 
using namespace std;
#define int long long int
#define float double
#define pb push_back
#define FF first
#define SS second
#define N 201000
#define MOD 1000000007
#define fn(i,n) for(int i=0;i<n;i++)
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define pii pair<int,int>
#define INF 1000000000000000000
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

signed main() 
{
    speed;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    int n,W;
    cin>>n>>W;
    int A[n],B[n];
    int dp[n+1][W+1];
    for(int i=0;i<n;i++)
    {
    	cin>>A[i]>>B[i];
    }

    for(int i=0;i<=n;i++)
    {
    	for(int w=0;w<=W;w++)
    	{
    		if(i==0 || w==0) dp[i][w]=0;
    		else if(A[i-1]<=w) dp[i][w]=max(B[i-1]+dp[i-1][w-A[i-1]],dp[i-1][w]);
    		else dp[i][w]=dp[i-1][w];
    	}
    }
    cout<<dp[n][W];
}


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

#include<list>

int main()
{
	string S;

	

	cin >> S;

	
	int result = 0;
	int now = 0;

	for (int a = 0; a < 3; a++) {
		if (S[a] == 'R') {
			now++;
		}
		else {
			if (now > result) {
				result = now;
			}
			now = 0;
		}
	}

	if (now > result) {
		result = now;
	}

	
	cout << result<< endl;
}



int hyoe() {

	return 0;
}


Measured memory_bytes: 3624
/// Kazuki Hoshino


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pi> vpi;
#define inf 10000000000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define endl '\n'

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

ll n , a[101010], dp[101010], sum[101010], x, pre, mn=-inf, t;
bool pm[101010];
char ch;

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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);


    //cin >> t;

//while(t--){

    cin >> n >> x;
    dp[0]=x;

    n--;

    rep(i, 0, n-1){
        cin >> ch >> x;

        pm[i]=ch!='+';

        sum[i+1]=x;
        a[i]=x;

    }

    rep(i,1,n){
        sum[i+1]+=sum[i];
    }

    pre=-1;

    rep(i,0,n-1){

        if(pm[i] && pre!=-1){
            chmax(mn,dp[pre]-(sum[i]-sum[pre])-sum[i]);
        }
        if(!pm[i]){
            dp[i+1]=max(dp[i],mn+sum[i])+a[i];
        }
        else{
            dp[i+1]=max(dp[i]-a[i],mn+sum[i]+a[i]);
            pre=i;
        }
    }
    cout<<dp[n]<<endl;

//}


return 0;
}
///....


Measured memory_bytes: 2688
dayCount [y1,m1,d1, y2,m2,d2]
  | y1 < y2 || m1 < m2 = monLen y1 m1 + dayCount (nextMon ++ [y2,m2,d2])
  | otherwise          = d2 - d1
  where nextMon | m1 < 12   = [y1, m1+1, d1]
                | otherwise = [y1+1,  1, d1]

monLen y m
  | m == 2    = 28 + leap y
  | otherwise = [31,28,31,30,31,30,31,31,30,31,30,31] !! (m - 1)

leap y = if isLeapYear y then 1 else 0
isLeapYear y = (y `mod` 4 == 0 && y `mod` 100 /= 0) || y `mod` 400 == 0

main = do
  s <- getLine
  let ls = map read . words $ s
  if or $ map (< 0) ls
    then return ()
    else do putStrLn . show . dayCount $ ls
            main

Measured memory_bytes: 5548
#include <bits/stdc++.h>
using namespace std;
 
/*てんぷれぞーん！*/
//static const int INF = 2147483647;
static const int INF = 1000000000;
static const long long llINF = 9223372000000000000;
static const int NIL = -1;
static const int MOD = 1000000007;
typedef long long ll;
typedef pair<int,int> P;
struct edge {int to,cost;};
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
/* t y p o っ て 知 っ て る ゥ ！ ？ */
#define itn int
#define scnaf scanf
#define reutnr return
/*必要に応じて使ってね*/
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
//#define int ll
//#define INF llINF

signed main(){
    int a;
    scanf("%d",&a);
    printf("%d\n",(a*(a+1))/2);
}

Measured memory_bytes: 256
#dpp
import sys
sys.setrecursionlimit(10**7)
MOD = 10**9+7
n = int(input())
dp = [[1 for _ in range(2)] for _ in range(n)]
edges = [[] for _ in range(n)]
for _ in range(n-1):
	x, y = map(int, input().split())
	edges[x-1].append(y-1)
	edges[y-1].append(x-1)

def dfs(le, ro):
	for ed in edges[le]:
		if ed == ro:
			continue
		dfs(ed, le)
		dp[le][0] = (dp[le][0] * (dp[ed][0] + dp[ed][1])) % MOD
		dp[le][1] = (dp[le][1] * dp[ed][0]) % MOD
	return

dfs(0, -1)
print((dp[0][0] + dp[0][1]) % MOD)

Measured memory_bytes: 111636
#include<bits/stdc++.h>
using namespace std;
long long pi = 3.14159265358979323846264338327;
string s;
int main() {
	cin >> s;
	if(s.at(2) == s.at(3) && s.at(4) == s.at(5)){
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
 	return 0;
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    int x;
    cin >> x;
    vector<int> ans;
    ans.push_back(1);
    for(int i = 2; i * i <= x; i++){
        int num = i*i;
        while(num <= x){
            ans.push_back(num);
            num *= i;
        }
    }
    sort(rall(ans));
    cout << ans[0] << endl;
    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

const ll mod = 1e9+7;
const ll INF = ll(1e18)+1;
const ll MAXN = 1e6;

int main()
{
    int n;
    cin>>n;
    int a[n];
    int count=0;
    rep(i,n)
    {
        cin>>a[i];
    }

    rep(i,n)
    {
        if(i+1!=a[i])count++;
    }
    if(count<=2)
    {
        cout<<"YES";
    }
    else
    {
        cout<<"NO";
    }
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  string s,t,u;
  ll a,b;
  cin >> s >> t >> a >> b >>u;

  if(u==s)cout << a-1 << " " << b << endl;
  else cout << a << " " << b-1 << endl;

}

Measured memory_bytes: 3604
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	ArrayList<Double> x = new ArrayList<Double>();
	ArrayList<Double> y = new ArrayList<Double>();
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

		try {
			int nico = Integer.parseInt(in.readLine());
			x.add(0.0);
			x.add(100.0);
			y.add(0.0);
			y.add(0.0);
			
			draw(nico);
			
			for (int i = 0; i < x.size(); i++) {
				System.out.println(x.get(i) + " " + y.get(i));
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	private void draw(int nico) {
		if (nico == 0) return;
		
		for (int i = 1; i < x.size(); i++) {
			double x0 = x.get(i - 1);
			double y0 = y.get(i - 1);
			
			double x1 = x.get(i);
			double y1 = y.get(i);
			
			double dx = (x1 - x0) / 3;
			double dy = (y1 - y0) / 3;
			
			double rad = (Math.PI / 3);

			x.add(i, x0 + dx);
			y.add(i, y0 + dy);
			i++;

			double rx = Math.cos(rad) * dx - Math.sin(rad) * dy;
			double ry = Math.sin(rad) * dx + Math.cos(rad) * dy;
			
			x.add(i, x0 + dx + rx);
			y.add(i, y0 + dy + ry);
			i++;
			
			x.add(i, x1 - dx);
			y.add(i, y1 - dy);
			i++;
		}
		
		draw(nico - 1);
	}
}

Measured memory_bytes: 30960