akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(){
    int h[10];
    for(int i=0;i<10;i++){
        cin >> h[i];
    }
    for(int s=0;s<9;s++){
        for(int t=s+1;t<10;t++){
            if(h[s]<h[t]) swap(h[s],h[t]);
        }
    }
    cout << h[0] << "\n" << h[1] << "\n" << h[2] <<endl;
    return 0;
}

Measured memory_bytes: 1164
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define mp make_pair
ll mod = 10e9+7;
ll mod2 = 998244353;

int main(){
    int m,k;cin>>m>>k;
    if (pow(2,m)-1<k){
        cout<<-1<<endl;
        return 0;
    }
    if (k==0){
        rep(i,0,pow(2,m)){
            cout<<i<<endl;
            cout<<i<<endl;
        }
        return 0;
    }
    ll num = 0;
    rep(i,0,pow(2,m)){
        num ^= i;
    }
    if (num==0){
        cout<<k<<endl;
        rep(i,0,pow(2,m)){
            if (i==k) continue;
            cout<<i<<endl;
        }
        cout<<k<<endl;
        for(int i=pow(2,m)-1;i>=0;i--){
            if (i==k) continue;
            cout<<i<<endl;
        }
    }else{
        cout<<-1<<endl;
    }
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <fstream>
#include <stdio.h>
#include <string>
#include <typeinfo>
#define REP(i, n) for (int i = 1; i <= n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
using namespace std;

int main(){
  int n, i;
  cin >> n >> i;
  cout <<  n - i + 1 << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
		
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	int[] A = new int[sc.nextInt()];
		int[] B = new int[sc.nextInt()];
		int[][] M = new int[sc.nextInt()][3];
		
		for(int i = 0; i < A.length; i++){
			A[i] = sc.nextInt();
		}
		
		for(int i = 0; i < B.length; i++){
			B[i] = sc.nextInt();
		}
		
		for(int i = 0; i < M.length; i++){
			M[i][0] = sc.nextInt() - 1;
          	M[i][1] = sc.nextInt() - 1;
          	M[i][2] = sc.nextInt();
		}
		
		List<Integer> ret = new ArrayList<>();
        int a = Arrays.stream(A).min().getAsInt();
        int b = Arrays.stream(A).min().getAsInt();
        int ab = a+b;
        ret.add(ab);
      
		for(int i = 0; i < M.length; i++){
			int cul = A[M[i][0]] + B[M[i][1]] - M[i][2];
			ret.add(cul);
		}
		System.out.println(ret.stream().min(Comparator.naturalOrder()).get());
	}

}

Measured memory_bytes: 161276
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools, os, pdb
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)
def perr(s): return print(s, file=sys.stderr)

ans = []
lines_dict =None
d=None
def main():
    global AB, PX, T
    if 'LOCAL' in os.environ:
        N = 2* 10** 5
        Q = 2 * 10 ** 5
        AB = [[i, i + 1] for i in range(1, N)]
        PX = [[i, 10] for i in range(Q)]
    else:
        N, Q = LI()
        #  AB = []
        T = [[] for _ in range(N+1)]
        PX = [0] * (N+1)
        for i in range(N-1):
            a, b = LI()
            #  AB += (a, b)
            T[a] += [b]
            T[b] += [a]

        for i in range(Q):
            p, x = LI()
            PX[p] += x
        #  perr(AB)
        perr(PX)
        dfs(1, -1)
        for i in PX[1:]:
            print(i, end=' ')
        #  ans = [0 for _ in range(N)]

#  def dfs(parent: int, parent_parent: int) -> None:
def dfs(parent, parent_parent):
    for node in T[parent]:
        if node != parent_parent:
            PX[node] += PX[parent]
            dfs(node, parent)

if __name__ == '__main__':
    main()


Measured memory_bytes: 232884
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	aa := make([]int, n)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
	}
	bb := make([]int, 0)
	l := 0
	for r := 0; r < n; r++ {
		for r > l && aa[l] != aa[r] {
			l++
		}
		if l == r {
			bb = append(bb, aa[l])
		}
	}
	for i := 0; i < len(bb); i++ {
		if i > 0 {
			fmt.Fprint(writer, " ")
		}
		fmt.Fprint(writer, bb[i])
	}
	fmt.Fprintln(writer, "")
}



Measured memory_bytes: 7996
#include <bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

#define impl(x, last) x == last ? 0 : 31 - __builtin_clz(x ^ last)

class RadixHeap{
private:
    int last, size_;
    vector<P> bucket_[32];
public:
    RadixHeap() : last(0), size_(0){}
    void push(int x, int val){
        size_++, bucket_[impl(x, last)].emplace_back(x, val);
    }
    P pop(bool flag = true){
        if(bucket_[0].empty()){
            int id = 1;
            while(bucket_[id].empty()) id++;
            last = min_element(bucket_[id].begin(), bucket_[id].end())->first;
            for(auto val : bucket_[id]){
                bucket_[impl(val.first, last)].push_back(val);
            }
            bucket_[id].clear();
        }
        P res = bucket_[0].back();
        if(flag) size_--, bucket_[0].pop_back();
        return res;
    }
    P top(){
        return pop(false);
    }
    bool empty(){
        return !size_;
    }
};

struct edge{
    int to, cost;
};

vector<edge> G[MAX_N];
int d[MAX_N];
void solve(int s){
    memset(d, INF, sizeof(d));
    RadixHeap que;
    d[s] = 0;
    que.push(0, s);
    while(!que.empty()){
        P p = que.top();
        que.pop();
        int v = p.second;
        if(d[v] < p.first) continue;
        for(auto& e : G[v]){
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(d[e.to], e.to);
            }
        }
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, s;
    cin >> n >> m >> s;
    rep(i,m){
        int a,b,c;
        cin >> a >> b >> c;
        G[a].pb((edge){b, c});
    }
    solve(s);
    rep(i,n){
        if(d[i] == INF){
            cout << "INF\n";
        }else{
            cout << d[i] << "\n";
        }
    }
    return 0;
}



Measured memory_bytes: 13460
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
using namespace std;
const int N = 200000 + 50;

vector<int> G[N];
int vis[N];
int n,m;
int flag = 0;

void dfs(int cur, int target, int step)
{
    vis[cur] = 1;
    if(step > 2)
    {
        return;
    }
    if(cur == target)
    {
        flag = 1;
        return;
    }
    for(int i = 0; i < G[cur].size(); i++)
    {
        int v = G[cur][i];
        if(vis[v]) continue;
        dfs(v, target, step+1);
        if(flag)
            return;
    }
}
void init(int n)
{
    for(int i = 0; i <= n; i++)
        G[i].clear();
}
int main()
{
    int u,v;
    scanf("%d%d", &n, &m);
    init(n);
    for(int i = 0; i < m; i++)
    {
        scanf("%d%d", &u, &v);
        G[u].push_back(v);
    }
    flag = 0;
    memset(vis, 0, sizeof(vis));
    dfs(1, n, 0);
    if(flag)
        printf("POSSIBLE\n");
    else
        printf("IMPOSSIBLE\n");


}


Measured memory_bytes: 9344
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
constexpr int MOD = int(1e9) + 7;

int main() {
    int N;
    cin >> N;
    vector<bool> up;
    for (int i = 0; i < N; ++i) {
        char c;
        cin >> c;
        cin.ignore();

        if (c == 'U') {
            up.push_back(true);
        }
        else if (c == 'D') {
            up.push_back(false);
        }
    }
    N = up.size();

    vector<vector<vector<ll>>> dp(N + 1, vector<vector<ll>>(N + 1, vector<ll>(N + 1, 0LL)));
    dp[0][0][0] = 1;

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) for (int k = 0; k < N; ++k) {
            if (up[i]) {
                dp[i + 1][j][k] = (dp[i + 1][j][k] + j * dp[i][j][k]) % MOD;
                dp[i + 1][j + 1][k + 1] = (dp[i + 1][j + 1][k + 1] + dp[i][j][k]) % MOD;
            }
            else {
                if (j > 0 && k > 0) {
                    dp[i + 1][j - 1][k - 1] = (dp[i + 1][j - 1][k - 1] + (ll)j * k * dp[i][j][k]) % MOD;
                }
                if (k > 0) {
                    dp[i + 1][j][k] = (dp[i + 1][j][k] + k * dp[i][j][k]) % MOD;
                }
            }
        }
    }

    cout << dp[N][0][0] << endl;
}


Measured memory_bytes: 63484
'''
aiが偶数のとき
似ている配列は
ai +- 1:奇数
ai:偶数

aiが奇数のとき
似ている配列は
ai +- 1:偶数
ai:奇数

似ている配列すべてのパターン数(3 ** N)から
奇数のみのパターン数を引けばいい
aiが偶数なら奇数2パターン
aiが奇数なら奇数1パターン
をfor i in range(N)で掛け合わせる
'''

n = int(input())
a = list(map(int, input().split()))
ttl = 3 ** n
odd_ttl = 1
for i in range(n):
    odd_ttl *= 2 if (a[i] % 2 == 0) else 1
print(ttl - odd_ttl)

Measured memory_bytes: 3060
ans = 0
 
def dfs(S, i, cur, sum_v):
    global ans
    if i == len(S)-1:
        ans += sum_v
        return 
    dfs(S, i+1, int(S[i+1]), sum_v+int(S[i+1]))
    dfs(S, i+1, cur*10+int(S[i+1]), sum_v+cur*9+int(S[i+1]))
 
S = input()
dfs(S, 0, int(S[0]), int(S[0]))
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
#define INF (1e9)

int D = 365;
vi c, ans;
vvi s;

void input() {
  cin >> D;
  c = vi(26);
  s = vvi(D, vi(26));
  for (int i = 0; i < 26; i++) {
    cin >> c[i];
  }
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s[i][j];
    }
  }
}

void output() {
  for (int i = 0; i < D; i++) {
    cout << ans[i] + 1 << endl;
  }
}

int simulate(vi a) {
  int sum = 0;
  vi last(26, 0);
  for (int i = 0; i < D; i++) {
    sum += s[i][a[i]];
    last[a[i]] = i + 1;
    for (int j = 0; j < 26; j++) {
      sum -= c[j] * (i - last[j] + 1);
    }
  }
  return (int)1e6 + sum;
  // return max((int)1e6 + sum, 0);
}

void solve() {
  int best = simulate(ans);

  // 周期
  for (int i = 0; i < 26; i++) {
    vi a(D);
    for (int j = 0; j < D; j++) {
      a[j] = (i + j) % 26;
    }

    int x = simulate(a);
    if (x > best) {
      best = x;
      ans = a;
    }
  }

  // その日の最高2
  {
    vi a = ans;
    for (int i = 0; i < D; i++) {
      vi b = a;
      int idx = 0, bst = simulate(b);
      for (int j = 0; j < 26; j++) {
        b[i] = j;
        int x = simulate(b);
        if (x > bst) {
          bst = x;
          idx = j;
        }
      }
      a[i] = idx;
    }
    int x = simulate(a);
    if (x > best) {
      best = x;
      ans = a;
    }
  }
}

int main() {
  input();
  ans = vi(D, 0);
  solve();
  output();
}


Measured memory_bytes: 3708
/*
0-1 ナップザック問題
価値が vi 重さが wi であるような N 個の品物と、容量が W のナップザックがあります。次の条件を満たすように、品物を選んでナップザックに入れます：
 
選んだ品物の価値の合計をできるだけ高くする。
選んだ品物の重さの総和は W を超えない。
価値の合計の最大値を求めてください。
 
入力
１行目に２つの整数　N、W　が空白区切りで１行に与えられます。 続く N 行で i 番目の品物の価値 vi と重さ wi が空白区切りで与えられます。
 
出力
価値の合計の最大値を１行に出力してください。
 
制約
1 ≤ N ≤ 100
1 ≤ vi ≤ 1,000
1 ≤ wi ≤ 1,000
1 ≤ W ≤ 10,000
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>
 
 
using namespace std;
 
// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<int,int> point;
#define rep(i,n) for(i,0,n)

// 各桁の和を計算する関数
int rev(int n) {
  int a[3]={0};
  int i;
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    a[i] = n % 10;
    n /= 10;
    i++;
  }
  if (a[2]!=0) return a[0]*100+a[1]*10+a[2];
  else if (a[1]!=0) return a[0]*10+a[1];
  else return a[0];
}

 
int main() {
	// 入力
	ll N;
	cin >> N;
	ll x[N], y[N], h[N];
	for (int i = 0; i <= N; ++i) cin >> x[i] >> y[i] >> h[i];
 
	// 解法
	ll ans_x, ans_y, ans_h;
	for (ll Cx = 0; Cx <= 100; ++Cx){
		for (int Cy = 0; Cy <= 100; ++Cy){
			bool hit = true;
			ll h_just = -1;
			ll h_max = -1;
			for (int i = 0; i < N; ++i){
				if (h[i]!=0){
					ll h_i = abs(Cx-x[i]) + abs(Cy-y[i]) + h[i];
					if (h_just==-1) h_just = h_i;
					if (h_just!=-1 & h_just!=h_i) hit = false;
					if (h_max!=-1 & h_max<h_just) hit = false;
				}
				else{
					ll h_max_i = abs(Cx-x[i]) + abs(Cy-y[i]);
					if (h_max==-1) h_max = h_max_i;
					if (h_max!=-1 & h_max>h_max_i) h_max = h_max_i;
					if (h_just!=-1 & h_just>h_max) hit = false;
					if (h_max!=-1 & h_max<h_just) hit = false;
				}
				if (hit==false) break;
			}
			if (hit==true){
				ans_x = Cx;
				ans_y = Cy;
				ans_h = h_just;
			}
		}
	}
	printf("%lld %lld %lld\n", ans_x, ans_y, ans_h);
	
}
 

Measured memory_bytes: 764
n = int(input())

abc = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n"]
# results = []
# if n == 1:
#     results = ["a"]
# elif n == 2:
#     results = ["aa", "ab"]
# elif n == 3:
#     results = ["aaa", "aab", "aba", "abb", "abc"]
# elif n == 4:
#     results = ["aaaa", "aaab", "aaba", "aabb", "aabc", "abaa", "abab", "abac", "abba", "abbb", "abbc", "abca", "abcb", "abcc", "abcd"]

results = []
for i in range(n):
    if i == 0:
        results.append(["a"])
    else:
        standards = []
        for result in results[i-1]:
            abcs = list(set(result))
            abcs.append(abc[len(abcs)])
            for a in abcs:
                standards.append(result + a)
        results.append(standards)

# for result in results:
for result in sorted(results[n-1]):
    print(result)


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


/*
ll gcds(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    ll r=a%b;
    if(r==0){
        return b;
    }
    while(r>0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}


ll lcms(ll a,ll b){
    ll mmr=gcds(a,b);
    a=a/mmr;
    b=b/mmr;
    return a*b*mmr;
}
*/

int main(){
    int A,B,C;
    cin>>A>>B>>C;
    int flaga=0;
    int flagb=0;
    int flagc=0;
    if(A==B){
        flaga=1;
    }
    if(B==C){
        flagb=1;
    }
    if(A==C){
        flagc=1;
    }
    int ans=flaga+flagb+flagc;
    if(ans==1){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


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

const int inf = 1e9 + 7;

void Frog_1(vector<int> &h)
{
	int n = h.size();

	vector<int> dp(n, inf);

	/* dp[i] represents the minimum cost to reach the end when you start at i */
	
	// No out of bound acces due to input constraints
	dp[n-1] = 0;
	dp[n-2] = abs(h[n-1] - h[n-2]);

	for(int i = n-3; i >= 0; i--)
		for(int j = i + 1; j <= i + 2; j++)
			dp[i] = min(dp[i], abs(h[j]-h[i]) + dp[j]);

	cout << dp.front() << endl;
}

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

	vector<int> h(n);
	for(auto &ele : h)
		cin >> ele;

	Frog_1(h);
	return 0;
}


Measured memory_bytes: 1024
import sys
s=input()
t=input()
l=len(s)
d={}
for i in range(26):
    d[chr(ord("a")+i)]=i
ref=[[] for _ in range(26)]
for i in range(l):
    ref[d[s[i]]].append(i)

for i in range(26):
    if ref[i]==[]: ref[i].append(-1)

tmp=[0 for i in range(26)]
next=[[-1]*26 for i in range(l)]
for i in range(l):
    x=d[s[i]]
    tmp[x]=(tmp[x]+1)%len(ref[x])
    for j in range(26):
        next[i][j]=ref[j][tmp[j]]

p=s.find(t[0])
ans=p

if p==-1: print(-1);sys.exit()
for i in range(1,len(t)):
    x=d[t[i]]
    q=next[p][x]
    if q==-1: print(-1);sys.exit()
    ans+=-p+q
    if p>=q: ans+=l
    p=q
print(ans+1)

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> vec(N);
  for (int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    vec.at(A - 1)++;
    vec.at(B - 1)++;
  }
  for (int i = 0; i < N; i++) {
    cout << vec.at(i) << endl;
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{


	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		// input
		String tempStr= br.readLine();//clear

		// Constraints

	/*	for (int i = 0; i < tempStr.length(); i++){
			String str;
			if(tempStr.charAt(i) >= 'a' && tempStr.charAt(i) <= 'z') {
				str = Character.toString(tempStr.charAt(i));
				str = tempStr.toUpperCase();
				System.out.print(str);
			}else{
				str = Character.toString(tempStr.charAt(i));
				str = str.toLowerCase();
				System.out.print(str);
			}
		}*/

		// output
		/*for (int i = 0; i < tempStr.length(); i++) {
			System.out.print(tempStr);
		}*/
		for(int i= 0; i < tempStr.length(); i++){
			if(Character.isLowerCase(tempStr.charAt(i)))
				System.out.print(Character.toUpperCase(tempStr.charAt(i)));
		else
			System.out.print(Character.toLowerCase(tempStr.charAt(i)));
		}
		System.out.println();
	}
}

Measured memory_bytes: 25104
import java.io.*;
import java.util.ArrayList;
public class Main{
	public static void main(String args[]){
    int a=0,b=0,c=0,d=1000,z=0,i=0,n=0,m=0;
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    



    while(true){
    try{
      z = 0;
      c = 0;
      d = 1000;
      String line = reader.readLine();
      a = Integer.parseInt(line);
      if (a == 0) break;
      for(i=0;i<a;i++){
        line = reader.readLine();
        b = Integer.parseInt(line);
        if (b > c) c = b;
        if (b < d) d = b;
        z += b;
      }
      System.out.println((z - c - d)/(a - 2));



		}catch(Exception e){
      break;
    }





  }



  
	}
}


Measured memory_bytes: 24376
#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;

struct Point {
  double x;
  double y;
};

double dot(Point p0, Point p1, Point p2) {
  return (p1.x - p0.x) * (p2.x - p0.x) + (p1.y - p0.y) * (p2.y - p0.y);
}

double cross(Point p0, Point p1, Point p2) {
  return ( p1.x - p0.x ) * ( p2.y - p0.y ) - ( p2.x - p0.x) * (p1.y - p0.y);
}

double area(vector<Point> p) {
  double S = 0.0;
  for(int i = 2; i < p.size(); i++) {
    S += cross(p[0], p[i - 1], p[i]) / 2;
  }
  return S;
}

int main(void) {
  int q;
  cin >> q;
  vector<Point> p;

  for(int i = 0; i < q; i++) {
    Point pi;
    cin >> pi.x >> pi.y;
    p.push_back(pi);
  }
  
  printf("%.1lf\n", area(p));

}


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

int main()
{
    int h,w,k;
    cin>>h>>w>>k;
    int x,y,x2,y2;
    cin>>x>>y>>x2>>y2;
    vector<string>v(h);
    vector<vector<int>> f(h,vector<int>(w,0));
    for(int i=0;i<h;++i){
        cin>>v[i];
    }
    int sx=x-1,sy=y-1;
    int gx=x2-1,gy=y2-1;
    queue<pair<pair<int,int>,int>>q;
    q.push({{sx,sy},0});
    f[sx][sy]=true;
    int ans=-1;
    while(!q.empty()){
        auto now = q.front().first;
        int num = q.front().second;
        //cout<<now.first<<now.second<<endl;
        if(now.first == gx && now.second == gy){
            ans=num;
            break;
        }
        q.pop();
        for(int i=1;i<=k;++i){
            if(now.first+i<h && now.first+i>=0){
                auto next = make_pair(now.first+i, now.second);
                if(v[next.first][next.second]!='@'){
                    if(!f[next.first][next.second]){
                        q.push({next,num+1});
                        f[next.first][next.second]=num+1;
                    }else if(f[next.first][next.second]<=num)break;
                }else break;
            }else break;
        }
        for(int i=1;i<=k;++i){
            if(now.first-i<h && now.first-i>=0){
                auto next = make_pair(now.first-i, now.second);
                if(v[next.first][next.second]!='@'){
                    if(!f[next.first][next.second]){
                        q.push({next,num+1});
                        f[next.first][next.second]=num+1;
                    }else if(f[next.first][next.second]<=num)break;
                }else break;
            }else break;
        }
        for(int i=1;i<=k;++i){
            if(now.second+i<w && now.second+i>=0){
                auto next = make_pair(now.first, now.second+i);
                if(v[next.first][next.second]!='@'){
                    if(!f[next.first][next.second]){
                        q.push({next,num+1});
                        f[next.first][next.second]=num+1;
                    }else if(f[next.first][next.second]<=num)break;
                }else break;
            }else break;
        }
        for(int i=1;i<=k;++i){
            if(now.second-i<w && now.second-i>=0){
                auto next = make_pair(now.first, now.second-i);
                if(v[next.first][next.second]!='@'){
                    if(!f[next.first][next.second]){
                        q.push({next,num+1});
                        f[next.first][next.second]=num+1;
                    }else if(f[next.first][next.second]<=num)break;
                }else break;
            }else break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 11176
#include<stdio.h>

int main(){

int n,i,j,u,k,p,v;

int G[150][150];

scanf("%d\n",&n);

for(i=0;i<n;i++){
for(j=0;j<n;j++){
G[i][j]=0;
}
}


for(i=0;i<n;i++){

scanf("%d %d ",&u,&k);

if(k!=0){
for(p=0;p<k;p++){
scanf("%d ",&v);
G[u-1][v-1]=1;
}
}

scanf("\n");

}

for(i=0;i<n;i++){
for(j=0;j<n-1;j++){
printf("%d ",G[i][j]);
}
printf("%d\n",G[i][n-1]);
}

return 0;
}






Measured memory_bytes: 2100
import java.util.*;

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

        long a = sc.nextLong() - 1;
        long b = sc.nextLong();
        long c = sc.nextLong();
        long d = sc.nextLong();

        long x = lcm(c, d);

        long modB = b - b / c - b / d + b / x;
        long modA = a - a / c - a / d + a / x;

        System.out.println(modB - modA);

    }

    static long lcm (long a, long b) {
        long temp;
        long c = a;
        c *= b;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return c/b;
    }

}


Measured memory_bytes: 23124
n = int(input())
li = []
for i in range(n):
    a,b = map(int,input().split())
    li.append([b,a])
li.sort()

f = 0
sum = 0
for i in range(n):
    sum += li[i][1]
    if li[i][0] < sum:
        f = 1

if f == 0:
    print('Yes')
else:
    print('No')

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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a(200005);
  rep(i,n) cin >> a[i];
  int c=a[0];
  rep(i,n-k){
    if(c>=a[k+i]){printf("%s\n", "No");}
    else printf("%s\n", "Yes");
    c=a[1+i];
  }
  return 0;
}


Measured memory_bytes: 3996
import java.util.Scanner;

public class Main {

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

		int a = sc.nextInt();
		int b = sc.nextInt();
		int x = sc.nextInt();

		System.out.println(a <= x && a + b >= x ? "YES" : "NO");

		sc.close();
	}

}




Measured memory_bytes: 21844
#include <cstdio>
typedef long long ll;

int p[1024];
bool mrk[8096];

int main() {
	int n; scanf("%d",&n);
	int *q = p+1 + (n<<1);
	*p = *q = 1;
	for (int x = 2, *t = p+1; t < q; x++) {
		if (!mrk[x]) *t++ = x;
		for (int *i = p+1; i < t && x**i < 8096; i++) {
			mrk[x**i] = true;
			if (!(x % *i)) break;
		}
	}
	q = p+1 + n + (n>>1);
	for (int x = 0; x < n; x++, putchar(10))
		for (int y = 0; y < n; y++) {
			int s = x+y >> 1, d = x-y >> 1;
			if ((x ^ y) & 1) printf("%d ", p[s+1] * q[d]);
			else printf("%lld ", ll(p[s+1] * p[s]) * ll(q[d] * q[d-1]) + 1);
		}
	return 0;
}


Measured memory_bytes: 3072
a, b, m = map(int, input().split())
reizouko_list = list(map(int, input().split()))
densi_list = list(map(int, input().split()))

waribiki_list = []
for i in range(m):
    waribiki_list.append(list(map(int, input().split())))

ans = min(reizouko_list) + min(densi_list)

for x, y, c in waribiki_list:
    value = reizouko_list[x - 1] + densi_list[y - 1] - c
    if ans > value:
        ans = value
print(ans)


Measured memory_bytes: 38568
def check(dist, tak, aok, lim):
    for s, t in zip(ss, ts):
        if s == tak:
            if dist == 0:
                return True
            dist -= 1
        if t == aok:
            if dist < lim:
                dist += 1
    return False


def solve():
    if check(sr - 1, 'U', 'D', h - 1):
        return True
    if check(sc - 1, 'L', 'R', w - 1):
        return True
    if check(h - sr, 'D', 'U', h - 1):
        return True
    if check(w - sc, 'R', 'L', w - 1):
        return True
    return False


h, w, n = list(map(int, input().split()))
sr, sc = map(int, input().split())
ss = input()
ts = input()
print('NO' if solve() else 'YES')


Measured memory_bytes: 3768
//package AtCoder;
import java.io.*;
import java.util.*;

public class Main {
	static int n,W,v[];
	static long w[],dp[][];
	static long dp(int i,int val)
	{
		if(val <= 0)
			return 0;
		
		if(i==n)
			return (int)1e18;
		
		if(dp[i][val]!=-1)
			return dp[i][val];
		
		long take=w[i]+dp(i+1,val-v[i]);
		long leave=dp(i+1,val);

		return dp[i][val]=Math.min(take, leave);
	}
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter pw = new PrintWriter(System.out);
		n=sc.nextInt();W=sc.nextInt();
		v=new int[n];// 0 for weight 1 for value
		w=new long[n];// 0 for weight 1 for value
		dp=new long[n][100001];
		for(int i=0;i<n;i++)
		{
			w[i]=sc.nextLong();
			v[i]=sc.nextInt();
			Arrays.fill(dp[i], -1);
		}
		for(int i=0;i<100001;i++)
			dp(0, i);
		
		for(int i=100000;i>=0;i--)
			if(dp[0][i]<=W && dp[0][i]>=0 )
			{
				System.out.println(i);
				break;
			}
		pw.close();
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
			}
			return st.nextToken();
		}

		int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		String nextLine() throws IOException {
			return br.readLine();
		}

		boolean hasnext() throws IOException {
			return br.ready();
		}

		public int[] nextIntArray(int n) throws IOException {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public Integer[] nextIntegerArray(int n) throws IOException {
			Integer[] a = new Integer[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		char[] nextCharArray() throws IOException {
			return br.readLine().toCharArray();
		}

		public double[] nextDoubleArray(int n) throws IOException {
			double[] ans = new double[n];
			for (int i = 0; i < n; i++)
				ans[i] = nextDouble();
			return ans;
		}

	}
}


Measured memory_bytes: 126164
import java.util.Scanner;

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

        int A = sc.nextInt();
        int B = sc.nextInt();

        System.out.println(solve(A, B));

        sc.close();
    }

    static String solve(int A, int B) {
        return (A + B >= 10) ? "error" : String.valueOf(A + B);
    }
}

Measured memory_bytes: 23124
H, W, *SS = open(0).read().split()
H, W = int(H), int(W)

R = [[0]*(W) for _ in [0]*(H)]
C = [[0]*(W) for _ in [0]*(H)]

for i, S in enumerate(SS):
    cnt = 0
    pre = S[0]
    for j, s in enumerate(S):
        if s == '.':
            cnt += 1
        else:
            if pre == '.':
                for k in range(1, cnt+1):
                    R[i][j-k] = cnt
                cnt = 0
        pre = s
    if pre == '.':
        for k in range(1, cnt+1):
            R[i][-k] = cnt

for j in range(W):
    cnt = 0
    pre = SS[0][j]
    for i in range(H):
        s = SS[i][j]
        if s == '.':
            cnt += 1
        else:
            if pre == '.':
                for k in range(1, cnt+1):
                    C[i-k][j] = cnt
                cnt = 0
        pre = s
    if pre == '.':
        for k in range(1, cnt+1):
            C[-k][j] = cnt

ans = 0
for i in range(H):
    for j in range(W):
        if R[i][j] and C[i][j]:
            area = R[i][j]+C[i][j]-1
            if ans < area:
                ans = area
print(ans)

Measured memory_bytes: 141416
#include <bits/stdc++.h>
#include <atcoder/segtree>
#include <cstdio>
#include <vector>

using namespace std;
using namespace atcoder;

int op(int a, int b) { return max(a, b); }

int e() { return 0; }

int main(){
    int n,k,x;
    cin >> n >> k;
    vector<int> a(300001);
    segtree<int,op,e> seg(a);
    int dp[300001];
    int ans = 0;
    for(int i = 0; i < n; i++){
        cin >> x;
        int temp = seg.prod(max(0,x-k),min(x+k+1,300001));
        dp[i] = temp+1;
        seg.set(x,dp[i]);
        ans = max(dp[i],ans);
       // cout << dp[i] << " ";
    }
    cout << ans << endl;
}


Measured memory_bytes: 8540
#include <bits/stdc++.h>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int n, xs;
    int x[100000];
    int delta[100000];

    cin >> n >> xs;
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }

    sort(&x[0], &x[n - 1]);

    int d;
    if (abs(xs - x[0]) <= abs(x[n-1] - xs)) {
        d = abs(xs - x[0]);
    } else {
        d = abs(x[n-1] - xs);
    }

    for (int i = 1; i < n; i++) {
        d = boost::math::gcd(d, (x[i] - x[i-1]));
    }

    cout << d << endl;

    return 0;
}


Measured memory_bytes: 640
N = int(input())
S = input()
ans = 0
count = [[0 for i in range(N)] for j in range(3)]
for i in range(N):
    if S[i] == 'R':
        count[0][i] = 1
    if S[i] == 'G':
        count[1][i] = 1
    if S[i] == 'B':
        count[2][i] = 1
for i in range(3):
    for j in range(N-1,0,-1):
        count[i][j-1] += count[i][j]
for i in range(N-2):
    a = S[i]
    for j in range(i+1,N-1):
        b = S[j]
        if a != b:
            if a != 'R' and b != 'R':
                ans += count[0][j]
                if 2*j-i < N and S[j+j-i] == 'R':
                    ans -= 1
            if a != 'G' and b != 'G':
                ans += count[1][j]
                if 2*j-i < N and S[j+j-i] == 'G':
                    ans -= 1
            if a != 'B' and b != 'B':
                ans += count[2][j]
                if 2*j-i < N and S[j+j-i] == 'B':
                    ans -= 1
print(ans)

Measured memory_bytes: 74588
def main():
    N, C, K = list(map(int, input().split()))
    T = [int(input()) for _ in range(N)]
    # 到着時刻が遅い人から貪欲に拾っていく
    T.sort(reverse=True)
    arrival_time_from = T[0] - K
    cnt_bus, cnt_passenger = 1, 0
    for t in T:
        if t >= arrival_time_from and cnt_passenger < C:
            cnt_passenger += 1
        else:
            arrival_time_from = t - K
            cnt_passenger = 1
            cnt_bus += 1
    print(cnt_bus)


if __name__ == '__main__':
    main()

Measured memory_bytes: 13300
#include<bits/stdc++.h>
using namespace std;
int main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);cout.tie(NULL);
        int x;
        cin>>x;
        for(int j=1;j<=8;j++){
                if(x>=2000-200*j && x<2000-200*(j-1)){
                        cout<<j;
                }
        }
return 0;
}
/*

        creation time:  15.09.2020 11:04:53

*/                      



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

int main(){
    int n, p_t, p_h;
    string card_t, card_h;
    p_t = 0;
    p_h = 0;
    
    cin >> n;
    
    for(int i = 0; i < n; i++){
        cin >> card_t >> card_h;
        
        if(card_t > card_h){
            p_t += 3;
            continue;
        }
        else if(card_t < card_h){
            p_h += 3;
            continue;
        }
        else{
            p_t++;
            p_h++;
            continue;
        }
    }
    
    cout << p_t << " " << p_h << endl;
    
    return 0;
}


Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
int main(){
    const int mod=1000000007;
    int n;
    cin>>n;
    int x[n+1]={};
    for(int i=2;i<=n;i++){
        int I=i;
        for(int j=2;j<=sqrt(I);j++){
            while(I%j==0){
                x[j]++;
                I/=j;
            }
        }
        if(I>1)x[I]++;
    }
    long long factor=1;
    for(int i=2;i<=n;i++){
        factor*=(x[i]+1);
        factor%=mod;
    }
    cout<<factor<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int _fib(int n, int target, int last, int last2) {
  if (n == target)
    return last + last2;
  else
    return _fib(n + 1, target, last + last2, last);
}

int fib(int n) {
  if (n == 0 or n == 1)
    return 1;
  else
    return _fib(2, n, 1, 1);
}

int main() {
  int n;
  cin >> n;
  cout << fib(n) << endl;
}


Measured memory_bytes: 3100
import java.util.*;
import java.awt.*;

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

    int n = sc.nextInt();
    String[] words = new String[n];
    String ans = "Yes";

    for (int i = 0; i < n; i++) {
      words[i] = sc.next();

      for (int j = 0; j < i; j++) {
        if (words[j].equals(words[i])) {
          ans = "No";
        }
      }
    }

    for (int i = 0; i < n-1; i++) {
      if (words[i].charAt(words[i].length()-1) != words[i+1].charAt(0)) {
        ans = "No";
      }
    }

    System.out.println(ans);
  }
}


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

int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	for(int i=0;i<N;i++){
	    cin >> a.at(i);
	}
	vector<int> s(N+1,0);
	for(int i=0;i<N;i++){
	    s.at(a.at(i))++;
	}
	vector<long long> C(N+1,0),D(N+1,0),f(N+1,0);
	long long E=0;
	for(int i=0;i<N;i++){
	    long long t=s.at(a.at(i));
	    C.at(a.at(i))=t*(t-1)/2;
	    D.at(a.at(i))=(t-1)*(t-2)/2;
	}
	for(int i=0;i<N;i++){
	   if(f.at(a.at(i))==0){
	       E+=C.at(a.at(i));
	       f.at(a.at(i))++;
	   }
	}
	for(int i=0;i<N;i++){
	    cout << E-C.at(a.at(i))+D.at(a.at(i)) << endl;
	}
}


Measured memory_bytes: 8832
#include <stdio.h>
#include <math.h>
 
int main()
{
    int i;
 
    int n;
    scanf("%d", &n);
    int x[n], y[n];
    for( i = 0; i < n; ++i )
        scanf("%d", &x[i]);
    for( i = 0; i < n; ++i )
        scanf("%d", &y[i]);
 
    int p;
    double D;
    for( p = 1; p < 4; ++p ){
        D = 0;
        for( i = 0; i < n; ++i )
            D += (double)(pow(fabs(x[i] - y[i]), p));
        D = (double)pow(D, 1.0/p);
        printf("%lf\n", D);
    }
 
    D = 0;
    for( i = 0; i < n; ++i ){
        double tmp = (double)(fabs(x[i] - y[i]));
        D = D < tmp ? tmp : D;
    }
    printf("%lf\n", D);
 
    return 0;
}

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

int main(){
  int x, y;
  cin >> x >> y;
  string ans = "No";
  for (int a = 0; a < x + 1; a++){
    int b = x - a;
    if (2 * a + 4 * b == y){
      ans = "Yes";
      break;
    }
  }
  cout << ans;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
using ll = long long;

using namespace std;



int main() {
    int x;
    cin >> x;
    int s = x/100;
    int t = x % 100;
    if(t > s*5) {
        cout << 0 << endl;
        return 0;
    }
    while(s > 0) {
        t -= 5;
        --s;
    }
    if(t > 0) {
        cout << 0 << endl;
        return 0;
    }
    cout << 1 << endl;

    return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll=long long;

int main(){
    ll N;
    cin>>N;
    vector<ll> A(N,0);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    sort(A.begin(),A.end(),greater<ll>());
    ll sum=0;
    for(int i=0;i<N-1;i++){
        sum+=A[(i+1)/2];
    }
    cout<<sum<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

const auto MAX_N = 1001;
const auto P = (ll) 1e9 + 7;

ll factorial_count(ll N) {
    vector<int> count(MAX_N, 0);

    for (int i = 2; i <= N; i++) {
        int t = i;
        for (int p = 2; p <= t; ++p) {
            while (t % p == 0) {
                count[p]++;
                t /= p;
            }
        }
    }

    ll ans = 1;
    for (auto x : count) {
        ans = ans * (x + 1) % P;
    }
    return ans;
}

int main() {
    ll N;
    cin >> N;
    ll ans = factorial_count(N);
    cout << ans << endl;
}

Measured memory_bytes: 256
#ax+by=c
#dx+ey=f
#
#->x=(ce-bf)/(ae-bd),y=(af-cd)/(ae-bd)
#
def maru(f):
	if f>=0:
		sgn="+"
	else:
		sgn="-"
	f=abs(f)
#
	f*=1000
	f_int  =f-f%1
	f_float=f%1
#	
	if f_float>=0.5:
		f_int+=1
	else:
		pass
#
	f=int(f_int)
	if f%1000==0:
		s="000"
	else:
		s=f%1000
	if sgn=="-":
		p="-"+str(f//1000)+"."+str(s)
	else:
		p=str(f//1000)+"."+str(s)
	return p

##########################################
#test_sisyagonyuu
#while True:
#	k=float(input())
#	print("k=",k)
#	print("maru(k)=",maru(k))
##########################################
ans=[]
while True:
	try:
		a,b,c,d,e,f=list(map(float,input().split(" ")))
		if c*e-b*f==0:
			x=0
		else:
			x=(c*e-b*f)/(a*e-b*d)
		if a*f-c*d==0:
			y=0
		else:
			y=(a*f-c*d)/(a*e-b*d)
		ans.append(maru(x)+" "+maru(y))
	except:
		break

for i in ans:
	print(i)

Measured memory_bytes: 7532
N = gets.to_i
vs = gets.split.map(&:to_i)
hashes = Array.new(2){Hash.new(0)}
hashes[0][0] = 0
hashes[1][0] = 0

N.times do |i|
    hashes[i%2][vs[i]] += 1
end

a1 = hashes[0].to_a.sort_by{|a| -a[1]}
a2 = hashes[1].to_a.sort_by{|a| -a[1]}
if a1[0][0] != a2[0][0]
    num = a1[0][1] + a2[0][1]
else
    num = [a1[0][1] + a2[1][1], a1[1][1] + a2[0][1]].max
end
puts N - num

Measured memory_bytes: 21488
#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 <<"No";
  }else if(S.at(0)==S.at(1) && S.at(2)==S.at(3)){
    cout <<"Yes";
  }else if(S.at(0)==S.at(2) && S.at(1)==S.at(3)){
    cout <<"Yes";
  }else if(S.at(0)==S.at(3) && S.at(1)==S.at(2)){
    cout <<"Yes";
  }else{
    cout <<"No";
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define ll long long
//#define cccgift
#define lowbit(x) ((x)&-(x))
#define rep(i,l,r) for(res i=l,_r=r;i<=_r;++i)
#define per(i,r,l) for(res i=r,_l=l;i>=_l;--i)
#define mkp make_pair
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem0n(a,n) memset(a,0,n*sizeof(a[0]))
#define iter(x,v) for(res v,_p=head[x];v=ver[_p],_p;_p=nxt[_p])
#ifdef cccgift //by lqh
#define SHOW(x) cerr<<#x"="<<(x)<<endl
#else
#define SHOW(x) 0
#endif
//#define getchar()(ip1==ip2&&(ip2=(ip1=ibuf)+fread(ibuf,1,1<<21,stdin),ip1==ip2)?EOF:*ip1++)
//char ibuf[1<<21],*ip1=ibuf,*ip2=ibuf;
template<typename T>
inline void read(T &x)
{
    static char ch;bool f=1;
    for(x=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') f=0;
    for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=getchar());x=f?x:-x;
}
template<typename T>
void print(T x)
{
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
template<typename T>
inline void print(T x,char ap) {print(x);if (ap) putchar(ap);}
template<typename T>
inline void chkmax(T &x,const T &y) {x=x<y?y:x;}
template<typename T>
inline void chkmin(T &x,const T &y) {x=x<y?x:y;}
const int mod=1e9+7;
int n,a,b,f[5010][2],g[5001][2],h[5001];
#define inc(x,y) x+=y,x>=mod?x-=mod:0
inline int kuai(int p,int q,int mod) {int tot=1;for(;q;p=(ll)p*p%mod,q>>=1) if(q&1) tot=(ll)tot*p%mod;return tot;}
int main()
{
	read(n),read(a),read(b);if(a>b) swap(a,b);
	g[0][0]=g[0][1]=h[0]=1;
	rep(i,1,b) {
		rep(j,0,i-1) {
			if(i-j>=a) inc(g[i][0],g[j][1]);
			inc(g[i][1],g[j][0]);
		}
		h[i]=(g[i][0]+g[i][1])%mod;
	}
	f[0][0]=f[0][1]=1;
	rep(i,1,n) {
		rep(j,max(i-a+1,0),i-1) inc(f[i][0],f[j][1]);
		if(i<n) {
			rep(j,max(i-b+1,0),i-1) {
				int now=(j==i-1)?1:h[j?(i-j-2):(i-1)];
				inc(f[i][1],(ll)f[j][0]*now%mod);
			}	
		}
		else {
			rep(j,max(i-b+1,0),i-1) inc(f[i][1],(ll)f[j][0]*h[i-j-1]%mod);
		}
	}
	int now=(f[n][0]+f[n][1])%mod;
	print((kuai(2,n,mod)-now+mod)%mod,'\n');
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do something instead of nothing and stay organized
*/ 

Measured memory_bytes: 3636
import java.util.*;

public class Main {
  public static void main(String[] args) {
    @SuppressWarnings("resource")
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    int count = 0;

    for (char c : str.toCharArray()) {
      count = (c == '1') ? count + 1 : count;
    }

    System.out.println(count);
  }
}

Measured memory_bytes: 21844
#include "bits/stdc++.h"
using namespace std;
long long n;
int ans = 0;
int main()
{
	cin>>n;
	for(long long i = 2ll; i * i <= n; i++)
	{
		int cnt = 0;
		while(n % i == 0ll)
		{
			cnt++;
			n /= i;
		}
		int now = 1, res = 0;
		while(1)
		{
			if(cnt < now)
				break;
			cnt -= now;
			res++;
			now++;
		}
		ans += res;
	}
	if(n > 1ll)
		ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3640
N, Ma, Mb = map(int, input().split())
items = []
for i in range(N):
    a, b, c = map(int, input().split())
    items.append((a, b, c))

a_sum = sum([item[0] for item in items])
b_sum = sum([item[1] for item in items])
inf = float("inf")
dp = [[[inf for _ in range(a_sum + 100)] for _ in range(b_sum + 100)] for i in range(N+1)]
dp[0][0][0] = 0

for i in range(N):
    for a in range(a_sum + 1):
        for b in range(b_sum + 1):
            dp[i + 1][a][b] = min(dp[i + 1][a][b], dp[i][a][b])
            dp[i + 1][a + items[i][0]][b + items[i][1]] = min(dp[i + 1][a + items[i][0]][b + items[i][1]],
                                                              dp[i][a][b] + items[i][2])
ans = inf
for a in range(1, a_sum + 1):
    for b in range(1, b_sum + 1):
        if a * Mb == b * Ma:
            ans = min(ans, dp[N][a][b])
if ans != inf:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 139740
#include<bits/stdc++.h>
#define lson (o<<1)
#define rson (o<<1|1)
#define fi first
#define sc second
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
using namespace std;
const double pi=acos(-1);
const double eps=1e-6;
inline int lowbit(int x){return x&(-x);}
inline int read(){
	int f=1,x=0;char ch;
	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
	do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
	return f*x;
}
template<typename T> inline T max(T x,T y,T z){return max(max(x,y),z);}
template<typename T> inline T min(T x,T y,T z){return min(min(x,y),z);}
template<typename T> inline T sqr(T x){return x*x;}
template<typename T> inline void checkmax(T &x,T y){x=max(x,y);}
template<typename T> inline void checkmin(T &x,T y){x=min(x,y);}
template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}
template<typename A,typename B,typename C> inline A fpow(A x,B p,C yql){
	A ans=1;
	for(;p;p>>=1,x=1LL*x*x%yql)if(p&1)ans=1LL*x*ans%yql;
	return ans;
}
struct FastIO{
	static const int S=1310720;
	int wpos;char wbuf[S];
	FastIO():wpos(0){}
	inline int xchar(){
		static char buf[S];
		static int len=0,pos=0;
		if(pos==len)pos=0,len=fread(buf,1,S,stdin);
		if(pos==len)return -1;
		return buf[pos++];
	}
	inline int read(){
		int c=xchar(),x=0;
		while(c<=32&&~c)c=xchar();
		if(c==-1)return -1;
		for(;'0'<=c&&c<='9';c=xchar())x=x*10+c-'0';
		return x;
	}
}io;
//#define read io.read
int main()
{
	int a,b,c,sum=0;
	cin >> a >> b >> c;
	for(int i=max(a,b);i>=1;i--)
	{
		if(a%i==0&&b%i==0) sum++;
		if(sum==c)
		{
			cout << i;
			break;
		}
	}
	return 0;
}



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

#define int long long

#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define low(a,b) lower_bound(all(a),(b))
#define upp(a,b) upper_bound(all(a),(b))
#define fill(i,n) memset(i,n,sizeof(i))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<vint> vvint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;

int N,K;
int dp[55];
int pdp[55];
signed main() {
    IOS();
    cin>>N>>K;
    pdp[0]=dp[0]=1;
    rep(i,0,50){
        pdp[i+1]=2*pdp[i]+1;
        dp[i+1]=2*dp[i]+3;
    }
    int cnt=N;
    int ans=0;
    int x=0;
    while(K){
        if(K>=dp[cnt]){
            K-=dp[cnt];
            ans+=pdp[cnt];
        }else{
            if(K>=dp[cnt-1]+2){
                K-=dp[cnt-1]+2;
                ans+=pdp[cnt-1]+1;
            }else K--;
            cnt--;
        }
    }
    cout<<ans<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    




















































    return 0;
}

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

int main(){
    double N;
    cin >> N;
    double a= 0;
    for(int i = 1;i <= N;i++){
        if(i % 2 == 1){
            a += 1 / N;
        }
    }
    printf("%.10f\n",a);
    return 0;
    }

Measured memory_bytes: 256