akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int n, k;
    cin >> n >> k;
    vector< LL > v;
    for( int i = 0; i < n; ++i ) {
        LL a;
        cin >> a;
        v.push_back(a);

    }
    sort(all(v), greater< int >());
    LL t = 0;
    for( int i = 0; i < n; ++i ) {
        if( k > 0 ) {
            --k;

        } else {
            t += v[i];

        }
    }
    cout << t << endl;

    return 0;
}



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

#define LL long long
#define PLL pair<LL,LL>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	LL n;
	cin >> n;
	vector<PLL> res(n);
	for (LL i = 0; i < n; i++){
		cin >> res[i].first;
		res[i].second = i+1;
	}
	sort(res.begin(),res.end());
	cout << res[0].second;
	for (LL i = 1; i < n; i++)
		cout << " " << res[i].second;
	cout << "\n";
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int A, B;
  char op;
  cin >> A >> op >> B;
  if (op == '+') {
    cout << A + B << endl;
  } else {
    cout << A - B << endl;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast","inline","-ffast-math")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
//#define int long long
using namespace __gnu_pbds;
using namespace std;

int n,a[3][3];
bool vis[110];

signed main()
{
	ios::sync_with_stdio(false);
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin>>a[i][j];
		}
	}
	cin>>n;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		vis[x]=1;
	}
	if(vis[a[0][0]]&&vis[a[0][1]]&&vis[a[0][2]]) cout<<"Yes"<<endl;
	else if(vis[a[1][0]]&&vis[a[1][1]]&&vis[a[1][2]]) cout<<"Yes"<<endl;
	else if(vis[a[2][0]]&&vis[a[2][1]]&&vis[a[2][2]]) cout<<"Yes"<<endl;
	else if(vis[a[0][0]]&&vis[a[1][0]]&&vis[a[2][0]]) cout<<"Yes"<<endl;
	else if(vis[a[0][1]]&&vis[a[1][1]]&&vis[a[2][1]]) cout<<"Yes"<<endl;
	else if(vis[a[0][2]]&&vis[a[1][2]]&&vis[a[2][2]]) cout<<"Yes"<<endl;
	else if(vis[a[0][0]]&&vis[a[1][1]]&&vis[a[2][2]]) cout<<"Yes"<<endl;
	else if(vis[a[0][2]]&&vis[a[1][1]]&&vis[a[2][0]]) cout<<"Yes"<<endl;
	else cout<<"No"<<endl; 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

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

    int n;
    cin >> n;
    if (n % 2 == 1)
    {
        cout << 0 << endl;
        return 0;
    }
    int ans = 0;
    for (int i = 10; i <= n; i *= 5)
        ans += (n / i);
    cout << ans << endl;
}


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

#define fastIO ios::sync_with_stdio(false);cout.tie(0);cin.tie(0);
#define endl '\n'
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define MP make_pair
#define inf INT_MAX
#define minf INT_MIN

typedef long long int lli;

ofstream outfile;
ifstream infile;

int main()
{
	infile.open("input.txt");
	outfile.open("output.txt");

	int n,  i, yes = 0, no = 0, even = 0;
	int t;
	cin >> n;
	for(i = 1; i <= n; ++i)
	{
		cin >> t;
		if( !(t%4))
			++yes;
		else if( !(t%2))
			++even;
		else
			++no;
	}

	if( yes >= n/2)
	{
		cout << "Yes\n";
		return 0;
	}
	else
	{
		if( !even){
			cout << "No\n";
			return 0;
		}
		n = n-even+1;
		if(yes >= n/2)
			cout << "Yes\n";
		else
			cout << "No\n";
	}
}

Measured memory_bytes: 256
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from functools import reduce
from math import gcd
def resolve():
    n = int(input())
    A = list(map(int, input().split()))

    if reduce(gcd, A) != 1:
        print("not coprime")
        return

    M = max(A)
    sieve = list(range(M + 1))
    sieve[0] = sieve[1] = INF
    for p in range(2, M + 1):
        if sieve[p] != p:
            continue
        for i in range(2 * p, M + 1, p):
            sieve[i] = min(sieve[i], p)

    used = set()
    for a in A:
        primes = set()
        while a > 1:
            p = sieve[a]
            primes.add(p)
            a //= p
        for p in primes:
            if p in used:
                print("setwise coprime")
                return
            used.add(p)

    print("pairwise coprime")
resolve()

Measured memory_bytes: 191508
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>
using namespace std;

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;

int main(void) {
	int N, jur, cou,ans,num;
	num=0;
	ans = 0;
	cou = 0;
	cin >> N;
	vint h(N);
	vint H(N);
	for (int i = 0; i < N; ++i) {
		cin >> h[i];
		H[i] = 0;
	}


	for (int j = 0;num==0; ++j) {
		jur = 0;
		cou = 0;
		num = 0;
		for (int i = 0; i < N; i++) {
			if (H[i] == h[i])jur++;
		}
		if (jur == N) {
			ans = j;
			num = 1;
		}

		for (int i = 0; i < N; ++i) {
			if (H[i] != h[i]) {
				++H[i];
				++cou;
			}
			else if (cou != 0)break;

		}
		
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
use io::*;
use std::collections::BinaryHeap;

fn main() {
    let input = read_string();
    let mut sc = Scanner::new(&input);
    let n: usize = sc.next();
    let xs: Vec<i64> = sc.next_vec(n);
    let mut ys: Vec<i64> = sc.next_vec(n);
    let zs: Vec<i64> = sc.next_vec(n);
    let mut sumx = xs.iter().sum();
    let mut sumz = zs.iter().sum();
    let mut hx = BinaryHeap::new();
    let mut a = vec![sumx];
    for x in xs {
        hx.push(-x);
    }
    for y in ys.clone() {
        hx.push(-y);
        let out = hx.pop().unwrap();
        sumx += y + out;
        a.push(sumx);
    }
    let mut hz = BinaryHeap::new();
    let mut b = vec![sumz];
    for z in zs {
        hz.push(z);
    }
    ys.reverse();
    for y in ys {
        hz.push(y);
        let out = hz.pop().unwrap();
        sumz += y - out;
        b.push(sumz);
    }
    b.reverse();
    let ans: i64 = a.iter().zip(b.iter()).map(|x: (&i64,&i64)| *x.0 - *x.1).max().unwrap();
    println!("{}",ans);
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }

        pub fn next_mat<T: FromStr>(&mut self, w: usize, h: usize) -> Vec<Vec<T>> {
            (0..h).map(|_| self.next_vec(w)).collect()
        }

        pub fn next_vec_char(&mut self) -> Vec<char> {
            self.next::<String>().chars().collect()
        }

        pub fn next_mat_char(&mut self, n: usize) -> Vec<Vec<char>> {
            (0..n).map(|_| self.next_vec_char()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 16504
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  int N; cin >> N;
  vi T(N); rep(i,N) cin >> T.at(i);
  int M; cin >> M;
  vi P(M), X(M); rep(i,M) cin >> P.at(i) >> X.at(i);
  
  rep(i,M) {
    int ans = 0;
    rep(j,N) {
      if (j == P.at(i)-1) {
        ans += X.at(i);
      }
      else {
        ans += T.at(j);
      }
    }
    cout << ans <<endl;
  }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

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


"""
Sの通り数で良い

X+D ~ X+(N-1)*D まで
a個とったとして，aX + bDの形になる.add()
Dの個数bについて，minとmaxを考えれば，その間は全部作れるはず

N,X,D=5,4,2
[4,6,8,10,12]からa=3個選ぶ場合
3X+3D ~ 3X+9Dまでの7通り作れる，

a個選ぶ場合，Dの係数は
min b : (a-1)*a // 2            ... 0~(a-1)までの和
max b  : a*(N-1) - (a-1)*a // 2      ... (N-a)~(N-1)までの和

通り数： a*(N-1) - 2*((a-1)*a // 2) + 1

ここからXとDが変動した時のかぶりをどうするか

aを決め打つと，表せる範囲は等差数列になる（等差D）
結局，いろんな等差数列が出てくるのでそれらで表せるものを探す．

min b = L
max b = Rとする
RーL = R'とする
初項Ca = a*X + D*Lとする

この数列はCa ~ Ca + D*R'

(a*X)mod D の値が異なれば絶対に同じ値にはならない
mod Dごとにグループを分けて考える，
各グループでCa/D =Ca'として
Ca' ~ Ca'+R'　の区間を考える．どこかの区間に入っていればOK
=>イベントソート，+1と−１

"""
def main():
    N,X,D=MI()
    if D==0:
        if X==0:
            print(1)
            exit()
        else:
            print(N+1)
            exit()
            
    #グルーピング
    from collections import defaultdict
    dd = defaultdict(list)
    for a in range(N+1):
        L = ((a-1)*a)//2
        R = a*(N-1) - ((a-1)*a)//2
        R2 = R-L
        Ca = a*X + D*L
        key=(a*X)%D
        dd[key].append([Ca//D , Ca//D + R2])
        
    #イベントそーと
    ans=0
    for k,vs in dd.items():
        E=[]
        for v in vs:
            E.append([v[0],1])
            E.append([v[1]+1,-1])
        E.sort()
        
        # print(k,vs)
        # print(E)
        
        now=-10**10
        score=0
        for e in E:
            nxt=e[0]
            diff=nxt-now
            if score>=1:
                ans+=diff
            score+=e[1]
            now=nxt
            
    print(ans)
            
            
        
    


    

main()


Measured memory_bytes: 137560
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


from heapq import heappush, heappop


def dijkstra(graph: list, start, INF=float('inf')) -> list:
    n = len(graph)
    dist = [INF] * n
    visited = [False] * n

    dist[start] = 0
    que = [(0, start)]

    while que:
        cost, cur = heappop(que)

        if visited[cur]:
            continue

        visited[cur] = True

        for nextnode, edgecost in graph[cur]:
            nextcost = cost + edgecost
            if nextcost < dist[nextnode]:
                dist[nextnode] = nextcost
                heappush(que, (nextcost, nextnode))

    return dist

n, m, l = li()
graph = [[] for _ in range(n)]
costgraph = [[] for _ in range(n)]
for _ in range(m):
    a, b, c = li()
    a -= 1
    b -= 1
    graph[a].append((b, c))
    graph[b].append((a, c))

for st in range(n):
    dist = dijkstra(graph, st)
    for ds in range(n):
        if st == ds:
            continue

        if dist[ds] <= l:
            costgraph[st].append((ds, 1))

q = ni()
INF = float("inf")

dist = [[INF]*n for _ in range(n)]
for i in range(n):
    dist[i] = dijkstra(costgraph, i, INF)

for _ in range(q):
    st, ds = li_()
    if dist[st][ds] == INF:
        print(-1)
    else:
        print(dist[st][ds] - 1)

Measured memory_bytes: 93788
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int main(){
  int s;
  cin >> s;
  vector<int> vec;
  vec.push_back(s);
  int count = 1;
  while(1){
    count++;
    if (s % 2 == 0) s /= 2;
    else s = 3 * s + 1;
    if (binary_search(vec.begin(), vec.end(), s)) break;
    vec.push_back(s);
    sort(vec.begin(), vec.end());
  }
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 3604
n,m=map(int,input().split())
sc=[list(map(int,input().split())) for i in range(m)]

ans=[-1]*n
for s,c in sc:
  s-=1
  if ans[s]!=-1 and ans[s]!=c:
    print(-1)
    exit()
  ans[s]=c

if n==1 and ans[0]==0:
  print(0)
  exit()
if n==1 and m==0:
  print(0)
  exit()

if ans[0]==0:
  print(-1)
  exit()

if ans[0]==-1:
  ans[0]=1
for i in range(1,len(ans)):
  if ans[i]==-1:
    ans[i]=0

ans=[str(i) for i in ans]
print(''.join(ans))

Measured memory_bytes: 3192
/* 
    HARSHAD VAGHASIYA

        @DAIICT
    
          H_M_Vaghasiya
    
  */
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MAX_INT 100000
#define ld long double
int main()
{
   ll n,i,j,k,d,x,y;
   string s;
   cin>>n>>s;
   if(n >=3200){
       cout<<s<<endl;
       return 0;
   }
   cout<<"red"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;

vector<pair<int,int> > v[112345];
pair<int,int> x[112345]; 

int N,M;
int main () {
    cin >> N >> M;
    for(int i=0; i<M; i++) {
        int p,y;
        cin >> p >> y;
        v[p].push_back(make_pair(y,i));
    }
    for(int i=1; i<=N; i++) {
        if(v[i].size()) {
            sort(v[i].begin(),v[i].end());
            for(int j=0; j<v[i].size(); j++) {
                int id = v[i][j].second;
                x[id] = make_pair(i,j+1);
            }
        }
    }
    for(int i=0;i<M; i++) printf("%06d%06d\n",x[i].first,x[i].second);
    return 0;
}


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

using namespace std;
using ll = long long;
using pii = pair<ll, ll>;

int K, X;
int main(){

    cin >> K >> X;
    if(500 * K >= X){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int x[10000000];
int a, n, m, c;
int main() {
	cin >> n >> m >> c;
	for (int i = 1; i <= n; i++) {
		cin >> a;
		for (int j = 0; j < 10000000; j += a) {
			x[j] = i;
		}
	}
	for (int i = m - c; i <= m + c; i++) {
		if (x[i] >= 1) { cout << x[i] << endl; goto E; }
	}
	cout << "-1" << endl;
E:;
	return 0;
}

Measured memory_bytes: 40224
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
    long n=0;
    string T;
    cin >>T;
    n=T.size();
    for(int i=0;i <n;i++){
        if(T[i]=='?'){
            T[i]='D';
        }
    }
    cout << T;
}

Measured memory_bytes: 3756
import java.awt.Point;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Queue;
import java.util.Scanner;

class Main {

  private static final int INF = Integer.MAX_VALUE / 4;
  private static final Integer[] di = { 1, -1, 0, 0 };
  private static final Integer[] dj = { 0, 0, 1, -1 };

  public static boolean isIn(int i, int j, int H, int W) {
    if (0 <= i && i < H && 0 <= j && j < W) {
      return true;
    } else {
      return false;
    }
  }

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int H = scanner.nextInt();
    int W = scanner.nextInt();
    char[][] map = new char[H][W];
    Queue<Point> queue = new ArrayDeque<>();
    int[][] min = new int[H][W];
    for (int[] is : min) {
      Arrays.fill(is, INF);
    }
    for (int i = 0; i < H; i++) {
      scanner.next().getChars(0, W, map[i], 0);
      for (int j = 0; j < W; j++) {
        if (map[i][j] == '#') {
          queue.add(new Point(i, j));
          min[i][j] = 0;
        }
      }
    }
    while (!queue.isEmpty()) {
      Point p = queue.poll();
      for (int k = 0; k < 4; k++) {
        int ci = p.x + di[k];
        int cj = p.y + dj[k];
        if (isIn(ci, cj, H, W) && min[ci][cj] == INF) {
          min[ci][cj] = min[p.x][p.y] + 1;
          queue.add(new Point(ci, cj));
        }
      }
    }
    int ans = 0;
    for (int[] is : min) {
      for (int i : is) {
        ans = Math.max(ans, i);
      }
    }
    System.out.println(ans);
  }
}


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

using namespace std;

const int MAX_N = 110000;

int memo[MAX_N]; // memo[i] が i についての答え

int rec(int n) {
  if(n == 0) return 0; // 終端条件
  if(memo[n] != -1) return memo[n]; // すでに探索済みならreturn

  int res = n; // INF の気持ち

  // 1, 6, 6^2, ..., を試す (nを超えない範囲で)
  for(int pow6 = 1; pow6 <= n; pow6 *= 6) {
    res = min(res, rec(n - pow6) + 1);
  }

  // 1, 9, 9^2, ..., を試す (nを超えない範囲で)
  for(int pow9 = 1; pow9 <= n; pow9 *= 9) {
    res = min(res, rec(n - pow9) + 1);
  }

  // メモしながらリターン
  return memo[n] = res;
}

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

  // テーブルを -1 で初期化
  for(int i = 0; i < MAX_N; i++) {
    memo[i] = -1;
  }
  cout << rec(n) << endl;
}

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


#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ll long long


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int ab, bc, ac;
    cin >> ab >> bc >> ac;

    cout << min(ab + bc, min(bc + ac, ab + ac)) << endl;


    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys

n = int(input())
d, x = map(int, input().split())
a = []
for i in range(n):
    a.append(int(input()))

sum_choco = 0

for i in range(n):
    j = 0
    while (a[i] * j + 1) <= d:
        sum_choco += 1
        j += 1

sum_choco += x

print (sum_choco)

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

int main(){
  int N;
  cin>>N;
  unordered_set<int> A;
  for(int i=0;i<N;i++){
    int j;
    cin>>j;
    if(A.count(j))
      A.erase(j);
    else
      A.insert(j);
  }
  cout<<A.size()<<endl;
}

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

int main()
{
  int A,B,K;scanf("%d %d %d",&A,&B,&K);
  set<int> s;
  for(int i=A;i<A+K;i++){if(i>B)continue;printf("%d\n",i);s.insert(i);}
  for(int i=B-K+1;i<B+1;i++){if(i<A)continue;if(!s.count(i))printf("%d\n",i);}
}

Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
#define sz(x) int(x.size())
#define pb push_back
#define ff first
#define ss second
typedef long long ll;

int main(){
	int n;cin>>n;
	vector<int>vec(n);
	for(int i=0;i<n;i++)cin>>vec[i];
	vector<int>s=vec;
	sort(s.begin(),s.end());
	if(vec==s){
		cout<<"YES"<<endl;
		return 0;
	}
	for(int i=0;i<n;i++)for(int j=i+1;j<n;j++){
		vector<int>g=vec;
		swap(g[i],g[j]);
		if(g==s){
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
	return 0;
}


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

using namespace std;

int main()
{
    int n;

    while (cin >> n) {
        int a[n], b[n], c[n];

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

        int dp[n][3];

        memset(dp, 0, sizeof dp);

        for (int i = 0; i < n; i++) {
            if (i == 0) {
                dp[i][0] = a[i];
                dp[i][1] = b[i];
                dp[i][2] = c[i];
            }
            else {
                dp[i][0] = max(dp[i][0], max(dp[i - 1][1], dp[i - 1][2]) + a[i]);
                dp[i][1] = max(dp[i][1], max(dp[i - 1][0], dp[i - 1][2]) + b[i]);
                dp[i][2] = max(dp[i][2], max(dp[i - 1][0], dp[i - 1][1]) + c[i]);
            }
        }

        cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
    }
    return 0;
}


Measured memory_bytes: 2560
#include <cmath>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; i++)

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

    if((a < c && c < b ) || (b < c && c < a))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;

}


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

int main() {
	int n, x, y;
	cin >> n >> x >> y;
	x--; y--;
	// vector<vector<int>> g(n);
	// rep(i, n-1) {
	// 	g[i].push_back(i+1);
	// 	g[i+1].push_back(i);
	// }
	// g[x].push_back(y);
	// g[y].push_back(x);
	vector<vector<int>> dis(n, vector<int>(n));
	rep(i, n) {
		for(int j = i+1; j < n; j++) {
			int a = j-i;
			int b = abs(x-i) + 1 + abs(y-j);
			int c = abs(x-j) + 1 + abs(y-i);
			dis[i][j] = min(min(a, b), c);
		}
	}
	vector<int> ans(n-1);
	rep(i, n) {
		for(int j = i+1; j < n; j++) {
			ans[dis[i][j]-1]++;
		}
	}
	rep(i, n-1) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 16000
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        char[] line1 = line.toCharArray();
        if(line1[0] == line1[1]){
            if(line1[2] != line1[1]){
                if(line1[2] == line1[3])
                System.out.println("Yes");
                else
                System.out.println("No");
            }
            else
            System.out.println("No");
        }
        else if(line1[0] == line1[2]){
            if(line1[0] != line1[1]){
                if(line1[1] == line1[3])
                System.out.println("Yes");
                else
                System.out.println("No");
            }
            else
            System.out.println("No");
        }
        else if(line1[0] == line1[3]){
            if(line1[0] != line1[1]){
                if(line1[1] == line1[2])
                System.out.println("Yes");
                else
                System.out.println("No");
            }
            else
            System.out.println("No");
        }
        else if(line1[1] == line1[2]){
            if(line1[0] != line1[1]){
                if(line1[0] == line1[3])
                System.out.println("Yes");
                else
                System.out.println("No");
            }
            else
            System.out.println("No");
        }
        else if(line1[1] == line1[3]){
            if(line1[0] != line1[1]){
                if(line1[0] == line1[2])
                System.out.println("Yes");
                else
                System.out.println("No");
            }
            else
            System.out.println("No");
        }
        else if(line1[2] == line1[3]){
            if(line1[1] != line1[2]){
                if(line1[0] == line1[1])
                System.out.println("Yes");
                else
                System.out.println("No");
            }
            else
            System.out.println("No");
        }
        else
        System.out.println("No");
    }
}

Measured memory_bytes: 23380
from collections import Counter
n = int(input())
s = [input() for i in range(n)]
c = Counter(s)
m = 0
for i in c.values():
    m = max(m, i)
res = []
for k, v in c.items():
    if v == m:
        res.append(k)
res.sort()
print('\n'.join(res))

Measured memory_bytes: 36032
# class Map(dict):
#     def __missing__(self, key):
#         # この割当てなしのほうが速い。
#         # self[key] = 0
#         return 0


def main():
    int(input())

    d = {}
    ans = 0
    d_setdefault = d.setdefault
    d_get = d.get
    for i, height in enumerate(input().split()):
        height = int(height)
        # 引き算のほうの i は足し算のよりも大きい。
        # 従って，このように順番に見ていく必要がある。
        got = d_get(i + height) or 0
        d[i + height] = got + 1
        ans += d_setdefault(i - height, 0)

    return ans


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

# 大いに参考にした。
# https://kmjp.hatenablog.jp/entry/2020/05/03/1030


Measured memory_bytes: 66964
#include <iostream>
#include<string.h>
using namespace std;

int main(){
  int a,b;
  int i = 0,k = 0;
  string s0 = ".";
  string s1 = "#";
  while(1){
    cin >> a >> b;
    while(i < a){
      while(k < b ){
        if((i+k)%2 != 0){
          cout << s0;
        } else {
          cout << s1;
        }
        k++;
      }
      k = 0;
      i++;
      cout << endl;
    }
     i = 0;
    if( a == 0 && b ==0){
      break;
    }
    cout << endl;
  }
}



Measured memory_bytes: 3156
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define IOS cin.tie(0); ios::sync_with_stdio(false)
const int INF = 1e9;
using namespace std;

signed main() {
    int N; cin >> N;
    bool can = false;
    rep(i,N){
        int a; cin >> a;
        if(a%2==1) can = true;
    }
    cout << (can ? "first":"second") << endl;
}

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

using lint = long long;
const lint MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<lint> c(N + 1);
    for (int i = 1; i <= N; i++) {
        cin >> c[i];
    }
    vector<lint> dp(N + 1);
    map<lint, int> last;
    dp[0] = 1;
    for (int i = 1; i <= N; i++) {
        if (last[c[i]] == 0 or last[c[i]] == i - 1) {
            dp[i] = dp[i - 1];
            last[c[i]] = i;
        } else {
            dp[i] = (dp[i - 1] + dp[last[c[i]]]) % MOD;
            last[c[i]] = i;
        }
    }
    cout << dp[N] << endl;
    return 0;
}

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

int main(){
  int64_t N,Vmin,Vmax;
  cin >> N >> Vmin >> Vmax;

  int64_t ans= (N==1) ? ((Vmax==Vmin) ? 1
                                      : 0)
              :(Vmax < Vmin)          ? 0
                                      : (N-2)*(Vmax-Vmin)+ 1;

  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    private static HashMap<Integer, List<Integer>> graph;
    public static void main(String[] args) throws Exception{
        Scanner scanner = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int V = scanner.nextInt();
        int E = scanner.nextInt();

        graph = new HashMap<>(V);
        for(int i = 0; i < V; ++i){
            graph.put(i, new LinkedList<>());
        }

        for(int i = 0; i < E; ++i){
            int u = scanner.nextInt();
            int v = scanner.nextInt();
            graph.get(u).add(v);
        }

        boolean[] visited = new boolean[V];

        for(int i = 0; i < V; ++i){
            boolean[] recStack = new boolean[V];
            if(!visited[i] && cyclicUtil(i, visited, recStack)){
                System.out.println("1");
                return;
            }
        }

        System.out.println("0");
        return;
    }

    private static boolean cyclicUtil(int cur, boolean[] visited, boolean[] recStack){
        visited[cur] = true;
        recStack[cur] = true;

        for(Integer adj : graph.get(cur)){
            if(recStack[adj]){
                return true;
            }
            else if(!visited[adj] && cyclicUtil(adj, visited, recStack)){
                return true;
            }
        }

        recStack[cur] = false;
        return false;
    }
}

Measured memory_bytes: 31252
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
int main(){
ll n,k;
cin>>n>>k;
ll a[n];
f(i,0,n){
    cin>>a[i];
}

bool dp[k+2];
f(i,0,k+1){
    dp[i]=0;
}
dp[0]=0;

f(i,1,k+1){
    for(ll j=0;j<n;j++){
        ll val=i-a[j];
        if(val>=0){
dp[i]=(!dp[val])||dp[i];
        }
       
    }
}
if(dp[k]){
    cout<<"First"<<endl;
}
else{
    cout<<"Second"<<endl;
}

}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;

// コンテスト中のみ
//#define int long long

#define ll long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define P pair<ll,ll>
#define ld long double
ll INF = (1LL << 60);
int MOD = 1000000007;

ll n;
ll Q;
bool isprime[200010];
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	n = 200000;
	rep(i, 200010)isprime[i] = true;
	isprime[0] = false;
	isprime[1] = false;
	for (int i = 2; i <= n; i++) {
		if (isprime[i]) {
			for (int j = 2 * i; j <= n; j += i)isprime[j] = false;
		}
	}
	vector<ll>sum(n + 2);
	rep(i, n + 1) {
		sum[i + 1] += sum[i];
		if (i%2==1&&isprime[i] && isprime[(i+1)/2]) {
			sum[i + 1]++;
		}
	}
	cin >> Q;
	rep(_, Q) {
		int l, r; cin >> l >> r;
		cout << sum[r + 1] - sum[l - 1] << endl;
	}
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  bool c = true;
  int n = s.size();
  for(int i = 0;i < n;i++) {
    if(i % 2 == 0) {
      if(s[i] == 'L') {
        c = false;
        break;
      }
    } else {
      if(s[i] == 'R') {
        c = false;
        break;
      }
    }
  }
  cout << (c ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include <iomanip>
#include <limits>
#include<unordered_set> 
#include<cmath>
using namespace std;
//long long p = 998244353;
long long p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define fcout cout << fixed << setprecision(15)
#define rev(s) reverse(s.begin(),s.end())
#define lower(h,val) lower_bound(h.begin(),h.end(),val)-h.begin()
#define upper(h,val) upper_bound(h.begin(),h.end(),val)-h.begin()
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n) {
    if (n == 0) { return 1; }
    int x = rui(a, n / 2);
    x *= x; x %= p;
    if (n % 2 == 1) { x *= a; x %= p; }
    return x;
}
int inv(int a) { return rui(a, p - 2); }
void make_kai() {
    for (int i = 1; i < max_kai; i++) { kai[i] = kai[i - 1] * i; kai[i] %= p; }
    inv_kai = kai;
    rep(i, max_kai) { inv_kai[i] = inv(kai[i]); }
}
int nCr(int n, int r) {
    if (n < 0 || r<0 || r>n) { return 0; }
    int a = kai[n] * inv_kai[r]; a %= p;
    a *= inv_kai[n - r]; a %= p;
    return a;
}
vel pa;
int root(int x) {
    if (pa[x] == -1) { return x; }
    int ans = root(pa[x]); pa[x] = ans;
    return ans;
}
void marge(int x, int y) {
    x = root(x);
    y = root(y);
    if (x != y) { pa[x] = y; }
}
int gcd(int x, int y) {
    if (x < y) { return gcd(y, x); }
    if (y == 0) { return x; }
    return gcd(y, x % y);
}
#define pd pair<int,double>
#define ved vector<double>
int l;
V<string> s;
int ord_2(int n) {
    if (n % 2 == 1) { return 1; }
    return 2 * ord_2(n / 2);
}
int solve(string &now, int st, int to) {
    if (st == to) {
        int ql = l - now.size();
        return ord_2(ql + 1);
    }
    if (s[st] == now) { return 0; }
    now.append(1, '1');
    int mid = lower_bound(s.begin(), s.end(), now)-s.begin();
    int ans1 = solve(now, mid, to);
    now.erase(now.end() - 1);
    now.append(1, '0');
    int ans0 = solve(now, st, mid);
    now.erase(now.end() - 1);
    return (ans0 ^ ans1);
}
signed main() {
    int n; cin >> n >> l;
    s = V<string>(n);
    rep(i, n) { cin >> s[i]; }
    sor(s);
    string now = "";
    int ans = solve(now, 0, n);
    //cout << ans << endl;
    if (ans == 0) { cout << "Bob" << endl; return 0; }
    cout << "Alice" << endl;
    return 0;
}

Measured memory_bytes: 12672
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if (a >= 13) {
        cout << b << endl;
    } else if (a >= 6) {
        cout << b / 2 << endl;
    } else {
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
import copy

n = int(raw_input())
cards = raw_input().split()
cards1 = copy.deepcopy(cards)
cards2 = copy.deepcopy(cards)

def isbig(card1, card2):
	if int(card1[1]) > int(card2[1]):
		return 2
	elif int(card1[1]) == int(card2[1]):
		return 1
	else:
		return 0

def BubbleSort(c, n):
	temp = 0
	for i in range(n):
		for j in reversed(range(i+1,n)):
			if isbig(c[j], c[j-1]) == 0:
				temp = c[j]
				c[j] = c[j-1]
				c[j-1] = temp
	return c

def SelectionSort(c, n):
	temp = 0
	for i in range(n):
		minj = i
		for j in range(i,n):
			if isbig(c[j], c[minj]) == 0:
				minj = j
		temp = c[i]
		c[i] = c[minj]
		c[minj] = temp
		#print("*{:}".format(c))
	return c

def isstable(unsort, sort):
	for i in range(n):
		for j in range(i+1,n):
			for k in range(n):
				for l in range(k+1,n):
					if isbig(unsort[i], unsort[j]) == 1 and unsort[i] == sort[l] and unsort[j] == sort[k]:
						return 0
	return 1

for i in range(n):
	if i != n-1:
		print BubbleSort(cards1, n)[i],
	else:
		print BubbleSort(cards1, n)[i]

if isstable(cards, BubbleSort(cards1, n)) == 1:
	print("Stable")
else:
	print("Not stable")

for i in range(n):
	if i != n-1:
		print SelectionSort(cards2, n)[i],
	else:
		print SelectionSort(cards2, n)[i]

if isstable(cards, SelectionSort(cards2, n)) == 1:
	print("Stable")
else:
	print("Not stable")

Measured memory_bytes: 6524
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <stack>
#include <ctype.h>
#include <cstring>

using namespace std;

bool is_numeric(char c[],int len){
    bool flag=true;
    for(int i=0;i!=len;++i){
        if(c[i]<'0'||c[i]>'9'){
            flag=false;
        }
    }
    
    return flag;
}

long long num_char(char c[],int len){
    long long num=0;
    int k=1;
    for(int i=len;i!=0;--i){
        //cout<<c[i-1]<<endl;
        num+=(c[i-1]-'0')*k;
        //cout<<num<<endl;
        k=k*10;
    }
    
    return num;
}


int main(){
    //入力部分
    char ch[300][8];
    char c;
    int i=0;
    int M=0;  //単語数
    while((c=fgetc(stdin))!='\n'){
        if(c!=' '){
            //printf("%c\n",c);
            ch[M][i]=c;
            ++i;
        }else if(c==' '){
            ch[M][i]='\0';
            ++M;
            i=0;
        }
    }
    ch[M][i]='\0';
    
    /*
    for(int i=0;i!=100;++i){
        printf("%s\n",&ch[i][0]);
    }
    */
    // 計算部分
    stack<long long> st;
    int len;
    long long a,b;
    // int i=7;
    int j=0;
    while(j<=M){
        len=strlen(ch[j]);
        //cout<<len<<endl;
        //cout<<ch[j]<<endl;
        
        if(is_numeric(ch[j], len)){
            //cout<<"数字"<<endl;
            st.push(num_char(ch[j],len));
                    // cout<<"top:"<<st.top()<<endl;
        }else{
            switch(ch[j][0]){
            case '+':
                    a=st.top();
                    //cout<<a<<endl;
                    st.pop();
                    b=st.top();
                    //cout<<b<<endl;
                    st.pop();
                    st.push(a+b);
                break;
            case '-':
                    a=st.top();
                    st.pop();
                    b=st.top();
                    st.pop();
                    st.push(b-a);
                break;
            case '*':
                a=st.top();
                st.pop();
                b=st.top();
                st.pop();
                st.push(a*b);
                break;
            }
        }
        //cout<<st.top()<<endl;
        ++j;
    }
    cout<<st.top()<<endl;
    
}



Measured memory_bytes: 3112
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


class SegmentTree:
    def __init__(self, init_val, ide_ele, op):
        n = len(init_val)
        self.num = 2 ** (n - 1).bit_length()
        self.seg = [ide_ele] * 2 * self.num
        self.ide_ele = ide_ele
        self.op = op
        for i in range(n):
            self.seg[i + self.num - 1] = init_val[i]
            # built
        for i in range(self.num - 2, -1, -1):
            self.seg[i] = self.op(self.seg[2 * i + 1], self.seg[2 * i + 2])


    def update(self, k, x):
        k += self.num - 1
        self.seg[k] = x
        while k + 1:
            k = (k - 1) // 2
            self.seg[k] = self.op(self.seg[k * 2 + 1], self.seg[k * 2 + 2])


    def query(self, p, q):
        if q <= p:
            return self.ide_ele
        p += self.num - 1
        q += self.num - 2
        res = self.ide_ele
        while q - p > 1:
            if p & 1 == 0:
                res = self.op(res, self.seg[p])
            if q & 1 == 1:
                res = self.op(res, self.seg[q])
            p = p // 2
            q = (q - 2) // 2
        if p == q:
            res = self.op(res, self.seg[p])
        else:
            res = self.op(self.seg[p], self.op(res, self.seg[q]))
        return res


n, k = LI()
L = LI()
min_ST = SegmentTree(L, INF, min)
max_ST = SegmentTree(L, -INF, max)
cnt = 1
for i in range(n - k):
    if min_ST.query(i, i + k) == L[i] and max_ST.query(i + 1, i + k + 1) == L[i + k]:
        continue
    else:
        cnt += 1


ret = -INF
increasing_block_num = 0
max_len = 0
for j in range(n):
    if L[j] >= ret:
        max_len += 1

    else:
        if max_len >= k:
            increasing_block_num += 1
        max_len = 1
    ret = L[j]


if max_len >= k:
    increasing_block_num += 1



if increasing_block_num:
    print(cnt - (increasing_block_num - 1))
else:
    print(cnt)

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

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

int main(void) {
	pair <string, int> s,t;
	string x;
	int N,M;
	cin >> s.first >> t.first;
	cin >> s.second >> t.second;
	cin >> x;
	if(x == s.first) cout << s.second-1 << ' ' << t.second << endl;
	else cout << s.second << ' ' << t.second-1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main(void)
{
    int N;
    cin >> N;
    unsigned long ans;

    unsigned long a, b;
    cin >> a >> b;

    unsigned long A, B;
    for (int i = 1; i < N; i++) {
        cin >> A >> B;
        unsigned long at = a % A == 0 ? a / A : (a / A) + 1;
        unsigned long bt = b % B == 0 ? b / B : (b / B) + 1;
        unsigned long x = at >= bt ? at : bt;
        a = A * x;
        b = B * x;
    }
    cout << a + b << endl;
}


Measured memory_bytes: 256
/*/ Author:amar1503/*/
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("Ofast")
#define fio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ull unsigned long long
#define ll long long
#define inf INT_MAX
#define mninf INT_MIN
#define Mod 1000000007
#define endl "\n"
#define cp(x) cout<<(x)<<" "
#define cl(x) cout<<(x)<<endl
#define nl   cout<<endl
//const double PI=3.1415926535897932384626433832;
//looping
#define For(i,a,b) for(int i=a;i<b;i++)
#define test(t)  int (t); cin>>(t); while((t)--)
#define array(a,n) int (n); cin>>(n); int a[n]; for(int i=0;i<(n);i++) cin>>a[i];
#define trace(x) clog<<#x<<": "<<x<<" "<<endl
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define printa(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define printv(v)  for(int i=0;i<(v).size();i++) cout<<v[i]<<" "
#define printmatrix(v,n,m) for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { cout<<v[i][j]<<" ";} cout<<endl;}
//containers
#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define all(v) (v).begin(),(v).end()
#define mp make_pair
#define itr(it, a) for(auto it = (a).begin(); it != (a).end(); it++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ers(v)    sort(all(v)); (v).erase(unique(all(v)),(v).end())
typedef vector<int> vi;
typedef vector< vector< int > > vvi;
typedef pair <int, int> pii;
typedef vector < pair <int, int> > vpii;
//#define int long long
#define float double
/*/-----------------------------Code begins----------------------------------/*/
int main(){
    fio;
    int n;
    cin>>n;
    cout<<fixed<<setprecision(10);
    float p[n];
    For(i,0,n)
    cin>>p[i];
    float dp[n+1][n];
    memset(dp,0,sizeof(dp));
    dp[0][0]=1-p[0];
    dp[1][0]=p[0];
    for(int i=0;i<n+1;i++){
        for(int j=1;j<n;j++){
        if(i==0)
            dp[i][j]=dp[i][j-1]*(1-p[j]);
        else
        dp[i][j]=dp[i][j-1]*(1-p[j])+dp[i-1][j-1]*p[j];
        }
    }
    float sum=0;
    for(int i=(n+1)/2;i<=n;i++)
        sum+=dp[i][n-1];
    cout<<sum;
}



















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

int main()
{
    int a;
    string s;
    cin >> a >> s;
    if (a >= 3200)
    {
        cout << s << endl;
    }
    else
    {
        cout << "red" << endl;
    }
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()


from collections import deque  #listよりdequeの方が両端へのアクセスは計算量が少ない
def main():
    s = input()
    t = input()
    l = len(s)
    even_list = [1 for i in range(l) if t[i] != s[i]]
    print(len(even_list))

if __name__=='__main__':
    main()

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int a, b;
    cin >> a >> b;
    if(a + b < 10){
cout << a+b <<endl;
} else {
cout << "error" << endl;
}
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
using namespace std;
using ll = long long;

void Output(const vector<int> &a){
  REP(i,a.size()){
    cout << a[i];
    if(i != a.size()-1) cout << " ";
  }
  cout << endl;
}

int main(){
  int n; cin >> n;
  vector<int> a(n);
  REP(i,n) cin >> a[i];
  FOR(i,1,n){
    Output(a);
    int v = a[i], j = i-1;
    while(j >= 0 && a[j] > v){
      a[j+1] = a[j];
      --j;
    }
    a[j+1] = v;
  }
  Output(a);
  return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
int H, W;
void dfs(vector<string> &A, vector<vector<ll>> &Ans, int num, P id) {
  if (id.first == H - 1 && id.second == W - 1) {
    if (A[id.first][id.second] == '#') num++;
  }
  if (Ans[id.first][id.second] <= num) return;
  Ans[id.first][id.second] = min(Ans[id.first][id.second], (ll)num);
  if (id.first < H - 1) {
    int ny = id.first + 1, nx = id.second;
    if (A[ny][nx] == '.' && A[id.first][id.second] == '#') {
      dfs(A, Ans, num + 1, P(ny, nx));
    } else {
      dfs(A, Ans, num, P(ny, nx));
    }
  }
  if (id.second < W - 1) {
    int ny = id.first, nx = id.second + 1;
    if (A[ny][nx] == '.' && A[id.first][id.second] == '#') {
      dfs(A, Ans, num + 1, P(ny, nx));
    } else {
      dfs(A, Ans, num, P(ny, nx));
    }
  }
}
int main() {
  cin >> H >> W;
  vector<string> A(110);
  REP(i, H) cin >> A[i];
  vector<vector<ll>> Ans(H + 2, vector<ll>(W + 2, 1e8));
  dfs(A, Ans, 0, P(0, 0));
  cout << Ans[H - 1][W - 1] << endl;
}

Measured memory_bytes: 3716
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e16;
typedef long long ll;

int main(){
  int A, B; cin >> A >> B;
  if (A >= 10 || B >= 10){
    cout << -1 << endl;
  }else{
    cout << A * B << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<fstream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    string s;
    cin >> s;
    ll L = s.size();

    // 010101..
    ll count = 0;
    FOR(i, 0, L){
        if(i%2==0){
            if(s[i]=='1'){
                count++;
            }
        }
        else{
            if(s[i]=='0'){
                count++;
            }
        }
    }

    // 101010...
    ll count2 = 0;
    FOR(i, 0, L){
        if(i%2==0){
            if(s[i]=='0'){
                count2++;
            }
        }
        else{
            if(s[i]=='1'){
                count2++;
            }
        }
    }

    p(min(count, count2));
    
    return 0;
}

Measured memory_bytes: 512