akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define MP make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<ll, int> pli;
const int N = 1e5 + 5;

int n;
ll D[N];
pli a[N];
int sz[N];

vector <int> g[N];

void add(int x, int y) {
    sz[x] += sz[y];
    g[x].push_back(y);
}

ll res;

void dfs(int u, int fa, ll d) {
    res += d;
    for(auto v : g[u]) {
        if(v != fa) dfs(v, u, d + 1);
    }
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> D[i];
    for(int i = 1; i <= n; i++) {
        a[i] = MP(D[i], i); sz[i] = 1;
    }
    sort(a + 1, a + n + 1);
    int f = 1;
    for(int i = n; i > 1 && f; i--) {
        ll t = a[i].fi + 2ll * sz[a[i].se] - n;
        int x = lower_bound(a + 1, a + i, MP(t, 0)) - a;
        if(a[x].fi != t) f = 0;
        add(a[x].se, a[i].se);
    }
    if(f == 0) {cout << -1; return 0;}
    dfs(a[1].se, 0, 0);
    if(res != a[1].fi) {cout << -1; return 0;}
    for(int i = 1; i <= n; i++) {
        for(auto it : g[i]) cout << i << ' ' << it << '\n';
    }
    return 0;
}


Measured memory_bytes: 11904
#include <stdio.h>

int main(void)
{
  int i1,cnt=0;
  char s[3];
  
  for(i1=0;i1<3;i1++){
    scanf("%c", &s[i1]);
    if(s[i1]=='o') cnt++;
  }
  
  printf("%d", 700+100*cnt);
  
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

typedef struct { char suit, value; } Card;

void bubble(Card A[], int N) {
  int i,j;
  Card t;
  for(i = 0; i<N; i++) {
    for(j = N-1; j >= i; j--) {
      if(A[j].value < A[j-1].value) {
        t = A[j]; A[j] = A[j-1]; A[j-1] = t;
      }
    }
  }
}

void selection(Card A[], int N) {
  int i,j,minj;
  Card t;
  for(i=0;i<N;i++) {
    minj = i;
    for(j=i; j<N; j++) {
      if(A[j].value < A[minj].value) minj = j;
    }
    t = A[i]; A[i] = A[minj]; A[minj] = t;
  }
}

void print(Card A[], int N) {
  int i;
  for(i=0; i<N; i++) {
    if(i>0) printf(" ");
      printf("%c%d",A[i].suit,A[i].value);
  }
  printf("\n");
}

int isStable(Card C1[], Card C2[], int N) {
  int i;
  for(i=0; i<N; i++) {
    if(C1[i].suit != C2[i].suit) return 0;
  }
  return 1;
}

void str2Card(Card *t,char str[]) {
    t->suit  = str[0];
    t->value = str[1] - '0';
}

int main(void) {
  Card C1[100], C2[100];
  int N,i;
  char str[3];

  scanf("%d",&N);
  for(i=0;i<N; i++) {
    scanf("%s",str);
    str2Card(&C1[i],str);
  }

  for(i=0; i<N; i++) C2[i] = C1[i];

  bubble(C1,N);
  selection(C2,N);

  print(C1,N);
  printf("Stable\n");
  print(C2,N);
  if(isStable(C1,C2,N)) {
    printf("Stable\n");
  } else {
    printf("Not stable\n");
  }

  return 0;
}


Measured memory_bytes: 2056
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <bitset>
#include <stack>
#include <cstdlib>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = s; n > i; i++)
#define REP(i,n) rep(i,0,n)
#define MODU 33
#define Range(x,a,b) ((a) <= (x) && (x) <= (b))
#define POWT(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef vector<int> Ivec;
typedef pair<int, int> pii;
typedef long long int ll;

int main() {
	int a, b, c, p, d;
	scanf("%d %d %d %d %d", &a, &b, &c, &d, &p);
	printf("%d\n",min( p*a, b + max((p-c),0)*d));
	return 0;
}

Measured memory_bytes: 3220
import java.util.*;
public class Main {
    public static void main(String args []){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Map<String,Integer> Num = new HashMap<>();
        for(int i=0;i<N;i++){
            String s = sc.next();
            if(Num.get(s)==null) Num.put(s,1);
            else Num.replace(s,Num.get(s)+1);
        }
        int max = Collections.max(Num.values());
        ArrayList<String> OPT = new ArrayList<>(Num.keySet());
        Collections.sort(OPT);
        for(String s:OPT) if(Num.get(s)==max) System.out.println(s);
    }
}

Measured memory_bytes: 87324
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main(){
	ll a, b, c;
	cin >> a >> b >> c;
	ll x[3] = { a,b,c }; sort(x, x + 3);
	int k; cin >> k;
	for (int i = 0; i < k; i++) {
		x[2] *= (ll)2;
	}
	cout << x[0]+x[1]+x[2] << endl;
	char nyaa;
	cin >> nyaa;
	return 0;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let n: usize = read();
    let p: Vec<i32> = read_vec();

    let mut cnt: i32 = 0;
    for i in 1..n - 1 {
        if (p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i - 1] > p[i] && p[i] > p[i + 1]) {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}


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

typedef long long ll;

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

    int s,w;
    cin >> s >> w;
    if(w>=s) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    return 0;
}

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

int main(){
    long long x,k,d;
    cin>>x>>k>>d;
    long long tmp = abs(x)/d;
    if(tmp>k) cout<<abs(x)-d*k<<endl;
    else{
        long long time = k - tmp;
        if(time%2==0) cout<<abs(x)%d<<endl;
        else cout<<d-abs(x)%d<<endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ll long long
#define endl "\n"
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
const int N = 2000 + 10;
const ll inf = 1e18 + 10, mod = 1e9 + 7;
int x, y;
int main()
{
    ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("lca_rmq.in", "r", stdin);
    //freopen("lca_rmq.out", "w", stdout);
    cin >> x >> y;
    if((y - 2 * x) % 2 == 0 && y - 2 * x >= 0 && 4 * x - y >= 0 && (4 * x - y) % 2 == 0)cout << "Yes";
    else cout << "No";
}

















Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int x[10];
    for (int i = 0; i < 10; i++) {
        cin >> x[i];
    }
    sort(x, x + 10);
    for (int i = 9; i >= 7; i--) {
        cout << x[i] << endl;
    }
}


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

int digit_sum(int x){
  int ret = 0;
  while(x > 0){
    ret += x%10;
    x /= 10;
  }
  return ret;
}

int main(){
  int N;
  cin >> N;
  int ans = 1e9;
  for(int i = 1; i < N; ++i){
    int j = N - i;
    ans = min(ans, digit_sum(i) + digit_sum(j));
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
string a,b;
  cin>>a>>b;
  if(a.size()>b.size())
    cout<<"GREATER"<<endl;
  else if(a.size()<b.size())
    cout<<"LESS"<<endl;
  else{
  for(int i=0;i<a.size();i++){
    if(a.at(i)>b.at(i)){
    cout<<"GREATER"<<endl;
      break;
    }
  else if(a.at(i)<b.at(i)){
    cout<<"LESS"<<endl;
    break;
  }
    else if(i==a.size()-1)
      cout<<"EQUAL"<<endl;
  }
  }
}

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

int main()
{
    long w, h, x, y;
    scanf("%ld%ld%ld%ld", &w, &h, &x, &y);
    printf("%f ", w * h / 2.);
    if (w / 2. == x && h / 2. == y)
    {
        printf("1\n");
    }
    else
    {
        printf("0\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <iomanip>
using namespace std;

int abs(int n) {
  if (n < 0) {
    return -n;
  }
  return n;
}

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

  int sum = 0;
  int minabs = 999999;
  int ex;
  for (int i = 1; i <= n; i++) {
    sum += l + i - 1;
    if (abs(l+i-1) < minabs) {
      ex = l+i-1;
    }
    minabs = min(minabs, abs(l+i-1));
  }

  cout << sum - ex << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && (ch != '-')) ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

double const PI = acos(-1.0);
double t[3005];

int main() {

#ifdef LOCAL
  FILEIO("a");
#endif

  int n, l; read(n), read(l);
  for (RI i = 1; i <= n; ++i) {
    read(t[i]);
    t[i] = t[i] / l * 2.0 * PI;
  }
  sort(t + 1, t + 1 + n);
  double x = 0, y = 0;
  for (RI i = 1; i <= n; ++i)
    for (RI j = i + 1; j <= n; ++j) {
      double YouHu = (t[i] + t[j]) / 2, LieHu = YouHu + PI;
      x += cos(YouHu) * (n + i - j - 1), y += sin(YouHu) * (n + i - j - 1);
      x += cos(LieHu) * (j - i - 1), y += sin(LieHu) * (j - i - 1);
    }
  double all = n * (n - 1) / 2.0 * (n - 2) / 3.0;
  printf("%.9lf %.9lf\n", x / all, y / all);

  cerr << (double)(clock()) / CLOCKS_PER_SEC * 1000 << "ms" << endl;

  return 0;
}

// created by Daniel yuan

Measured memory_bytes: 384
#include <iostream>
#include <vector>
using namespace std;
using LL = long long;

LL calc(vector<LL> xs, LL n, LL mod){
    LL cum = 0;
    for (int i = 1; i < n; ++i){
        LL inc = xs[i] - xs[i - 1];
        inc = (inc * i) % mod;
        inc = (inc * (n - i)) % mod;
        cum = (cum + inc) % mod;
    }
    return cum;
}

int main() {
    LL n, m;
    cin >> n >> m;
    vector<LL> xs(n, 0);
    vector<LL> ys(m, 0);
    for (auto &x: xs) cin >> x;
    for (auto &y: ys) cin >> y;
    LL mod = 1e9 + 7;
    auto cumx = calc(xs, n, mod);
    auto cumy = calc(ys, m, mod);
    auto result = (cumx * cumy) % mod;
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 2560
/* author   : mpily :-()
title : Competing1.cpp
time :Sun Jan 19 14:54:36 2020

*/
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int>arr(n);
	int mn = 500000;
	int count = 0;
	for(int i = 0; i < n; i++){
		cin>>arr[i];
		if(arr[i] < mn){
			count+=1;
			mn = arr[i];
		}
	}
	cout<<count<<"\n";
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n)repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
typedef pair<int,int> P;
typedef pair<int, P> PP;
#define all(v) v.begin(),v.end()
#define fi first
#define se second
const int inf = 1e9;
int mod = 1e9+7;

vector<vector<int> > G(100002);
struct query{int a,b,c;};
query Q[100002];
int ans[100002], used[100002];

void dfs(int u, int color, int k){
	if(used[u] >= k)return ;
	if(ans[u] == 0)ans[u] = color;
	used[u] = k;
	rep(i,G[u].size()){
		if(used[G[u][i]] < k-1){
			dfs(G[u][i], color, k-1);
		}
	}
	return ;
}

signed main(){
	int n, m, q;
	fill(used, used+100002, -1);
	scanf("%lld%lld", &n, &m);
	rep(i,m){
		int x, y;
		scanf("%lld%lld", &x, &y);
		G[x-1].push_back(y-1);
		G[y-1].push_back(x-1);
	}
	scanf("%lld", &q);
	rep(i,q){
		int a, b, c;
		scanf("%lld%lld%lld", &a, &b, &c);
		Q[i] = (query){a, b, c};
	}
	
	drep(i,q-1,0)dfs(Q[i].a-1, Q[i].c, Q[i].b);
	rep(i,n)printf("%lld\n", ans[i]);
	return 0;
}

Measured memory_bytes: 10740
#include<bits/stdc++.h>
using  namespace std;
#define ll long long
#define pb push_back
#define sc second
#define fr first
#define mp make_pair
const int N = 2e5 + 10 , OO = 1e9 + 2, Max = 50 + 10;
const ll  MOD = 998244353 ;
int dp[N] , a[N];
int dx[] = {1,2};
int main() {
    int n;
    cin >> n ;
    for(int i = 1;i<=n;++i) cin >> a[i] , dp[i] = OO;
    dp[1] = 0 ;
    for(int i = 1;i<=n;++i) {
        for(int j =0;j < 2;++j) {
            int nx = i + dx[j];
            if(nx <=n)
                dp[nx] = min(dp[nx],dp[i] + abs(a[nx] - a[i]));
        }
    }
    cout << dp[n] << endl;

}


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

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

    set<int> values;
    for(int i = 0; i < n; i++){
        values.insert(a[i]);
    }

    int ans = 0;
    int l = values.size();
    vector<int> count(n);
    for(int i = 0; i < n; i++){
        count[i] = 0;
    }
    for(int i = 0; i < n; i++){
        count[a[i]]++;
    }
    sort(count.begin(), count.end(), greater<int>());

    int sum = 0;
    for(int i = 0; i < k; i++){
        sum += count[i];
    }

    ans = n - sum;
    cout << ans << endl;

}

Measured memory_bytes: 11136
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define maxn 200010
#define mod 924844033
#define G 5
using namespace std;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n;
int head[maxn],nxt[maxn*2],to[maxn*2],tot;
void add(int u,int v)
{
    tot++;
    nxt[tot]=head[u];
    head[u]=tot;
    to[tot]=v;
}
int h[maxn*3],size[maxn],g[maxn*3];
void dfs(int x,int las)
{
    size[x]=1;
    for(int i=head[x];i;i=nxt[i])
    {
        if(to[i]==las)  continue;
        dfs(to[i],x);
        h[size[to[i]]]++;
        size[x]+=size[to[i]];
    }
    if(size[x]<n) h[n-size[x]]++;
}
int fac[maxn],inv[maxn];
int quick_pow(int x,int p)
{
    int an=1,po=x;
    while(p)
    {
        if(p&1)  an=1ll*an*po%mod;
        po=1ll*po*po%mod;
        p>>=1;
    }
    return an;
}
int r[maxn*3];
int lim=1,len;
void NTT(int A[maxn*3],int type)
{
    for(int i=0;i<lim;i++)
      if(i<r[i])  swap(A[i],A[r[i]]);
    for(int mid=1;mid<lim;mid<<=1)
    {
        int Wn=quick_pow(G,(mod-1)/(mid<<1));
        if(type==-1)  Wn=quick_pow(Wn,mod-2);
        for(int j=0;j<lim;j+=(mid<<1))
        {
            int w=1;
            for(int k=0;k<mid;k++,w=1ll*w*Wn%mod)
            {
                int x=A[j+k],y=1ll*w*A[j+k+mid]%mod;
                A[j+k]=(x+y)%mod;
                A[j+k+mid]=(x-y+mod)%mod;
            }
        }
    }
    if(type==-1)
    {
        int tmp=quick_pow(lim,mod-2);
        for(int i=0;i<lim;i++)  A[i]=1ll*A[i]*tmp%mod;
    }
}
int C(int x,int y)
{
    return 1ll*fac[x]*inv[y]%mod*inv[x-y]%mod;
}
int main()
{
    n=read();
    for(int i=1;i<n;i++)
    {
        int q=read(),w=read();
        add(q,w);
        add(w,q);
    }
    dfs(1,0);
    fac[0]=1;
    for(int i=1;i<=n;i++)  fac[i]=1ll*fac[i-1]*i%mod;
    inv[n]=quick_pow(fac[n],mod-2);
    for(int i=n-1;i>=0;i--) inv[i]=1ll*inv[i+1]*(i+1)%mod;

    for(int i=0;i<=n;i++)    h[i]=1ll*h[i]*fac[i]%mod;
    for(int i=0;i<=n;i++)    g[i]=inv[n-i];
   
    while(lim<=2*n) lim<<=1,len++;
    for(int i=0;i<lim;i++)  r[i]=(r[i>>1]>>1)+((i&1)<<(len-1));
    
    NTT(h,1);NTT(g,1);
    for(int i=0;i<lim;i++)  g[i]=1ll*g[i]*h[i]%mod;
    NTT(g,-1);

    for(int i=1;i<=n;i++)
    {
        int res=1ll*C(n,i)*n%mod;
        res=(res-1ll*g[n+i]*inv[i]%mod+mod)%mod;
        printf("%d\n",res);
    }
    return 0;
}

Measured memory_bytes: 23424
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	h, w := iScan(), iScan()
	s := []string{strings.Repeat(".", w+2)}
	for i := 0; i < h; i++ {
		s = append(s, "."+Scan()+".")
	}
	s = append(s, strings.Repeat(".", w+2))
	for i := 1; i <= h; i++ {
		for j := 1; j <= w; j++ {
			if string(s[i][j]) == "#" {
				fmt.Print("#")
			} else {
				c := 0
				for _, p := range []int{-1, 0, 1} {
					for _, q := range []int{-1, 0, 1} {
						if string(s[i+p][j+q]) == "#" {
							c++
						}
					}
				}
				fmt.Print(c)
			}
		}
		fmt.Println("")
	}
}


Measured memory_bytes: 1792
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

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

    string s;
    
    int A, B, K; cin >> A >> B >> K;
    for(int i=A; i<=B; ++i){
        if(i-A<K){ cout << i << endl; continue; }
        if(B-i<K){ cout << i << endl; continue; }
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#define mm(a,x) memset(a,x,sizeof(a))
#define sync std::ios::sync_with_stdio(false);std::cin.tie(0)
#define ll long long
using namespace std;
const int MAXN=3e3+10;
const int MOD=998244353;
int a[MAXN];
ll dp[MAXN];
int main(void)
{
    sync;
    int n,s;
    cin>>n>>s;
    for(int i=1;i<=n;++i)
        cin>>a[i];
    ll res=0;
    for(int i=1;i<=n;++i)
    {
        ++dp[0];
        for(int j=s;j>=a[i];--j)
            dp[j]=(dp[j]+dp[j-a[i]])%MOD;
        res=(res+dp[s])%MOD;
    }
    cout<<res<<endl;
    return 0;
}

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

int main(void) {
  int i;
  double dev,n,s[1001],sum = 0,ave;
  while(1){
    scanf("%lf",&n);
    if(n == 0)break;
    for(i = 0; i < n; i++){
      scanf("%lf",&s[i]);
      sum += s[i];
    }
    for(i = 0; i < n; i++)ave = sum / n;
    for(i = 0; i < n; i++){
      dev += (s[i] - ave) * (s[i] - ave);
    }
    dev = dev / n;
    printf("%lf\n",sqrt(dev));
    sum = 0;
    dev = 0;
  }
  return 0;
}


Measured memory_bytes: 2104
#include <stdio.h>

int main(void){
    int n,E,i,s,j;
    int a[4][14];
    char e,moji[4];
    
    scanf("%d",&n);
    
    for(i=0;i<4;i++){
        for(j=1;j<=13;j++){
            a[i][j]=0;
        }
    }
    for(i=0;i<4;i++){
        if(i==0) moji[i]= 'S';
        if(i==1) moji[i]= 'H';
        if(i==2) moji[i]= 'C';
        if(i==3) moji[i]= 'D';
    }
    for(i=0;i<n;i++){
        scanf("%s %d",&e,&s);
        if(e=='S'){
            E=0;
        }
        if(e=='H'){
            E=1;
        }
        if(e=='C'){
            E=2;
        }if(e=='D'){
            E=3;
        }
        a[E][s]=1;
    }
    for(j=0;j<4;j++){
        for(i=1;i<=13;i++){
            if(a[j][i]!=1){
                printf("%c %d\n",moji[j],i);
            }
        }
    }
    return 0;
}

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

    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846

    void solve(){
        int a ,b;
        cin>>a>>b;
        cout<<6-a-b;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
        int t=1;
//        cin>>t;
        for(int i=1;i<=t;i++){
            solve();
        }
        return 0;
    }


Measured memory_bytes: 3612
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
constexpr ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
ll n,m;
ll dp[100005],ans[100005];
V<ll> graph[100005];
void dfs1(int now,int par){
    for(int v:graph[now]){
        if(v==par)continue;
        dfs1(v,now);
    }
    dp[now]=1;
    for(int v:graph[now]){
        if(v==par)continue;
        dp[now]*=(dp[v]+1);
        dp[now]%=m;
    }
}
void dfs2(int now,int par){
    ans[now]=dp[now];
    int sz=graph[now].size();
    V<ll> lpro(sz+1,1),rpro(sz+1,1);
    for(int i=0;i<sz;i++){
        lpro[i+1]*=lpro[i]*(dp[graph[now][i]]+1)%m;
        lpro[i+1]%=m;
    }
    for(int i=sz-1;i>=0;i--){
        rpro[i]*=rpro[i+1]*(dp[graph[now][i]]+1)%m;
        rpro[i]%=m;
    }
    for(int i=0;i<sz;i++){
        int v=graph[now][i];
        if(v==par)continue;
        ll memo1=dp[now],memo2=dp[v];
        dp[now]=lpro[i]*rpro[i+1]%m;
        dp[v]=dp[v]*(dp[now]+1)%m;
        dfs2(v,now);
        dp[now]=memo1;
        dp[v]=memo2;
    }
}
int main(){
cin>>n>>m;
for(int i=0;i<n-1;i++){
    int a,b;cin>>a>>b;
    a--;b--;
    graph[a].emplace_back(b);
    graph[b].emplace_back(a);
}
dfs1(0,-1);
dfs2(0,-1);
for(int i=0;i<n;i++){
   cout<<ans[i]<<"\n";
}
}

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

int main(int argc, const char * argv[]) {
    int N;
    cin >> N;
    string S;
    cin >> S;
    
    vector<char> ans;
    char c = S[0];
    for (int i = 1; i < S.size(); i++) {
        if (c != S[i]) {
            ans.push_back(c);
        }
        c = S[i];
    }
    ans.push_back(c); // last 1
    
    cout << ans.size() << endl;
    
    return 0;
}

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

int main(){
  char c;
  cin >> c;
  
  if ( c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o' )
    cout << "vowel" << endl;
    
  else
    cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()

typedef pair<int,int> P;

class UnionFind {
private:
  vector<int> parent;
  vector<int> height;
  vector<int> m_size;

public:
  UnionFind(int size_) : parent(size_), height(size_, 0), m_size(size_, 1) {
    for (int i = 0; i < size_; ++i) parent[i] = i;
  }
  void init(int size_) {
    parent.resize(size_);
    height.resize(size_, 0);
    m_size.resize(size_, 0);
    for (int i = 0; i < size_; ++i) parent[i] = i;
  }
  int find(int x) {
    if (parent[x] == x) return x;
    return parent[x] = find(parent[x]);
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    int t = size(x) + size(y);
    m_size[x] = m_size[y] = t;
    if (height[x] < height[y]) parent[x] = y;
    else parent[y] = x;
    if (height[x] == height[y]) ++height[x];
  }
  bool same(int x, int y) {
    return find(x) == find(y);
  }
  int size(int x) {
    if (parent[x] == x) return m_size[x];
    return size(parent[x] = find(parent[x]));
  }
};


signed main(){
  int N,K,L;
  cin >> N >> K >> L;
  UnionFind a(N);
  UnionFind b(N);
  a.init(N);
  b.init(N);
  //init(N);
  rep(i,K){
    int p,q;
    cin >> p >> q;
    p--;
    q--;
    a.unite(p,q);
  }
  rep(i,L){
    int r,s;
    cin >> r >> s;
    r--;
    s--;
    b.unite(r,s);
  }
  map<pair<int, int>, int> mp;
  rep(i,N){
    mp[make_pair(a.find(i), b.find(i))]++;
  }
  rep(i,N) cout << mp[make_pair(a.find(i), b.find(i))] << endl;
  return 0;
}


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

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)
#define INF 1000000000
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;
vector<vector<int> > v(55);

bool check(vector<int> vec){
	string str = "012";
	//cout << "!!" << endl;
	REP(i,vec.size()){
		int now = vec[i];
		REP(j,v[now].size()){
			if(v[now][j] == 0){
				swap(str[0],str[1]);
			}
			else{
				swap(str[1],str[2]);
			}
		}
		//cout << str << endl;
		if(str == "012")return true;
	}
	
	return false;
}

int main()
{
	int n;cin >> n;
	
	REP(i,n){
		int w;cin >> w;
		REP(j,w){
			int tmp;cin >> tmp;
			v[i].PB(tmp);
		}
	}
	
	if(n > 7){
		cout << "yes" << endl;
		return 0;
	}
	else
	{
		vector<int> par(n);
		REP(i,n)par[i] = i;
		do{
			if(check(par)){
				cout << "yes" << endl;
				return 0;
			}
		}while(next_permutation(ALL(par)));
	}
	
	cout << "no" << endl;
	
	return 0;
}


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

int main(){
  int N,K;
  string S;
  cin >> N >> K >> S;
  if(S[K-1]=='A')
    S[K-1]='a';
  else if(S[K-1]=='B')
    S[K-1]='b';
  else
    S[K-1]='c';
  cout << S << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, K;
  cin >> N >> K;
  int heights[N];
  vector <int> dp(N, (int)1e9+5);
  //cout << dp[1] << endl;
  for (int i = 0; i < N; ++i){
    cin >> heights[i];
    if (i <= K && i != 0){
      dp[i] = abs(heights[0] - heights[i]);
      //cout << dp[i] << endl;
    }
  }
  for (int i = 1; i < N - 1; ++i){
    for (int j = i + 1; j <= i + K; ++j){
      if (j < N){
        dp[j] = min(dp[j], dp[i] + abs(heights[i] - heights[j]));
      }
    }
  }
  cout << dp[N-1];
}


Measured memory_bytes: 4068
def sol():
    N, M = map(int, input().split())

    minDist = [[float('inf') for _ in range(N)] for _ in range(N)]
    edges = set([])

    for _ in range(M):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        minDist[a][b] = c
        minDist[b][a] = c
        edges.add((min(a, b), max(a, b)))

    noEdge = set([])

    for k in range(N):
        for i in range(N):
            for j in range(N):
                if minDist[i][j] > minDist[i][k] + minDist[k][j]:
                    minDist[i][j] = minDist[i][k] + minDist[k][j]
                    noEdge.add((min(i, j), max(i, j)))

    nessEdge = edges - noEdge
    print(M - len(nessEdge))

sol()

Measured memory_bytes: 43888
#include<stdio.h>
int main()
{
    char s[5];
    scanf("%s",&s);
    if(s[0]=='S'){
    printf("Cloudy\n");
    }
else if(s[0]=='R'){
    printf("Sunny\n");
}
else{
    printf("Rainy\n");
}
    return 0;
}

Measured memory_bytes: 128
while True:
    n=int(input())
    if n==0:
        break
    else:
        x=[]
        for i in range(n):
            a=int(input())
            x.append(a)
        x.sort()
        b=0
        for j in range (0,10):
            m=x.count(b)
            
            
            if m==0:
                print("-")
                    
            else:
                print("*"*m)
            b+=1
        
    


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

int main()
{
    int n,k,i,j;
    cin>>n;
   vector<double>dp(n+1);
   dp[0]=1;
   
   for(int coin =0;coin<n;coin++)
   {
       double d;
       cin>>d;
       for(i=coin+1;i>=0;i--)
       {
           dp[i]=(i==0?0:dp[i-1]*d)+(dp[i]*(1-d));
       }
   }
   
   double answer=0;
   
   
   for(i=0;i<=n;i++)
   {
       j=n-i;
       if(i>j) answer+=dp[i];
   }
   
    cout<<fixed<<setprecision(10)<<answer<<endl;
    
    
}

Measured memory_bytes: 256
X = int(input())
ans = 1
a = 1

for b in range(2,X+1):
  p = 2
  while(True):
    if pow(b, p) > X:
      if ans < a:
        ans = a
      break
    else:
      a = pow(b, p)
      p += 1

    
print(ans)


Measured memory_bytes: 2940
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>
#include <list>
#include <iomanip>
#include <cctype>
#include<chrono>
#include<random>

#define for0(i, N)    for (long long i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (long long i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (long long i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (long long i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (long long i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (long long i = (x), a = 0; a < (N);    \
                              i = (i + 1) % (N), ++a)
#define int long long

long double constexpr pi = 3.141592653589793;

template<class T>
constexpr T sigma1(T i, T n){
    return (n - i + 1) * (i + n) / 2;
}

template<class T>
constexpr T sigma2(T i, T n){
    return (i == 1 ? n * (n + 1) * (2 * n + 1) / 6 :
            sigma2(1, n) - sigma2(1, i - 1));
}

template<class T>
constexpr T sigma3(T i, T n){
    if (i == 1) {
        auto temp = sigma1(i, n);
        return temp * temp;
    }
    return sigma2(1, n) - sigma2(1, i - 1);
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

long long constexpr inf = std::numeric_limits<long long>::max();

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vector<ll>> vvll;


signed main(void){
    cin.tie(0); ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);
    ll n, k;
    cin >> n >> k;

    vll s(n, 0);

    for0(i, k){
        ll d;
        cin >> d;
        for0(i, d){
            ll a;
            cin >> a;
            --a;
            ++s[a];
        }

    }
    ll result = 0;
    for(auto &x : s){
        if (x == 0) {
            ++result;
        }
    }
    cout << result;

    return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    int list[] = { a, b, c };

    int five = 0;
    int seven = 0;
    for (int x : list)
    {
        if (x == 5){
            five++;
        }
        if (x == 7)
        {
            seven++;
        }
    }

    if (five == 2 && seven == 1){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a==b && b==c)
        System.out.println(1);
        else if(a==b || b==c || c==a)
        System.out.println(2);
        else
        System.out.println(3);
    }
}

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

using namespace std;

int main(void){
    int N;
    cin>>N;
    if(N==1){
        cout<<"Hello World"<<endl;
    }else{
        int A,B;
        cin>>A>>B;
        cout<<A+B<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
table = m.times.map { gets.split.map(&:to_i) }
known = Array.new(n)
edges = Hash.new { [] }

table.each do |x, y, z|
  x -= 1
  y -= 1
  edges[x] <<= y
  edges[y] <<= x
end

cost = 0
(0...n).each do |i|
  unless known[i]
    cost +=1

    stack = []
    stack.push(i)
    until stack.empty?
      node = stack.pop
      next if known[node]
      known[node] = true
      edges[node].each do |other|
        unless known[other]
          stack.push(other)
        end
      end
    end
  end
end
puts cost


Measured memory_bytes: 20604
k=int(input())
def s(n):
    m=str(n)
    l=list(m)
    l=map(int,l)
    return n/sum(l)
p=1
q=0
for i in range(k):
    print(p)
    if s(p+10**q)>s(p+10**(q+1)):
        q+=1
    p+=10**q

Measured memory_bytes: 38768
program together
  implicit none
  integer :: n, i, m, summ
  integer,allocatable :: a(:)
  real :: ave
  read(*,*) n
  allocate(a(n))
  read(*,*) a

  ave = real(sum(a),4)/real(size(a),4)

  if ( ave - int(ave) >= 0.5 ) then
     m = int(ave) + 1
  else
     m = int(ave)
  end if
  
  summ = 0
  do i = 1, n
     summ = summ + (a(i)-m)*(a(i)-m)
  end do
  write(*,*) summ
  deallocate(a)
  stop
end program together


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  ll n;
  cin >> n;
  ll num = 26;
  string s;
  while(n > 0) {
    if(n % num == 0) {
      s.push_back('z');
      n--;
    } else {
      s.push_back((char)(n % num + 'a' - 1));
    }
    n /= num;
  }
  reverse(s.begin(), s.end());
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3624
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline
    n = int(input())
    v = list(map(int, input().split()))
    import collections
    c1 = collections.Counter(v[::2]).most_common()
    c2 = collections.Counter(v[1::2]).most_common()
    c1.append(('a',0))
    c2.append(('b',0))
    if c1[0][0]==c2[0][0]:
        print(n-c1[0][1]-c2[0][1]+min([c1[0][1]-c1[1][1], c2[0][1]-c2[1][1]]))
    else:
        print(n-c1[0][1]-c2[0][1])


Measured memory_bytes: 20636
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<string > vecstr;
int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max(min(b,d) - max(a,c),0) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
const int N = 6e5+20;

vector <int> v;
int n, este, actual;
int arr [N];

void f(int actual)
{
    if(actual == 0) arr[0] = 0;
    else
    {
        if(actual-1 >= 0)
        {
            int peso1 = arr[actual-1] + abs(v[actual] - v[actual-1]);
            //cout<<peso1<<endl;
            if(peso1 < arr[actual])
                arr[actual] = peso1;
        } 
        if(actual-2 >= 0)
        {
            int peso2 = arr[actual-2] + abs(v[actual] - v[actual-2]);
            if(peso2 < arr[actual])
                arr[actual] = peso2;
        } 
    }
}
int main()
{
    cin>>n;
    for(int i = 0; i < n; i++){cin>>este;v.push_back(este);}
    memset(arr, 1000000, sizeof arr);
    for(int i = 0; i < n; i++)f(i);
    cout<<arr[n-1]<<endl;
    //for(int i = 0; i < n; i++)cout<<arr[i]<<" - ";
}

Measured memory_bytes: 5696
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define f first
#define s second
const int INF = 1000 * 1000 * 1000;
const ll LINF = (ll)INF * INF;
const ll mod = INF + 7;
const double EPS = 1e-9;

int main()
{
	ll x , y;
	cin >> x >> y;
	if(not(x % y))
	{
		cout << -1;
	}
	else
		cout << x;
}


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    String s = sc.next();
    String t = sc.next();
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    String u = sc.next();
    if (u.equals(s)) {
      pw.println((a - 1) + " " + b);
    } else {
      pw.println(a + " " + (b - 1));
    }
  }
}


Measured memory_bytes: 21972
using namespace std;
#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 300010
#define ll long long
int n,L;
int x[N],t[N],s[N];
ll ans;
int st[N],tp;
int q[N],head,tail;
int main(){
	scanf("%d%d",&n,&L);
	ans+=(ll)2*L*(1+n);
	int cnt=0;
	for (int i=1;i<=n;++i)
		scanf("%d",&x[i]);
	for (int i=1;i<=n;++i){
		scanf("%d",&t[i]);
		ans+=t[i]/(2*L)*(2*L);	
		t[i]%=(2*L);
		if (t[i]==0) {ans-=2*L;continue;}
		int _0=(t[i]<=2*(L-x[i])),_1=(t[i]<=2*x[i]);
		s[i]=_0|_1<<1;
	}
	head=1,tail=0;
	int las=0;
	for (int i=1;i<=n;++i)	
		if (s[i]==2)
			st[++tp]=i;
		else if (s[i]==1){
			if (i==n)
				las=n;
			else if (tp)
				--tp,ans-=2*L;
			else if (head<=tail)
				++head,ans-=2*L;
		}
		else if (s[i]==3)
			q[++tail]=i;
	int rem=0;
	for (int i=1;i<=tp;++i){
		for (;head<=tail && q[head]<st[i];++head) ++rem;
		if (head<=tail)
			++head,ans-=2*L;
	}
	if (head<=tail && q[tail]==n)
		las=n,tail--;
	rem+=tail-head+1;
	ans-=(ll)2*L*(rem/2+(las==n));
	printf("%lld\n",ans);
	return 0;
}




















Measured memory_bytes: 6404
#include <iostream>
using namespace std;
int main() {
	int n,i,x,y;
	cin>>n;
	int a[n];
	for(i=0;i<n;i++)
	cin>>a[i];
	for(i=0;i<n;i++)
	{
	    if(i==0)
	    x=0;
	    else if(i==1)
	    {
	        y=x+abs(a[i]-a[i-1]);
	    }
	    else
	    {
	        int z=y;
	        y=min(y+abs(a[i]-a[i-1]),x+abs(a[i]-a[i-2]));
	        x=z;
	    }
	}
	cout<<y<<endl;
	return 0;
}

Measured memory_bytes: 640
// 18.0 / 24.0
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m;
    cin>>n>>m;
    
    vector<ll> A(n);
    vector<pair<ll,int>> B;

    for(int i=0; i<n; i++){
        cin>>A[i];
    }
    sort(A.begin(), A.end());
    
    int b;  ll c;
    for(int i=0; i<m; i++){
        cin>>b>>c;
        B.push_back({c,b});
    }
    
    sort(B.rbegin(), B.rend());

    int left = 0;
    for(int i=0; i<m; i++){
        int x = B[i].second;
        ll y = B[i].first;
        for(int j=0; j<B[i].second; j++){
            if(A[left] < B[i].first){
                A[left] = B[i].first;
                left ++;
                if(left == n)
                    break;
            }
            else
                    break;
        }
    }

    ll ans=0;
    for(ll x : A)
        ans += x;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n,k=0;
    string s;
    cin>>n;
    s=to_string(n);
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='7')
        {
            cout<<"Yes";
            k=1;
            break;
        }
    }
    if(k==0)
    cout<<"No";
    return 0;
}


Measured memory_bytes: 3696
#include<stdio.h>
int main(){
  int a,b; //変数宣言
  float t;
  int sum=0;
  int work=0;
  scanf("%d%d%f",&a,&b,&t); //入力
  
  if(a>t+0.5){
    goto a;
  }
  
  for(int i=1;i<=t;i++){
    if(i*a <= t+0.5){
      sum+=b;
    }
  }
  a:
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

int A[200000];

long long int merge(int a1[], int a2[], int a[], int n, int m)
{
	int i = 0, j = 0;
	long long int inv = 0;
	while (i < n||j < m)
	{
		if (i == n)
		{
			a[i + j] = a2[j];
			j++;
		}
		else if (j == m)
		{
			a[i + j] = a1[i];
			i++;
		}
		else
		{
			if (a1[i] < a2[j])
			{
				a[i + j] = a1[i];
				i++;
			}
			else
			{
				a[i + j] = a2[j];
				j++;
				inv += n - i;
			}
		}
	}
	return inv;
}

long long int mergeSort(int a[], int l)
{
	if (l > 1)
	{
		long long int inv = 0;
		int m = l / 2;
		int n = l - m;
		int* a1 = new int[m];
		int* a2 = new int[n];
		for (int i = 0; i < m; i++)
		{
			a1[i] = a[i];
		}
		for (int i = 0; i < n; i++)
		{
			a2[i] = a[m + i];
		}

		inv += mergeSort(a1, m);
		inv += mergeSort(a2, n);
		inv += merge(a1, a2, a, m, n);
		delete[] a1;
		delete[] a2;
		return inv;
	}
	return 0;
}

int main()
{
	int N;
	scanf("%d", &N);

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

	printf("%lld\n", mergeSort(A, N));
	return 0;
}


Measured memory_bytes: 5304
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;


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

  int X;
  cin >> X;

  int ans = 1;
 
  for(int p=2;p<10;p++){
    for(int i=1;i<100;i++){
      int v = pow(i, p);
      if(v > X) break;
      if(ans < v){
	ans = v;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.next());
		//int k = Integer.parseInt(sc.next());
		int[] a = new int[n];
		TreeMap<Integer, Integer> tm = new TreeMap<>();

		for (int i = 1; i <= n; i++) {
			tm.put(Integer.parseInt(sc.next()), i);
		}

		for (Integer x : tm.keySet()) {
			System.out.print(tm.get(x) + " ");
		}

		sc.close();
	}
}

Measured memory_bytes: 72208
#include <bits/stdc++.h>
#define FAST_INPUT ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long

using namespace std;


void solve() {
	int n; cin >> n;
	vector<double> dp(n + 1);
	dp[0] = 1;
	for (int i = 0; i < n; i++) {
		double pHeads; cin >> pHeads;
		for (int j = i + 1; j >= 0; j--) {
			dp[j] = (j == 0 ? 0 : dp[j - 1]) * pHeads + dp[j] * (1 - pHeads);
		}
	}

	double ans = 0;
	for (int heads = 0; heads <= n; heads++){
		int tails = n - heads;
		if (heads > tails) {
			ans += dp[heads];
		}
	}

	cout << setprecision(20) << ans << endl;
}

void solve2() {
	int n; cin >> n;
	vector<double> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	// dp[i][j] - given i coins what the probability of getting j heads
	vector<vector<double>> dp(n + 1, vector<double>(n + 1));
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			dp[i][j] = dp[i - 1][j - 1] * p[i - 1] + dp[i - 1][j] * (1 - p[i - 1]);
		}
	}

	double ans = 0;
	for (int i = 0; i <= n; i++){
		int j = n - i;
		if (i > j) {
			ans += dp[n][i];
		}
	}

	cout << setprecision(20) << ans << endl;
}

int main() {
    FAST_INPUT;

    solve2();

    return 0;
}


Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define fi            first
#define se            second
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    vector<int>sad;
    int cnt=0,a,fl=0,mx=10,ro=0;
    for(int i=0;i<5;i++)
    {
        cin>>a;
        if(a%10==0)
        {
            cnt+=a;
            ro++;
        }
        else
        {
          sad.PB(a);
          if(a%10<mx)
          {
              mx=a%10;
              fl=a;
          }
        }
    }
    if(ro==5)
    {
        cout<<cnt<<nl;
        return 0;
    }
    vector<int>:: iterator it;

    for(it=sad.begin();it!=sad.end();it++)
    {
        int xx=*it;
        if(xx==fl)
        {
            sad.erase(it);
            break;
        }
    }
    int j=9,k=SZ(sad);
    bool gu=false;
    while(1)
    {
        for(int i=0;i<SZ(sad);i++)
        {

            if((sad[i]%10==j))
            {
                cnt+=sad[i];
                sad[i]=-1;
                cnt+=(10-cnt%10);
                k--;
               // cout<<cnt<<nl;
                if(k==0)
                {
                  gu=true;
                  break;
                }
            }
        }
        if(gu)
        {
            break;
        }
        j--;
    }
    //cnt+=(10-cnt%10);
    cnt+=fl;
    cout<<cnt<<nl;
    return 0;
}


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

int main() {
  string S;
  bool flag = true;
  cin >> S;
  vector<int> check(26, 0);
  for(int i = 0; i < S.size(); i++){
    int s;
    s = int(S.at(i)) - 97;
    if(check.at(s) == 1){
      flag = false;
      break;
    }else{
      check.at(s) = 1;
    }
  }
  if(flag) cout << "yes" <<endl;
  if(!flag) cout << "no" <<endl;
}

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

int main() {
  string S;
  
  cin >> S;
  if(S.at(0)!=S.at(1) || S.at(1)!=S.at(2)){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256