akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define     ll          long long
#define     MOD         10e9+7
#define     pb          push_back
#define     vll         vector<long long>
#define     vi          vector<int>
#define     vl          vector<long>
#define     pii         pair<int, int>
#define     all(a)      (a).begin(),(a).end()
#define     rep(i,a,b)  for(int i=a;i<b;i++)
#define     MAX         100002 
#define     ios	      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int main() {
    
      ios
      string s,t;
      cin >> s >>t;
      int l=t.length();
      int count=0;
      for(int i=0;i<l-1;i++){
            if(t[i]==s[i])count++;
            else break;
      }
      int len=s.length();
      if(count==len)cout <<"Yes\n";
      else cout <<"No\n";
      return 0;
        
}


Measured memory_bytes: 3652
#include <iostream>
// #include <algorithm>
using namespace std;

int main (void) {
  int n, price;
  cin >> n >> price;

  int x=0;
  int y=0;
  int z=0;

  bool flag = false;

  for (x = 0; x <= n; x++){
    y = 0;
    z = n - x;
    while (10000 * x + 5000 * y + 1000 * z <= price && !(flag) && y >= 0 && z >= 0) {
      if ((10000 * x + 5000 * y + 1000 * z) == price) {
        flag = true;
        cout << x << " " << y << " " << z << endl;
      }
      z--;
      y++;
    }
  }

  if (!flag) {
    cout << -1 << " " << -1 << " " << -1 << endl;
  }
}

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

int main(){
    string s; cin >> s;
    int n = s.size();
    int ans[n];
    rep(i,n) ans[i] = 0;
    rep(i,n - 1) {
        if(s[i]=='R' && s[i+1]=='L'){
            int j = i;
            while(s[j] == 'R'){
                if((i-j)%2==0) ans[i]++;
                else ans[i+1]++;
                j--;
            }
            int k = i+1;
            while(s[k] == 'L'){
                if((k-i-1)%2==1) ans[i]++;
                else ans[i+1]++;
                 k++;
            }
        }
    } 
    rep(i,n){
        if(i == 0) cout << ans[i];
        if(i) cout << " " << ans[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <map>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <vector>
//const int maxn = 1e5+5;
#define ll long long
#define MAX INT_MAX
#define FOR(i,a,b) for( int i = a;i <= b;++i)

using namespace std;

int H,W;
char v[210][210];
int main()
{
    scanf("%d %d",&H,&W);
    for(int i=1;i<=H;++i)
    {
        for(int j=1;j<=W;++j)
        {
            cin>>v[i][j];
        }
    }
    for(int i=1;i<=H;++i)
    {
        for(int j=1;j<=W;++j)
        {
            cout<<v[i][j];
        }
        cout<<endl;
        for(int j=1;j<=W;++j)
        {
            cout<<v[i][j];
        }
        cout<<endl;
    }


}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<iostream>
#include<map>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<deque>
#define ll long long
using namespace std;
#define BUF_SIZE 1048576
char _buf[BUF_SIZE],*_is=_buf,*_it=_buf;
inline char rdc(){
	if (_is==_it) _it=(_is=_buf)+fread(_buf,1,BUF_SIZE,stdin);
	return *_is++;
}
inline int rdi(){
	int x=0,f=0;
	register char ch=rdc();
	while ((ch<'0' or ch>'9') and (ch^'-')) ch=rdc();
	if (ch=='-') f=1,ch=rdc();
	while (ch>='0' and ch<='9') x=(x<<3)+(x<<1)+(ch^'0'),ch=rdc();
	return f?-x:x;
}
inline void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
inline void _write(int x){
	write(x);
	putchar(' ');
}
inline void print(int x){
	write(x);
	putchar('\n');
}
int h[100005],n,k;
ll dp[100005];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>k;
	int i,j;
	for(i=1;i<=n;++i) cin>>h[i];
	memset(dp,63,sizeof(dp));
	dp[0]=0;
	dp[1]=0;
	for(i=2;i<=n;++i) for(j=max(i-k,1);j<=i-1;++j) dp[i]=min(dp[j]+abs(h[i]-h[j]),dp[i]);
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

signed main() {
    ll n;
    cin >> n;
    ll ans = 0;
    for (int i = 1; i * i <= n; i++) {
        int j = i;
        ll sum = n / j;
        ans += (1 + sum) * sum / 2 * j;
        ll sum2 = (ll)sqrt (n);
        // cout << sum2 << " " << sum << "\n";
        sum2++;
        if (sum2 > sum) continue;
        ans += (sum2 + sum) * (sum - sum2 + 1) / 2 * j;
        // cout << ans << "\n";
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i <= (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)

int main()
{
    ll N, Y;
    cin >> N >> Y;
    repi(i, N, 0)
    {
        repi(j, N - i, 0)
        {
            repi(k, N - i - j, 0)
            {
                if (i * 10000 + j * 5000 + k * 1000 == Y && i+j+k == N)
                {
                    cout << i << " " << j << " " << k << endl;
                    return 0;
                }
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
MOD=10**9+7
dp=[[0]*5 for _ in range(210000)]

def add(a,b):
  ret_val=a+b
  if ret_val>=MOD:
    ret_val-=MOD
  return ret_val

S=input()

dp[0][0]=1
for i in range(len(S)):
  for j in range(5):
    if S[i]!="?":
      temp=add(dp[i+1][j],dp[i][j])
      dp[i+1][j]=temp
    else:
      temp=add(dp[i+1][j],dp[i][j]*3%MOD)
      dp[i+1][j]=temp

  if S[i]=="A" or S[i]=="?":
    temp=add(dp[i+1][1],dp[i][0])
    dp[i+1][1]=temp
  if S[i]=="B" or S[i]=="?":
    temp=add(dp[i+1][2],dp[i][1])
    dp[i+1][2]=temp
  if S[i]=="C" or S[i]=="?":
    temp=add(dp[i+1][3],dp[i][2])
    dp[i+1][3]=temp
print(dp[len(S)][3])


Measured memory_bytes: 108696
#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))
  
n=int(input())
A=input_array()

front=0 # 1つ前の人の身長
ans=0 # 踏み台のたかさの合計
for a in A:
	if a < front:
		ans+=front-a
	else:
		front=a

print(ans)

Measured memory_bytes: 32220
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
    public static void main(String[] args)throws IOException {
        BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
        String line=br.readLine();
        String split[]=line.split(" ",0);
        int a=Integer.parseInt(split[0]);
        int b=Integer.parseInt(split[1]);
        if (a>b) {
            System.out.println("a > b");
        }
        else if(a<b){
            System.out.println("a < b");
        }
        else{
            System.out.println("a == b");
        }
    }
}

Measured memory_bytes: 17088
#include <iostream>

using namespace std;

int main(void){

  int n;
  while( cin >> n ){

    while(1){
      if( n <= 39 ) break;
      else n -= 39;
    }
    cout << "3C";
    if( 1 <= n && n <= 9 ) cout << "0";
    cout << n << endl;

  }
  return 0;
}

Measured memory_bytes: 1160
#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;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const int MOD = 998244353;
int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
void radd(int &a, int b)
{
	a=add(a,b); 
}

string s;
int suf[333][333][333]; //# of strings s.t. LCS from back with s goes to that long
int f[333][333][333];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin>>s;
	int n=s.length();
	f[0][0][0]=1;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<=n;j++)
		{
			for(int k=0;k<=n;k++)
			{
				//assert(f[i][j][k]==g[i][j][k]);
				if(!f[i][j][k]) continue;
				f[i+1][j][k]=1;
				if(i+3<=n) 
				{
					if(s[i+2]=='1') f[i+3][j+1][k]=1;
					else f[i+3][j][k+1]=1;
				}
				if(i+2<=n) 
				{
					if(s[i+1]=='1') f[i+2][j+1][k]=1;
					else f[i+2][j][k+1]=1;
					if(s[i]=='1') f[i+2][j+1][k]=1;
					else f[i+2][j][k+1]=1;
				}
				if(j>0&&s[i]=='0')
				{
					f[i+1][j-1][k+1]=1;
				}
				if(j>0&&s[i]=='1')
				{
					f[i+1][j+1][k-1]=1;
				}
			}
		}
	}
	suf[0][n][0]=1;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<=n;j++)
		{
			for(int k=0;k<=n;k++)
			{
				if(suf[i][j][k]==0) continue;
				int v=suf[i][j][k];
				//choose s[j-1]!
				radd(suf[i+1][j-1][k],v);
				//choose opposite of s[j-1] sia
				radd(suf[i+1][j][k+(s[j-1]=='0')],v);
			}
		}
	}
	int ans = 1; //match completely
	for(int i=1;i<n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			for(int k=0;k<n;k++)
			{
				int v = suf[i][j][k];
				if(v==0) continue;
				//s[0..j-1]
				//j=1 special care
				int ones = k;
				int zeroes = i-k-(n-j); //length - number of matches 
				if(zeroes<0) continue;
				if(zeroes+ones==0)
				{
					radd(ans,v); 
					continue;
				}
				if(j==1)
				{
					radd(ans,v); 
					continue;
				}
				if(f[j][ones][zeroes])
				{
					radd(ans,v);
				}
			}
		}
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 93936
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans,n;
    cin>>n;

    ans=n*(n+1)/2;

     cout <<ans<<endl;

    return 0;

}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class UnionFind{
	vector<ll> rank;
	vector<ll> diff_weight;
	vector<ll> num;
public:
	vector<ll> par;

	UnionFind(ll N):par(N),num(N),rank(N),diff_weight(N){
		for(ll i=0;i<N;i++){
			par[i]=i;
			num[i]=1;
			rank[i]=0;
			diff_weight[i]=0;
		}
	}

	ll root(ll x){
		if(par[x]==x){
			return x;
		}
		ll r = root(par[x]);
		diff_weight[x]+=diff_weight[par[x]];
		return par[x]=r;
	}

	void unite(ll x,ll y){
		ll rx = root(x);
		ll ry = root(y);
		if (rx == ry) return;
		if(rank[rx]<rank[ry]) swap(rx,ry);
		if(rank[rx]==rank[ry]) ++rank[rx];
		par[ry] = rx;
		num[rx] += num[ry];
	}

	void relate(ll x,ll y,ll w){
		w+=weight(x),w-=weight(y);
		ll rx = root(x);
		ll ry = root(y);
		if (rx == ry) return;
		if(rank[rx]<rank[ry]){
			swap(rx,ry);
			w = -w;
		}
		if(rank[rx]==rank[ry]) ++rank[rx];
		par[ry] = rx;
		diff_weight[ry] = w;
		num[rx] += num[ry];
	}

	bool same(ll x,ll y){
		ll rx = root(x);
		ll ry = root(y);
		return rx == ry;
	}

	ll getsize(ll x){
		return num[root(x)];
	}

	ll weight(ll x){
		root(x);
		return diff_weight[x];
	}

	ll diff(ll x,ll y){
		return weight(y)-weight(x);
	}
};

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

	while(true){
		int H=in(),W=in();
		if(!H && !W) break;
		UnionFind uf(H*W);
		vector<string> M(H);
		REP(i,H){
			M[i]=in<string>();
			REP(j,W){
				if(i>0 && M[i-1][j]==M[i][j]) uf.unite(j+(i-1)*W,j+i*W);
				if(j>0 && M[i][j-1]==M[i][j]) uf.unite(j-1+i*W,j+i*W);
			}
		}
		set<int> S;
		REP(i,H*W){
			S.emplace(uf.root(i));
		}
		out(S.size());
	}

	return 0;
}



Measured memory_bytes: 3400
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(int i = a;i < n;i++)
#define LINF (ll)1e17
#define INF 1e9
#define MOD 1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
}


signed main(){
	
	ll a,b,ans = 0;
	cin >> a >> b;
	
	
	ans = max(max(a+a-1,a+b),b+b-1);
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
char a[105],b[105];
int main(){
    int len;
    scanf("%s%s",a,b);
    len=strlen(a);
    for(int i=0;i<len;i++){
    	int tmp=0;
    	for(int j=0;j<len;j++){
    		if(a[j]!=b[(j+i)%len]){
    			tmp=1;break;
			}
		}
		if(tmp==0){
			printf("Yes");
			return 0;
		}
	}
	printf("No");
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
    return 0;
}


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

int n;
string s[100];
int parent[100];
vector<int> child[100];

int dfs(int v) {
	char op = s[v][s[v].length() - 1];
	
	if ('0' <= op && op <= '9') return (int)(op - '0');
	
	int ret = (op == '*');
	for (int i = 0; i < child[v].size(); i++) {
		if (op == '*') ret *= dfs(child[v][i]);
		else ret += dfs(child[v][i]);
	}
	return ret;
}

int main() {
	while (cin >> n) {
		if (!n) break;
		
		int i, j;
		
		for (i = 0; i < n; i++) cin >> s[i];
		for (i = 0; i < n; i++) child[i].clear();
		
		//s[i]???s[parent[i]]????¢????????????§??????
		//s[i]???s[child[i][hoge]]??????????????§??????
		parent[0] = 0;
		for (i = 1; i < n; i++) {
			for (j = i; j >= 0; j--) {
				if (s[i].length() == s[j].length() + 1) {
					break;
				}
			}
			parent[i] = j;
			child[j].push_back(i);
		}
		
		//??°??????????????§?¨??????????
		cout << dfs(0) << endl;
	}
	return 0;
}

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

#pragma region Macro
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define vvi vector<vector<int>>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#pragma endregion

void solve(){
	#define int ll
	// ここに処理を記述
	// コンパイル時はエイリアス「gpp」--> c++17でコンパイル
	int x;
	rep(i,5){
		cin >> x;
		if(!x) cout << i+1 << "\n";
	}
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	
	solve();
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <tuple>

int gcd(int a, int b) {
  while (true) {
    if (a < b)
      std::swap(a, b);
    if (b == 0)
      return a;
    a %= b;
  }
  return a;
}

int main(int argc, char *argv[]) {
  long a, b;
  std::cin >> a >> b;

  std::cout << a * b / gcd(a, b) << std::endl;
}


Measured memory_bytes: 256
from sys import stdin

def main():
    point = 0
    r,g,b,n = [int(x) for x in stdin.readline().rstrip().split()]
    for i in range(n//r+1):
        for j in range((n-r*i)//g+1):
            if n-r*i-g*j >= 0:
                if (n-r*i-g*j)%b == 0:
                    point += 1
    print(point)

if __name__ == "__main__":
    main()

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> s(M), c(M);
    vector<int> ans(N, -1);
    

    for(int i=0; i<M; i++){
	cin >> s[i] >> c[i];
	if(ans[s[i]-1]!=-1 && ans[s[i]-1]!=c[i]){
	    cout << -1 << endl;
	    return 0;
	}
	ans[s[i]-1]=c[i];
    }

    if(M==0 && N==1){
	cout << 0 << endl;
	return 0;
    }	
    
    if(N==1&&ans[0]==0){
	cout << 0 << endl;
	return 0;
    }	
    else if(ans[0]==0){
	cout << -1 << endl;
	return 0;
    }

    if(ans[0]==-1)
	ans[0]=1;

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

    for(int i=0; i<N; i++){
	cout << ans[i];
    }
    cout << endl;

}




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

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let s: Vec<u8> = sc.chars().iter().map(|&c| c as u8).rev().collect();
    let mut ans = s.len();
    for c in 'a' as u8..'z' as u8 + 1 {
        let mut ac = 0;
        let mut mx = 0;
        for &d in s.iter() {
            if c == d {
                ac = 0;
            } else {
                ac += 1;
                mx = max!(mx, ac);
            }
        }
        ans = min!(ans, mx);
    }
    put!(ans);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 4352
#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;
  cin>>n;
  ll ans=0;
  rep(i,n){
    ans+=i;
  }
  cout<<ans<<endl;
}

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

int main() {
  std::string x(3, ' ');
  std::string y(3, ' ');
  std::string z(3, ' ');
  scanf("%s", &x[0], x.size());
  scanf("%s", &y[0], y.size());
  scanf("%s", &z[0], z.size());
  printf("%c%c%c", x[0], y[1], z[2]);
}


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

int main(){
  int N; cin>>N;
  int maxA=-100,minA=100;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
    maxA=max(maxA,A.at(i));
    minA=min(minA,A.at(i));
  }
  
  long long res=999999999999;
  
  for(int i=minA;i<=maxA;i++){
    long long count=0;
    for(int j=0;j<N;j++){
      int d=i-A.at(j);
      count+=d*d;
    }
    res=min(res,count);
  }
  
  cout<<res;
}

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

int main() {
  int N, M;
  cin >> N >> M;

  vector<int> H(N);
  for(int i=0;i<N;i++){
    cin >> H.at(i);
  }
  vector<int> A(M);
  vector<int> B(M);
  for(int i=0;i<M;i++){
    cin >> A.at(i) >> B.at(i);
  }

  vector<bool> G(N,true);

  for(int i=0;i<M;i++){
    if(H.at(A.at(i)-1) <= H.at(B.at(i)-1)){
      G.at(A.at(i)-1) =false;
    }

    if(H.at(B.at(i)-1) <= H.at(A.at(i)-1)){
      G.at(B.at(i)-1) =false;
    }
  }
  int cnt=0;

  for(int i=0;i<N;i++){
    if(G.at(i)==true){
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 4500
#include <bits/stdc++.h>
#include<unordered_map>
#define lli long long int
using namespace std;

int main() {

	std::ios::sync_with_stdio(0);
	std::cin.tie(0);

	//freopen("text.in", "r", stdin);
	//freopen("text.out", "w", stdout);
	
	int x;
	cin >> x;
	lli res = 3 * x * x;
	cout << res << '\n';
	
	return 0;
}

Measured memory_bytes: 256
from sys import exit

def rotate(l, d):
    if d == 'S':
        return [l[4], l[0], l[2], l[3], l[5], l[1]]
    if d == 'N':
        return [l[1], l[5], l[2], l[3], l[0], l[4]]
    if d == 'W':
        return [l[2], l[1], l[5], l[0], l[4], l[3]]
    if d == 'E':
        return [l[3], l[1], l[0], l[5], l[4], l[2]]
    if d == 'R':
        return [l[0], l[2], l[4], l[1], l[3], l[5]]

def check(d1, d2):
    for k in 'EE':
        for i in 'NNNN':
            for j in 'RRRR':
                if d1 == d2:
                    return 1
                else:
                    d2 = rotate(d2, j)
            d2 = rotate(d2, i)
        d2 = rotate(d2, k)
    return 0


if __name__ == '__main__':
    ds = []
    n = int(input())

    for i in range(n):
        ds.append(list(map(int, input().split())))

    for i in range(n):
        for j in range(i + 1, n):
            if check(ds[i], ds[j]):
                print('No')
                exit(0)
    print('Yes')



Measured memory_bytes: 5616
#!/usr/bin/env python3
import sys


def solve(S: str):
    print(S.count("+") - S.count("-"))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()

class modfact(object):
    def __init__(self, n):
        fact, invfact = [1] * (n + 1), [1] * (n + 1)
        for i in range(1, n + 1): fact[i] = i * fact[i - 1] % MOD
        invfact[n] = pow(fact[n], MOD - 2, MOD)
        for i in range(n - 1, -1, -1): invfact[i] = invfact[i + 1] * (i + 1) % MOD
        self._fact, self._invfact = fact, invfact

    def fact(self, n):
        return self._fact[n]

    def invfact(self, n):
        return self._invfact[n]

    def comb(self, n, k):
        return self._fact[n] * self._invfact[k] % MOD * self._invfact[n - k] % MOD if 0 <= k <= n else 0

    def perm(self, n, k):
        return self._fact[n] * self._invfact[n - k] % MOD if 0 <= k <= n else 0

def resolve():
    n = int(input())
    mf = modfact(n)
    ans = 0
    for k in range(n):
        ans += mf.comb(n - 1 - 2 * k, k - 1)
    print(ans % MOD)
resolve()

Measured memory_bytes: 65380
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(12)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
    result=(result*base)%modulus;
    exponent=exponent>>1;
    base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
  if(N<K)return 0;
  if(K==0)return 1;
  if(N==0)return 0;

  ll den=1;
  for(ll i=1;i<=K;i++)den*=i;
  ll num=1;
  while(K--){
    num*=N;
    if(num%den==0){
      num/=den;
      den=1;
    }
    N--;
  }

  return num;
}
*/
ll n;
ld dp[301][301][301];
ll f[4],a[301];
ld solve(ll x,ll y,ll z){
  if(!(x|y|z)){
    return 0;
  }
  if(dp[x][y][z]!=-1)return dp[x][y][z];
  ll alive = x+y+z;
  ll dead = n - alive;
  ld ans = 0;
  ld p = (ld)n/(n-dead);
  if(x){
    ans+=(ld)x/alive*(p+solve(x-1,y,z));
  }
  if(y){
    ans+=(ld)y/alive*(p+solve(x+1,y-1,z));
  }
  if(z){
    ans+=(ld)z/alive*(p+solve(x,y+1,z-1));
  }
  return dp[x][y][z] = ans;
}
int main(){FAST;
  dofloat;
cin>>n;
for(ll i=1;i<=n;++i){
  cin>>a[i];
  ++f[a[i]];
}
for(ll i=0;i<=n;++i){
  for(ll j=0;j<=n;++j){
    for(ll k=0;k<=n;++k){
      dp[i][j][k] = -1;
    }
  }
}
cout<<solve(f[1],f[2],f[3]);
return 0;
}

/*
 WA? check edge cases, N=1,M=1 etc. Read code fully once and check all variables.
 Read the question again and see what you might have missed.
 Consider changing your solution or find more cases.
 */


Measured memory_bytes: 429964
#include <iostream>
int main() {
int A,B,x,y,z;
std::cin >> A >> B;
x=A+B;
y=A-B;
z=A*B;

  	if (x > y)
	{
		if (x > z)
		{
			std::cout << x << std::endl;
		}
		else
		{
			std::cout << z << std::endl;
		}
	}
	else
	{
		if (y > z)
		{
			std::cout << y << std::endl;
		}
		else
		{
			std::cout << z << std::endl;
		}
	}
 
 return 0;
 }
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  int a[12]={3,1,3,2,3,2,3,3,2,3,2,3};
  int i,j; cin >> i >> j;
  if(a[i-1] == a[j-1]){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}

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

#define ar array
#define ll long long int

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) {
       string s;
       cin >> s;
       int ans = 0, c = 0;
       for (char ch : s) {
           if (ch == 'R')
                ++c;
            else c = 0;
            ans = max(ans, c);
       }
       cout << ans;
    }

    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define res register int
#define N 5000
#define inf 0x3f3f3f3f
#define ll long long
using namespace std;
int head[N],n,m,k,tot,tot1,ans;
struct data{
	int to,nxt;
}edge[N];

inline void add(int x,int y)
{
	edge[++tot1].to=y;
	edge[tot1].nxt=head[x];
	head[x]=tot1;
}


inline void dfs(int root,int fa,int deth)
{
	if (deth>k/2)
	tot++;
	for(res i=head[root];i;i=edge[i].nxt)
	{
		int y=edge[i].to;
		if(fa==y) continue;
		dfs(y,root,deth+1);
	}
}

int main()
{
	scanf("%d%d",&n,&k);
	int x,y,z;
	for(res i=1;i<=n-1;i++)
	{
		scanf("%d%d",&x,&y);
		add(x,y);
		add(y,x);
	}
	
	ans=inf;
	
	if(k&1)
	{
		for(res i=1;i<=n;i++)
		  for(res j=head[i];j;j=edge[j].nxt)
		  {
		  	int y=edge[j].to;
		  	tot=0;
		  	dfs(i,y,0);
		  	dfs(y,i,0);
		  	ans=min(ans,tot);
		  }
	}
	
	else
	
	{
		for(res i=1;i<=n;i++)
		{
			tot=0;
			dfs(i,0,0);
			ans=min(ans,tot);
		}
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 384
#include <stdio.h>
 
int main(){
    int h,n;
    scanf("%d%d", &h, &n);
    int a[n],i,p=0;
    for( i = 0; i < n; i++ ){
        scanf("%d", &a[i]);
        p += a[i];
    }
    if(p<h) printf("No\n");
    else printf("Yes\n");
 
    return 0;
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#define Swap(x,y)	{int _t=x; x=y; y=_t;}

int main(void){
	int x, y;

	while (1){
		scanf("%d%d", &x, &y);
		if (x == 0 && y == 0) return 0;
		if (x > y){
			Swap(x, y);
		}
		printf("%d %d\n", x, y);
	}
}

Measured memory_bytes: 600
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto S = RD!string;
	long ans = 700;
	foreach (c; S)
	{
		if (c == 'o')
			ans += 100;
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}


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

#define rep(i, n) for (int i = 0; i < n; i++)
#define vi vector<int>
#define pb push_back

int main() {
	int n, m;
	int h[100010], a, b;
	int ans[100010]={};
	cin >> n >> m;
	rep(i, n) cin >> h[i];
	rep(i, m)
	{
		cin >> a >> b;
		a--;
		b--;
		if(h[a]<=h[b]) ans[a]++;
		if(h[b]<=h[a]) ans[b]++;
	}
	int aans=0;
	rep(i, n) if(ans[i]==0) aans++;
	cout << aans << endl;
	return 0;
}

Measured memory_bytes: 4408
#include <stdio.h>
#include <stdlib.h>

#define N 4
#define NN N*N
#define LIMIT 100

int H[NN][NN];//マンハッタン距離の組み合わせの集合
int dx[4] = {0,-1,0,1};
int dy[4] = {1,0,-1,0}; //方向
int states_count = 0;

void swap(int *x,int *y){
  int tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

typedef struct puzzle
{
  int field[NN];//どの場所になんの数字が入っているか
  int space;//空マス
  int h_value;//マンハッタン距離
}Puzzle;

Puzzle state;//現在の状態
int limit;//深さの制限
int path[LIMIT];

int heuristic(Puzzle pz){
  int sum = 0;
  int i;
  for(i=0; i<NN; i++){
    if(pz.field[i] == NN)continue; //正しい位置にあればそのまま
    sum += H[i][pz.field[i] - 1];//マンハッタン距離を加える
  }
  return sum;
}

int isSolved(){
  int i;
  for (int i = 0; i < NN; ++i)if(state.field[i] != i+1)return 0;
  return 1;
}

int dfs(int depth, int prev){
  states_count++;
  if(state.h_value == 0)return 1; //終了
  if(depth + state.h_value > limit)return 0;

  int sx = state.space / N; //空のマスのx座標;
  int sy = state.space % N; //空のマスのy座標;

  Puzzle tmp;
  int r;
  for(r = 0;r < 4;r++){
    int tx = sx + dx[r]; //空のマスの次の位置
    int ty = sy + dy[r];
    if(tx < 0|| ty <0||tx >= N||ty >= N)continue; //行けないマスはスルー
    if((prev - r == 2)||(prev - r == -2))continue;//一個前の状態に戻る操作はスルー
    tmp = state;
    state.h_value -= H[tx * N + ty][state.field[tx * N + ty]-1];//入れ替わった分のマンハッタンん距離の増減を加算
    state.h_value += H[sx * N + sy][state.field[tx * N + ty]-1];
    swap(&state.field[tx * N + ty],&state.field[sx * N + sy]);
    state.space = tx * N + ty;
    if(dfs(depth+1,r) != 0){path[depth] = r; return 1;}
    state = tmp;
  }
  return 0;
}

int iterative_deepening(Puzzle in){
  in.h_value = heuristic(in);

  for(limit = in.h_value;limit <= LIMIT; limit++){//limit = c
    state = in;
    if(dfs(0,-100) != 0){
      //pathに入っている文字数を数えたい
      int count = 0,l;
      for(l=0;l<limit;l++){
        if(path[l] != ' ')count++;
      }
      return count;

    }
  }
  return -1;
}

int main(void){
  int i,j;
  for(i=0;i<NN;i++){
    for(j=0;j<NN;j++){
      H[i][j] = abs(i/N - j/N) + abs(i%N -j%N);//マンハッタン距離の組み合わせの初期化
    }
  }

  Puzzle in;//初期のパズル

  for(i=0;i<NN;i++){
    scanf("%d", &in.field[i]);
    if(in.field[i]==0){
      in.field[i] = NN;
      in.space = i;
    }
  }

  int ans = iterative_deepening(in);
  printf("%d\n",ans);
  //printf("states_count = %d\n", states_count);
  return 0;

}


Measured memory_bytes: 2752
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
 
 
 
 


ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}



int main()
{
    int n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    bool flag=0;
    for(int i=0;i<n;i++)
    {
         if(a[i]%2){flag=1;break;}
    }
    if(flag)cout<<"first";
    else cout<<"second";
}















 














 
 

















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

using namespace std;

int main()
{
	int ans = 0;
	bool buy[101] = {};
	for (int i = 0; i < 3; i++)
	{
		int tmp;
		cin >> tmp;
		if (!buy[tmp])
			ans++;
		buy[tmp] = true;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

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

func scanInts(n int) []int {
	sl := make([]int, n)
	for i := range sl {
		sl[i] = scanInt()
	}
	return sl
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	as, bs, cs := scanInts(n), scanInts(n), scanInts(n)

	sort.Ints(as)
	sort.Ints(cs)
	var sum int
	for _, b := range bs {
		aCnt := lowerBound(as, b)
		cCnt := n - upperBound(cs, b)
		sum += aCnt * cCnt
	}

	fmt.Println(sum)
}

func upperBound(a []int, x int) int {
	return sort.Search(len(a), func(i int) bool { return a[i] > x })
}

func lowerBound(a []int, x int) int {
	return sort.Search(len(a), func(i int) bool { return a[i] >= x })
}


Measured memory_bytes: 5504
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), cout, ", ") << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, ostream &os = cout, string sep = " ")
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), os, ", ") << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(string, S);
    auto f = [&](ll i, ll j) {
        bool ok = true;
        REP(k, j - i)
        {
            ok &= S[i + k] == S[j - k - 1];
        }
        return ok;
    };
    ll N = S.size();
    YES(f(0, N) and f(0, (N - 1) / 2) and f((N + 1) / 2, N));
}

Measured memory_bytes: 256
/*     ####   ####  #               ####  #        ##   #    # #    # ###### #####
	  #      #    # #              #      #       #  #  ##  ## ##  ## #      #    #
	   ####  #    # #               ####  #      #    # # ## # # ## # #####  #    #
		   # #  # # #                   # #      ###### #    # #    # #      #####
	  #    # #   #  #              #    # #      #    # #    # #    # #      #   #
	   ####   ### # ###### #######  ####  ###### #    # #    # #    # ###### #    #
*/
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<pair<LL, LL> > VP;
 
 
#define For(in) for (LL i = 0; i < (n); i++)
#define FOR(in) for(LL i=1; i <= (n); i++)
#define pb push_back
#define srt(v) sort(v.begin(), v.end())
#define rev(v) reverse(v.begin(), v.end())
#define uniq(v) v.erase(unique(v.begin(), v.end()), v.end());
#define exit(); return 0;
#define no "NO"
#define yes "YES"
#define con continue;
 
 
LL concate(LL a, LL b)
{
	ostringstream os;
	os <<a <<b;
	istringstream is(os.str());
	LL c;
	is>> c;
	return c;
}
 
LL binpow(LL a, LL b, LL c)
{
	a %= c;
	LL res = 1 ;
	while(b > 0){
		if(b & 1)
		res = res * a % c ;
		a = a * a % c ;
		b >>= 1;
		//cout<<res<<endl;
	}
	return res;
}
 
LL check(char vowel)
{
	return vowel=='a' || vowel=='e' || vowel=='i' || vowel=='o' || vowel=='u';
}
LL mod = 1e9+7;
 
 
int main()
{
	//LL q,t;
	//cin>>t;
	//while(t--)
	//{
	    LL a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,r=0,u=0,w=0,x=0,y=0,z=0;
		LL aa[1000];
		LL flag=0, flag1=0, co=0, co1=0, co2=0, co3=0, x1=0, x2=0, y1=0, y2=0, z1=0, z2=0;
		LL ma=0, mi=100000000;
		LL mid=0, temp=0, stop=0, start=0;
		double pi= 3.141592653589793;
		double d1=0.0, d2, d3, d4;
		VLL v,v1,v2,v3,v4,v5,v6,v7,v8,v9,v10;
		VS vs, vs1, vs2, vs3, vs4;
		VP vp, vp1,vp2;
		char ch, ch1, ch2[1001];
		string str, str1, str2, str3, str4, str5;
		pair<LL, LL> pa;
		list<LL> li, li1;
		map<LL, LL> mp, mp1;
		set<LL> st;
		map<LL ,LL> :: iterator imll;
		VLL :: iterator ivll;
		set<LL> :: iterator isll;
		VP :: iterator ivp;
 

		cin>>n;
		for(i=0; i<n; i++)
		{
			cin>>str;
			if(str=="AC")x++;
			if(str=="WA")y++;
			if(str=="TLE")z++;
			if(str=="RE")d++;
		}
		cout<<"AC x "<<x<<endl;
		cout<<"WA x "<<y<<endl;
		cout<<"TLE x "<<z<<endl;
		cout<<"RE x "<<d<<endl;

		
	//}
	exit()
 
 
}


Measured memory_bytes: 3560
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val ans = fact(sc.nextInt)

  def fact(num: Int): Int = num match {
    case n if n == 0 => 0
    case n if n == 1 => 1
    case n => n + fact(n - 1)
  }

  println(ans)
}


Measured memory_bytes: 25412
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <climits>
using namespace std;

int main() {
	while(true) {
		double s;
		if(scanf("%lf", &s)<1)break;
		double y = s*s/19.6;
		double k = ceil(y/5+1);
		printf("%d\n", (int)k);
	}
	return 0;
}

Measured memory_bytes: 0
import math

n = int(input())

def make_prime_list(num):
  if num < 2:
        return []

  prime_list = [i for i in range(num + 1)]
  prime_list[1] = 0
  num_sqrt = math.sqrt(num)

  for prime in prime_list:
    if prime == 0:
      continue
    if prime > num_sqrt:
      break

    for non_prime in range(2 * prime, num, prime):
      prime_list[non_prime] = 0

  return [prime for prime in prime_list if prime != 0]

def search_divisor_num(num):
  if num < 0:
    return None
  elif num == 1:
    return 1
  else:
    num_sqrt = math.floor(math.sqrt(num))
    prime_list = make_prime_list(num_sqrt)

    divisor_num = 1
    for prime in prime_list:
      count = 1
      while num % prime == 0:
        num //= prime
        count += 1
      divisor_num *= count

    if num != 1:
      divisor_num *= 2

    return divisor_num

i = 1
result = 0

while i <= n:
  divisor_count = search_divisor_num(i)
  if divisor_count == 8:
    result += 1
  i += 2

print(result)



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

int main() {
  int A, B; cin >> A >> B;
  int first_reward = max(A, B);
  if (A > B) {
    A--;
  }
  else {
    B--;
  }
  int second_reward = max(A, B);
  cout << first_reward + second_reward << endl;
}


Measured memory_bytes: 256
def compare(a, b)
  if a > b
    'GREATER'
  elsif a < b
    'LESS'
  end
end

a = gets.chomp!.split('')
b = gets.chomp!.split('')

ans = 'EQUAL'

if a.size == b.size
  while !a.empty?
    e_a = a.shift.to_i
    e_b = b.shift.to_i
    next if e_a == e_b

    ans = compare(e_a, e_b)
    break
  end
else
  ans = compare(a.size, b.size)
end

puts ans


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/15  Problem: 057_abc_d / Link: https://abc057.contest.atcoder.jp/tasks/abc057_d?lang=en  ----- */
/* ------問題------

N 個の品物が与えられます。
i 番目の品物の価値は vi(1≦i≦N) です。
これらの品物から、A 個以上、B 個以下を選ばなければなりません。
この制約下において、選んだ品物の価値の平均の最大値を求めてください。
また、選んだ品物の平均が最大となるような品物の選び方が何通りあるかを求めてください。

-----問題ここまで----- */
/* -----解説等-----

選択区間は二種類しかなく、これを場合分けする
1:全部A->たくさん選べるね
2:そうではない->最小の要素の選択

----解説ここまで---- */

#define nCk_MAX 100
long long  comb[nCk_MAX + 1][nCk_MAX + 1];
/* nCk を求める */
void calcomb() {
	int  i, j;
	for (i = 0; i <= nCk_MAX; i++) {
		for (j = 0; j <= i; j++) {
			if (j == 0 || j == i)
				comb[i][j] = 1;
			else
				comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
		}
	}
}
#undef nCk_MAX
LL N,A,B;

LL ans = 0LL;

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

	cin >> N>>A>>B;
	VL a(N);
	FOR(i, 0, N) {
		cin >> a[i];
	}

	calcomb();
	double ave;
	SORT(a);
	reverse(ALL(a));
	if (a[0] == a[A - 1]) {
		int cnt = 0;
		FOR(i, 0, N) {
			if (a[0] == a[i])cnt++;
		}
		FOR(i, A, min((LL)cnt,B)+ 1) {
			ans += comb[cnt][i];
		}
		ave = a[0];
	}
	else {
		// A個が良いが、最後の選択ができる
		int cnt = 0;
		FOR(i, 0, N) {
			if (a[A - 1] == a[i])cnt++;
		}
		int cnt2 = 0;
		LL sum = 0;
		FOR(i, 0, A) {
			sum += a[i];
			if (a[A - 1] == a[i])cnt2++;
		}
		ans = comb[cnt][cnt2];
		ave = (double)sum / A;

	}
	cout <<fixed<<setprecision(10)<< ave << endl;
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 384
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//constant
const double EPS = 1e-10;
ll MOD = 1000000007;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

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

int main(void) {

	int N;
	cin >> N;
	vector<double> P(N);
	for (auto& p : P) {
		cin >> p;
	}
	vector<vector<double>> dp(N + 1, vector<double>(N + 1, 0));
	dp[0][0] = 1;

	REP(i, N) {
		REP(j, min<ll>(i+1, N)) {
			dp[i + 1][j + 1] += dp[i][j] * P[i];
			dp[i + 1][j] += dp[i][j] * (1 - P[i]);
		}
	}

	double ans = 0;
	FOR(i, ceil((N+1) / 2), N + 1) {
		ans += dp[N][i];
	}
	cout << setprecision(10) << ans << endl;

	return 0;
}

Measured memory_bytes: 70784
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
using namespace std;

int main(void){
    int n;
    int low[100005];
    cin >> n;
    for(int i=1; i<=n; i++)cin >> low[i];
    int count=0;
    for(int i=1; i<=n; i++){
        if(low[i]==i){
            count++;
            i++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(6) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;

signed main(){

    while(1){
        int h,w;
        cin >> h >> w;
        if(h==0 && w==0){
            break;
        }
        REP(i,h){
            REP(j,w){
                if((i+j)%2==0){
                    cout << "#";
                }
                else{
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}



Measured memory_bytes: 3100