akhauriyash/Code-Regression huggingface dataset:
def IsEvenString(sl):
    Nsl = len(sl)
    if Nsl%2 is not 0:
        return False
    else:
        if sl[:Nsl//2] == sl[-Nsl//2:]:
            return True
        else:
            return False

S = input()

LS = len(S)
i = LS%2
j = LS // 2
N = 0
for k in range(1,j):
    # print(S[:LS-2*k+i])
    if IsEvenString(S[:LS-2*k+i]):
        N = LS-2*k+i
        break

# print(IsEvenString(S))
print(N)
    



Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <iomanip> // setprecisionを使用するのに必要 cout << fixed << setprecision(15) << p でpを小数点以下15桁表示
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
#define DIV0 1000000007
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
/*

*/
int main()
{
    string s1,s2;
    cin >> s1 >> s2;
    int ans = 0;
    REP(i,s1.length()){
        if(s1[i] != s2[i]){
            ans++;
        }
    }
    fin(ans);
    return 0;
}

Measured memory_bytes: 3464
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
using namespace std;
struct unionfindtree {
    vector<int> par,rank,kids;
    unionfindtree(int n):par(n),rank(n,0),kids(n,1) {
        rep(i,n) par[i] = i;
    }
    int root(int n) {
        if(par[n] == n) return n;
        else return par[n] = root(par[n]);
    }
    bool same(int i,int j) {
        return root(i) == root(j);
    }
    void unite(int i,int j) {
        int ri = root(i);
        int rj = root(j);
        if(ri == rj) return;

        if(rank[ri] < rank[rj]) {
            par[ri] = rj;
            kids[rj] += kids[ri];
            kids[ri] = 0;
        } else {
            par[rj] = ri;
            kids[ri] += kids[rj];
            kids[rj] = 0;
            if(rank[ri] == rank[rj]) rank[ri]++;
        }
    }
};

int main() {
    int n,m,k;
    cin >> n >> m >> k;
    unionfindtree ufr(n);
    vector<set<int>> s(n);
    rep(i,m) {
        int a,b;
        cin >> a >> b;
        a--; b--;
        s[a].insert(b);
        s[b].insert(a);
        ufr.unite(a,b);
    }
    rep(i,k) {
        int c,d;
        cin >> c >> d;
        c--; d--;
        if(ufr.same(c,d)) {
            s[c].insert(d);
            s[d].insert(c);
        }
    }
    vector<int> ans(n);
    rep(i,n) {
        int nans = ufr.kids[ufr.root(i)]-1;
        nans -= s[i].size();
        ans[i] = nans;
    }
    rep(i,n-1) cout << ans[i] << " ";
    cout << ans[n-1] << endl;
}

Measured memory_bytes: 25856
/*
  
                                _oo0oo_
                               088888880
                               88" . "88
                               (| -_- |)
                                0\ = /0
                             ___/'---'\___
                          .' \\\\|     |// '.
                         / \\\\|||  :  |||// \\
                        /_ ||||| -:- |||||-  \\
                        |   | \\\\\\  -  /// ||
                        | \_|  ''\---/''  |_/ |
                        \  .-\__  '-'  __/-.  /
                      ___'. .'  /--.--\  '. .'___
                   ."" '<  '.___\_<|>_/___.' >'  "".
                  | | : '-  \'.;'\ _ /';.'/ - ' : | |
                  \  \ '_.   \_ __\ /__ _/   .-' /  /
              ====='-.____'.___ \_____/___.-'____.-'=====
                                '=---='

            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
             AC  AC  AC  AC  AC  AC  AC  AC  AC  AC  AC  AC
     
*/
#define OJ
#include <bits/stdc++.h>
#define pb push_back
#define _1 first
#define _2 second
#define FOR(i,a,b) for(int i=a;i<(b);i++)
#define FORN(i,b) for(int i=0;i<(b);i++)
#define reset(a,b) memset(a,b,sizeof(a))
#define MAX(a,b)  a>b?a:b
#define MIN(a,b)  a>b?b:a
#define INF 100000
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int> > vii;

int main()
{
	#ifndef OJ
	freopen("abc.in","r",stdin);
	freopen("abc.out","w",stdout);
	#endif
  int n,a[100];
  cin>>n;
  int i,min=INF,max=-INF,j;
  for(i=0;i<n;i++)
  {
    cin>>j;
    if(j>max) max=j;
    if(j<min) min=j;
  }
  cout<<max-min;
	#ifndef OJ
	fclose(stdin);
	fclose(stdout);
	#endif
  return 0;
}

Measured memory_bytes: 256
from collections import deque

N, T, A, *AB = map(int, open(0).read().split())

E = [[] for _ in range(N + 1)]
for a, b in zip(*[iter(AB)] * 2):
    E[a].append(b)
    E[b].append(a)

takahashi = [-1] * (N + 1)
takahashi[T] = 0
Q = deque([T])
while Q:
    a = Q.popleft()
    for b in E[a]:
        if takahashi[b] != -1:
            continue
        takahashi[b] = takahashi[a] + 1
        Q.append(b)

aoki = [-1] * (N + 1)
aoki[A] = 0
Q = deque([A])
while Q:
    a = Q.popleft()
    for b in E[a]:
        if aoki[b] != -1:
            continue
        aoki[b] = aoki[a] + 1
        Q.append(b)

ma = 0
for t, a in zip(takahashi[1:], aoki[1:]):
    if t < a:
        ma = max(ma, a)

print(ma - 1)


Measured memory_bytes: 32500
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
using namespace std;
char s[101],t[101];
int main(){
    cin>>s>>t;
    int s_len=strlen(s);
    int t_len=strlen(t);
    sort(s,s+s_len);
    sort(t,t+t_len,greater<char>());
    for(int i=0;i<t_len;i++){
        if(i>=s_len||s[i]<t[i]){
            cout<<"Yes";
            return 0;
        }if(s[i]>t[i]){
            cout<<"No";
            return 0;
        }
    }
    cout<<"No";
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<cstring>
#include<algorithm>

#define L(x) (x<<1)
#define R(x) (x<<1|1)
#define ll long long
using namespace std;

const int M=220,inf=1e8;
const double z=1e-6;

bool is(int x)
{
    int ct=0;
    while(x)
    {
        ct++;
        x/=10;
    }
    return ct%2;
}

int main()
{
    int n,ans=0;
    cin>>n;
    for(int i=1;i<=n;i++)if(is(i))ans++;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
#define pb push_back
#define INF 1e10
using namespace std;

struct edge { int v, d, c; };
struct state {
  int n, p, v;
  double t;
  bool operator<(const state &s) const {
    return t > s.t;
  }
};

int N, M, S, G, X, Y, D, C;
vector<edge> E[50];
double dp[50][50][50];

int main(void) {
  while(cin >> N >> M, N || M) {
    cin >> S >> G; S--; G--;
    REP(i, 0, 50) E[i].clear();
    REP(i, 0, M) {
      cin >> X >> Y >> D >> C; X--; Y--;
      E[X].pb((edge) { Y, D, C });
      E[Y].pb((edge) { X, D, C });
    }

    priority_queue<state> q;
    REP(i, 0, E[S].size()) q.push((state) { E[S][i].v, S, 1, (double) E[S][i].d });
    REP(i, 0, 50) REP(j, 0, 50) REP(k, 0, 50) dp[i][j][k] = INF;

    double ans = -1;
    while(q.size()) {
      state c = q.top();
      q.pop();

      if(c.t >= dp[c.n][c.p][c.v]) continue;
      dp[c.n][c.p][c.v] = c.t;

      if(c.n == G && c.v == 1) {
        ans = c.t;
        break;
      }

      REP(i, 0, E[c.n].size()) {
        int nn = E[c.n][i].v;
        if(nn == c.p) continue;
        REP(j, -1, 2) {
          int np = c.n;
          int nv = c.v + j;
          if(nv <= 0 || nv > E[c.n][i].c) continue;
          double nt = c.t + ((double) E[c.n][i].d / nv);
          q.push((state) { nn, np, nv, nt });
        }
      }
    }
    if(ans < 0) cout << "unreachable" << endl;
    else cout << ans << endl;
  }
}

Measured memory_bytes: 22668
#include <bits/stdc++.h>
using namespace std;
long long a[105],b[105];
int main()
{
	long long n,sum=1e9;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		b[i]=b[i-1]+a[i];
	}
	for(int i=1;i<=n;i++)
		sum=min(sum,abs(b[i]-(b[n]-b[i])));
	cout<<sum;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int Num, Sum, Ans;

void FuncCheckSum(int i, int sum, int n);

int main(void)
{
	while (1) {
		scanf("%d %d", &Num, &Sum);
		if (Num == 0 && Sum == 0) break;
		
		Ans = 0;
		
		FuncCheckSum(0, 0, 0);
		printf("%d\n", Ans);
	}

	return 0;
}

void FuncCheckSum(int i, int sum, int n)
{
	if (sum == Sum && n == Num) Ans++;
	if (i == 10 || n == Num) return;
	FuncCheckSum(i + 1, sum, n);
	FuncCheckSum(i + 1, sum + i, n + 1);
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

void solve(istream& cin, ostream& cout) {
  int x;
  cin >> x;
  x -= 400;
  int ans = 8 - (x / 200);
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 3592
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
const int N=1e5+11;
typedef long long ll;
ll len[N],ans[2];
int n;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%lld",&len[i]);
	sort(len+1,len+1+n);
	for(int i=1;i<=n;++i){
		int flag=0;
		if(i>=4&&len[i]==len[i-1]&&len[i-1]==len[i-2]&&len[i-2]==len[i-3]) flag=1;
		if(flag==0&&i>=3&&len[i]==len[i-1]&&len[i-1]==len[i-2]) continue;
		if(len[i]==len[i-1]){
			if(!ans[0]) ans[0]=len[i];
			else if(!ans[1]) ans[1]=len[i];
			else ans[0]=ans[1],ans[1]=len[i];
		}
	}
	printf("%lld\n",ans[0]*ans[1]);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

	int N;
	cin >> N;

	if (N<=999) {
		cout << "ABC" << endl;
	} else if (N>=1000) {
		cout << "ABD" << endl;
	}
	return 0;
}


Measured memory_bytes: 3608
#include <algorithm>
#include <climits>
#include <iostream>
#include <vector>

class comb {
private:
  static const long long MAX = 2000000 + 1;    // limit<k>::max() + 1
  static const long long MOD = 1000000000 + 7; // 10**9 + 7

  std::vector<long long> fac, finv, inv;

public:
  comb() : fac(MAX, 0), finv(MAX, 0), inv(MAX, 0) {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (long long i = 2; i < MAX; i++) {
      fac[i] = fac[i - 1] * i % MOD;
      inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
      finv[i] = finv[i - 1] * inv[i] % MOD;
    }
  }

  // k個の中からn個選ぶ
  long long calc(long long n, long long k) {
    if (k < n) {
      return 0;
    }
    if (n < 0 || k < 0) {
      return 0;
    }

    return fac[k] * (finv[n] * finv[k - n] % MOD) % MOD;
  }
};


class modint {
private:
  static constexpr long long int MOD = 1000000000 + 7; // (10 ** 9) + 7
  long long int x;

  static long long int sanitize(long long int n) {
    while (n < 0) {
      n += modint::MOD;
    }
    return n % modint::MOD;
  }

public:
  modint(long long int x) : x(sanitize(x)) {}
  modint() : x(0) {}

  modint &operator=(const modint &other) {
    this->x = other.x;
    return *this;
  }

  modint operator+(const modint &other) const {
    modint ret;
    ret.x = (this->x + other.x) % modint::MOD;
    return ret;
  }

  modint operator-(const modint &other) const {
    modint ret;
    ret.x = (this->x - other.x);
    if (x < 0) {
      ret.x += modint::MOD;
    }
    return ret;
  }

  modint operator*(const modint &other) const {
    modint ret;
    ret.x = (this->x * other.x) % modint::MOD;
    return ret;
  }

  modint &operator+=(const modint &other) {
    this->x = (this->x + other.x) % modint::MOD;
    return *this;
  }

  modint operator<<(const long long int shift) const {
    modint base = modint(2).pow(shift);
    return *this * base;
  }

  modint pow(long long int n) const {
    modint ret;
    ret.x = _pow(n);
    return ret;
  }

  friend std::ostream &operator<<(std::ostream &stream, const modint &value);

private:
  long long int _pow(long long int n) const {
    long long int a = this->x;
    long long res = 1;
    while (n > 0) {
      if (n & 1) {
        res = res * a % modint::MOD;
      }
      a = a * a % modint::MOD;
      n >>= 1;
    }
    return res;
  }
};

std::ostream &operator<<(std::ostream &stream, const modint &value) {
  return stream << value.x;
}



#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;


void solve();

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

void solve() {
  comb comb;
  int K;
  string S;
  cin >> K >> S;

  vector<modint> v(K+1);
  v[0] = 1;

  for (int i = 1; i <= K; i++) {
    v[i] = v[i-1]*25;
  }

  modint m = 1;
  modint ans = 0;
  for (int i = 0; i <= K; i++) {
    int n = S.size();
    int r = K-i;
    ans += m * v[K-i] * comb.calc(r, r+n-1);

    m = m * 26;
  }

  cout << ans << endl;
}


Measured memory_bytes: 58584
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().solve();
	}

	private void solve() throws IOException {
		try {
			solveA();
			//			 solveB();
			//			 solveC();
			//			 solveD();
			//			 solveE();
			//			 solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		long count = Arrays.stream(next().split("")).filter(i -> i.equals("o")).count();
		out.println(700 + count * 100);
	}

	private void solveB() {
		int n = nextInt();

		out.println("");
	}

	private void solveC() {
		int n = nextInt();

		out.println("");
	}

	private void solveD() {
		int n = nextInt();

		out.println("");
	}

	private void solveE() {
		int n = nextInt();

		out.println("");
	}

	private void solveF() {
		int n = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

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

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 28756
package main

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

func main() {
	var len, num, count int
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	len, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println("err:", err)
		os.Exit(1)
	}
	for i := 0; i < len; i++ {
		sc.Scan()
		num, err = strconv.Atoi(sc.Text())
		if err != nil {
			fmt.Println("err:", err)
			os.Exit(1)
		}
		if IsPrimeNumber(num) {
			count++
		}
	}
	fmt.Println(count)
}

// IsPrimeNumber return bool
func IsPrimeNumber(num int) bool {
	for num < 3 {
		return true
	}
	for num % 2 == 0 {
	    return false
	}
	var max = int(math.Sqrt(float64(num)))
	for i := 3; i < max+1; i += 2 {
		if num%i == 0 {
			return false
		}
	}
	return true
}



Measured memory_bytes: 1180
import bisect
import collections
import sys

sys.setrecursionlimit(100000)
input = sys.stdin.readline
ACMOD = 1000000007
INF = 1 << 62


def lmi():
    return list(map(int, input().split()))


def llmi(n):
    return [lmi() for _ in range(n)]


N, M = lmi()
H = lmi()

AB = llmi(M)
flag = [1] * N
for a, b in AB:
    a = a - 1
    b = b - 1
    ha = H[a]
    hb = H[b]
    if ha >= hb:
        flag[b] = 0
    if hb >= ha:
        flag[a] = 0
print(sum(flag))


Measured memory_bytes: 32920
N = int(input())
dp = [pow(10, 10)] * 100010
dp[0] = 0
dp[1] = 1
for n in range(100010):
    # for 6
    power = 1
    while n - power >= 0:
        dp[n] = min(dp[n], 1 + dp[n - power])
        power *= 6
    # for 9
    power = 1
    while n - power >= 0:
        dp[n] = min(dp[n], 1 + dp[n - power])
        power *= 9
print(dp[N])


Measured memory_bytes: 3828
#include<iostream>
#include<string>
using namespace std;
int main()
{
  
 char c;
  cin>>c;
  if(c>=65 && c<=90)
  {
    cout<<"A"<<endl;
  }
  else if(c>=97 && c<=122)
  {
    cout<<"a"<<endl;
  }
return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<string>
#include <algorithm>
#include <queue>
#include <climits>
#include<cmath>

bool sort_pair( std::pair< int, int > origin, std::pair< int, int > another )
{
    return origin.first < another.first;
}

int main()
{
    unsigned long long big = pow( 10, 9 ) + 7;
    unsigned long long a,b;
    std::cin>> a;
    std::cin>> b;
    unsigned long long count1 = 0;
    unsigned long long count = 0;

    std::vector< unsigned long long > c( a );

    for( int i = 0; i < a; i++ )
    {
        std::cin>> c[i];
    }

    for( int i = 0; i < a; i++ )
    {
        for( int r = i; r < a; r++ )
        {
            if( c[r] < c[i] )
            {
                count1 += 1;
            }
        }
    }

    count1 = count1 * b;

    std::vector< unsigned long long > use;
    unsigned long long count2 = 0;
    //std::sort( c.begin(), c.end() );

    for( int i = 0; i < a; i++ )
    {
        for( int r = 0; r < a ; r++ )
        {
            if( c[i] < c[r] )
            {
                count2 += 1;
            }
        }
    }

    unsigned long long d = b * ( b - 1 );
    d = d / 2;
    d %= big;
    count2 = count2 * d;
    count2 %= big;
    count = count1 + count2;
    count %= big;

    std::cout<< count;

}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys 
from collections import deque
from collections import defaultdict
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, T = map(int, readline().split())
A = list(map(int,readline().split()))

### セグメント木
# 0-index
# N: 処理する区間の長さ
N0 = 2**(N-1).bit_length()
data = [0]*(2*N0)

# 初期化
def init(A):
    for i in range(N):
        data[i+N0-1] = A[i]
    for i in range(N0-2,-1,-1):
        data[i] = max(data[2*i+1],data[2*i+2])

# a_k の値を x に更新
def update(k, x):
    k += N0-1
    data[k] = x
    while k >= 0:
        k = (k - 1) // 2
        data[k] = max(data[2*k+1], data[2*k+2])

# 区間[l, r)の最小値
def query(l, r):
    L = l + N0; R = r + N0
    s = 0
    while L < R:
        if R & 1:
            R -= 1
            s = max(s, data[R-1])

        if L & 1:
            s = max(s, data[L-1])
            L += 1
        L >>= 1; R >>= 1
    return s

init(A)
d = defaultdict(int)
for i in range(N-1):
    a = A[i]
    high = query(i+1,N+1)
    p = high - a
    d[p] += 1
d = sorted(d.items(),reverse=True)
print(d[0][1])

Measured memory_bytes: 31380
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import heapq
import sys

def check_out_of_map(pos,H,W):
    if pos[0] < 0 or pos[1] < 0:
        return False
    if pos[0] >= H or pos[1] >= W:
        return False
    return True

def bfs(s,g,Map,H,W):
    queue = []
    queue.append(s)
    dist = [[-1 for i in range(W)] for j in range(H)]
    direct = [(1,0),(-1,0),(0,1),(0,-1)]
    count = 0
    dist[s[0]][s[1]] = 0

    while queue != []:
        q = queue.pop(0)
        if q == g:
            return dist[q[0]][q[1]]
        for i in range(4):
            nextPos = (q[0]+direct[i][0],q[1]+direct[i][1])
            if check_out_of_map(nextPos,H,W) and Map[nextPos[0]][nextPos[1]] != "X":
                if dist[nextPos[0]][nextPos[1]] == -1:
                    dist[nextPos[0]][nextPos[1]] = dist[q[0]][q[1]] + 1
                    queue.append(nextPos)

H,W,N = map(int,input().split(" "))
cheese_queue = []
Map = []
for i in range(H):
    count = 0
    line = []
    while True:
        char = sys.stdin.read(1)
        if char == "S":
            s = (i,count)
        elif char.isnumeric():
            heapq.heappush(cheese_queue,(int(char),(i,count)))
        elif char == "\n":
            break
        line.append(char)
        count += 1
    Map.append(line)
count = 0
while cheese_queue != []:
    q = heapq.heappop(cheese_queue)
    count += bfs(s,q[1],Map,H,W)
    s = q[1]
print(count)

Measured memory_bytes: 38348
s=input()
l=[chr(i) for i in range(ord('a'),ord('z')+1)]#アルファベットのリストを生成
s=set(s)
ans=''
for i in l:
    if i not in s:
        ans=i
        break
    if len(s)==26:
        ans='None'
print(ans)

Measured memory_bytes: 3188
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
const int maxn=510;
int a[maxn][maxn],dp[maxn][maxn];
int n,m,q;

int main()
{
    //freopen("1.txt","r",stdin);
    while (scanf("%d%d%d",&n,&m,&q)!=EOF)
    {
        int l,r;
        memset(dp,0,sizeof(dp));
        memset(a,0,sizeof(a));
        while (m--)
        {
            scanf("%d%d",&l,&r);
            a[l][r]++;
        }
        for (int i=n;i>=1;i--)
            for (int j=i;j<=n;j++)
                dp[i][j]=a[i][j]+dp[i+1][j]+dp[i][j-1]-dp[i+1][j-1];

        while (q--)
        {
            scanf("%d%d",&l,&r);
            printf("%d\n",dp[l][r]);
        }
    }
    return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]C - Same Integers
            var numbers = ReadLine();

            int max = numbers.Max();
            int count = 0;

            for(int i = 0; i < 3; i++)
            {
                while (numbers[i] + 2 <= max)
                {
                    numbers[i] += 2;
                    count++;
                }
            }

            switch (numbers.Count(x => x == max))
            {
                case 3:
                    Console.WriteLine(count);
                    break;
                case 2:
                    Console.WriteLine(count + 2);
                    break;
                case 1:
                    Console.WriteLine(count + 1);
                    break;
            }
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<int,int>;
const int INF=1001001;

int n;
int dfs(string s,int i){
  if (s.size()==n){
    cout<<s<<endl;
    return 0;
  }
  for(char c='a';c<'a'+i+1;c++){
    string t=s+c;
    //cout<<s<<endl;
    //cout<<i<<endl;

    dfs(t,max(i,c-'a'+1));

  }
}
int main(){

  cin>>n;
dfs("",0);

}


Measured memory_bytes: 1536
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Lesen std::ios::sync_with_stdio(false);std::cin.tie(0);

int N, M, maxi = 0;
map <int, int> mp;

void solve(void){
	cin >> N;
	rep(N, i) {
		int d; cin >> d;
		mp[d] = mp[d-1]+1;
		maxi = max(maxi, mp[d]);
	}
	cout << N - maxi << endl;
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 9600
n=int(input())
c=list(input())
numW=0
numR=c.count("R")
W=n-numR
a=[]
if numR==0 or W==0:
    print(0)
else:
    for i in range(n):
        if c[i]=="W":
            numW+=1
        else:
            numR-=1
        a.append(max(numR,numW))
    print(min(a))

Measured memory_bytes: 18532
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)


ll searchMax(ll c[], ll sd[], ll picked[]){
    ll max = -1;
    ll maxP = -1;
    REP(i, 26){
        if(picked[i] == 1){
            if(max < sd[i] + c[i]){
                max = sd[i] + c[i];
                maxP = i;
            }
        }else{
            if(max < sd[i]){
                max = sd[i];
                maxP = i;
            }
        }
    }

    return maxP;
}

int main(){
    // input
    ll D;
    cin >> D;

    ll c[27];
    ll s[D + 1][27];
    REP(i, 26){
        cin >> c[i];
    }
    REP(i, D){
        REP(j, 26){
            cin >> s[i][j];
        }
    }

    // preparation
    ll t[D + 1];
    ll picked[27];

    // main
    REP(i, D){
        t[i] = searchMax(c, s[i], picked);
        picked[t[i]] = 1;
    }

    // output
    REP(i, D){
        cout << (i + 7) % 26 + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3708
#include <bits/stdc++.h>
#define aio()                         \
    do {                              \
        std::ios::sync_with_stdio(0); \
        std::cin.tie(0);              \
    } while (0)
using namespace std;
typedef long long ll;
typedef long double ld;

int main()
{
    aio();

    string s;
    cin >> s;
    long cnt = 0, max = 0;
    for (auto &&i : s) {
        if (i == 'S') {
            cnt = 0;
        } else {
            cnt++;
        }
        max = std::max(max, cnt);
    }
    cout << max;
}


Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long sum = 0;
		long n;
		long num = scan.nextLong();
		for(long a = 1; a<=num; a++) {
			for(long b = 1; b<=num; b++) {
				for(long c = 1; c<=num; c++) {
					if(a>=b) {
						n = gcd(a,b);
					}else {
						n = gcd(b,a);
					}

					if(a>=c) {
						n = gcd(n,c);
					}else {
						n = gcd(c,n);
					}

					sum = sum+n;
				}
			}
		}System.out.println(sum);

	}

	public static long gcd(long x, long y) {
    long tmp;
    while ((tmp = x % y) != 0) {
        x = y;
        y = tmp;
    }

    return y;
}

}


Measured memory_bytes: 27324
#include<bits/stdc++.h>
#define N 1000006
using namespace std;
char s0[N],t[N];
int n;
int val[N],match[N],ed[N];
int main(){
    scanf("%d%s%s",&n,s0+1,t+1);
    
    for(int i=n,p=n;i>=1;i--){
        p=min(p,i);
        while(p!=0 && s0[p]!=t[i]) p--;
        if(p==0) return puts("-1"),0;
        else if(match[p]==0) match[p]=i;
    }
    
    queue<int> q;
    int ans=0;
    for(int i=1;i<=n;i++){
        if(match[i]==i) continue;
        else{
            while(!q.empty() && q.front()+(int)q.size() <= i ) q.pop();
            if(match[i]!=0) q.push(match[i]);
            ans=max(ans,(int)q.size());
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 13952
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

fn main() {
    let (N, K) = get!(usize, usize);
    let hs = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse::<i32>().unwrap())
            .collect::<Vec<_>>()
    };

    let mut dp: Vec<Option<i32>> = vec![None; N];
    dp[0] = Some(0);

    for i in 1..N {
        dp[i] = (1..(std::cmp::min(i+1, K+1))).into_iter()
                     .map(|k| {
                          dp[i-k].expect("A")+(hs[i]-hs[i-k]).abs()
                     })
                     .min()
    }
    
    println!("{}", dp[N-1].expect("B"));
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using in6 = int64_t;
using ind = double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int a,b;
  cin >> a >> b;
  int x = 1;
  while(x <= 1250) {
    if((int)(x * 0.08) == a && (int)(x * 0.1) == b) {
      cout << x << endl;
      break;
    }
    x++;
  }
  if(x == 1251) cout << -1 << endl;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 60;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, M; cin >> N >> M;
    int pos[M], dig[M]; rep(i, M) cin >> pos[i] >> dig[i];

    int rng[] = {0, 10, 100, 1000};
    int dlim = rng[N-1], ulim = rng[N];
    for(int i = dlim; i < ulim; i++){
        bool ok = true;
        string S = to_string(i);
        rep(j, M){
            if(S[pos[j]-1] - '0' != dig[j]) ok = false;
        }
        if(ok){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

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

int main() {
    ll h,w,k;
    std::cin >> h>>w>>k;
    
    vector<string> s(h);
    vector<ll> c(h,0);
    for (int i = 0; i < h; i++) {
        std::cin >> s[i];
        for (int j = 0; j < w; j++) {
            if(s[i][j] == '#'){
                c[i]++;
            }
        }
    }
    
    vector<vector<ll>> ans(h,vector<ll>(w,0));
    
    ll rem = 0;
    
    ll now = 1;
    
    for (int i = 0; i < h; i++) {
        if(c[i]==0){
            rem++;
            continue;
        }
        
        ll tmpc = c[i];
        for (int j = 0; j < w; j++) {
            for (int k = 0; k <= rem; k++) {
                ans[i-k][j] = now;
                if(k == rem && s[i][j] == '#' && tmpc>1){
                    now++;
                    tmpc--;
                }
            }
        }
        rem = 0;
        
        // if(c[i]==1){
        now++;
        // }
    }
    
    if(rem>0){
        for (int i = h-1; i >= 0 ; i--) {
            if(c[i]==0)continue;

            for (int j = 0; j < w; j++) {
                for (int k = 1; k <= rem; k++) {
                    ans[i+k][j] = ans[i][j];
                    // std::cout << i+k << std::endl;
                }
            }
            break;
        }
    }
    
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            std::cout << ans[i][j]<<" ";
        }
        std::cout << std::endl;
    }
}


Measured memory_bytes: 1664
#include<stdio.h>
 
int main(void)
{
    char str[1200] = {0} ;
    int i=0 ;
 
    fgets(str ,sizeof str ,stdin);
 
    for (i=0 ;i<1200 ;i++){
 
        if (str[i]=='\n') break;
 
        if (str[i]>='A' && str[i]<='Z'){
            str[i]=str[i]+32;
 
        } else if (str[i]>='a' && str[i]<='z'){
            str[i]=str[i]-32;
        }
 
    }
 
    printf("%s",str);
    return 0;
}


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

int main() {
    int a, b, c, k, ans = 0;
    cin >> a >> b >> c >> k;
    
    if (k > a) {
        k -= a;
        ans += a;
    } else {
        cout << k << endl;
        return 0;
    }

    if (k <= b) {
        cout << ans << endl;
    } else {
        k -= b;
        cout << ans - k << endl;
    }
    return 0;
}

Measured memory_bytes: 3496
#include <iostream>
#include <string>

int main() {
  int n;
  std::string s;
  std::cin >> n >> s;
  int cnt = 0;
  for (int i = 0; i <=n-3; ++i) {
    if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') ++cnt; 
  }
  std::cout << cnt << std::endl;
  
  return 0;
}

Measured memory_bytes: 3608
/*
ID: y1197771
PROG: test
LANG: C++
*/
#include<bits/stdc++.h>
#define pb push_back
#define FOR(i, n) for (int i = 0; i < (int)n; ++i)
#define dbg(x) cout << #x << " at line " << __LINE__ << " is: " << x << endl
typedef long long ll;
using namespace std;
typedef pair<int, int> pii;
const int maxn = 1e5 + 10;
vector<int> e[maxn * 2];
int n, m;
bool vis[maxn * 2];
void dfs(int x) {
    vis[x] = 1;
    for (int u : e[x]) {
        if(!vis[u])
            dfs(u);
    }
}
void solve() {
    cin >> n >> m;
    int x, y;
    for (int i = 1; i <= n; i++) {
        cin >> x;
        for (int j = 0; j < x; j++) {
            cin >> y;
            y += n;
            e[i].pb(y); e[y].pb(i);
        }
    }
    dfs(1);
    for (int i = 1; i <= n; i++) {
        if(!vis[i]) {
            cout << "NO" << endl;
            return;
        }
    }
    cout << "YES" << endl;
}
int main() {
    //freopen("test.in", "r", stdin);
    //freopen("test.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 8704
#include <iostream>

char flip(const char c) {
  if (c == 'A')
    return 'T';
  else if (c == 'T')
    return 'A';
  else if (c == 'C')
    return 'G';
  else
    return 'C';
}

int main() {
  char c;
  std::cin >> c;
  std::cout << flip(c) << std::endl;
}

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

int main(){
	string s;
	cin>>s;
	uint64_t ans=0,tmp;
	for(int i=0,n=(1<<(s.size()-1)),jn=s.size()-1;i<n;++i){
		tmp=s.at(0)-'0';
		for(int j=0;j<jn;++j){
			if(i&(1<<j)){
				ans+=tmp;
				tmp=0;
			}
			tmp=tmp*10+s.at(j+1)-'0';
		}
		ans+=tmp;
	}
	cout<<ans<<"\n"s;
}

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

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;

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

  vector < pair<ll, int> > graph[N];
  for (int i = 0; i < M; i++){
    int L, R; ll C; cin >> L >> R >> C;
    L--; R--;
    graph[L].push_back(make_pair(C, R));
  }

  for (int i = N - 1; i > 0; i--){
    graph[i].push_back(make_pair(0, i - 1));
  }
  
  
  vector <bool> visited(N);
  vector <ll> ans(N);

  priority_queue < pair<ll, int>, vector< pair<ll, int> >, greater<pair<ll, int> > > que;
  que.push(make_pair(0, 0));

  while (!que.empty()){
    pair <ll, int> P = que.top(); que.pop();

    ll dist = P.first; int now = P.second;

    if (visited[now] == false){
      visited[now] = true;
      ans[now] = dist;

      for (int i = 0; i < graph[now].size(); i++){
        ll edge = graph[now][i].first;
        int node = graph[now][i].second;

        if (visited[node] == false){
          que.push(make_pair(dist + edge, node));
        }
      }
    }
  }
  
  if (visited[N - 1] == false){
    cout << -1 << endl;
  }else{
    cout << ans[N - 1] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 10100
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
template<class T = ll> T in(){T x; cin >> x; return (x);}

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

 string s = in<string>();
rep(i,s.size()){
cout << s[i];
if(i==3) cout << " " ;
}
cout << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<iostream>
#define ll long long
using namespace std;
#define max(a,b)	(a)>(b)?(a):(b)
#define min(a,b)	(a)<(b)?(a):(b)
#define s(i)		scanf("%d",&(i))
#define ss(i)		scanf("%s",(i))
#define p(i)		printf("%d",i)
#define ps(i)		printf("%s",(i))
#define pc(i)		printf("%c",(i))
#define end			printf("\n")
#define f(i,n)		for(i=1;i<=n;i++)
#define w(i)		while(i--)
int a[100010]; 
ll b[100010];
int main()
{
	int n,m,i,j;
	s(n);
	f(i,n)
		s(a[i]);
	sort(a+1,a+n+1);
	f(i,n)
		b[i]=b[i-1]+a[i];
	for(i=n-1;i>=1;i--)
	{
		if(b[i]*2<a[i+1])
			break;
	}
	p(n-i);
	end;
	return 0; 
}



Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const ll mod = 1000000007;
const int MAX_N = 100010;
 
/*struct edge {
    int to;
    int weight;
};*/
 
//vector<edge> G[200010];

Graph to(MAX_N), cost(MAX_N);
vector<int> visit(MAX_N);
vector<int> d(MAX_N);

bool dfs(int v, int dist) {
 
    if(visit[v]) {

        if(d[v] != dist) {
            return false;
        }
        
        return true;
    }

    visit[v] = 1;
    d[v] = dist;
    rep(u, to[v].size()) {
        if( !dfs(to[v][u], d[v] + cost[v][u]) ) {
            return false;
        }
    }
 
    return true;
}
 
int main() {
    int n, m;
    cin >> n >> m;

    rep(i, m) {
        int L, R, w;
        cin >> L >> R >> w;
        L--;  R--;
        to[L].push_back(R);
        to[R].push_back(L);
        cost[L].push_back(w);
        cost[R].push_back(-w);
    }

    rep(i, n) {
        if(!visit[i] && !dfs(i, 0)) {
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
    return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  for (int i=0; i<W+2; i++)
    cout << "#";
  cout << endl;
  
  for (int i=0; i<H; i++){
    string s;
    cin >> s;
    cout << "#" << s << "#" << endl;
  }
  for (int i=0; i<W+2; i++)
    cout << "#";
  cout << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t,u;
  int a,b;
  cin>>s>>t>>a>>b>>u;
  if(s==u){
    cout<<a-1<<" "<<b<<endl;
  }
    else cout<<a<<" "<<b-1<<endl;
}


Measured memory_bytes: 256
n, a, b, c, d = map(int, input().split())
s = input()
#s = '.' + s

if '##' in s[a:c-1] or '##' in s[b:d-1]:
    print('No')
else:
    if c < b or c < d:
        print('Yes')
    else:
        if '...' in s[b-2:d+1]:
            print('Yes')
        else:
            print('No')


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

using namespace std;

const int N = 2e5 + 5;
long long m, n, a[N];

main() {
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  long long tot = 0;
  cin >> n >> m;
  for(int i = 1; i <= n; ++i) cin >> a[i], tot += a[i];
  long long per = ceil((double)tot / (4 * m));
  int cnt = 0;
  for(int i = 1; i <= n; ++i) cnt += (a[i] >= per);
  cout << (cnt >= m ? "Yes" : "No");
}


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

int main() {
  int N, L;
  cin >> N >> L;
  int ans = 0;
  for(int i = 1; i <= N; i++) {
    ans += L + i - 1;
  }
  if(L > 0) {
    ans -= L;
  }
  else if(-L + 1 > N) {
    ans -= L + N - 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3584
#include<iostream>
#include<cstring>
#include<cmath>
#include<cstdio>
using namespace std;

struct Edge
{
    int to;
    int next;
}a[400009];
int cnt;
int head[400009];
int n;
int vis[400009];
void addedg(int u,int v)
{
    a[cnt].to=v;
    a[cnt].next=head[u];
    head[u]=cnt++;
}
int flag=0;
void dfs(int s,int t)
{
    if(t>2)return;
    else if(t==2)
    {   if(s==n)
         {
             flag=1;
         }
        return;
    }
    else
    {
        for(int e=head[s];e!=-1;e=a[e].next)
        {
            if(vis[e]==0)
            {   
                vis[e]=1;
                dfs(a[e].to,t+1);
                vis[e]=0;
            }
        }
    }
}
int main()
{
   int m;
   cin>>n>>m;
   memset(vis,0,sizeof(vis));
   memset(head,-1,sizeof(head));
   cnt=0;
   for(int i=1;i<=m;i++)
   {
       int u,v;
       cin>>u>>v;
       addedg(u,v);
       addedg(v,u);
   }
  // vis[1]=0;
  dfs(1,0);
   if(flag==1)
   {
       cout<<"POSSIBLE";
   }
   else
   {
       cout<<"IMPOSSIBLE";
   }
}


Measured memory_bytes: 6528
def main():
    s = input()
    K = int(input())
    lst = sorted(set(s))
    ans = []

    def dfs(c):
        if len(ans) < K:
            ans.append(c)
            for li in lst:
                if c + li in s:
                    dfs(c + li)

    for li in lst:
        dfs(li)
    print(ans[K - 1])
    return


main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int n, T;
    cin >> n >> T;
    int c[100], t[100];
    rep(i, n){
        cin >> c[i] >> t[i];
    } 

    int cost = 100000;
    rep(i, n){
        if(t[i] <= T){
            cost = min(cost, c[i]);
        }
    }
    if(cost == 100000){
        cout << "TLE";
    }
    else{
        cout << cost;
    }


    return 0;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
 
public class Main{

  public static void main(String[] args) throws IOException {
    try ( BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) ) {

      String[] lines = br.readLine().split(" ");
      int n = Integer.parseInt(lines[0]);
      int m = Integer.parseInt(lines[1]);
      int[][] mA = new int[n][m];
      int[]   vb = new int[m];
      int[]   vc = new int[n];

      for(int i = 0; i < n; i++ ) {
        lines = br.readLine().split(" ");
        for( int j = 0; j < m; j++ ) {
          mA[i][j] = Integer.parseInt(lines[j]);
        }
      }
      for( int i = 0; i < m; i++ ) {
        lines = br.readLine().split(" ");
        vb[i] = Integer.parseInt(lines[0]);
      }

      for( int i = 0; i < n; i++ ) {
        for( int j = 0; j < m; j++ ){
          vc[i] += mA[i][j] * vb[j];
        }
        System.out.println(vc[i]);
      }
    }
  }
}


Measured memory_bytes: 28168
c1, c2, c3 = map(int, input().split())
c4, c5, c6 = map(int, input().split())
c7, c8, c9 = map(int, input().split())

if c4-c1 == c5-c2 == c6-c3 and\
   c7-c1 == c8-c2 == c9-c3 and\
   c7-c4 == c8-c5 == c9-c6:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
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(a < 9 && b < 9 ? "Yay!" : ":(");

		sc.close();

	}
}



Measured memory_bytes: 21460
using System;

namespace Ex160506_1{
    public class Program{
        public static void Main(string[] args){
            var input = Console.ReadLine().Split(' ');
            var a = int.Parse(input[0]);
            var b = int.Parse(input[1]);

            Console.WriteLine("{0} {1} {2}", a / b, a % b, (decimal)a / b);
        }
    }
}

Measured memory_bytes: 9208
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

sumB = sum(B)

cnt = []

for i in range(n-1):
    if A[i]+1 == A[i+1]:
        cnt.append(A[i]-1)

sumC = 0
for i in cnt:
    sumC += C[i]

print(sumB+sumC)


Measured memory_bytes: 9192
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
const string YES = "Yes";
const string NO = "No";
void solve(long long N, long long A, long long B, std::string S){
  ll ab = A+B , x = 0 , y = 0;
  for (int i = 0; i < N; i++) {
    bool ac = false;
    if(S[i] == 'a' && x < ab){
      ac = true;
      x++;
    }else if(S[i] == 'b' && x < ab && y < B){
      ac = true;
      x++; y++;
    }
    cout << (ac ? YES : NO) << endl;
  }
}

int main(){
    long long N;
	scanf("%lld",&N);
	long long A;
	scanf("%lld",&A);
	long long B;
	scanf("%lld",&B);
	std::string S;
	std::cin >> S;
    solve(N, A, B, S);
}


Measured memory_bytes: 896
N=int(input())
A=list(map(int,input().split()))
l=[]
for i in range(N):
    if A[i]%2==0:
        l.append(A[i])
flag=True
for i in range(len(l)):
    if l[i]%3==0 or l[i]%5==0:
        pass
    else:
        flag=False
if flag:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3064
io = STDIN
$h,$w=io.gets.split.map(&:to_i)
$n=io.gets.to_i
a=io.gets.split.map(&:to_i)

(1..a.size).zip(a).map do |color,cnt|
  [color] * cnt
end.flatten.each_slice($w).with_index do |part,rowno|
  puts (rowno.odd? ? part.reverse : part).join(" ")
end


Measured memory_bytes: 4220