akhauriyash/Code-Regression huggingface dataset:
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,z,w = inm()
a = inl()
a[0:0] = [w]
f = [0]*n
g = [0]*n
f[n-1] = g[n-1] = minf = maxg = abs(a[n]-a[n-1])
for i in range(n-2,-1,-1):
    f[i] = max(maxg, abs(a[i]-a[n]))
    g[i] = min(minf, abs(a[i]-a[n]))
    minf = min(minf, f[i])
    maxg = max(maxg, g[i])
print(f[0])


Measured memory_bytes: 40048
#include<stdio.h>

int main(void)
{
	int a[7], b, c, i;
	for (i = 0;i < 7;i++)
	{
		scanf("%d %d", &b, &c);
		a[i] = b - c;
	}
	for (i = 0;i < 7;i++)
	{
		printf("%d\n", a[i]);
	}
	return 0;
}

Measured memory_bytes: 600
S = input()
acgt = ('A', 'C', 'G', 'T')
right = 0
res = -1
for left in range(len(S)):
    while right < len(S) and S[right] in acgt:
        right += 1
    res = max(res, right - left)
    if left == right:
        right += 1
print(res)


Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Pair = System.Collections.Generic.KeyValuePair<long, long>;

namespace CF2016C_CC
{
    class Program
    {
        static long N;
        static long mod = 1000000007;
        static void Main(string[] args)
        {
           
            N = scan[0];
            var T = scan;
            var A = scan;
            var ans = new long[N];
            var G = new long[N];
           

            ans[0] = T[0];
            for (long i = 1; i < N; i++)
            {
                if (T[i] != T[i-1])
                {
                    ans[i] = T[i];
                }
                else
                {
                    G[i] = T[i];
                }
            }


            if (ans[N - 1] == 0)
            {
                if (A[N - 1] > G[N - 1])
                {
                    Console.WriteLine(0);
                    return;
                }
            }
            else
            {
                if (A[N - 1] != ans[N-1])
                {
                    Console.WriteLine(0);
                    return;
                }
            }

            ans[N - 1] = A[N - 1];
          
            for (long i = N -2; i >= 0; i--)
            {
                if (A[i] != A[i + 1])
                {
                    if (ans[i] == 0)
                    {
                        if (A[i] > G[i])
                        {
                            Console.WriteLine(0);
                            return;
                        }
                    }
                    else
                    {
                        if (A[i] != ans[i])
                        {
                            Console.WriteLine(0);
                            return;
                        }
                    }
                    ans[i] = A[i];
                }

                else
                {
                    if (ans[i] == 0)
                    {
                        G[i] = Math.Min(G[i], A[i]);
                    }
                    else
                    {
                        if (A[i] < ans[i])
                        {
                            Console.WriteLine(0);
                            return;
                        }
                       
                    }
                }
            }

            long sum = 1;

            for (int i = 0; i < N; i++)
            {
                if (ans[i] == 0)
                {
                    //Console.WriteLine(G[i].Value+" "+i);
                    sum *= G[i];
                }
                
                sum %= mod;
            }
            Console.WriteLine(sum);

        }

        static long[] scan { get { return Array.ConvertAll(Console.ReadLine().Split(), long.Parse); } }
    }
}


Measured memory_bytes: 24400
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	vector<int>h;
	for(int i=0;i<n;i++)
	{
		int input;
		cin>>input;
		h.push_back(input);
	}
	int dp[n+1]={INT_MAX};
	for(int i=0;i<=n;i++)
	{
		dp[i]=INT_MAX;
	}
	dp[1]=0;
	for(int i=2;i<=n;i++)
	{
		for(int j=1;j<=k;j++)
		{
		if (j<i)
		dp[i]=min(dp[i],dp[i-j]+abs(h[i-j-1]-h[i-1]));
		else
		break;	
		}
		
	}
	cout<<dp[n];
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define ALL(obj) (obj).begin(),(obj).end()
#define space <<" "<<
#define ll long long
#define bpm %1000000007

using namespace std;

ll powAns(ll,ll);

int main(){
    int r,c,s;
    cin>>r>>c;
    int T[r+1][c+1];
    rep(i,r){
        s=0;
        rep(j,c){
        cin>>T[i][j];
        s+=T[i][j];
        }
    T[i][c]=s;
    }
    rep(i,c+1){
        s=0;
    rep(j,r){
        s+=T[j][i];
    }
    T[r][i]=s;
    }
    rep(i,r+1){
        rep(j,c+1){
        if(j==c){
        cout<<T[i][j]<<endl;
        }else{
        cout<<T[i][j]<<" ";
        }
        }
    }
}

ll powAns(ll m ,ll n){
    ll res=1;
    while(n>0){
        if(n & 1)res = res*m bpm;

        m=m*m bpm;
        n>>=1;
    }

    return res;
}



Measured memory_bytes: 3096
#include<iostream>

using namespace std;

int main() {
	char a, b;
	bool t;
	cin >> a >> b;
	
	if (a == 'H') {
		if (b == 'H')t = true;
		else t=false;
	}
	else {
		if (b == 'H')t = false;
		else t = true;
	}

	if (t)cout << 'H' << endl;
	else cout << 'D' << endl;
	return 0;
}

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

int main(){
long long N,K,min,tmp;
  scanf("%lld %lld",&N,&K);
  min=N;
  tmp=N%K;
  if(tmp<=N){min=tmp;}
  tmp=llabs(K-tmp);
  if(tmp<=min){min=tmp;}
  printf("%lld",min);
  return 0;



}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
#define REP(i,m,n) for(LL i=(m);i<(n);i++)

int main(){
  int n;
  cin >> n;
  VS s(n);
  REP(i,0,n){
    cin >> s.at(i);
    if(s.at(i) == "Y"){
      cout << "Four" << endl;
      return 0;
    }
  }
  
  
  cout << "Three" << endl;
  
  return 0;
}


Measured memory_bytes: 3608
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 C = sc.nextInt();
		
		if((A-B) >= C) {
			System.out.print(0);
		} else if ((A-B) < C ) {
			System.out.print(C-(A-B));
		}
	}
}

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

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

    int k,n;
    cin>>k>>n;
    int mario[n];
    long sum=0;
    for(int i=0;i<n;i++){
        cin>>mario[i];
        sum+=mario[i];
    }
    if(k-sum<0)
        puts("-1");
    else
        cout<<k-sum;
}


Measured memory_bytes: 3696
#include <stdio.h>
#include <math.h>
int main(){
    int a, b, c, k, count = 0;
    scanf("%d%d%d", &a, &b, &c);
    scanf("%d", &k);
    while(a >= b){
        b = 2*b;
        count++;
    }
    while(b >= c){
        c = 2*c;
        count++;
    }
    if(count <= k)printf("Yes\n");
    else printf("No\n");
    return 0;
}

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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)

int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  string s, t;
  cin >> s >> t;
  int ans = 0;
  for (int i = 0; i < 3; i++) {
    if (s.at(i) == t.at(i)) ans++;
  }
  cout << ans << endl;

  return 0;
}



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

int main(){
double a[11],s;
int i;

while(scanf("%lf",&a[1])!=EOF){
s=0;
for(i=2;i<11;i++){
if(i%2==0){
a[i]=a[i-1]*2;
}
else if(i%2==1){
a[i]=a[i-1]/3;
}
}
for(i=1;i<11;i++){
s+=a[i];
}
printf("%f\n",s);
}

return 0;
}

Measured memory_bytes: 1076
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;


    void calc()
    {
        cin = new Scanner();
        string s = cin.next();
      if(s[0]==s[2])Console.WriteLine("Yes");
      else Console.WriteLine("No");
    }


}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}
 

Measured memory_bytes: 13140
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;


#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;
    
    input!{
        n: usize,
        c_vec: Chars,
    }

    if c_vec.iter().all_equal() {
        println!("0")
    } else {
        let mut r_pos = VecDeque::new();
        let mut w_pos = VecDeque::new();
        for i in 0..n {
            if c_vec[i] == 'R' {
                r_pos.push_back(i);
            } else {
                w_pos.push_back(i);
            }
        }
        // dbg!(&r_pos, &w_pos);

        let mut ans = 0;
        loop {
            let r_last = r_pos.pop_back().unwrap();
            let w_first = w_pos.pop_front().unwrap();

            if r_last < w_first {
                break;
            } else {
                r_pos.push_front(w_first);
                w_pos.push_back(r_last);
            }
            ans += 1;
        }

        println!("{}", ans)
    }
    println!("", );
}

fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}


Measured memory_bytes: 5200
#include<stdio.h>
#define MAX 100005
#define NIL -1

struct Node{int p,l,r;};
struct Node T[MAX];
int n,H,D[MAX];

int getDepth(int u){
  int d = 0;
  while(T[u].p != -1){
    u = T[u].p;
    d++;
  }

  return d;

}

void print(int u){
  int i=0,count = 0;
  printf("node %d: parent = %d, depth = %d, ",u,T[u].p,D[u]);
  if(T[u].p == -1){
    printf("root, [");
    if(T[u].l != -1 ){
      printf("%d",T[u].l);
      if(T[u].r != -1) printf(", %d",T[u].r);
      for (i=0; i<n; i++){
	if(T[i].p==u && T[u].l!=i && T[u].r!=i){
	  printf(", %d",i);
	}       
      }
    }
    printf("]\n");
  }
  
  else{
    if(T[u].l != -1){
      printf("internal node, [%d",T[u].l);    
      if(T[u].r != -1 ){
	printf(", %d",T[u].r);

	for (i=0; i<n; i++){
	  if(T[i].p==u && T[u].l!=i && T[u].r!=i){
	    printf(", %d",i);
	  }
	}
      }
      printf("]\n");
    }
    else printf("leaf, []\n");
  }
}

  

main(){
  int i,j,d,v,c,l;

  scanf("%d",&n);

  for (i=0; i<n; i++) {
    T[i].p = T[i].l = T[i].r = NIL;
  }

  for (i=0; i<n; i++){
    scanf("%d %d",&v,&d);
    for (j=0; j<d; j++){
      scanf("%d",&c);
      if(j == 0){
	T[v].l = c;
	T[c].p = v;
      }
      else if(j == 1){
	T[v].r = c;
	T[c].p = v;
      }
      else T[c].p = v;
    }
  }

  for (i=0; i<n; i++){
    D[i] = getDepth(i);
  }

  for (i=0; i<n; i++) print(i);
  return 0;
}

Measured memory_bytes: 2172
import java.util.Scanner;

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

        for (int i = 0; i < n; i++) {
            if (sc.next().charAt(0) == 'Y') {
                System.out.println("Four");
                return;
            }
        }

        System.out.println("Three");
    }
}


Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt(), l = sc.nextInt();
		int sum = 0;
		int min = Integer.MAX_VALUE;
		int minIndex = 0;
		for(int i = 1; i <= n; i++) {
			int x = i + l - 1;
			if(Math.abs(x) < min) {
				minIndex = i;
				min = Math.abs(x);
			}
			sum += x;
		}
		
		System.out.println(sum - (l + minIndex - 1));
		
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S, T;
  cin >> S >> T;
  int j = 0;
  for (int i = 0; i < S.size(); i++)
  {
    if (S.at(i) == T.at(i))
    {
      j += 1;
    }
  }
  if (S.size() == j)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

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

int main(){
  int N,K;
  vector <int> A(100000);
  cin >> N >> K;
  int count = 0;
  for (int i = 0;i<N;i++){
    cin >> A[i];
    if(A[i] > K-1 ){
      count++;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 640
from math import gcd
from collections import defaultdict

N = int(input())
X = [list(map(int, input().split())) for _ in range(N)]

d = {}
for a, b in X:
    if a == b == 0:
        pass
    elif a == 0:
        if b > 0:
            b = 1
        else:
            b = -1
    elif b == 0:
        if a > 0:
            a = 1
        else:
            a = -1
    else:
        v = gcd(a, b)
        a //= v
        b //= v

    if a != 0 and a * b >= 0:
        pair = (abs(a), abs(b))
        if pair not in d:
            d[pair] = [0, 0]
        d[pair][0] += 1
    else:
        pair = (abs(b), abs(a))
        if pair not in d:
            d[pair] = [0, 0]
        d[pair][1] += 1

MOD = 10 ** 9 + 7
zero = 0
ans = 1
for p in d:
    if p == (0, 0):
        zero = d[p][1]
    else:
        a, b = d[p]
        ans *= pow(2, a, MOD) + pow(2, b, MOD) - 1
        ans %= MOD

print((ans + zero - 1) % MOD)


Measured memory_bytes: 146940
n,q = map(int,input().split())
s = input()
t,d = [],[]
for i in range(q):
    tt,dd = input().split()
    t.append(tt)
    d.append(dd)

def judge(k):#0:false 1:L 2:R
    pos = k
    posc = s[k]

    for i in range(q):
        if(t[i] != posc):continue
        if(d[i] == 'L'):
            pos -= 1
        else:
            pos += 1
        if pos == -1:
            return 1
        if pos == n:
            return 2
        posc = s[pos]

if(judge(0) != 1):ansl = 0
else:
    ll,rr = 0,n
    for i in range(100):
        if(rr -ll == 1): break
        
        md = (ll+rr) // 2

        if(judge(md) != 1) : rr = md
        else : ll = md
    ansl = ll+1

if(judge(n-1) != 2):ansr = 0
else:
    ll,rr = -1,n-1
    for i in range(100):
        if(rr -ll == 1): break
        
        md = (ll+rr) // 2

        if(judge(md) != 2) : ll = md
        else : rr = md
    ansr = n-rr

print(n-ansl-ansr)

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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N;
int a[440], acc[440];
int dp[440][440];
int dfs(int l, int r) {
    if (r - l == 1) { return 0; }
    if (dp[l][r] != 0) { return dp[l][r]; }
    dp[l][r] = LLONG_MAX;
    for (int i = l + 1; i < r; i++) { chmin(dp[l][r], dfs(l, i) + dfs(i, r)); }
    dp[l][r] += acc[r] - acc[l];
    return dp[l][r];
}
signed main() {
    cin >> N;
    rep(i, N) { cin >> a[i]; }
    rep(i, N) { acc[i + 1] = acc[i] + a[i]; }
    cout << dfs(0, N) << endl;
}


Measured memory_bytes: 4892
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

int main() {
    ll N[4];
    bool ok[4];
    fill(ok, ok + 4, false);
    REP(i, 0, 4) {
        cin >> N[i];
        if (N[i] == 1) {
            ok[0] = true;
        }
        if (N[i] == 9) {
            ok[1] = true;
        }
        if (N[i] == 7) {
            ok[2] = true;
        }
        if (N[i] == 4) {
            ok[3] = true;
        }
    }
    bool ans = true;
    REP(i, 0, 4) {
        if (!ok[i]) {
            ans = false;
        }
    }
    if (ans) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


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

using namespace std;

int main()
{
	int n;

	while (cin >> n) {
		int cnt = 0;

		for (int i = 0; i <= 9; ++i) {
			for (int j = 0; j <= 9; ++j) {
				for (int k = 0; k <= 9; ++k) {
					int a = n - i - j - k;
					if (0 <= a && a <= 9) cnt++;
				}
			}
		}

		cout << cnt << endl;
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    string s;
    long long k;
    cin >> s >> k;
    
    for(int i =0; i < s.length(); i++)
    {
        if(s[i] != '1')
        {
            if(k <= i)
            {
                cout << '1' << endl;
            }
            else
            {
                cout << s[i] << endl;
            }
            return 0;
        }
    }
    cout << '1' << endl;
    return 0;
}

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

using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf("%.12lf\n",mid);
// __builtin_popcount(int) count 1's in binary
// get decimal pert of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
int mod = 998244353;

long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}

/*string sentence = "And I feel fine...";
    istringstream iss(sentence);
*/  

double eps = .000000001;
bool cmp(const pair<int, int> &a, const pair<int, int> &b){
    if (a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second > b.second;
    }
}
int main ()
{
  prep();
  int n, m;
  cin >> n >> m;
  vector<pair<int, int> > v;
  for (int i=0; i<n; i++){
      int a, b;
      cin >> a >> b;
      v.emplace_back(a, b);
  }
  multiset<int> st;
  sort(v.begin(), v.end(), cmp);
  int days = 1;
  int cur = 0;
  long long p = 0;
  for (int i=0; i<m && days <= m; i++){
      while (cur < n && v[cur].first <= days){
          st.insert(v[cur].second);
          cur++;
      }
      if (st.size() == 0){
          days++;
          continue;
      }
      set<int>::iterator end = st.end();
      end--;
      p += *end;
      st.erase(end);
      days++;
  }
  cout << p;
  return 0; 
}

Measured memory_bytes: 5748
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0066
"""
import sys


def prepare_board(size=3):
    return [[1]*size for _ in range(size)]


def check_horizontal(status):
    dp = prepare_board()
    for y in range(len(status)):
        for x in range(1, len(status[0])):
            if status[y][x] == status[y][x-1]:
                dp[y][x] = dp[y][x-1] + 1
                if dp[y][x] == 3:
                    if status[y][x] != 's':
                        return status[y][x]
    return 'd'


def check_vertical(status):
    dp = prepare_board()
    for y in range(1, len(status)):
        for x in range(len(status[0])):
            if status[y][x] == status[y-1][x]:
                dp[y][x] = dp[y-1][x] + 1
                if dp[y][x] == 3:
                    if status[y][x] != 's':
                        return status[y][x]
    return 'd'


def check_diagonal(status):
    # ????????????????????????????§??????????????????§??????
    dp = prepare_board()
    for y in range(1, len(status)):
        for x in range(1, len(status[0])):
            if status[y][x] == status[y-1][x-1]:
                dp[y][x] = dp[y-1][x-1] + 1
                if dp[y][x] == 3:
                    if status[y][x] != 's':
                        return status[y][x]

    # ????????????????????????????§??????????????????§??????
    dp = prepare_board()
    for y in range(1, len(status)):
        for x in range(len(status[0])-2, -1, -1):
            if status[y][x] == status[y-1][x+1]:
                dp[y][x] = dp[y-1][x+1] + 1
                if dp[y][x] == 3:
                    if status[y][x] != 's':
                        return status[y][x]
    return 'd'


def solve(status):
    result = check_horizontal(status)
    if result != 'd':
        return result
    result = check_vertical(status)
    if result != 'd':
        return result
    return check_diagonal(status)


def main(args):
    for line in sys.stdin:
        # ??\???????????????3x3?????¶????????????????????????????§£?????¢??°?????????
        status = []
        line = line.strip()
        status.append(list(line[:3]))
        status.append(list(line[3:6]))
        status.append(list(line[6:]))
        result = solve(status)

        # ?????????????¨?
        print(result)

if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 7568
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <memory>
#include <queue>

using namespace std;

int N,M;

struct Edge {
    int src, dst, weight;
    Edge *next, *prev;
    Edge(int s, int d, int w, Edge *n, Edge *p)
        : src(s), dst(d), weight(w), next(n), prev(p) {}
    Edge() : Edge(0, 0, 0, nullptr, nullptr) {}

    void *operator new (size_t) {
        static char buf[500010*sizeof(Edge)];
        static int i = 0;
        Edge *res = (Edge*)(buf + i);
        i += sizeof(Edge);
        return res;
    }
};

vector<Edge*> first;

void add_edge(int u, int v, int d){
    Edge *next = first[u];
    first[u] = new Edge(u, v, d, next, nullptr);
    if(next != nullptr) next->prev = first[u];
}

int main(){
    int V,E,r;
    while(cin >> V >> E >> r){
        first.assign(V, nullptr);
        for(int i = 0; i < E; ++i){
            int s,t,d;
            cin >> s >> t >> d;
            add_edge(s,t,d);
        }

        using State = pair<int,int>;
        priority_queue<State> q;
        vector<long long> dist(V, 1e18);
        q.emplace(0,r);
        dist[r] = 0;

        while(q.size()){
            long long d,v;
            tie(d,v) = q.top();
            q.pop();
            d = -d;
            if(dist[v] < d) continue;
            for(Edge *e = first[v]; e != nullptr; e = e->next){
                if(dist[e->dst] > e->weight + dist[v]){
                    dist[e->dst] = e->weight + dist[v];
                    q.emplace(-dist[e->dst], e->dst);
                }
            }
        }

        for(int i = 0; i < V; ++i){
            if(dist[i] == 1e18) cout << "INF";
            else cout << dist[i];
            cout << '\n';
        }
    }
    
    // {
    //     vector<string> u, v;
    //     static char s[3000], t[3000];
    //     map<string,int> id;
    //     N = 0;
    //     M = 0;
    //     while(cin >> s >> t){
    //         u.push_back(s);
    //         v.push_back(t);
    //         if(id.count(s) == 0) id[s] = N++;
    //         if(id.count(t) == 0) id[t] = N++;
    //         ++M;
    //     }

    //     first.assign(N, nullptr);
    //     for(int i = 0; i < M; ++i){
    //         add_edge(id[u[i]], id[v[i]]);
    //     }
    // }
}

Measured memory_bytes: 20576
A, B, C, X, Y = tuple(map(int, input().split()))

# 大きな値で初期化
TOTAL_MIN = A * X + B * Y + C * (X+Y) * 2

for a in range(X + 1):
    c = (X - a) * 2
    if c // 2 < Y:
        if B < 2 * C:
            b = Y - c // 2
        else:
            b = 0
            c = max(c, Y * 2) 
    else:
        b = 0
    
    total_tmp = A * a + B * b + C * c
    if total_tmp < TOTAL_MIN:
        TOTAL_MIN = total_tmp
        

print(TOTAL_MIN)


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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define MSGF(x, n) MSG(fixed << setprecision(n) << x)
#define END(x) cout << x << endl; return(0);
#define IPT(v, n) REP(i, 0, n){ cin >> v[i]; }
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
const static ll INF = 1LL << 30;

ll a, b, c, d, k, l, m, n, h, w, q, x, y;
string s, t;

ll ans = 0;
ll sum = 0;
ll cnt = 0;
ll cur = 0;
ll tmp = 0;
ll mini = INF;
ll maxi = 0;

double ave = 0.0;

ll mod_pow(ll base, ll power) {
    if (power == 0) return 1;
    if (power == 1) return base % MOD;
    if (power % 2 == 0) return ((mod_pow(base % MOD, (power / 2)) % MOD) * (mod_pow(base, (power / 2)) % MOD)) % MOD;
    return (base % MOD * (mod_pow(base % MOD, power - 1) % MOD)) % MOD;
}

ll mod_fact(ll number) {
    ll ret = 1;
    ll count = 1;
    while (count <= number) {
        ret *= (count % MOD);
        ret %= MOD;
        count++;
    }
    return ret % MOD;
}

ll gcd(ll a, ll b) {
    if (a < b) {
        return gcd(b, a);
    }
    ll c = a % b;
    while (c != 0) {
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    cin >> s >> t;

    ans = 0;
    REP(i, 0, s.size()) {
        if (s.at(i) != t.at(i)) ans++;
    }
    MSG(ans)
}


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

template<class T> void chmax(T &a, T b) {
    if (a < b) a = b;
}

int main() {
    int N, W;
    cin >> N >> W;
    vector<int> weight(N), value(N);
    for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];

    vector<long long> dp(W+1, 0);
    for (int i = 0; i < N; ++i) {
        for (int w = W; w >= 0; --w) {
            if (w - weight[i] >= 0) {
                chmax(dp[w], dp[w - weight[i]] + value[i]);
            }
        }
    }
    cout << dp[W] << endl;
}


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

int main() {
int n;
cin >> n;
vector<int> b(n-1);
rep(i,n-1) cin >> b[i];
vector<int> a(n);
a[0] = b[0];
for(int i = 1; i <= n-2; i++)
{
	a[i] = min(b[i],b[i-1]);
}
a[n-1] = b[n-2];
int ans = 0;
rep(i,n) ans += a[i];
cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
 int r,g,b,n;
  cin>>r>>g>>b>>n;
  int ans=0;
  for(int i=0;i<=n/r;i++){
  	for(int j=0;j<=(n-r*i)/g;j++){
    	if((n-r*i-g*j)%b==0) ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
using namespace std;
int main() {
	int N;
	int d[110];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> d[i];
	}
	set<int> values;
	for (int i = 0; i < N; i++) {
		values.insert(d[i]);
	}
	cout << values.size() << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(int i=0;i<(n); ++i)
using namespace std;
typedef long long ll;


int main()
{
	string s, t;
	ll cnt = 0;
	cin >> s >> t;
	for (int i = 0; i < 3; i++) {
		if (s[i] == t[i])cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
H,W = map(int,input().split())
Ch,Cw = map(int,input().split())
Dh,Dw = map(int,input().split())
S = [list(input()) for i in range(H)]
 
res_S = [[-1]*W for i in range(H)]
dx = [1,-1,0,0]
ddx = [-2,-1,0,1,2,-2,-1,1,2,-2,2,-2,-1,1,2,-2,-1,0,1,2]
dy = [0,0,1,-1]
ddy = [-2,-2,-2,-2,-2,-1,-1,-1,-1,0,0,1,1,1,1,2,2,2,2,2]
count = 0
 
que = [(Ch,Cw)]
que_warp =[(Ch,Cw)]
res_S[Ch-1][Cw-1] = 0
 
while (que or que_warp):
    l = len(que)
    while (que):
        if l > 0:
            que_warp.append(que[0])
            l -= 1
        for i in range(4):
            nx = int(que[0][0]+dx[i])
            ny = int(que[0][1]+dy[i])
            if (1<=nx<=H) and (1<=ny<=W):
                if res_S[nx-1][ny-1]<0 and S[nx-1][ny-1]=='.':
                    res_S[nx-1][ny-1]=count
                    que.append((nx,ny))
                    que_warp.append((nx,ny))
        que.pop(0)
 
    count += 1
 
    while(que_warp):
        for i in range(len(ddx)):
            nx = int(que_warp[0][0] + ddx[i])
            ny = int(que_warp[0][1] + ddy[i])
            if (1 <= nx <= H) and (1 <= ny <= W):
                if res_S[nx-1][ny-1]<0 and S[nx-1][ny-1]=='.':
                    res_S[nx-1][ny-1] = count
                    que.append((nx, ny))
        que_warp.pop(0)
 
print (res_S[Dh-1][Dw-1])


Measured memory_bytes: 117932
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define putchar putchar_unlocked
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 18;
char cn[cm], *ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		C[keta] = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--) putchar(C[i]);
	putchar('\n');
}

int main() {
	int N;
	N = getint();
	int A[200001] = {};

	int mae = 0;
	int kotae = 1;
	int mod = 1e9 + 7;
	rep(i, N) {
		int C;
		C = getint();
		if (mae != C) kotae = (kotae + *(A + C)) % mod;
		*(A + C) = kotae;
		mae = C;
	}

	putint(kotae);

	Would you please return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <cstdlib>
#include <math.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;
const long long BIG_NUM = pow(10,9)+ 7;

template<class T> inline bool add(T& a, T b) { a += b; if (a > BIG_NUM) {a -= BIG_NUM;}}
// 入力
int h,w;
vector<string> map;
int dp[1010][1010] = {0};

int main() {
    cin >> h >> w;
    map.resize(h);
    for (int i=0;i<h;i++) {
        cin >> map[i];
    }
    // 初期化 

    // 初期条件
    dp[0][0] = 1;
    for (int i =0;i<h;i++) {
        for (int j=0;j<w;j++) {
            if (map[i][j] == '.') {
                add(dp[i][j+1], dp[i][j]);
                add(dp[i+1][j], dp[i][j]);
            }
        }
    }
    cout << dp[h-1][w-1] << endl;
}

Measured memory_bytes: 5248
n,m = [int(i) for i in input().split()]
s = [input().split()[1:] for _ in range(m)]
p = [int(i) for i in input().split()]

cnt = 0
for n_i in range(2**n):
    s_now = bin(n_i)[2:].zfill(n)
    #print(s_now)
    next_m = False

    for m_i in range(m):
        sum_tmp = 0
        for s_i in s[m_i]:
            sum_tmp += int(s_now[int(s_i)-1])
        #print(sum_tmp,p[m_i])
        if sum_tmp % 2 != p[m_i]:
            next_m = True
            break
    if next_m:
        continue
    cnt += 1

print(cnt)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

vector<int> G[200'010];
bool visited[200'010];
long long cnt[2];

void dfs(int v){
  if(visited[v])return;
  visited[v] = true;
  cnt[v/100'001] += 1;
  for(int next_:G[v]){
    dfs(next_);
  }
  return;
}

int main(){
  
  int n;
  cin>>n;
  bool exist[200'010] = {};
  REP(i,n){
    int x,y;
    cin>>x>>y;
    G[x].push_back(y+100'000);
    G[y+100'000].push_back(x);
    exist[x] = exist[y+100'000] = true;
  }
  
  long long ans = 0;
  REP(i,200'010){
    if(!exist[i])continue;
    if(visited[i])continue;
    dfs(i);
    ans += cnt[0]*cnt[1];
    cnt[0] = cnt[1] = 0;
  }
  
  ans -= (long long)n;
  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 9856
#include<iostream>
using namespace std;
int sum=0, n, a[53], b[53];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		b[i+1]=b[i]+a[i];
	}
	for(int i=0;i<n;i++){
		sum+=(a[i]*b[i]);
	}
	cout<<sum<<endl;
	return 0;
}

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

#define fir first
#define sec second
using namespace std;
typedef long long LL;
typedef unsigned long long u64;

template <typename T> inline bool cmin(T & a, const T & b) { return a > b ? a = b, 1 : 0;}
template <typename T> inline bool cmax(T & a, const T & b) { return a < b ? a = b, 1 : 0;}
int gint() {
	int x = 0, f = 1;char ch;
	for(ch = getchar(); !isdigit(ch); ch = getchar())
		if(ch == '-') f = -1;
	for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
	return x * f;
}

const int MaxN = 1001234;

int n; char s[MaxN], t[MaxN];
int H[MaxN << 1], *h = H;

int main() {
	int i;
	scanf("%d %s %s", &n, s + 1, t + 1);
	if(!strcmp(s + 1, t + 1)) return puts("0"), 0;
	
	int l, r, d, ans;
	l = n + 1; r = n; d = ans = 0;
	for(i = n; i; i--) {
		if(t[i] == t[i - 1]) continue;
		int x, p;
		for(x = min(l - 1, i); x && s[x] != t[i]; x--);
		if(!x) return puts("-1"), 0;
		for(p = i; t[p + 1] == t[i]; ++p);
		for(; l > x; h[--l] = -d);
		for(; r >= p; cmax(ans, h[r--] + d));
		++h; ++d;
	}	
	for(; l > 1; h[--l] = -d);
	for(; r >= 1; cmax(ans, h[r--] + d));
	cout << ans;
	return 0;
}


Measured memory_bytes: 7680
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();
            var N = input[0];
            var K = input[1];
            var h = ReadArrayInt();
            var ans = Enumerable.Repeat(int.MaxValue, N).ToArray();
            ans[0] = 0;
            for (int i = 0; i < N - 1; i++)
            {
                for (int j = i+1; j <= i + K && j < N; j++)
                {
                    if (ans[i] + Math.Abs(h[i] - h[j]) < ans[j]) ans[j] = ans[i] + Math.Abs(h[i] - h[j]);
                }
            }

            Console.WriteLine(ans[N - 1]);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 19552
function Main(input) {

    input = input.split("\n");
    
    var regex = /s$/g;
    var a = input[0].match(regex);

    var plural;

    if(a != null) {
        plural = input[0] + 'es';
    } else {
        plural = input[0] + 's';
    }

    console.log(plural);

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 29636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
typedef long long int64;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; } return 0; }
#include <chrono>

int n = 4;
int k = 8;
int MAX_N = 4;
vi a = { 1, 2, 4, 7 };

bool dfs(int i, int sum) {
	if (i == n) {
		cout << 1 << " " << i << " " << sum << endl;
		return sum == k;
	}
	// a[i]を使わない場合
	if (dfs(i + 1, sum)) {
		cout << 2 << " " << i << " " << sum << endl;
		return true;
	}
	// a[i]を使う場合
	if (dfs(i + 1, sum + a[i])) {
		cout << 3 << " " << i << " " << sum << endl;
		return true;
	}
	// a[i]を使う使わないに拘わらずkが作れないのでfalseを返す
	cout << 4 << " " << i << " " << sum << endl;
	return false;
}
void solve() {
	if (dfs(0, 0)) cout << "Yes" << endl;
	else cout << "No" << endl;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	string str;
	cin >> str;
	rep(i, str.length()) {
		if (str.at(i) == '7') {
			Yes;
		}
	}
	No;

	return 0;
}


Measured memory_bytes: 3612
from collections import Counter
from functools import reduce

n = int(input())
a = list(map(int, input().split()))

count = Counter((a))
len_count = len(count)

if len_count >= 4:
    print("No")
elif len_count == 1:
    if a[0] == 0:
        print("Yes")
    else:
        print("No")
elif len_count == 3:
    count_count = Counter(count.values())
    if len(count_count) == 1 and reduce(lambda x, y: x ^ y, count.keys()) == 0:
        print("Yes")
    else:
        print("No")
else:
    if count[0] * 3 == len(a):
        print("Yes")
    else:
        print("No")



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

typedef long long ll;


int main()
{
    int N;
    string tmp1;
    int tmp2;
    vector < pair<string, int> > sp, sp2;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> tmp1 >> tmp2;
        sp.push_back(make_pair(tmp1, -1*tmp2));
        sp2.push_back(make_pair(tmp1, -1*tmp2));
    }
    sort(sp.begin(), sp.end());

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (sp[i].first == sp2[j].first && sp[i].second == sp2[j].second) {
                cout << j+1 << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Volume5_0506
{
	class Program
	{
		static void Main(string[] args)
		{
			string before_string = "";
			string next_string = "";
			int count;
			StringBuilder str = new StringBuilder("");

			while (true)
			{
				try
				{
					//Console.WriteLine("操作回数を入力してください。(≦20,0:終了)");
					int repeat = int.Parse(Console.ReadLine());
					if (repeat == 0)
					{
						break;
					}
					else
					{
						//Console.WriteLine("操作するデータを入力してください。(≦100)");
						string data = Console.ReadLine();
						for (int i = 0; i < repeat; i++)
						{
							count = 1;
							for (int j = 0; j < data.Length; j++)
							{
								before_string = data.Substring(j, 1);
								try
								{
									next_string = data.Substring(j + 1, 1);
								}
								catch
								{
									next_string = "";
								}
								if (before_string == next_string)
								{
									count++;
								}
								else
								{
									str.Insert(str.Length, count);
									str.Insert(str.Length, before_string);
									count = 1;
									if (j == data.Length - 1 )
									{
										data = str.ToString();
										str.Remove(0,str.Length);
										break;
									}
								}
							}
						}
						Console.WriteLine("{0}", data);
					}
				}
				catch
				{
					//Console.Write("エラー");
					break;
					
				}

			}
			//Console.WriteLine("終了");
			//Console.ReadKey();
		}
	}
}



Measured memory_bytes: 28820
#include <iostream>
#include <string>
#include <algorithm>
 
int main() {
  std::string s;
  std::cin >> s;
  std::string b(s.length(), '1'), w(s.length(), '0');
  long long bc = 0, wc = 0;
  for (long long i = 0; i < s.length(); i++) {
    if (i % 2 == 1) {
      b[i] = '0';
      w[i] = '1';
    } else {
      b[i] = '1';
      w[i] = '0';
    }
  }
  for (long long i = 0; i < s.length(); i++) {
    if (s[i] != b[i]) {
      bc++;
    }
    if (s[i] != w[i]) {
      wc++;
    }
  }
  std::cout << std::min(bc, wc) << "\n";
  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
  int n;
  double ans;
  scanf("%d",&n);
  
  if(n == 1) ans = 1.000000;
  else if(n %2 == 0) ans = 0.5000000;
  else if(n %2 == 1) ans = (n / 2 + 1) / (double)n;

  printf("%17.12lf\n",ans);
  
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main (){
  int a,b[110],c;
  cin >> a >>c;
  
  for(int i=0;i<a;i++)
    cin >> b[i];
  
  sort(b,b+a);
  
  for(int i=0;i<a;i++){
    
    if(c < b[i]){
     cout << i << endl;
      
      return 0;
    }
   
  c -= b[i];
  }
  
if(c !=0){
  cout << a-1 << endl;
}
  
  else{
    cout << a << endl;
  }

}
  
    


Measured memory_bytes: 256