akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ll long long
#define pb push_back
#define sz(x) (int)(x).size()
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(), x.end()

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()
template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& a) {
	os << '{';
	for(int i=0;i<sz(a);i++)
	{
		if(i>0&&i<sz(a)-1)
			os << ", ";
		os << a[i];
	}
	os << '}';
    return os;
}
const int N=100;
const int K=1e5+5;
int dp[K][2];
vector<int> rem;
int calc(int k,int p)
{
    if(dp[k][p]!=-1)
        return dp[k][p];
    if(p==0)
    {
        dp[k][p]=1;
        for(auto d:rem)
        {
            if(d<=k)
            {
                int a=calc(k-d,1);
                if(a==0)
                    dp[k][p]=0;
            }
        }
    }
    else
    {
        dp[k][p]=0;
        for(auto d:rem)
        {
            if(d<=k)
            {
                int a=calc(k-d,0);
                if(a==1)
                    dp[k][p]=1;
            }
        }
    }
    return dp[k][p];
}
int main()
{
    memset(dp,-1,sizeof(dp));
    int n,k;
    scanf("%i %i",&n,&k);
    for(int i=0;i<n;i++)
    {
        int a;
        scanf("%i",&a);
        rem.pb(a);
    }
    if(calc(k,0)==0)
        printf("First\n");
    else
        printf("Second\n");
    return 0;
}


Measured memory_bytes: 7296
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
#define il inline
#define re register
#define fo(i,j,k) for(register int i=j;i<=k;i++)
#define inf 0x7fffffff
typedef long long ll;
using namespace std;
il ll read()
{
	re ll x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return f*x;	
}
queue<ll> q;
int main()
{
	int k=read();
	fo(i,1,9) q.push(i);
	fo(i,1,k)
	{
		ll x=q.front();
		q.pop();
		int y=x%10;
		if(y!=0) q.push(x*10+y-1);
		q.push(x*10+y);
		if(y!=9) q.push(x*10+y+1);
		if(i==k)
		{
			printf("%lld\n",x);
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<cctype>

using namespace std;

int main(){

	int sx,sy,tx,ty;
	
	cin>>sx>>sy>>tx>>ty;
	
	const int dx=tx-sx,dy=ty-sy;
	

	cout<<string(dy,'U')<<string(dx,'R');
	
	cout<<string(dy,'D')<<string(dx,'L');
	
	cout<<'L'<<string(dy+1,'U')<<string(dx+1,'R')<<'D';
	
	cout<<'R'<<string(dy+1,'D')<<string(dx+1,'L')<<'U'<<endl;
	
	return 0;

}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func nextInt() int {
	var x int
	fmt.Scan(&x)
	return x
}

func main() {
	n := nextInt()
	a := make([]int, n)
	for i := range a {
		a[i] = nextInt()
	}

	ans := math.MaxInt64
	for j := 0; j <= 1; j++ {
		miniAns := 0
		now := 0
		for i, v := range a {
			k := pow(-1, (i+j)%2)
			now += v
			if sign(now) != k {
				miniAns += abs(k - now)
				now = k
			}
		}
		ans = min(ans, miniAns)
	}
	fmt.Println(ans)
}

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func sign(a int) int {
	if a != 0 {
		return a / abs(a)
	}
	return 0
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func pow(a, b int) int {
	res := 1
	for range make([]struct{}, b) {
		res *= a
	}
	return res
}


Measured memory_bytes: 5504
N = int(input())
A = list(map(int, input().split()))
# print(A)

cnt = {}
for a in A:
  if a not in cnt:
    cnt[a] = 1
  else:
  	cnt[a] += 1
  
s, e = 1, 100000
while True:
  while (s not in cnt or cnt[s] <= 1) and s < e:
    s += 1
  while (e not in cnt or cnt[e] <= 1) and s < e:
    e -= 1
  if e < s:
    break
  if s == e:
    if s in cnt:
      if cnt[s] <= 1:
        break
    else:
      break
  if s in cnt:
  	cnt[s] -= 1
  if e in cnt:
    cnt[e] -= 1

ans = 0
for i in range(1, 100001):
  if i in cnt and cnt[i] > 0:
    ans += 1
    
print(ans)

Measured memory_bytes: 17400
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=k;i++)
using namespace std;
template<typename T> void read(T &num){
	char c=getchar();T f=1;num=0;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){num=(num<<3)+(num<<1)+(c^48);c=getchar();}
	num*=f;
}
template<typename T> void qwq(T x){
	if(x>9)qwq(x/10);
	putchar(x%10+'0');
}
template<typename T> void write(T x){
	if(x<0){x=-x;putchar('-');}
	qwq(x);putchar('\n');
}
template<typename T> void chkmin(T &x,T y){x=x<y?x:y;}

int main(){
	int n,x;read(n);
	int mi=n+1;int ans=0; 
	rep(i,1,n){
		read(x);chkmin(mi,x);
		ans+=(mi==x);
	}
	write(ans);
	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++)


int main() {
  double D, T, S;
  cin >> D >> T >> S;
  
  if (D/S <= T){
    cout << "Yes";
  }else{
    cout << "No";
  }
  
}


Measured memory_bytes: 3716
//by azidoazideazide(c2n14)
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm> //#include<map>
#include<vector>
using namespace std;
typedef long long ll;
//#include<fstream>
//ifstream fin("rps.in");
//ofstream fout("rps.out");
//#define pb push_back
int main(){
	ios::sync_with_stdio(0);
	int a,b;
  cin>>a>>b;
  cout<<a*b<<" "<<a+a+b+b<<endl;
return 0;
}


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

int main() {
  int n;
  int rank = 0;
  string kekka = "";
  
  cin >> n;
  
  vector<int> vec(n);
  vector<int> tmp(n,0);
  for(int i = 0; i < n; i++){
    cin >> vec.at(i);
  }
  
  for(int i = 0; i < n; i++){
    tmp.at(vec.at(i) - 1) = i + 1;
    //rank = vec.at(i) * 2 - 1;
    //kekka.replace(rank, 1, to_string(i+1));
  }
  
  for(int i = 0; i < n; i++){
    kekka += to_string(tmp.at(i)) + " ";
  }
  
  cout << kekka;
}


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

#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(var,start,end) for(int var=start; var<end; var++)
#define repr(var,start,end) for(int var=start; var>=end; var--)
#define repi(var,start,end) for(int var=start; var<=end; var++)
#define debg(var) cerr<<#var<<" : "<<var<<" "
#define pb push_back
#define mp make_pair

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

void solve() {
    int n;
    cin>>n;
    string s;
    cin>>s;
    int r = 0;
    rep(i,0,n) {
        r = (s[i]=='R')?r+1:r;
    }
    int ans = 0;
    rep(i,0,r){
        ans = (s[i]=='W')?ans+1:ans;
    }
    cout<<ans;

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

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
int n;
string s;
set<string> a;
int main() 
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		a.insert(s);
	}
	cout<<a.size();  
	return 0;
}


Measured memory_bytes: 19164
N,M = map(int,input().split())
LRD = [list(map(int,input().split())) for _ in [0]*M]

E = [{} for _ in [0]*N]
for L,R,D in LRD:
    E[L-1][R-1] = D
    E[R-1][L-1] = -D

V = [None]*N
breakFlg = False
for i in range(N):
    if V[i]!=None:continue
    V[i] = 0
    q = [i]
    while q:
        j = q.pop()
        v = V[j]
        for k,d in E[j].items():
            if V[k] == None:
                V[k] = v+d
                q.append(k)
ans = True
for l,e in enumerate(E):
    for r,d in e.items():
        ans = ans and V[r]-V[l]==d
    if not ans:break
print("Yes" if ans else "No")

Measured memory_bytes: 113424
#include <iostream>
using namespace std;
int main() {
  int x, ans;
  cin >> x;
  if(x>=400 && x<=599){
    ans=8;
  } else if(x>=600 && x<=799) {
    ans=7;
  } else if(x>=800 && x<=999) {
    ans=6;
  }else if(x>=1000 && x<=1199) {
    ans=5;
  }else if(x>=1200 && x<=1399) {
    ans=4;
  }else if(x>=1400 && x<=1599) {
    ans=3;
  }else if(x>=1600 && x<=1799) {
    ans=2;
  }else if(x>=1800 && x<=1999) {
    ans=1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define intl long long
#define mod 1000000007
int main()
{
	intl m,n;
	cin>>m>>n;
	char a[m+1][n+1];
	for(intl i=1;i<=m;i++)
	{
		for(intl j=1;j<=n;j++)
		{
			cin>>a[i][j];
		}
	}
	intl dp[1001][1001]={0};
	memset(dp,0,sizeof dp);
	for(int i=1;i<=m;i++)
	{
		if(a[i][1]=='#')
		{
			break;
		}else{
			dp[i][1]=1;
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(a[1][i]=='#')
		{
			break;
		}else{
			dp[1][i]=1;
		}
	}
	for(intl i=2;i<=m;i++)
	{
		for(intl j=2;j<=n;j++)
		{
            if(a[i][j]!='#'){
			if(a[i-1][j]!='#' and a[i][j-1]!='#')
			{
				dp[i][j]=(dp[i][j-1]+dp[i-1][j])%mod;
			}else{
                if(a[i-1][j]=='#' and a[i][j-1]!='#')
                {
                    dp[i][j]=dp[i][j-1];
                }else if(a[i-1][j]!='#' and a[i][j-1]=='#')
                {
                    dp[i][j]=dp[i-1][j];
                } 
            }
            }
		}
	}
	// for(intl i=1;i<=m;i++)
	// {
	// 	for(intl j=1;j<=n;j++)
	// 	{
	// 		// if(a[i-1][j]!='#' and a[i][j-1]!='#')
	// 		// {
	// 		// 	dp[i][j]=dp[i][j-1]+dp[i-1][j];
	// 		// }
	// cout<<dp[i][j]<<" ";
	// 	}
	// cout<<endl;
	// }
    
	cout<<dp[m][n]%mod;
}

Measured memory_bytes: 12440
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::ops::Bound::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout]
fn main() {
    input! {
        R: usize, C: usize, K: usize,
        yxv: [(Usize1, Usize1, i64); K],
    }

    let mut items = vec![vec![0; C]; R];
    for (y, x, v) in yxv {
        items[y][x] = v;
    }

    let mut dp = vec![vec![0; C+1]; 4];
    for y in 1..R+1 {
        let mut dp2 = vec![0; C+1];
        for x in 0..C {
            for k in (1..=3).rev() {
                dp[k][x] = max(dp[k][x], dp[k-1][x] + items[y-1][x]);
                dp[k][x+1] = max(dp[k][x+1], dp[k][x]);
                dp2[x] = max(dp2[x], dp[k][x]);
            }
        }
        dp[0] = dp2;
    }
    let mut ans = 0;
    for i in 0..=3 {
        ans = max(ans, dp[i][C-1]);
    }
    println!("{}", ans);
}


Measured memory_bytes: 80684
#!/usr/bin/env python3
n = int(input())
x = input()
c = x.count("1")
m = 0
m2 = 0
for i in range(n):
    if x[i] == "1":
        m += pow(2, (n - i - 1), c + 1)
        m %= c + 1
m2 = 0
if c!=1:
    for i in range(n):
        if x[i] == "1":
            m2 += pow(2, (n - i - 1), c - 1)
            m2 %= c - 1

for i in range(n):
    if x[i] == "1":
        if c != 1:
            t = m2 - pow(2, (n - i - 1), c - 1)
            t %= c - 1
            count = 1
        else:
            t = 0
            count = 0
    else:
        t = m + pow(2, (n - i - 1), c + 1)
        t %= c + 1
        count = 1
    while t > 0:
        t %= bin(t).count("1")
        count += 1
    print(count)


Measured memory_bytes: 79956
#include <bits/stdc++.h>
using namespace std;
const int N = 200;
struct node {
    int x;
    int id;
    bool operator < (const node& a) const {
        return x < a.x;
    }
}a[N];
int n;

void big() {
    for(int i=1;i<n;i++)
        cout<<i<<" "<<i + 1<<endl;
}

void small() {
    for(int i=n;i>1;i--)
        cout<<i<<" "<<i - 1<<endl;
}

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i].x), a[i].id = i;

    sort(a + 1, a + n + 1);
    if(a[1].x >= 0) {
        cout<<n-1<<endl;
        big();
    }else if(a[n].x <= 0) {
        cout<<n-1<<endl;
        small();
    }else {
        cout<<2 * n - 1<<endl;
        if(abs(a[1].x) > abs(a[n].x)) {
            for(int i=1;i<=n;i++)
                cout<<a[1].id<<" "<<i<<endl;
            small();
        }else {
            for(int i=1;i<=n;i++)
                cout<<a[n].id<<" "<<i<<endl;
            big();
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int dp[110000];

int main() {
    int n;
    cin>>n;

    int a[n];
    rep(i,n) cin>>a[i];

    bool first=false;
    rep(i,n){
        if(a[i]%2==1) first=true;
    }
    if(first) cout<<"first"<<endl;
    else cout<<"second"<<endl;
}

Measured memory_bytes: 640
/*      ░░█ ▄▀█ █   █▀ █░█ █▀█ █▀▀ █▀▀   █▀█ ▄▀█ █▀▄▀█  
        █▄█ █▀█ █   ▄█ █▀█ █▀▄ ██▄ ██▄   █▀▄ █▀█ █░▀░█     */

// Author : Udit "luctivud" Gupta @ (https://www.linkedin.com/in/udit-gupta-1b7863135/)


#include <bits/stdc++.h>
#pragma GCC optimize "trapv"

using namespace std;

typedef long long int lld;
typedef unsigned long long int llu;


#define       TESTCASES()  cin >> (T3X0); T353 = T3X0; while(T3X0--)
#define       _input(V3C)  for(auto &V3C_I7 : (V3C)) cin >> (V3C_I7)
#define mems(A77AY, V4LU)  memset((A77AY), (V4LU), sizeof((A77AY)))
#define  CH3K(I7, E4, S7)  (((S7)<0) ? (I7)>(E4) : (I7)<(E4))
#define for4(I7,S4,E4,S7)  for(auto I7=(S4); CH3K(I7,E4,S7); (I7)+=(S7))




void solveEachTest(lld T35TC453N = 1) {
    
    int n, m; cin >> n >> m;
    vector<int> arr(m+1, 0);
    for4(i, 0, n, 1) {
        int k; cin >> k;
        for4(j, 0, k, 1) {
            int temp; cin >> temp;
            arr[temp] += 1;
        }
    }

    int ans = 0;
    for (auto i : arr) {
        if (i == n) ans++;
    }

    cout << ans;

    cout << "\n"; 

    return;
}


signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);

    lld T3X0 = 0, T353 = 1;

    // TESTCASES() 
        solveEachTest(T353 - T3X0);
    return 0;
}
// Random Thought : thankyou next   

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
typedef pair<int,pair<int, int>> P1;
using Graph = vector<vector<int>>;



signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int N, K;
  cin >> N >> K;
  int A[N];
  int B[1010];
  double C[1010];
  B[0] = 0;
  for(int i=1;i<1010;i++){
    B[i] = B[i-1] + i;
    double a = i;
    C[i] = B[i] / a;
  }
  rep(i,N){
    cin >> A[i];
  }
  double sum1 = 0;
  rep(i, K){
    sum1 += C[A[i]];
  }
  double ans = sum1;
  rep(i, N-K){
    sum1 += C[A[i+K]] - C[A[i]];
    ans = max(ans, sum1);
  }
  cout << fixed << setprecision(10);
  cout << ans << endl;

}

Measured memory_bytes: 1792
o = input()
e = input()
s = ''
if len(o) == len(e):
    for i in range(len(o)):
        s += o[i]
        s += e[i]
    print(s)
else:
    for i in range(len(e)):
        s += o[i]
        s += e[i]
    s += o[-1]
    print(s)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<stdio.h>
#include<string.h>
using namespace std;
#define ll  long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define rep(i,t,n) for(int i=t;i<n;i++)
#define nd "\n"
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>




/*ll power(ll x,ll t){
if(t<=0){
    return 1;
}
ll y=(power(x,t/2));
y=(y*y)%ma;
if(t%2)
    y=(y*x)%ma;
return y;

}*/
/*ll ph[100001];
void E_phi(int n){

ph[0]=0;
ph[1]=1;
for(int i=2;i<=n;i++){
    ph[i]=i;
}
for(int i=2;i<=n;i++){
    if(ph[i]==i){
        for(int j=i;j<=n;j+=){
            ph[j]-=ph[j]/i;
        }
    }
}


}*/
/*string s,t;
vector<int>  z_fun(string s){

int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}*/

/*struct st{
ll sum,pre,suf,ans;
st(){}
st(ll k){
ans=k,pre=k,suf=k,sum=0;
}

};
ll t[4*200001+4];
ll a[200001];
ll lazy[4*200001+4];
ll mx=1e14;



void push(int ind){
int l=2*ind+1,r=2*ind+2;
t[l]+=lazy[ind];
t[r]+=lazy[ind];
lazy[l]+=lazy[ind];
lazy[r]+=lazy[ind];
lazy[ind]=0;

}

void build(int ind,int l,int r){
if(l==r){
    t[ind]=a[l];
return;
}
int mid=(l+r)/2;
build(2*ind+1,l,mid);
build(2*ind+2,mid+1,r);

  t[ind] =min(t[ind*2+1] , t[ind*2+2]);



}
ll query(int ind,int l,int r,int p,int q){

if(l>q || r<p )
    return mx;
    int mid=(l+r)/2;

if(l>=p && r<=q )
    {
      return t[ind];
    }
    push(ind);
ll x=query(2*ind+1,l,mid,p,q);
ll y=query(2*ind+2,mid+1,r,p,q);


return min(x,y);
}

void update(int ind,int l,int r,int p,int q,int val){
if(l>q || r<p )
    return;

if(l>=p && r<=q )
    {
      t[ind]+=val;
      lazy[ind]+=val;
      return;
    }
push(ind);
int mid=(l+r)/2;
    update(2*ind+1,l,mid,p,q,val);
     update(2*ind+2,mid+1,r,p,q,val);
    t[ind]=min(t[2*ind+1],t[2*ind+2]);



}


ll mod(ll a){
if(a>=0)
    return a;
else return -a;
}
*/
ll ma=1e9+7;

ll power(ll x,ll t){
if(t<=0){
    return 1;
}
ll y=(power(x,t/2));
y=(y*y)%ma;
if(t%2)
    y=(y*x)%ma;
return y;

}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    cout<<(power(10,n)+power(8,n)-2*power(9,n)+10*ma)%ma<<endl;
}


Measured memory_bytes: 3640
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, C, K, T;
    while(cin >> N >> C >> K) {
        multiset<int> rs;
        priority_queue<int, vector<int>, greater<int> > pq;
        rep(i, N) {
            cin >> T;
            rs.insert(T+K);
            pq.push(T);
        }

        int ans = 0;
        int now = -1;
        while(sz(rs)) {
            ans++;
            now = *rs.begin();
            int bus = 0;
            // rs.erase(rs.begin());
            while(sz(pq) && pq.top() <= now && bus++<C) {
                rs.erase(rs.find(pq.top()+K));
                pq.pop();
            }
        }
        cout << ans << endl;
    }
}


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

const int maxn = int(1e5)+5, inf = int(1e9)+5;

int vis[maxn];
vector<pair<int, int>> graph[maxn][2];

void rekt()
{
	printf("No\n");
	exit(0);
}

void dfs(int node, int loc)
{
	vis[node] = loc;
	for(auto it: graph[node][0])
	{
		if(vis[it.first] == -inf) dfs(it.first, loc+it.second);
		else if(vis[it.first] != loc+it.second) rekt();
	}

	for(auto it: graph[node][1])
	{
		if(vis[it.first] == -inf) dfs(it.first, loc-it.second);
		else if(vis[it.first] != loc-it.second) rekt();
	}
}

int main(void)
{
	int n, m, u, v, c;
	scanf("%d%d", &n, &m);

	for(int i = 0;i <= n;i++) vis[i] = -inf;

	while(m--)
	{
		scanf("%d%d%d", &u, &v, &c);
		u--, v--;
		graph[u][0].push_back({v, c});
		graph[v][1].push_back({u, c});
	}

	for(int i = 0;i < n;i++)
	{
		if(vis[i] == -inf) dfs(i, 0);
	}

	printf("Yes\n");
}

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

const int MAX = 1000000;

int a[100];
int minim = MAX + 1, maxim = -MAX - 1, minPoz, maxPoz;
int n;
int main()
{
   cin >> n;
   for (int i = 1; i <= n; i++)
   {
      cin >> a[i];
      if (a[i] < minim)
         minim = a[i], minPoz = i;
      if (a[i] > maxim)
         maxim = a[i], maxPoz = i;
   }
   cout << 2 * n - 2 << "\n";
   if (abs(minim) < abs(maxim))
   {

      // adaugam maxim la toate si vor fi pozitive
      for (int i = 1; i <= n; i++)
         if (i != maxPoz)
            cout << maxPoz << " " << i << "\n", a[i] += a[maxPoz];

      for (int i = 1; i < n; i++)
         cout << i << " " << i + 1 << "\n", a[i + 1] += a[i];
   }

   else
   {
      // adaugam minim la toate si vor fi negative
      for (int i = 1; i <= n; i++)
         if (i != minPoz)
            cout << minPoz << " " << i << "\n", a[i] += a[minPoz];

      for (int i = n; i > 1; i--)
         cout << i << " " << i - 1 << "\n", a[i - 1] += a[i];
   }

   return 0;
}


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

int main() {
  int N; cin >> N;
  vector<vector<int>> G(10, vector<int>(10, 0));
  for (int i = 1; i <= N; i++) {
    string num = to_string(i);
    int head = num.at(0) - '0';
    int tail = num.back() - '0';
    G.at(head).at(tail)++;
  }
  int ans = 0;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      ans += G.at(i).at(j) * G.at(j).at(i);
    }
  }
  cout << ans << endl;
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    cout << max(a+b, max(a-b, a*b)) << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

#define _GLIBCXX_DEBAC
using namespace std;
	

int main() {
	int n;
	int sum = 0;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			sum += a[i] * a[j];
		}
	}
	cout << sum;
		return 0;
}









Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <utility>

int main(){
  int K;
  std::cin >> K;

  std::vector<int> searched(K);
  std::stack<long long> current, next;
  current.push(1);
  long long length=1;
  bool found = false;
  while(true){
    while(current.size() > 0){
      long long n = current.top();
      current.pop();
      searched[n] = 1;
      if(n == 0){
        found = true;
        break;
      }
      long long n10 = (10*n)%K, n1 = (n+1)%K;
      if(searched[n10] == 0) current.push(n10);
      if(searched[n1] == 0) next.push(n1);
    }
    if(found) break;
    length++;
    std::swap(current, next);
  }

  std::cout << length << std::endl;

  return 0;
}



Measured memory_bytes: 1152
S = input()
check = []
flg = 0
ans = []
for i in range(len(S)):
    check.append(S[i])
    if S[i] == "L":
        flg = 1
    if S[i] == "R" and flg == 1:
        check.pop()
        for j in range(len(check)):
            if check[j] == "L":
                o = j
                break
        answer = [0 for p in range(len(check))]
        if len(check)%2 == 0:
            answer[o] = int(len(check)/2)
            answer[o-1] = int(len(check)/2)
        else:
            if o%2 == 0:
                answer[o] = len(check)//2+1
                answer[o-1] = len(check)//2
            else:
                answer[o] = len(check)//2
                answer[o-1] = len(check)//2 + 1
        for z in answer:
            ans.append(z)
        check = ["R"]
        flg = 0
for j in range(len(check)):
    if check[j] == "L":
        o = j
        break
answer = [0 for p in range(len(check))]
if len(check)%2 == 0:
    answer[o] = int(len(check)/2)
    answer[o-1] = int(len(check)/2)
else:
    if o%2 == 0:
        answer[o] = len(check)//2+1
        answer[o-1] = len(check)//2
    else:
        answer[o] = len(check)//2
        answer[o-1] = len(check)//2 + 1
for z in answer:
    ans.append(z)
for m in ans:
    print(m,end=" ")
print()


Measured memory_bytes: 11636
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  int n;
  cin>>n;
  map<string,int> m1;
  rep(i,0,n){
    string s;
    cin>>s;
    m1[s]++;
  }
  vector<string> v1={"AC", "WA", "TLE","RE"};
  for(auto j:v1){
    if(m1.find(j)!=m1.end())cout<<j<<" x "<<m1[j]<<endl;
    else cout<<j<<" x "<<0<<endl;
  }
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3524
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define ROOP() while (true)

int main(){
    
    int N,M,x,y;
    cin >> N >> M >> x >> y;
    for(int i=0; i<N; i++){
        int tmp;
        cin >> tmp;
        x = max(x,tmp);
    }
    for(int i=0; i<M; i++){
        int tmp;
        cin >> tmp;
        y = min(y,tmp);
    }

    if(x < y) cout << "No War" << endl;
    else cout << "War" << endl;
    
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
S=[list(map(int,input().split())) for _ in range(m)]
P=list(map(int,input().split()))

ans=0
for i in range(2**n):
  on=[0 for _ in range(n)]
  tmp=i
  for j in range(n):
    if tmp%2==1:
      on[j]=1
    tmp//=2
  flag=True
  for j in range(m):
    cnt=0
    for k in range(1,S[j][0]+1):
      cnt+=on[S[j][k]-1]
    if cnt%2!=P[j]:
      flag=False
      break
  if flag:
    ans+=1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

int N;
vector<int> A, C;

int main() {
  cin >> N;
  A.resize(N);
  C.resize(N);

  int ans = 0;

  rep(i, N) {
    cin >> A[i];
    A[i]--;
  }
  rep(i, N) {
    int B;
    cin >> B;
    ans += B;
  }

  rep(i, N - 1) cin >> C[i];

  for (int i = 1; i < N; ++i) {
    if (A[i] - A[i - 1] == 1) ans += C[A[i - 1]];
  }

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


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);

	int a, b;
	cin >> a >> b;
	if( (b - a)%2 == 0 ){
		cout << (b - a) / 2 + a << "\n";
	}else{
		cout << "IMPOSSIBLE" << "\n";
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF (1<<29)
 
int H, W;
char f[200][200];
  
int bfs(queue<int>& px, queue<int>& py, int gx, int gy)
{
    vector<vector<int>> d(H, vector<int>(W, INF));
    auto qx = px, qy = py;
    while (!px.empty()) {
        int x = px.front(), y = py.front();
        px.pop(); py.pop();
        d[y][x] = 0;
    }
    const int dx[] = {-1, +1, +0, +0}, dy[] = {+0, +0, -1, +1};
    while (!qx.empty()) {
        int x = qx.front(), y = qy.front();
        qx.pop(); qy.pop();
        for (int i = 0; i < 4; i++) {
            int nx = x + dx[i], ny = y + dy[i];
            if (0 <= nx && nx < W && 0 <= ny && ny < H &&
                f[ny][nx]=='.') {                
                if (d[y][x] + 1 < d[ny][nx]) {
                    d[ny][nx] = d[y][x] + 1;
                    qx.push(nx); qy.push(ny);
                }
            }
        }
    }
    return d[gy][gx];
}
  
int main()
{
    int gx, gy;
    cin >> H >> W;
    queue<int> ax, ay, bx, by;
    for (int i = 0; i < H; i++) {
        for (int j = 0 ; j < W; j++) {
            cin >> f[i][j];
            if (f[i][j] == '@') {
                f[i][j] = '.';
                ax.push(j); ay.push(i);
            } else if (f[i][j] == '$') {
                f[i][j] = '.';
                bx.push(j); by.push(i);
            } else if (f[i][j] == '%') {
                f[i][j] = '.';
                gx = j; gy = i;
            }
        }
    }
    cout << (bfs(ax, ay, gx, gy) < bfs(bx, by, gx, gy) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n;
    cin>>n;
    n%=10;
    if(n==2||n==4||n==5||n==7||n==9)
        cout<<"hon";
    else if(n==3)
        cout<<"bon";
    else
        cout<<"pon";
}

Measured memory_bytes: 3596
// 　　＿＿
// 　／　<＠ﾌ
//  ｜(ﾉﾉハ))
//  ﾉ从ﾟヮﾟ从
// 　ﾉ｜ｿﾉГ|つ author:hotarunx
// 〈_ﾉ^^^ヽ|
// 　~~tｧtｧ~
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int ans = a * c;
    ans = max(a * c, ans);
    ans = max(a * d, ans);
    ans = max(b * c, ans);
    ans = max(b * d, ans);

    cout << ans << "\n";
}


Measured memory_bytes: 3644
/*input

*/
#include <bits/stdc++.h>
#define up(i,a,b) for(int (i) = (a);(i)<=(b);++(i))
#define down(i,b,a) for(int (i) = (b);i>=(a);--i)
#define debug(x) cerr << (x) << '\n';
#define bits(x,i) ((x >> i) & 1)
#define mid ((l+r)/2)
#define pr pair<int,int>
using namespace std;
char c;
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> c;
	if (c >= 'a') cout << 'a';
	else cout << 'A';
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + 10;
int a[N], b[N];
vector<int> g[N];
ll ans[N];
void dfs(int fa, int u, ll d) {
    d += a[u];
    ans[u] = d;
    for(int v : g[u]) {
        if(v == fa) continue;
        dfs(u, v, d);
    }
}
int main() {
    int n, q;
    cin >> n >> q;
    for(int i = 1, u, v; i < n; i++) {
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    for(int i = 0, x, y; i < q; i++) {
        cin >> x >> y;
        a[x] += y;
    }
    dfs(-1, 1, 0);
    for(int i = 1; i <= n; i++) {
        cout << ans[i] << " \n"[i==n];
    }
    return 0;
}

Measured memory_bytes: 28288
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int[] l = IntStream.range(0, n).map(i -> scanner.nextInt()).toArray();
			int count = 0;
			for (int i = 0; i < n - 2; i++) {
				for (int j = i + 1; j < n - 1; j++) {
					if (l[i] != l[j]) {
						for (int k = j + 1; k < n; k++) {
							if ((l[k] != l[i]) && (l[k] != l[j])) {
								if ((l[i] < (l[j] + l[k])) && (l[j] < (l[i] + l[k])) && (l[k] < (l[i] + l[j]))) {
									count++;
								}
							}
						}
					}
				}
			}
			System.out.println(count);
		}
	}
}


Measured memory_bytes: 36976
from math import factorial
N,K = map(int, input().split())
mod = 10**9 + 7
def com(n,r):
    if n<r:
        return 0
    return int(factorial(n) // factorial(r) // factorial(n-r))
for i in range(1,K+1):
    comb = com(N-K+1,i)
    sec = com(K-1,i-1)
    print((comb * sec)%mod)

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

int main() {
    //input
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int f1 = abs(c-a);
    int f2 = abs(b-a);
    int f3 = abs(c-b);
    if(f1 <= d ||(f2 <= d && f3 <= d)){
        cout << "Yes";
    }else{
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 256
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def make4(initial, L, M, N, O):
    return [[[[initial for i in range(O)]
                for n in range(N)]
                for m in range(M)]
                for l in range(L)]


def make3(initial, L, M, N):
    return [[[initial for n in range(N)]
                for m in range(M)]
                for l in range(L)]


def debug(table, *args):
    ret = []
    for name, val in table.items():
        if val in args:
            ret.append('{}: {}'.format(name, val))
    print(' | '.join(ret), file=sys.stderr)


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    N, W = MI()
    v = [0] * N
    w = [0] * N
    dp = [[0] * (W+1) for i in range(N+1)]

    for i in range(N):
        v[i], w[i] = MI()

    for i in range(N):
        for j in range(W+1):
            dp[i+1][j] = max(dp[i+1][j], dp[i][j])
            if j + w[i] <= W:
                dp[i][j+w[i]] = max(dp[i][j+w[i]], dp[i][j] + v[i])
                dp[i+1][j+w[i]] = max(dp[i+1][j+w[i]], dp[i][j] + v[i])
    print(dp[N][W])

if __name__ == '__main__':
    main()



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

int main()
{
    int N, cnt = 0;
    cin >> N;
    bool flag = false;
    for (int i = 0; i <= N / 4; i++)
    {
        for (int j = 0; j <= N / 7; j++)
            if (4 * i + 7 * j == N)
            {
                flag = true;
                break;
            }
    }

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

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

int main() {
    int a, b;
    cin >> a >> b;
    if ((a + b) % 2 != 0) {
        cout << ((a + b) / 2) + 1 << endl;
    } else {
    cout << (a + b) / 2 << endl;
    }
 }    


Measured memory_bytes: 256
module ch
  implicit none
  type char
     character(10)      :: chara
  end type char
  type(char),allocatable :: namec(:)
  type(char),allocatable :: namecmax(:)
end module ch
program main
   
  use ch, only : namec, namecmax

  implicit none
  integer :: n
  integer, allocatable :: s(:)
  integer :: i,j,k, maxvals
  
  read(*,*) n
  allocate( s(n) )
  allocate( namec(n) )
  do i = 1, n
    read(*,*) namec(i)%chara
  end do

  call quicksort1( 1, n ) 

  j = 0 
  do i = 1, n
    if( namec(i)%chara /= namec(i+1)%chara ) then
      j = j + 1
    end if 
  end do

  print*,j

end program main
recursive subroutine quicksort1( first, last )

  use ch, only : namec, namecmax

  implicit none
  integer,intent(in)::first,last
  !
  ! Original
  ! https://gist.github.com/t-nissie/479f0f16966925fa29ea
  !
  character(100)::x,t
  integer::i,j

  x = namec((first+last)/2)%chara
  i = first
  j = last
  do
     do while ( LGT( x, namec(i)%chara ) )
        i=i+1
     end do
     do while ( LGT( namec(j)%chara, x ) )
        j=j-1
     end do
     if (i >= j) exit
     t = namec(i)%chara
     namec(i)%chara = namec(j)%chara
     namec(j)%chara = t
     i=i+1
     j=j-1
  end do
  if (first < i-1) call quicksort1( first, i-1  )
  if (j+1 < last)  call quicksort1( j+1  , last )

  return

end subroutine quicksort1


Measured memory_bytes: 4720
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define MOD 998244353LL
#define seg_size 262144*4
#define REP(a,b) for(long long a = 0;a < b;++a)
long long dp[4000][4000][2] = {};
int main() {
	iostream::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	dp[0][0][1] = 1;
	for (int i = 1; i <= n; ++i) {
		dp[0][i][0] = 1;
	}
	for (int i = 0; i < m; ++i) {
		for (int q = 0; q <= n; ++q) {
			long long remaining_b = n - q;
			if (q >= 1) {
				// A -> B
				if (q == 1) {
					dp[i + 1][1][1] += dp[i][1][0] + dp[i][1][1];
					dp[i + 1][1][1] %= MAX_MOD;
				}else{
					REP(j, 2) {
						dp[i + 1][q][j] += dp[i][q][j];
						dp[i + 1][q][j] %= MAX_MOD;
					}
				}
				// A -> A
				if (q == 1) {
					dp[i + 1][0][1] += dp[i][q][0] + dp[i][q][1];
					dp[i + 1][0][1] %= MAX_MOD;
				}
				else {
					REP(j, 2) {
						dp[i + 1][q - 1][j] += dp[i][q][j];
						dp[i + 1][q - 1][j] %= MAX_MOD;
					}
				}
			}
			if (remaining_b >= 1) {
				// B -> A
				REP(j, 2) {
					dp[i + 1][q][j] += dp[i][q][j];
					dp[i + 1][q][j] %= MAX_MOD;
				}
				// B -> B
				REP(j, 2) {
					dp[i + 1][q + 1][j] += dp[i][q][j];
					dp[i + 1][q + 1][j] %= MAX_MOD;
				}
			}
		}
	}
	long long ans = 0;
	for (int i = 0; i <= n; ++i) {
		ans += dp[m][i][1];
		ans %= MAX_MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 188288
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
template <class T>
using lim = numeric_limits<T>;

const int MOD = 1e9+7;
char letters[4] = {'A','C','G','T'};
string invalids[6] = {"AGC","GAC","ACG","AGGC","AGTC","ATGC"};

unordered_map<string,int> memo[100];
// checks if a 4-letter string is valid
bool isValid(string s){
	bool res = true;
	for (int i = 0; i < 6; i++){
		if (s.find(invalids[i]) != string::npos){
			res = false;
		}
	}
	return res;
}

ll dfs(int rec, int n, string s){
	if (rec == n) return 1;
	if (memo[rec].find(s) != memo[rec].end()) {
		return memo[rec][s];
	}
	
	ll ans = 0;
	for (int i = 0; i < 4; i++){
		string check = s+letters[i];
		if (isValid(check)){
			ans = (ans+dfs(rec+1, n, check.substr(1)))%MOD;
		}
	} 
	// memoization
	memo[rec][s] = ans;
	return ans;
}

int main() {
	ios_base::sync_with_stdio(false) ;
	cin.tie(0);
	
	int n;
	cin >> n;
	
	cout << dfs(0, n, "XXX") << endl;
}


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

using namespace std;

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

    int total = 0;

    cin >> n;

    for (int i = 1; i < n + 1; i += 2)
    {
        int count = 1;

        // cout << i << "\n";

        for (int j = 3; j < n + 1; j++)
        {
            if (i % j == 0)
            {
                count++;
            }
        }

        if (count == 8)
            total += 1;
    }

    cout << total << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

void yes() {
  cout << "Yes" << endl;
  exit(0);
}

void no() {
  cout << "No" << endl;
  exit(0);
}

int main() {
  string s;
  cin >> s;
  if (SZ(s) % 2 == 1) {
    no();
  }
  for (int i = 0; i < SZ(s); i += 2) {
    if (s[i] == 'h' && s[i + 1] == 'i') {
      continue;
    }
    no();
  }
  yes();
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
int n,q;
bool able[10];

inline int nxi(){
	int x=0;
	char c;
	while((c=getchar())>'9'||c<'0');
	while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
	return x;
}

inline bool jdg(int x){
	for(int y=x/10;x;x=y,y=x/10){
		if(!able[x-y*10]) return 0;
	}
	return 1;
}

int main(){
#ifndef ONLINE_JUDGE
//	freopen("c.in","r",stdin);
#endif
	n=nxi(),q=nxi();
	for(int i=0;i<10;++i) able[i]=1;
	for(int i=1;i<=q;++i){
		able[nxi()]=0;
	}
	for(int i=n;i<n*10;++i){
		if(jdg(i)){
			printf("%d\n",i);
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
<?php
//error_reporting(0);
//$S = trim(fgets(STDIN));
list($D,$G) = explode(" ",trim(fgets(STDIN)));
for($i=0;$i<$D;$i++) {
  list($p[],$c[]) = explode(" ",trim(fgets(STDIN)));
}
$res = 99999;
//$a = explode(" ",trim(fgets(STDIN)));
for($mask = 0; $mask < (1 << $D); ++$mask){
  $num = 0;
  $sum = 0;
  $rest = -1;
  for($i = 0; $i < $D; ++$i){
      if($mask >> $i & 1){
        $sum += (($i+1)*100)*$p[$i]+$c[$i];
        $num += $p[$i];
      }else{
        $rest = $i;
      }
  }
  if ($sum < $G) {
    for($j=0;$j<$p[$rest];$j++) {
      $sum += ($rest+1)*100;
      $num++;
      if ($sum >= $G) break;
    }
    if ($sum < $G) continue;
  }
  $res = min($res,$num);
}
printf("%d\n",$res);


Measured memory_bytes: 3576
#include <stdio.h>

int gcd(int x, int y)
{
  if (y == 0) return x;

  else return gcd(y, x % y);
}

int main()
{
  int x, y;

  while(scanf("%d %d", &x, &y) != EOF)
    printf("%d %d\n", gcd(x, y), x/gcd(x, y)*y);

  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <list>
#define INF 0x3f3f3f3f
#define maxn 205000
#define maxnn 6000
#define juzheng 300
#define line cout << "-------------------------" << endl;
#define PI acos(-1.0)
#define mem(a,b) memset(a,b,sizeof(a))
#define fill_(a,b,n) fill(a,a + n,b)
#define esp 1e-9
 
#define ri(n) scanf("%d",&n)
#define ri2(a,b) scanf("%d %d",&a,&b)
#define ri3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define rd(n) scanf("%lf",&n)
#define rd2(a,b) scanf("%lf %lf",&a,&b)
#define rd3(a,b,c) scanf("%lf %lf %lf",&a,&b,&c)
#define rl(n) scanf("%lld",&n)
#define rl2(a,b) scanf("%lld %lld",&a,&b)
#define rl3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define pr(n) cout << n << endl
#define ll long long
#define int64 __int64

using namespace std;

//Date:2018-8-4
//Author：HarryBlackCat

ll arr[maxn];

int main() {
	//cin.sync_with_stdio(false);//降低cin，cout时间
	int n;
	while(~ri(n)){
		for(int i = 0;i < n;i++)
			rl(arr[i]);
			
		ll ans = 0;
		for(int i = 0;i < n;i++)
			ans += arr[i] - 1;
			
		pr(ans);
	}
}

Measured memory_bytes: 384
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
ans = 0
for i in range(61):
	x = 0
	for j in a:
		if j >> i & 1:
			x += 1
	z = x*(n-x)%mod
	z *= 2**i
	z %= mod
	ans += z
	ans %= mod
print (ans)


Measured memory_bytes: 122936
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
    string s;
    cin>>s;
    map<string,int>m;
    m["SUN"]=7;
    m["MON"]=6;
    m["TUE"]=5;
    m["WED"]=4;
    m["THU"]=3;
    m["FRI"]=2;
    m["SAT"]=1;
    cout<<m[s]<<endl;
}

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

#define iFOR(idx, from, upto) for (int  idx = from; idx < upto; ++idx)
#define lFOR(idx, from, upto) for (long idx = from; idx < upto; ++idx)

#define ll long long

using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    while (true) {
        c -= b; if (c <= 0) break;
        a -= d; if (a <= 0) break;
    }

    if (a > 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3624
import heapq
import sys
input = sys.stdin.readline

N, M, S, T = map(int, input().split())


class Edge():

    def __init__(self, _to, _cost):
        self.to = _to
        self.cost = _cost


class Dijkstra():
    def __init__(self, V):

        self.G = [[] for i in range(V+1)]
        self._E = 0
        self._V = V

    def add(self, _from, _to, _cost):
        """ 2頂点と、辺のコストを追加"""
        self.G[_from].append(Edge(_to, _cost))
        self._E += 1

    def shortest_path(self, s):
        """ 始点sから頂点iまでの最短路リスト 
        """
        que = []
        heapq.heapify(que)
        d = [10**15] * (self._V+1)
        d[s] = 0
        heapq.heappush(que, (0, s))  # 始点の(最短距離, 頂点番号)をヒープに追加

        while que:
            cost, v = heapq.heappop(que)
            if d[v] < cost:
                continue

            for e in self.G[v]:
                if d[e.to] > d[v] + e.cost:
                    d[e.to] = d[v] + e.cost
                    heapq.heappush(que, (d[e.to], e.to))
        return d


graph_snuke = Dijkstra(N)
graph_yen = Dijkstra(N)
for _ in range(M):
    u, v, a, b = map(int, input().split())
    graph_yen.add(u, v, a)
    graph_yen.add(v, u, a)
    graph_snuke.add(u, v, b)
    graph_snuke.add(v, u, b)

yen = graph_yen.shortest_path(S)
snuke = graph_snuke.shortest_path(T)
minimum_case = [10**15 for i in range(N+1)]
for i in range(N):
    minimum_case[1+i] -= (yen[i+1]+snuke[i+1])
for i in range(N-1, -1, -1):
    minimum_case[i] = max(minimum_case[i], minimum_case[i+1])
for i in range(1, N+1):
    print(minimum_case[i])

Measured memory_bytes: 144444
W,H=map(int,input().split())
from heapq import heappush,heappop,heapify
p,q=[int(input()) for i in range(W)],[int(input()) for i in range(H)]
heapify(p),heapify(q)
r,i,j=0,W+1,H+1
while i>1 and j>1:
    if p[0]<q[0]:
        r+=heappop(p)*j
        i-=1
    else:
        r+=heappop(q)*i
        j-=1
print(r+sum(p)+sum(q))

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> work(m, vector<int>(0));
  ll ans = 0;
  rep(i, n){
    int a, b;
    cin >> a >> b;
    if(a > m)continue;
    a--;
    work[a].push_back(b);
  }
  priority_queue<int> que;
  rep(i, m){
    rep(j,work[i].size()){
      que.push(work[i][j]);
    }
    if(!que.empty()){
      ans += que.top();que.pop();
    }
  }
  cout << ans << endl;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	ll n, k;
	cin >> n >> k;
	vector<ll> ans(n);
	for (ll i = 0; i < n; i++) {
		cin >> ans[i];
	}
	sort(ans.begin(), ans.end());
	if (ans.size() <= k) cout << "0" << "\n";
	else {
		ll sum = 0;
		for (ll i = 0; i < ans.size() - k; i++) {
			sum += ans[i];
		}
		cout << sum << "\n";
	}
	return 0;
}


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

void solve(string S, string T)
{
    int res = INT_MAX;
    for (int l = 0; l < (int)S.size() - (int)T.size() + 1; l++)
    {
        int d = 0;
        for (int i = 0; i < (int)T.size(); i++)
        {
            if (S.at(l + i) != T.at(i))
            {
                d++;
            }
        }
        res = min(res, d);
    }
    cout << res << endl;
}

int main()
{
    string S;
    cin >> S;
    string T;
    cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 3600
def main():
    N, M = map(int, input().split())
    div = pow(10, 9) + 7
    fN, fM = 1, 1
    for i in range(1, N+1): fN = (i*fN) % div
    for i in range(1, M+1): fM = (i*fM) % div

    if N == M:
        return 2*fN*fM % div
    elif N == M+1 or N+1 == M:
        return fN*fM % div
    else:
        return 0


if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3064