akhauriyash/Code-Regression huggingface dataset:
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <vector>
#include <bitset>
#include <cstring>
#include <utility>
#include <iostream>
#include <algorithm>
#define LL long long
#define Rg register
#define RI register int
#define RC register char
#define ed puts("") 
#define pair pair<LL,LL>
#define space putchar(' ')
using namespace std;
    
template <typename tp> inline void read(tp & x)
{	
    x=0;
    RI f=1;
    RC c=getchar();
    while(c<'0' || c>'9'){if(c=='-') f=-1;c=getchar(); }
    while(c>='0' && c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();} 
 	x*=f;
} 	
    
template <typename Tp> inline void print(Tp x)
{		
    if(x<0) x=-x,putchar('-');
    if(x>9) print(x/10);
    putchar(x%10+'0');
}

int n,c,k;
int temp;
LL ans;
LL t[1000005];
int s[1000005];
bool vis[1000005];
bool flag=1;
LL kk;

int main()
{
	read(n),read(c),read(k);
	for(RI i=1;i<=n;++i)
		read(t[i]);
	stable_sort(t+1,t+n+1);
	for(RI i=1;i<=n;++i)
	{
//		int kk=t[i]+k;
//		ans++;
//		temp=c-1;
//		int flag=i;
//		for(RI j=flag+1;j<=n;++j)
//		{
//			if(t[j]<=kk && t[j]+k>=kk)
//			{
//				temp--;
//				if(temp==0)
//					break;	
//			}	
//		}	
//		int hh=c-temp;//多接了几个人
//		i+=hh-1;
		if(flag)
        {
            ++ans,++temp;
            kk=t[i]+k;
            flag=0;
        }
        else if(t[i]<=kk) 
			++temp;
        else if(t[i]>kk)
        {
            flag=true;
			temp=0;
            --i;
        }
        if(temp==c) 
        {
            flag=true;
			temp=0;
        }
	}	
	print(ans);		
	return 0;
}

Measured memory_bytes: 1792
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>  
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<ll> v32;
typedef vector<vector<ll> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
 

void solve()
{
	int a,b,c;
	cin>>a>>b>>c;
	if (a+b+c>=22)
		cout<<"bust"<<endl;
	else
		cout<<"win"<<endl;
}
int32_t main()
{
    fast_cin();
    int t;
    t=1;
    while (t--)
    {
    	solve();
    }
    return 0;
} 

Measured memory_bytes: 256
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let m: usize = read();
    let a: Vec<usize> = (0..m).map(|_| read()).collect();

    let mut broken = vec![false; n + 1];
    for &a_i in a.iter() {
        broken[a_i] = true;
    }

    let mut dp = vec![0; n + 1];
    dp[0] = 1;

    for i in 0..n {
        if !broken[i + 1] {
            dp[i + 1] += dp[i];
            dp[i + 1] %= 1_000_000_007usize;
        }
        if i + 1 < n {
            if !broken[i + 2] {
                dp[i + 2] += dp[i];
                dp[i + 2] %= 1_000_000_007usize;
            }
        }
    }

    println!("{}", dp[n]);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 6396
use proconio::input;

fn main() {
    input! {
        n: u64,
    }
    let factorize = prime_factorize(n);
    let mut ans = 0;

    for f in &factorize {
     let mut num = 1;
     let mut add = 2;
     while num <= f.1 {
         ans += 1;
         num += add;
         add += 1;
     }   
    }

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

fn prime_factorize(mut n: u64) -> Vec<(u64, u64)> {
    let mut vec = vec![];
    let mut a = 2;
    while a * a <= n {
        if n % a != 0 {
            a+=1;
            continue;
        }
        let mut ex = 0;
        while n % a == 0 {
            ex += 1;
            n /= a;
        }

        vec.push((a, ex));
        a+=1;
    }

    if n != 1 {
        vec.push((n, 1));
    }
    return vec;
}

Measured memory_bytes: 2172
using System;
using System.Collections.Generic;

namespace abc142_e
{
  class Program
  {
    static void Main(string[] args)
    {
      var n = CIn.ReadInt();
      var m = CIn.ReadInt();
      var keys = new Key[m];

      for (var i = 0; i < m; i++)
      {
        var a = CIn.ReadInt();
        var b = CIn.ReadInt();
        var c = 0;

        for (var j = 0; j < b; j++)
        {
          c += (int)Math.Pow(2, CIn.ReadInt() - 1);
        }

        keys[i] = new Key(a, c);
      }

      var pow = (int)Math.Pow(2, n) - 1;
      var dp = new int[m + 1, pow + 1];

      for (var i = 1; i <= pow; i++)
      {
        dp[0, i] = -1;
      }

      for (var i = 1; i <= m; i++)
      {
        var k = keys[i - 1];

        for (var j = 1; j <= pow; j++)
        {
          var sub = j & (k.CanBeOpened ^ pow);
          if (sub == j)
          {
            dp[i, j] = dp[i - 1, j];
          }
          else
          {
            if (dp[i - 1, j] == -1)
            {
              if (dp[i, sub] == -1)
              {
                dp[i, j] = -1;
              }
              else
              {
                dp[i, j] = dp[i, sub] + k.Price;
              }
            }
            else
            {
              if (dp[i, sub] == -1)
              {
                dp[i, j] = dp[i - 1, j];
              }
              else
              {
                dp[i, j] = Math.Min(dp[i - 1, j], dp[i, sub] + k.Price);
              }
            }
          }
        }
      }

      Console.WriteLine(dp[m, pow]);
    }
  }

  class Key
  {
    public int Price { get; }
    public int CanBeOpened { get; }

    public Key(int price, int canBeOpened)
    {
      Price = price;
      CanBeOpened = canBeOpened;
    }
  }

  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }

      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }

      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }

      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }

      return array;
    }
    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }

      return array;
    }
  }
}

Measured memory_bytes: 29152
s = raw_input()
k = int(input())
l = len(s)
arr = []

for i in range(l):
	for j in range(1,min(6,l-i+1)):
		arr.append(s[i:i+j])

arr_uni = list(set(arr))
arr_uni.sort()
print arr_uni[k-1]



Measured memory_bytes: 4484
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
	int i, j, h, b;
	while (1)
	{
		char r[5] = "", a[5] = "";
		cin >> r >> a;
		if (atoi(r) == 0 && atoi(a) == 0) break;
		h = b = 0;
		for (i = 0; i < 4; i++)
		{
			for (j = 0; j < 4; j++)
			{
				if (r[i] == a[j])
				{
					if (i == j)
						h++;
					else
						b++;
				}
			}
		}
		cout << h << " " << b << endl;
	}
}

Measured memory_bytes: 0
fun main(args : Array<String>){
    val (Q, H, S, D) = readLine()!!.split(" ").map{ it.toLong() }
    val N = readLine()!!.toLong()

    class BottleList(val q : Long, val h : Long, val s : Long, val d : Long) : Comparable<BottleList>{

        val price : Long = q * Q + h * H + s * S + d * D 
        override fun compareTo(other : BottleList) : Int {
            return price.compareTo(other.price)
        } 
    }

    val patOne = BottleList(4, 0, 0, 0)
    val patTwo = BottleList(2, 1, 0, 0)
    val patThree = BottleList(0, 2, 0, 0)
    val patFour = BottleList(0, 0, 1, 0)
    val patFive = BottleList(0, 0, 0, 1)

    val minOneL = arrayOf(patOne, patTwo, patThree, patFour).min()!!.price
    val minTwoL = arrayOf(minOneL * 2, patFive.price).min()!!
    println(N / 2 * minTwoL + N % 2 * minOneL)
}

Measured memory_bytes: 37948
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int N,M,T[5005][2],i,j,x1,x2,y1,y2,R;
int in(int a,int b,int c){return a<=b&&b<=c;}
int cmp(const void *a,const void *b){return ((int *)a)[0]>((int*)b)[0];}
int main()
{
	scanf("%d%d",&N,&M);
	for(i=0;i<N;i++)
		scanf("%d%d",&T[i][0],&T[i][1]);
	qsort(T,N,sizeof(int[2]),cmp);
	for(i=0;i<M;i++)
	{
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		for(j=R=0;T[j][0]<=x2&&j<N;j++)
			if(in(x1,T[j][0],x2)&&in(y1,T[j][1],y2))
				R++;
		printf("%d\n",R);
	}
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<string> vs;
const ll mod = 1e9+7;
const ll inf = 1e17;
const int INF = 1e9;
const double PI = acos(-1);
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  int n, m;
  cin >> n >> m;
  vi k(m);
  vvi s(m, vi(n));
  re(i, m) {
    cin >> k[i];
    re(j, k[i]) {
      cin >> s[i][j];
    }
  }
  vi p(m);
  re(i, m) cin >> p[i];

  int cnt = 0;
  re(bit, (1<<n)) //スイッチのつけ方全探索
  {
    vi w(n); //スイッチ
    re(i, n) {
      if(bit>>i & 1) {
        w[i] = 1; //on
      } else {
        w[i] = 0; //off
      }
    }

    bool turn = true;
    re(i, m) {
      int sum = 0;
      re(j, k[i]) {
        sum += w[s[i][j]-1];
      }
      if(sum % 2 != p[i]) {
        turn = false;
        break;
      }
    }
    if(turn) cnt++;
  }

  cout << cnt << endl;

  return 0;
}


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

typedef long long ll;
using namespace std;

int x, y, a, b, c;
struct node
{
	int id;
	int val;
}apple[300005];
bool cmp(const node & a, const node &b)
{
	return a.val > b.val;
}
int main()
{
	cin >> x >> y >> a >> b >> c;
	for(int i = 1; i <= a; i++)
	{
		cin >> apple[i].val;
		apple[i].id = 1;
	}
	for(int i = a+1; i <= a+b; i++)
	{
		cin >> apple[i].val;
		apple[i].id = 2;
	}
	for(int i = a+b+1; i <= a+b+c; i++)
	{
		cin >> apple[i].val;
		apple[i].id = 3;
	}
	sort(apple+1, apple+1+a+b+c, cmp);
	ll ans = 0;
	int nx = 0;
	int ny = 0;
	int cnt = 0;
	for(int i = 1; i <= a+b+c; i++)
	{
		if(apple[i].id == 1)
		{
			if(nx == x)
			{
				continue;
			}
			nx++;
		}
		else if(apple[i].id == 2)
		{
			if(ny == y)
			{
				continue;
			}
			ny++;
		}
		cnt++;
		ans += apple[i].val;
		if(cnt == x + y)
		{
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2560
H, W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))

b = []
for i in range(N):
    b += [i + 1] * a[i]

for i in range(H):
    c = b[i * W:i * W + W]
    if i % 2 == 1:
        c = c[::-1]
    print(" ".join(map(str, c)))


Measured memory_bytes: 71604
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;
const int INF=1e9;

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; }



int main(){
    char b;
    cin>>b;
    if(b=='A') cout<<'T'<<endl;
    if(b=='T') cout<<'A'<<endl;
    if(b=='C') cout<<'G'<<endl;
    if(b=='G') cout<<'C'<<endl;
    
    
}


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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
  int n, m;
  int a[110];
  cin >> n >> m;
  int sum = 0, cnt = 0;
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
    sum += a[i];
  }
  for (int i = 0; i < n; i++)
  {
    if (a[i] >= sum * (1.0 / (4 * m)))
      cnt++;
  }
  if (cnt >= m)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int d,t,s;
  cin >> d >>t >> s;
  if(s*t >= d)cout << "Yes\n";
  else cout << "No\n";
  
  

  return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ll long long

using namespace std;

int main(){
  string s,t;cin>>s>>t;

  sort(s.begin(),s.end());
  sort(t.rbegin(),t.rend());

//cout<<s<<endl;
//cout<<t<<endl;

  if(s<t){
    cout<<"Yes";
  }else{
    cout<<"No";
  }


  return 0;
}

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

int main()
{
	string s;
	cin >> s;
	const int n = s.size();
	ll res = 0;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'B' && i + 1 < n && s[i + 1] == 'C') {
			res += cnt;
			++i;
		}
		else if (s[i] == 'A') {
			++cnt;
		}
		else {
			cnt = 0;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 640
#include <cstdio>
using namespace std;

int main()
{
    int n,a,b,m;
    long long l;
    scanf("%d%d%d",&n,&a,&b);
    if(a==b) printf("1");
    else if(a<b&&n>1)
    {
        n-=2;
        m=b-a;
        l=(long long )n*m+1;
        printf("%lld",l);
    }
    else printf("0");
    return 0;
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl



int main(){
    int h,w;
    cin>>h>>w;
    string a;
    int cnt=0;
    REP(i,h){
        cin>>a;
        REP(j,w){
            if(a[j]=='#')cnt++;
        }
    }
    Poss(cnt==h+w-1);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <deque>
#include <utility>

using namespace std;
using ll = long long;

ll max(ll x, ll y) {
	if (x < y) {
		return y;
	} else {
		return x;
	}
}

int main(void) {
	ll ans = 0;
	deque<pair<char, int>> v = {make_pair(getchar(), 1)};
	int d;
	while ((d = getchar()) != EOF) {
		if (d != '<' && d != '>') {
			continue;
		}
		if (d != v.back().first) {
			v.push_back(make_pair(d, 0));
		}
		v.back().second++;
	}
	if (v.front().first == '>') {
		ans += (ll) (v.front().second + 1) * v.front().second / 2;
		v.pop_front();
	}
	if (v.back().first == '<') {
		ans += (ll) (v.back().second + 1) * v.back().second / 2;
		v.pop_back();
	}
	while (!v.empty()) {
		ll open, close;
		open = v.front().second;
		v.pop_front();
		close = v.front().second;
		v.pop_front();
		ans += (open - 1) * open / 2
					 + (close - 1) * close / 2
					 + max(open, close);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 2304
// https://atcoder.jp/contests/agc029/tasks/agc029_b

#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

// long gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// long lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, ans = 0;
    cin >> n;
    vector<int> v(n);
    // 値に対して個数を持つ。ペアとして使用する際に個数を数える。
    multiset<int> m;

    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        m.emplace(a);
    }

    // 大きい値から順に処理する
    while (!m.empty()) {
        int x = *(m.rbegin());
        // m.erase(x)にしてしまうと値xがすべて消えてしまう
        m.erase(m.find(x));
        // xより大きい２のべき乗を作成
        ll p = 1;
        while (p <= x)
            p *= 2;
        int y = p - x; // ペアとなるyは1通り
        auto itr = m.find(y);
        if (itr != m.end()) {
            m.erase(itr);
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    reverse(s1.begin(), s1.end());
    reverse(s2.begin(), s2.end());
    reverse(s3.begin(), s3.end());
    int turn = 1;
    while(1){
        if(turn == 1){
            if(s1.empty()) return cout << "A\n", 0;
            if(s1.back() == 'b'){
                turn = 2;
            }else if(s1.back() == 'c'){
                turn = 3;
            }
            s1.pop_back();
        }else if(turn == 2){
            if(s2.empty()) return cout << "B\n", 0;
            if(s2.back() == 'a'){
                turn = 1;
            }else if(s2.back() == 'c'){
                turn = 3;
            }
            s2.pop_back();
        }else if(turn == 3){
            if(s3.empty()) return cout << "C\n", 0;
            if(s3.back() == 'a'){
                turn = 1;
            }else if(s3.back() == 'b'){
                turn = 2;
            }
            s3.pop_back();
        }
    }
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

	int min=999999;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N;
		int a[] =new int[8];
		int over =0;
		N = sc.nextInt();
		for (int i=0;i<N;i++) {
			int rate = sc.nextInt();
			if (rate <3200) {
				a[rate/400]++;
			} else {
				over++;
			}
		}
		int min=0 ;
		for (int i=0;i<8;i++) {
			if (a[i]>0) {
				min++;
			}
		}
		if (min>0) {
			System.out.println(min+" "+(min+over));
		} else {
			System.out.println(1+" "+(over));
		}

	}
}

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

int main() {
  int r, g, b, sum;
  cin >> r >> g >> b;
  sum = r*100 + g*10 + b;
  if (sum % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  int a,b;cin >>a>>b;
  if(abs(a-b)%2 != 0){
    cout << "IMPOSSIBLE" << endl;
  } else {
    cout << min(a,b) + abs(a-b)/2 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
p = [(int(x) + 1) / 2 for x in input().split()]
p2 = [0] * (n + 1)
p2[0] = 0
for i in range(n):
    p2[i + 1] = p2[i] + p[i]
ans = 0
for i in range(n - k + 1):
    ans = max(ans, p2[k + i] - p2[i])
print(ans)

Measured memory_bytes: 23524
#include <cstdio>
#include <string>
#include <iostream>

using namespace std;

int main()
{
	int i, n, s = 0, d = 0;
	string x;

	cin >> x;

	n = x.size();

	for (i = 0; i < n; i++) {
		if (x[i] == 'S') {
			s++;
		}
		else {
			if (s > 0) {
				s--;
				d += 2;
			}
		}
	}

	cout << n - d << endl;

	return 0;
}

Measured memory_bytes: 640
s = input()
a = int(s[:2])
b = int(s[2:])

if (a > 12 or a == 0) and 0 < b <= 12:
  print("YYMM")
elif 0 < a <= 12 and (b > 12 or b == 0):
  print("MMYY")
elif 0 < a <= 12 and 0 < b <= 12:
  print("AMBIGUOUS")
else:
  print("NA")

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <cstring>
//#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define de(x,y) cout<<#x<<" :"<<x<<y;
#define int long long
#define SZ(xx) ((int)xx.size())
#define lowbit(xx) (xx&(-xx))
#define pb push_back
typedef pair<int,int> pii;

const int maxn = 3e3 + 5;
const int mod = 1e9 + 7;
int dp[maxn][maxn];
char s[maxn];

main() {
//	string s;
	int n;
	cin >> n >> (char*)(s + 2); 
	dp[1][1] = 1;
	for (int i = 2; i <= n; i++) {
		if (s[i] == '>') {
			dp[i][i] = 0;
			for (int j = i - 1; j >= 1; j--) {
				dp[i][j] = dp[i-1][j] + dp[i][j+1];
				dp[i][j] %= mod;
			}
		}else {
			dp[i][1] = 0;
			for (int j = 2; j <= i; j++) {
				dp[i][j] = dp[i-1][j-1] + dp[i][j-1];
				dp[i][j] %= mod;
			}
		} 
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		ans += dp[n][i];
		ans %= mod; 
	}
	cout << ans << "\n";

}


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

#define F first
#define S second
#define MP make_pair
#define PB push_back

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
typedef vector < ll > vl;

const int MAXN = 1e5 + 500;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int LOG = 18;
const double EPS = 1e-9;
const double PI = 3.1415926535;

vector <int> G[MAXN];
bool visited[MAXN];
ll black[MAXN];
ll white[MAXN];

ll add(ll a, ll b) {
    return (a + b) % MOD;
}

ll mult(ll a, ll b) {
    return (a * b) % MOD;
}

void preprocess() {
    for(int i = 0; i < MAXN; i++) {
        black[i] = 1;
        white[i] = 1;
    }
}

void dfs(int curr) {
    visited[curr] = true;
    for(auto v : G[curr]) {
        if(visited[v] == false) {
            dfs(v);
            black[curr] = mult(black[curr], white[v]);
            white[curr] = mult(white[curr], add(white[v], black[v]));
        }
    }
}

int main() {
    int N, u, v;
    int root = 0;

    cin >> N;
    for(int i = 0; i < N - 1; i++) {
        cin >> u >> v;
        u --; v --;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    preprocess();
    dfs(root);

    cout << add(black[root], white[root]) << endl;

    return 0;
}



Measured memory_bytes: 11520
<?php
//error_reporting(0);
//$N = trim(fgets(STDIN));
list($N,$M) =  explode(" ",trim(fgets(STDIN)));
$X = explode(" ",trim(fgets(STDIN)));

rsort($X);
//var_dump($X);
for($i=1;$i<$M;$i++) {
  $s[]=$X[$i-1]-$X[$i];
}
@rsort($s);
for($i=0;$i<$N-1;$i++) {
  unset($s[$i]);
}
printf("%d\n",@array_sum($s));


Measured memory_bytes: 18932
# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc084/tasks/abc084_d
AC
"""
import sys
from sys import stdin
from math import ceil, floor
input = stdin.readline


def create_prime_list(limit):
    """ エラトステネスの篩でlimitまでの素数リストを求める
    https://ja.wikipedia.org/wiki/%E3%82%A8%E3%83%A9%E3%83%88%E3%82%B9%E3%83%86%E3%83%8D%E3%82%B9%E3%81%AE%E7%AF%A9
    """
    x = limit**0.5
    primes = []
    #print('x={0}'.format(x))
    nums = [x for x in range(2, limit+1)]
    while nums[0]<=x:
        primes.append(nums[0])
        current_prime = nums[0]
        nums = [x for x in nums if x%current_prime != 0]
    primes.extend(nums)
    return primes


def solve(queries):
    primes = set(create_prime_list(10**5)) #  素数のテーブル、inでの判定が速くできるようにリストではなくセットにしておく
    dp = [0] * 100000

    # 1〜99,999までについて、1からのトータルで2017-likeな数字が累計でいくつあるか計算してテーブルにする
    p_num = 0
    for i in range(1, 100000, 2):
        if i in primes and ((i+1)//2) in primes:
            p_num += 1
        dp[i] = p_num

    # l 〜 r までで 2017-like数がいくつあるか求める
    for l, r in queries:
        if l == 1:
            ans = dp[r]         #  1からの場合、rまでの数がそのまま答え
        else:
            ans = dp[r] - dp[l-2] #  1〜rまでの数から 1〜l(エル)までの数を引けば、l〜rでの答えになる
        print(ans)


def main(args):
    queries = []
    Q = int(input())
    # Q = 0
    # for _ in range(100000):
    #     queries.append((1, 99999))
    for _ in range(Q):
        l, r = map(int, input().split())
        queries.append((l, r))
    solve(queries)


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


Measured memory_bytes: 22216
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<map>
#include<stack>
#include<queue>
#include<math.h>


long long int result;


using namespace std;


int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif


	ios_base::sync_with_stdio(false);
	cin.tie(NULL);



	long long int n, m;
	cin >> n >> m;
	char arr[n][m];
	for (long long int i = 0; i < n; i++)
	{
		for (long long int j = 0; j < m; j++)
			cin >> arr[i][j];
	}

	long long int brr[n][m];
	int ptr = 0;
	for (long long int i = 0; i < n; i++)
	{
		if (ptr == 1)
		{
			brr[i][0] = 0;
		}
		else if (arr[i][0] == '#')
		{	brr[i][0] = 0;
			ptr = 1;
		}
		else {
			brr[i][0] = 1;
		}
	}
	int tpr = 0;

	for (long long int i = 0; i < m; i++)
	{
		if (tpr == 1)
		{
			brr[0][i] = 0;
		}
		else if (arr[0][i] == '#')
		{	brr[0][i] = 0;
			tpr = 1;
		}
		else {
			brr[0][i] = 1;
		}
	}

	for (long long int i = 1; i < n; i++)
	{
		for (long long int j = 1; j < m; j++)
		{
			if (arr[i][j] == '#')
			{
				brr[i][j] = 0;
			}
			else {
				brr[i][j] = (brr[i - 1][j] + brr[i][j - 1]) % 1000000007;
			}
		}
	}
	cout << brr[n - 1][m - 1] % 1000000007 << endl;









	return 0;


}


Measured memory_bytes: 12400
n = int(input())
elements = list(map(int,input().split(" ")))

class Node():
    def __init__(self,value):
        self.value = value
        self.parent = -1
        self.kids = []

    def addParent(self,parent):
        self.parent = parent

    def addKid(self,kids):
        self.kids = kids

nodes = {}
for i in range(len(elements)):
    nodes[i] = Node(int(elements[i]))

parentIndex = 0
def checkKids(index):
    leftKid = index*2+1
    rightKid = index*2+2
    kids = []
    if leftKid in nodes:
        kids.append(leftKid)
        nodes[leftKid].addParent(index)
        checkKids(leftKid)
    if rightKid in nodes:
        kids.append(rightKid)
        nodes[rightKid].addParent(index)
        checkKids(rightKid)
    nodes[index].addKid(kids)

checkKids(parentIndex)

for id in nodes:
    ans = ""
    ans += "node " + str(id+1)
    ans += ": key = " + str(nodes[id].value)
    if not nodes[id].parent == -1:
        ans += ", parent key = " + str(nodes[nodes[id].parent].value)
    if len(nodes[id].kids) == 1:
        ans += ", left key = " + str(nodes[nodes[id].kids[0]].value)
    elif len(nodes[id].kids) == 2:
        ans += ", left key = " + str(nodes[nodes[id].kids[0]].value)
        ans += ", right key = " + str(nodes[nodes[id].kids[1]].value)
    print(ans + ", ")



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

int main(){
  int x,y,z;
  cin >> x >> y >> z;
  cout << (x-z)/(y+z) << endl;
}


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

using namespace std;

int main() {
	int N, K;
	string S;
	cin >> N >> K >> S;
	switch (S[K-1]) {
	case'A':
		S[K-1] = 'a';
		break;
	case'B':
		S[K-1] = 'b';
		break;
	case'C':
		S[K-1] = 'c';
		break;
	}
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np

N, M, K = map(int, input().split(' '))
A = list(map(int, input().split(' ')))
B = list(map(int, input().split(' ')))

a = [0]
b = [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])
b_set = set(b)
b_array = np.array(b)
max_cnt = 0

# print(a)
# print(b)

for i in range(N+1):
    temp = K - a[i]
    if temp >= 0:
        cnt = 0
        if temp in b_set:
            # print(b_array.searchsorted(temp))
            cnt = i + b_array.searchsorted(temp)
        else:
            # print(b_array.searchsorted(temp)-1)
            cnt = i + b_array.searchsorted(temp) - 1
        if max_cnt < cnt:
            max_cnt = cnt
print(max_cnt)

Measured memory_bytes: 80032
using System;

class Program
{
    static void Main(string[] args)
    {
        var xy = Console.ReadLine().Split(' ');
        var x1 = int.Parse(xy[0]);
        var y1 = int.Parse(xy[1]);
        var x2 = int.Parse(xy[2]);
        var y2 = int.Parse(xy[3]);

        var x3 = x2 - (y2 - y1);
        var y3 = y2 + (x2 - x1);

        var x4 = x1 - (y2 - y1);
        var y4 = y1 + (x2 - x1);

        Console.WriteLine($"{x3} {y3} {x4} {y4}");
    }
}


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

int main()
{
  int n;
  string s, t;
  cin >> n >> s >> t;

  for(int i = 0; i < n; i++){
    bool f = true;
    for(int j = 0; i+j < n; j++){
      if(s[i+j] != t[j]){
        f = false;
        break;
      }
    }
    if(f){
      cout << n+i << endl;
      return 0;
    }
  }

  cout << n*2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>

int main(void){
  int n, m, max=0;
  int price[1000];

  for(int t=0; t<10000; t++){

    max = 0;
    std::cin >> n;
    std::cin >> m;
    if(n == 0 && m == 0){
      break;
    }

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

    for(int j=0; j<n; j++){
      for(int s=0; s<n; s++){
	if(j == s){
	  break;
	}
	if(price[j] + price[s] > max && price[j] + price[s] <= m){
	  max = price[j] + price[s];
	}
      }
    }
    if(max > 0){
      std::cout << max << "\n";
    }else{
      std::cout << "NONE\n";
    }
  }
  return 0;
}



Measured memory_bytes: 3056
def main():
    n, k = map(int, input().split())
    sunuke = {}

    for i in range(1, k + 1):
        d = int(input())
        for a in input().split():
            if a in sunuke.keys():
                sunuke[a] += str(i)
            else:
                sunuke[a] = str(i)

    kind_of_sunuke = sunuke.keys()
    count = 0
    for j in range(1, n + 1):
        if str(j) not in kind_of_sunuke:
            count += 1
    print(count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9028
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

using ll=long long;

using vi=vector<int>;
using vll=vector<ll>;
using vvi=vector<vi>;

int main() {
  string S; cin >>S;
  string a="CODEFESTIVAL2016";
  int ans=0;
  rep(i,0,S.size()) {
    if (S[i]!=a[i]) {
      ans++;}
  }
  cout <<ans <<endl;
  return 0;
}


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

int main(){
    string s;
    int x, y;
    cin >> s >> x >> y;

    int n = s.length();
    vector<int> d(2);// x, y

    vector<vector<vector<bool>>> dp(2, // x, y
           vector<vector<bool>>(n, 
                  vector<bool>(16001, false)
            )
    );
    dp[1][0][8000] = true;

    int j = 0;
    bool flag = false;
    int first = 0;

    for(int i=0; i<n; i++){
        //cout << i << endl;
        if(s[i] == 'F' && flag == false) first += 1;
        if(s[i] == 'F' && flag == true)  d[j%2]  += 1;
        if(s[i] == 'T' || i == n-1){
            //cout << j << " " << d[j%2] << endl;
            if(flag == true){
                for(int k=0; k<16001; k++){
                    if(k - d[j%2] >= 0){
                        dp[j%2][j][k] = dp[j%2][j][k] || dp[j%2][j-1][k-d[j%2]];
                    }
                    if(k + d[j%2] < 16001){
                        dp[j%2][j][k] = dp[j%2][j][k] || dp[j%2][j-1][k+d[j%2]];
                    }
                    if(j+1 <= n-1) dp[j%2][j+1][k] = dp[j%2][j][k];
                    //if(8000 <= k && k <= 8005) cout << "dp[" << j%2 << "][" << j << "][" << k-8000 << "] = " << dp[j%2][j][k] << endl;
                }
            }
            if(flag == false){
                dp[0][0][8000 + first] = true;
                dp[0][1][8000 + first] = true;
                flag = true;
            }
            d[j%2] = 0;
            j += 1;
        }
    }

    if(dp[0][j-1][x + 8000] == true 
    && dp[1][j-1][y + 8000] == true) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 49800
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define INF (1e9)
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    ll a[200010];
    cin >> n;
    rep(i,0,n){
        cin >> a[i];
    }
    vector<int> ans;
    if(n % 2 == 0){
        rep(i,0,n/2){
            ans.push_back(a[2*(n/2 - i) - 1]);
        }
        rep(i,0,n/2){
            ans.push_back(a[2 * i]);
        }
    }else{
        rep(i,0,(n+1)/2){
            ans.push_back(a[2 * ((n+1)/2 - i - 1)]);
        }
        rep(i,0,(n-1)/2){
            ans.push_back(a[2 * i + 1]);
        }
    }
    int ll = ans.size();
    rep(i,0,ll){
        if(i == ll-1){
            cout << ans[i] << endl;
        }else{
            cout << ans[i] << " ";
        }
    }


}


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

int n, k;
int loc[6][50];
int sloc[3][100];
int sea[99][99][99];
long long int ans = 0;

bool judge(int i, int x, int y, int d)
{
  if(loc[0][i] <= sloc[0][x]&&
     sloc[0][x + 1] <= loc[3][i]&&
     loc[1][i] <= sloc[1][y]&&
     sloc[1][y + 1] <= loc[4][i]&&
     loc[2][i] <= sloc[2][d]&&
     sloc[2][d + 1] <= loc[5][i])
    return true;
  return false;
}

int main()
{
  cin >> n >> k;
  
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 6; j++){
      cin >> loc[j][i];
    }
  }

  for(int i = 0; i < 6; i++){
    for(int j = 0; j < n; j++){
      sloc[i % 3][2 * j + i % 2] = loc[i][j];
    }
  }

  for(int i = 0; i < 3; i++)
    sort(sloc[i], sloc[i] + n * 2);
  
  for(int i = 0; i < n; i++){
    for(int x = 0; x < n * 2 - 1; x++){
      for(int y = 0; y < n * 2 - 1; y++){
	for(int d = 0; d < n * 2 - 1; d++){
	  if(judge(i, x, y, d))
	    sea[x][y][d]++;
	}
      }
    }
  }
  
  for(int x = 0; x < n * 2 - 1; x++){
    for(int y = 0; y < n * 2 - 1; y++){
      for(int d = 0; d < n * 2 - 1; d++){
	if(sea[x][y][d] >= k)
	  ans += (long long int) (sloc[0][x + 1] - sloc[0][x]) * (sloc[1][y + 1] - sloc[1][y]) * (sloc[2][d + 1] - sloc[2][d]);
      }
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4924
def fight(no_mons, fighter, remain = 0):
    no_mons -= remain
    if no_mons < 0:
        return [0, fighter]
    no_mons -= fighter
    if no_mons < 0:
        return [0, abs(no_mons)]
    else:
        return [no_mons, 0]

n = int(input())
raw_town = input().split()
raw_fighter = input().split()
town = [int(x) for x in raw_town]
fighter = [int(x) for x in raw_fighter]
sum = 0
fighter_remain = 0
for i in range(n):
    mons_remain, fighter_remain = fight(town[i], fighter[i], fighter_remain)
    sum += town[i] - mons_remain
last_mons_remain = fight(town[n], fighter_remain)[0]
sum += town[n]- last_mons_remain
print(sum)

Measured memory_bytes: 80996
H, W = map(int, input().split())

table = [["#"] + list(input()) + ["#"] for _ in range(H)]
table = [["#" for _ in range(W+2)]] + table + [["#" for _ in range(W+2)]]

cnt = 0
for r in table:
    for s in r:
        if s == ".":
            cnt += 1

# BFS
connect = [[0 for _ in range(W+1)] for _ in range(H+1)]
used = [[1000 for _ in range(W+1)] for _ in range(H+1)]

# make dictionary
for r in range(1, H + 1):
    for c in range(W + 1):
        if table[r][c] == ".":
            connect_list = []
            if table[r+1][c] == ".":
                connect_list.append([r+1, c])

            if table[r-1][c] == ".":
                connect_list.append([r-1, c])

            if table[r][c+1] == ".":
                connect_list.append([r, c+1])

            if table[r][c-1] == ".":
                connect_list.append([r, c-1])

            connect[r][c] = connect_list


# search
queue = [[1, 1, 0]]


def bfs(x, y, num):
    while len(queue) > 0:
        r, c, num = queue.pop(0)
        if used[r][c] == 1000:
            used[r][c] = num
            for t in connect[r][c]:
                queue.append([t[0], t[1], num + 1])


bfs(1, 1, 0)

if used[H][W] == 1000:
    print(-1)

else:
    print(cnt - used[H][W] - 1)


Measured memory_bytes: 4340
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int imap[2001][2001];
int sum, maxw, maxh;



void dfs(int x, int y) {
    int nx, ny;
    imap[x][y] = 0;
    sum++;
    for (int i = -1; i <= 1; i++) {
        for (int j = -1; j <= 1; j++) {
            nx = x+i, ny = y + j;
            if (nx >= 0 && nx < maxh && ny >= 0 && ny < maxw && imap[nx][ny] == -1) dfs(nx, ny);
        }
    }
}

int main() {
    int x1, y1, w1, h1, x2, y2, w2, h2;

    scanf("%d %d %d %d", &x1, &y1, &w1, &h1);
    scanf("%d %d %d %d", &x2, &y2, &w2, &h2);
    sum = 0;
    maxw = max(x1+w1, x2+w2);
    maxh = max(y1+h1, y2+h2);
    for (int i = 0; i < maxh; i++) fill(imap[i], imap[i]+maxw, 0);

    for (int i = y1; i < y1+h1; i++) {
        for (int j = x1; j< x1+w1; j++) imap[i][j] = 1;
    }

    for (int i = y2; i < y2+h2; i++) {
        for (int j = x2; j< x2+w2; j++) {
            if (imap[i][j] == 1) imap[i][j] *= -1;
            else imap[i][j] = 1;
        }
    }


    for (int i = 0; i <= maxh; i++) {
        for (int j = 0; j<= maxw; j++)
            if (imap[i][j] == -1) {
                dfs(i, j);
                break;
            }
    }
    printf("%d\n", h1*w1+h2*w2-sum*2);


}



Measured memory_bytes: 73420
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <set>

using namespace std;

typedef long long ll;

int main(){
  int n, k; cin >> n >> k;
  set<int> S;
  for(int i=0;i<k;i++){
    int x; cin >> x;
    S.insert(x);
  }
  int ans=n;
  int i=0;
  while(ans != 0){
    ans = n+i;
    while(ans != 0){
      //cout << ans << endl;
      if(S.find(ans %10) != S.end()) break;
      ans = ans/10;
    }
    i++;
  }
  cout << n+i-1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll                  long long
#define dl                 long double
#define pb                push_back
#define F                  first
#define S                  second
#define endl              "\n"
#define rep(i,a,b)       for(i=a;i<b;i++)
#define all(v)             v.begin(),v.end()
#define allr(v)            v.rbegin(),v.rend()
#define mod              1000000007LL
#define CIN(V,s,n)      for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n)   {for(int i=s;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);      for(ll i=0;i<V.size();i++) V[i] = 0;
#define N                  105
#define tmod             998244353LL
using namespace std;

bool sBs(const pair<int,int> &a,const pair<int,int> &b)
{   return (a.second < b.second);   }

ll SUMD(ll n);
ll BS(vector<pair< ll ,ll > > &PS,ll s,ll e,ll ser);
ll MI(ll a, ll m);
ll P[N+1];
void Sieve(int n=N);
ll Powb(ll b,ll n,ll m);

int main()
{
fast;
ll q=1,t;
//cin >> q; t = q;
while(q--)
{
    ll i,j,n,m,k,l,r,a=0,b=0,c=0,d=0,e,g=1,p,u,v,w,x,y,flag=1;
    //n=m=k=i=j=l=r=a=b=c=d=u=v=w=p=x=y=0;
    dl x1;
    cin >> n >> x1;
    cout << (ll)floor(n*x1);

}
    return 0;
}

//*****************************************************************************************************************************************

ll Powb(ll b,ll n,ll m)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2,m);
    if(n%2==0){return (temp*temp)%m;}
    else{return (b*((temp*temp)%m))%m;}
}

ll SUMD(ll n)
{   ll sum=0;
    while(n>0){sum += n%10;n = n/10;}
    return sum;

}
ll BS(vector<pair<ll,ll> > &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid].F==ser)
    {
        return mid;
    }
    else if(PS[mid].F > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll MI(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}

void Sieve(int n)
{
    //memset(P,true,sizeof(P));
    //P[0] = false;
    //P[1]= false;
    for(int i=1;i<=n;i++) P[i] = i;
    for(ll i=2;i*i<=n;i++)
    {
        if(P[i]==i)
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                if(P[j]==j)
                    P[j]=i;
            }
        }
    }

}



Measured memory_bytes: 3756
#include <iostream>
#include <vector>
int main() {
    int N;
    std::cin >> N;
    std::vector <int> next(N+1,0);
    std::vector <bool> isBlack(N+1,false);//訪問済みノード

    for(int i=1;i<N+1;i++){
        std::cin >> next[i];
    }
    int nextNodeidx = next[1];
    int PushNum = 1;
    isBlack[1] = true;

    while(!isBlack[nextNodeidx] && nextNodeidx != 2){
        PushNum ++ ;
        isBlack[nextNodeidx] = true;
        nextNodeidx = next[nextNodeidx];
    }
    if(nextNodeidx == 2){
        std::cout << PushNum;
    }else{
        std::cout << -1;
    }

    return 0;
}

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

int main()
{
    string s,t;
    cin >> s >> t;
    int m = s.length(), n = t.length();
    int ans = n;
    for (int i=0; i<=m-n; i++) {
        int curr = 0;
        for (int j=0; j<n; j++) {
            if (s[i+j] != t[j]) {
                curr++;
            }
        }
        ans = min(curr, ans);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int d;
  cin >> d;
  vector<int> c(26), last(26);
  for (int i = 0; i < 26; i++) {
    cin >> c.at(i);
  }
  vector s(d, vector(26, 0));
  for (int i = 0; i < d; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s.at(i).at(j);
    }
  }
  int v = 0;
  for (int i = 0; i < d; i++) {
    int t;
    cin >> t;
    last.at(t - 1) = i + 1;
    v += s.at(i).at(t - 1);
    for (int j = 0; j < 26; j++) {
      v -= c.at(j) * (i + 1 - last.at(j));
    }
    cout << v << endl;
  }
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    ll A,B;

    cin >> A >> B;
    if(A < 1 || A > 9 || B < 1 || B > 9){
        cout << "-1" << endl;
    }else{
        cout << A*B << endl;
    }

    return 0;
}

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


int main() {

int a,b,c,d,e;

cin>>a>>b>>c>>d>>e;

if(a==0){
  cout<<1<<endl;
}
if(b==0){
  cout<<2<<endl;
}
if(c==0){
  cout<<3<<endl;
}
if(d==0){
  cout<<4<<endl;
}
if(e==0){
  cout<<5<<endl;
}
  return 0;
}

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

int main() {
  
  int a,b,ans=0;
  cin >> a >> b;
  for(int i=a;i<=b;i++){
    int e=i%10,r=i/10000%10,t=i/10%10,y=i/1000%10;
    if(e==r&&t==y)ans++;
  }
  cout << ans << endl;
      
}

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

int main() {
  string s;
  cin >> s;
  if (
    (s[0] == s[1] && s[2] == s[3] && s[0] != s[2])
    || 
    (s[0] == s[2] && s[1] == s[3] && s[0] != s[1])
    || 
    (s[0] == s[3] && s[1] == s[2] && s[0] != s[1])
    )
    cout << "Yes" << endl;
  else cout << "No" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  cin >> A >> B;
  
  if (10 <= A || 10 <= B) {
    cout << -1 << endl;
  } else {
    cout << A * B << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define MOD 1000000007
using namespace std;
using ll = long long;

const int MAX = 1000000;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int 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;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

template <class T> struct cord{
  T x,y;
};

template <class T> double dist(cord<T> a, cord<T> b){
  T dx=a.x-b.x;
  T dy=a.y-b.y;
  return sqrt(dx*dx+dy*dy);
}

int main()
{

  //cout << fixed << setprecision(10);
  
  int n; cin >> n;
  cout << n/3 << endl;

  return 0;
}


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

def main():
    N, W = tuple(map(int, input().rstrip().split()))
    A = tuple(tuple(map(int, input().rstrip().split())) for _ in range(N))
    lim = 10 ** 5
    dp = [0] + [float("inf")] * lim
    for i in range(N):
        for j in range(lim, A[i][1] - 1, -1):
            dp[j] = min(dp[j], dp[j - A[i][1]] + A[i][0])
    ans = [i for i, j in enumerate(dp) if j <= W]
    print(max(ans))


if __name__ == "__main__":
    main()

Measured memory_bytes: 72764