akhauriyash/Code-Regression huggingface dataset:
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func main() {
	sc.Split(bufio.ScanWords)

	N, A, B := getInt(), getInt(), getInt()

	if A > B {
		out(0)
		return
	}

	if N == 1 {
		if A == B {
			out(1)
			return
		}
		out(0)
		return
	}
	if N == 2 {
		out(1)
		return
	}

	n := N - 2
	x := A*(n+1) + B
	y := B*(n+1) + A
	out(y - x + 1)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

const Int MOD = 1e9+7;

Int calc(Int n,vector<Int> a){
  vector<Int> c(5,0),s(5,0);
  for(Int i=0;i<n;i++){
    c[to_string(a[i]).size()]++;
    s[to_string(a[i]).size()]+=a[i];
  }
 
  auto P=make_v<Int>(n+1,n+1);
  fill_v(P,0);
  for(Int i=0;i<=n;i++){
    for(Int j=0;j<=i;j++){
      P[i][j]=1;
      for(Int k=0;k<j;k++)
	P[i][j]=P[i][j]*(i-k)%MOD;
    }
  }
  vector<Int> dp2(n+1,0);
  for(Int i=0;i<=n;i++){
    for(Int j=0;j<=i;j++){
      dp2[i]+=P[i][j];
      dp2[i]%=MOD;
    }
  }
  
  vector<Int> fact(n+1,1);
  for(Int i=0;i<n;i++) fact[i+1]=fact[i]*(i+1)%MOD;
  vector<Int> po(n*4+1,1);
  for(Int i=0;i<n*4;i++) po[i+1]=po[i]*10%MOD;
  
  Int ans=0;
  for(Int d=1;d<=4;d++){
    if(!c[d]) continue;
    c[d]--;
    auto dp=make_v<Int>(n+1,n*4+1);
    fill_v(dp,0);
    dp[0][0]=1;
    for(Int a=1;a<=4;a++){
      for(Int x=0;x<c[a];x++){
	for(Int i=n;i>=0;i--){
	  for(Int j=n*4;j>=0;j--){
	    Int ni=i+1,nj=j+a;
	    if(ni<=n&&nj<=n*4){
	      dp[ni][nj]+=dp[i][j];
	      dp[ni][nj]%=MOD;
	    }
	  }
	}
      }
    }
    c[d]++;
    for(Int i=0;i<n;i++){
      for(Int j=0;j<=4*n;j++){
	Int tmp=dp[i][j]*fact[i]%MOD;
	Int k=n-(i+1);
	tmp*=dp2[k];	
	tmp%=MOD;
	
	tmp*=po[j];
	tmp%=MOD;

	tmp*=s[d];
	tmp%=MOD;
	
	ans+=tmp;
	ans%=MOD;
	
	if(0&&dp[i][j])
	  cout<<i<<":"<<dp[i][j]<<" "<<dp2[k]<<" "<<po[j]<<" "<<s[d]<<":"<<tmp<<endl;	
      }
    }
  }
  return ans;
}

signed main(){  
  cin.tie(0);
  ios::sync_with_stdio(0);
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  sort(a.rbegin(),a.rend());
  Int ans=calc(n,a);
  //cout<<ans<<endl;
  if(a.back()==0){
    a.pop_back();
    n--;
    ans+=MOD-calc(n,a);
    ans%=MOD;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 4616
dic={}

n=int(input())

for i in range(n):
  x=input()
  if x in dic:
    dic[x]=dic[x]+1
  else:
    dic[x]=1

print("AC x {}".format(dic.get("AC",0)))
print("WA x {}".format(dic.get("WA",0)))
print("TLE x {}".format(dic.get("TLE",0)))
print("RE x {}".format(dic.get("RE",0)))


Measured memory_bytes: 9188
n = gets.to_i
a = gets.chomp.split.map(&:to_i)

ans = []
a.each_with_index do |a_n, i|
    if n % 2 == 0
        if i % 2 == 0
            ans.push(a_n)
        else
            ans.unshift(a_n)
        end
    else
        if i % 2 == 1
            ans.push(a_n)
        else
            ans.unshift(a_n)
        end
    end
end

ans.each_with_index do |num, i|
    if i == n - 1
        puts num
    else
        print "#{num} "
    end
end


Measured memory_bytes: 25572
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

vl divisor(ll k){
    vl c;
    for(ll i=1; i*i<=k; i++){
        if(k % i == 0){
            c.push_back(i);
            if((k / i) != i){
                c.push_back(k/i);
            }
        }
    }
    sort(c.rbegin(), c.rend());
    return c;
}

int main(){
    ll n; cin >> n;
    ll ans = 0;
    for(ll i=1; i<=n; i+=2){
        vl div = divisor(i);
        if(div.size() == 8) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

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

int main(){

    int a,b;
    cin >> a >> b;
    if(a+b < 10){
        cout << a+b << endl;
    }else{
        cout << "error" << endl;
    }

    
   
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
using namespace std;
const int N = 2e5+107;
int n,i,b,j,x;
bitset <N> f;
int main()
{
    cin>>x;
    f[1]=1;
    f[0]=1;
    for (i=2;i*i<=N;++i)
    {
        if (!f[i])
        {
            b=N/i;
            for (j=i;j<=b;++j)
                 f[i*j]=1;
        }
    }
    while (f[x])
           x++;
    cout<<x;
}


Measured memory_bytes: 256
s = input()
counter = [0]*2019
counter[0] = 1
ans = 0
res, d = 0, 1
for i in range(len(s)-1, -1, -1):
    res = (res+int(s[i])*d)%2019
    counter[res] += 1
    d = d*10%2019
for count in counter:
    ans += count*(count-1)//2
print(ans)

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

int main() {
    int N;
    cin >> N;
    vector<int> B(N-1);
    for (auto& e : B)
        cin >> e;
    int sum = B[0];
    for (int i = 0; i < N-2; i++) {
        sum += min(B[i], B[i+1]);
    }
    sum += B.back();

    cout << sum << endl;
}

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

int main() {
	long inNum;
	
	cin >> inNum;

	int check = inNum;
	int total = 0;
	int result = 0;

	while (check > 0) {
		total = total + check % 10;
		check = check / 10;
	}

	result = inNum % total;

	if (result == 0) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	} 	
}

Measured memory_bytes: 256
# c, s, f

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


def main():
    import math
    import collections
    import itertools

    n = int(input())
    times = []
    for _ in range(n - 1):
        times.append(list(map(int, input().split())))

    for i in range(n - 1):
        time = 0
        for j in range(i, n - 1):
            times_j = times[j]
            if times_j[1] > time:
                time = times_j[1] + times_j[0]
            else:
                time = times_j[1] + ((time - times_j[1] + times_j[2] - 1) // times_j[2]) * times_j[2] + times_j[0]
        print(time)
    print(0)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3564
#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>
#include <unordered_map>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    ll a,b;
    cin>>a>>b;
    if((a+b)&1){
        cout<<"IMPOSSIBLE"<<endl;
    }
    else{
        cout<<(a+b)/2<<endl;
    }
}

Measured memory_bytes: 256
def is_prime?(x)
  max = Math.sqrt(x).floor
  nums = (2..max).to_a
  while ! nums.empty?
    i = nums.shift
    return false if x % i == 0

    nums.delete_if { |j| j % i == 0 }
  end
  true
end

x = gets.to_i
loop do
  if is_prime?(x)
    p x
    break
  end
  x += 1
end


Measured memory_bytes: 1788
#include <iostream>

using namespace std;

int main(){
  int H,W;
  cin >> H;
  cin >> W;
  char data[H][W];
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> data[i][j];
    }
  }

  for(int i=0;i<H;i++){
    bool flag = true;
    for(int j=0;j<W;j++){
      if(data[i][j]=='#'){
        flag = false;
      }
    }

    if(flag == true){
      for(int j=0;j<W;j++){
        data[i][j]='0';
      }
    }
  }

  for(int j=0;j<W;j++){
    bool flag = true;
    for(int i=0;i<H;i++){
      if(data[i][j]=='#'){
        flag = false;
      }
    }
    if(flag == true){
      for(int i=0;i<H;i++){
        data[i][j]='0';
      }
    }
  }



  for(int i=0;i<H;i++){
    int counter = 0;
    for(int j=0;j<W;j++){
      if(data[i][j]=='0'){
        continue;
      }
      cout << data[i][j];
      counter++;
    }
    if(counter!=0){
      cout << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  if(k == 0) {
    printf("%lld\n", n*(ll)n);
    return 0;
  }
  ll r = 0;
  for(int b = k+1; b <= n; b++) {
    int easymodo = n/b;
    r += easymodo * (b-k);
    int leftover = n % b;
    r += max(0, leftover-k+1);
  }
  printf("%lld\n", r);
}


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

using namespace std;

const int nmax = 40, abmax = 10, inf = 1e7;
int a[nmax], b[nmax], c[nmax];
int dp[nmax+1][nmax*abmax+1][nmax*abmax+1];

int main() {
        int n, ma, mb;
        cin >> n >> ma >> mb;
        for (int i = 0; i < n; i++)
                cin >> a[i] >> b[i] >> c[i];

        for (int i = 0; i <= n; i++)
                for (int ca = 0; ca <= n*abmax; ca++)
                        for (int cb = 0; cb <= n*abmax; cb++)
                                dp[i][ca][cb] = inf;

        dp[0][0][0] = 0;

        for (int i = 0; i < n; i++) {
                for (int ca = 0; ca <= n*abmax; ca++) {
                        for (int cb = 0; cb <= n*abmax; cb++) {
                                if (dp[i][ca][cb] == inf) continue;
                                dp[i+1][ca][cb] = min(dp[i+1][ca][cb], dp[i][ca][cb]);
                                dp[i+1][ca+a[i]][cb+b[i]] = min(dp[i+1][ca+a[i]][cb+b[i]], dp[i][ca][cb]+c[i]);
                        }
                }
        }

        int ans = inf;
        for (int ca = 1; ca <= n*abmax; ca++) {
                for (int cb = 1; cb <= n*abmax; cb++) {
                        if (ca*mb == cb*ma)
                                ans = min(ans, dp[n][ca][cb]);
                }
        }

        if (ans == inf) ans = -1;
        cout << ans << endl;


        return 0;
}


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  vector<int> vec(3);
  vec.at(0) = A;
  vec.at(1) = B;
  vec.at(2) = C;
  int sevs = 0;
  int fives = 0;
  for (int i : vec) {
    if (i == 5) {
      fives++;
    } else if (i == 7) {
      sevs++;
    }
  }
  
  if (fives == 2 && sevs == 1) {
    cout << "YES" << endl;
  } else {
    cout  << "NO" << endl;
  }
 
  return 0;
}

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

int main() {
 	string  a,b;
  	int n=0;
  cin >> a >>b ;

  for(int i=0;i<3 ;i++){
    if(a.at(i)==b.at(i)){
      n++;
    }
  }
    cout << n << endl;
  }
  

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    std::vector<long> pn[8];
    for (int i = 0; i < n; i++) {
        long x, y, z;
        cin >> x >> y >> z;
        pn[0].push_back(+x +y +z);
        pn[1].push_back(+x +y -z);
        pn[2].push_back(+x -y +z);
        pn[3].push_back(-x +y +z);
        pn[4].push_back(-x -y +z);
        pn[5].push_back(-x +y -z);
        pn[6].push_back(+x -y -z);
        pn[7].push_back(-x -y -z);

    }
    long res = 0;
    for (int i = 0; i < 8; i++) {
        sort(pn[i].begin(), pn[i].end(), greater<>());
        long tres = accumulate(pn[i].begin(), pn[i].begin() + m, 0l);
        if (tres > res) {
            res = tres;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B, ans;
  cin >> A >> B;
  if(B == 1){
    cout << 0 << endl;
  }else if(A >= B ){
    cout << 1 << endl;
  }else{  
  for (ans = 2; ans < 20; ans ++) {
    if(ans *A - ans + 1 >= B) break;
  }
  cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include<math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long int
#define py printf("Yes\n")
#define pn printf("No\n")
#define in cin>>
using namespace std;
const int INF = 1001001001;

int main()
{
    int n;
    in n;
    for(int i=1;;i++)
    {
        if(i*i>n)
        {
            cout<<((i-1)*(i-1))<<endl;
            break;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N, A, B; cin >> N >> A >> B;
    cout << min(N * A, B) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int K, N;
  cin >> K >> N;
  vector<int> home(N);
  for(int i=0; i<N; i++){
    int a;
    cin >> a;
    home.at(i)=a;
  }
  sort(home.begin(), home.end());
  int answer = K;
  for(int i=0; i<N-1; i++){
    if(answer >= K - home.at(i+1) + home.at(i)){
      answer = K - home.at(i+1) + home.at(i);
    }
    else{
      continue;
    }
  }
    if(answer >= home.at(N-1) - home.at(0)){
    answer = home.at(N-1) - home.at(0);
    }
  cout << answer << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;

const int kMaxn = 5e3 + 5;

int main() {
  //
  int X;
  cin >> X;
  if (X >= 30)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


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

#define mp make_pair
#define pb push_back

#define int int64_t

const int MOD = 1e9+7;
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,p;
    cin>>n>>p;
    string s;
    cin>>s;
    vector<int> pre(n+1);
    pre[0]=0;
    vector<int> arr(p, 0);
    arr[0]++;
    if(p==2||p==5) {
        int ans=0;
        for(int i=0;i<n;i++) {
            if((s[i]-'0')%p==0) {
                ans+=(i+1);
            }
        }
        cout<<ans;
        return 0;
    }
    int k=0;
    int t=1;
    for(int i=n-1;i>=0;i--) {
        k+=(s[i]-'0')*t;
        k%=p;
        //cout<<k<<"\n";
        arr[k]++;
        t*=10;
        t%=p;
    }   

    int ans=0;
    for(int i=0;i<p;i++) {
        ans+=((arr[i]*(arr[i]-1))/2);
    }

    cout<<ans;

    return 0;
}

Measured memory_bytes: 2196
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,men,fish,num,fishmax;
cin>>n;
for(int i=0;i<n;i++){
cin>>men>>fish;
if(i==0){
num=men;
fishmax=fish;
}
else {
if(fish>fishmax){
fishmax=fish;
num=men;
}
else if(num>men&&fish==fishmax)num=men;
}
}
cout<<num<<" "<<fishmax<<endl;
}

Measured memory_bytes: 1164
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}
  
int main()
{
  int n; cin >> n;
  int a[n],b[n],c[n-1];
  int i,t1,t2;
  int ans = 0;
  rep(i,n){cin >> a[i];}
  rep(i,n){cin >> b[i];}
  rep(i,n-1){cin >> c[i];}

  rep(i,n){
      t1 = a[i]-1; if(i<n-1){t2 = a[i+1]-1;}else{t2 = -1;}
      ans += b[t1];
      if(t2 - t1 == 1){ans += c[t1];}
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int a,b,c,d,e;
  int count=0;
  cin>>a>>b>>c>>d;
  for(int i=0;i<a+1;i++){
    for(int j=0;j<b+1;j++){
      for(int k=0;k<c+1;k++){
        e=i*500+j*100+k*50;
          if(d==e){
            count++;
          }
      }
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
n,d = map(int,input().split())
l = []
for i in range(n):
  l_ = list(input().split())
  l.append(l_)
count = 0
for i in range(n-1):
  for j in range(i+1,n):
    ans = 0
    for k in range(d):
      ans += (int(l[i][k])-int(l[j][k]))**2
      
    if ans**0.5 % 1 == 0:
      count += 1
print(count)

Measured memory_bytes: 3188
n = int(input())
h = list(map(int, input().split()))

cnt =0
m =[]
if n !=1:
    for i in range(n - 1):
	    if h[i] >= h[i + 1]:
		    cnt += 1
		    if i == n - 2:
			    m.append(cnt)
	    else:
		    m.append(cnt)
		    cnt = 0
else:
	m.append(0)
print(max(m))

Measured memory_bytes: 15020
from collections import deque

n = int(input())
graphs = [[] for i in range(n+1)]
visited = [False] * (n+1)
min_s = [-1] * (n+1)

for i in range(1, n+1):
    nodes = list(map(int, input().split()))
    graphs[i].extend(nodes[1:])

q = deque()
q.append([1, 0])
while q:
    node, j = q.popleft()
    if not visited[node]:
        visited[node] = True
        min_s[node] = j
    nodes = graphs[node]
    for node in nodes:
        if not visited[node]:
            q.append([node, j+1])

for i in range(1, n+1):
    print(i, min_s[i])


Measured memory_bytes: 16596
#include<bits/stdc++.h>
using namespace std;
int n,m;
int rea[100010];
vector<int> g[100010];
int ans;
int dfs(int v)
{
	int h = 0;
	for(int i = 0; i < g[v].size(); i++)
		if(g[v][i] > 1) h = max(h, dfs(g[v][i]) + 1);
	if(rea[v] >1 && h == m - 1)
	{
		ans++, rea[v] = 1;
		h = -1;
	}
	return h;
}
int main()
{
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
		cin >> rea[i],g[rea[i]].push_back(i);
	if(rea[1] > 1) ans = 1, rea[1] = 1;
	dfs(1);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 10752
from math import factorial
n=int(input())
*l1,=map(int,input().split())
*l2,=map(int,input().split())
ansl=[]
for l in [l1,l2]:
  l_ref = list(range(1,n+1))
  ans = 0
  m = n-1
  for i in l:
    ans += factorial(m) * l_ref.index(i)
    l_ref.remove(i)
    m-=1
  ansl.append(ans)
print(abs(ansl[1]-ansl[0]))


Measured memory_bytes: 3064
N, M = map(int, input().split())
D = {}
for i in range(M):
  p, S = map(str, input().split())
  p = p
  if p in D:
    if S == "AC":
      D[p][1] = 1
    if D[p][1] == 0:
      D[p][0] += 1
  else:
    if S == "WA":
      D[p] = [1, 0]
    else:
      D[p] = [0, 1]
SUM41 = 0
SUM42 = 0
for i in D:
  if D[i][1] == 1:
    SUM41 += D[i][0]
    SUM42 += 1
print(SUM42, SUM41)

Measured memory_bytes: 25276
#include <stdio.h>
#include <stdbool.h>
typedef unsigned int uint;
inline static uint gl(void){
    uint x = 0;
    for(;;){
        const uint c = getchar_unlocked() - 48;
        if(c < 10){
            x = x*10 + c;
        }else{
            return x;
        }
    }
}

inline static bool gg(void){
    uint x = 0;
    for(;;){
        const uint c = getchar_unlocked() - 48;
        if(c < 10){
            x = c;
        }else{
            return x&1;
        }
    }
}

int main(void){
    const size_t n = gl();
    for(size_t i=0; i<n; i++){
        if(gg()){
            puts("first");
            return 0;
        }
    }
    puts("second");
    return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
    static final int MOD = 1000000007;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] arr = sc.next().toCharArray();
		int length = arr.length;
		int[] values = new int[length + 1];
		for (int i = 0; i < length; i++) {
		    values[i + 1] = arr[i] - '0';
		}
		int kk = sc.nextInt();
		long[][][] dp = new long[length + 1][kk + 2][2];
		dp[0][0][1] = 1;
		for (int i = 1; i <= length; i++) {
		    for (int j = 0; j <= kk; j++) {
		        dp[i][j][0] += dp[i - 1][j][0];
		        dp[i][j][0] %= MOD;
	            dp[i][j + 1][0] += dp[i - 1][j][0] * 9;
	            dp[i][j + 1][0] %= MOD;
		        if (values[i] == 0) {
		            dp[i][j][1] += dp[i - 1][j][1];
		            dp[i][j][1] %= MOD;
		            continue;
		        }
	            dp[i][j][0] += dp[i - 1][j][1];
	            dp[i][j][0] %= MOD;
	            dp[i][j + 1][0] += dp[i - 1][j][1] * (values[i] - 1);
	            dp[i][j + 1][0] %= MOD;
		        dp[i][j + 1][1] += dp[i - 1][j][1];
		    }
		}
		System.out.println((dp[length][kk][0] + dp[length][kk][1]) % MOD);
   }
}


Measured memory_bytes: 23764
// Ti と Ai の記録から、各山の高さの上界がわかる
// T(i-1) < Ti のとき、i番目の山がSiなのが確定
// Ai > A(i-1) のとき、i番目の山がAiなのは確定
// 確定させたとき、両者の値が違う、若しくは、
// Tiで山の高さが確定したとき、Ti > Ai
// Aiで山の高さが確定したとき、Ai > Ti
// となる場合、矛盾が生じるので答えはない
// それ以外の値については1 ～ min(Ai, Ti)だけ山の高さがあり得そう
#include <bits/stdc++.h>
using namespace std;

const long long MOD = 1000000007LL;

int main() {
    int N;
    cin >> N;
    vector<int> T(N + 2, 0), A(N + 2, 0);
    for (int i = 1; i <= N; ++i) {
        cin >> T[i];
    }
    for (int i = 1; i <= N; ++i) {
        cin >> A[i];
    }

    vector<int> S(N + 2, 0);
    for (int i = 1; i <= N; ++i) {
        if (T[i - 1] < T[i]) {
            S[i] = T[i];
        }
    }
    for (int i = N; i >= 1; --i) {
        if (A[i] > A[i + 1]) {
            if (S[i] != 0 && A[i] != S[i]) {
                cout << 0 << endl;
                return 0;
            }
            // S[i] == 0のとき
            if (A[i] > T[i]) {
                cout << 0 << endl;
                return 0;
            }
            S[i] = A[i];
        }
    }

    long long res = 1;
    for (int i = 1; i <= N; ++i) {
        if (S[i] != 0) {
            continue;
        }
        res = res * min(A[i], T[i]) % MOD;
    }
    cout << res << endl;
    return 0;
}

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

using namespace std;

int main() {


    char a[3];
    for(int i=0; i<3; i++){
        cin>>a[i];
        if(a[i]=='7') {cout<<"Yes"<<endl; return 0;}
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3572
#!/usr/bin/env python3
import sys


def solve(N: int, x: int, a: "List[int]"):
    ans = 0
    a.sort()
    for i in a:
        if(x-i >= 0):
            ans += 1
            x -= i
        else:
            break
    else:
        if(x > 0):
            print(ans-1)
            exit()

    print(ans)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, x, a)

if __name__ == '__main__':
    main()


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

int main(){
long long int N;
cin >> N;
long long int A[5];


for(int i=0;i<5;i++){
    cin>>A[i];
}

sort(A,A+5);
long long int ans=0; 
ans += N/A[0];
ans += 5;
if(N%A[0]==0){
    ans--;
}
cout<<ans;
return 0;


}

Measured memory_bytes: 256
# E - Gluttony

import numpy as np

# np.arrayに変換する場合はsortedを使うよりnp.sortを使う方が少し速い
N, K = map(int, input().split())
A = np.sort(np.array((list(map(int, input().split())))))
F = np.sort(np.array(sorted((list(map(int, input().split()))))))[::-1]

lower = 0
upper = A[-1] * F[0]

# 達成可能な最高成績を二分探索する
while lower <= upper:
    result = (lower + upper) // 2
    # resultを達成可能なAと実際のAの差異の総和が必要な修行コスト
    # np.arrayの和を求める場合、sum(array)よりarray.sum()の方が速い(使わないとTLE)
    if np.clip(A - result//F, 0, None).sum() <= K:
        ans = result
        upper = result - 1
    else:
        lower = result + 1

print(ans)

Measured memory_bytes: 38748
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val xs = readLine()!!.split(' ').map { it.toInt() }.toIntArray()
    val ys = IntArray(n)
    val ans = mutableListOf<Int>()

    for (i in n - 1 downTo 0) {
        val s = (i until n step (i + 1)).map { ys[it] }.sum()
        if (s % 2 != xs[i]) {
            ys[i]++
            ans.add(i + 1)
        }
    }

    println(ans.size)
    ans.joinToString(" ").let { println(it) }
}


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

int main() {
  long long a;
  cin >> a;
  string b;
  cin >> b;

  b.erase(b.begin()+1);   
  int k = stoi(b);   
   
  cout << int64_t(a*k/100) << endl;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC(T, v) static_cast<T>(v)
#define SI(v) SC(int, v.size())
#define SL(v) SC( LL, v.size())
#define RF(e, v) for(auto & e: v)
#define ei else if
#define UR assert(false)

// ---- ----

LL cmCI(LL l, LL r, LL m, LL a) { assert(m > 0); return max(0LL, fl(r - a, m) - fl(l - a, m)); }
LL cmCD(LL l, LL r, LL m, LL a) { return cmCI(l    , r - 1, m, a); }
LL cmII(LL l, LL r, LL m, LL a) { return cmCI(l - 1, r    , m, a); }
LL cmID(LL l, LL r, LL m, LL a) { return cmCI(l - 1, r - 1, m, a); }

LL f(LL x) {
	LL ans = 0;
	inc(i, 40) {
		LL b = 1LL << i;
		LL c = fl(x, 2 * b) * b + max(0LL, x % (2 * b) - b);
		
		if(c % 2 == 1) { ans |= (1LL << i); }
	}
	
	return ans;
}

int main() {
	LL a, b;
	cin >> a >> b;
	
	cout << (f(a) ^ f(b + 1)) << endl;
	
	return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
    	cin >> h[i];
    }
    sort(h.rbegin(), h.rend());
    long long ans = 0;
    for(int i = k; i < n; i++){
    	ans += h[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <algorithm>
using namespace std;

typedef long long ll;

int dx[] = {0, -1, 0, 1};
int dy[] = {1, 0, -1, 0};
char field[1002][1002];

struct State {int x, y, step;};

int main()
{
    int h, w, n, sx, sy;
    cin >> h >> w >> n;
    for(int i = 0; i < 1002; i++) {
        fill(field[i], field[i] + 1002, 'X');
    }

    for(int i = 1; i <= h; i++) {
        for(int j = 1; j <= w; j++) {
            cin >> field[i][j];
            if(field[i][j] == 'S') {
                sx = j; sy = i;
                field[i][j] = '.';
            }
        }
    }
    
    int ans = 0;
    for(int k = 0; k < n; k++) {
        char goal = '0' + k + 1;
        queue<State> que;
        que.push((State){sx, sy, 0});
        bool visited[1002][1002];
        for(int j = 0; j < 1002; j++) {
            fill(visited[j], visited[j] + 1002, false);
        }

        while(!que.empty()) {
            State cur = que.front(); que.pop();
            //cout << cur.x << " " << cur.y << " " << cur.step << " " << field[cur.y][cur.x] << endl;
            if(visited[cur.y][cur.x]) {
                continue;
            }
            visited[cur.y][cur.x] = true;

            if(field[cur.y][cur.x] == goal) {
                ans += cur.step;
                sx = cur.x; sy = cur.y;
                break;
            }

            for(int i = 0; i < 4; i++) {
                int nx, ny;
                nx = cur.x + dx[i]; ny = cur.y + dy[i];
                if(field[ny][nx] == 'X' || visited[ny][nx]) {
                    continue;
                }
                que.push((State){nx, ny, cur.step + 1});
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int i,j;
  double l;
  cin>>l;
  l/=3.0;
  cout<<fixed<<setprecision(15)<<l*l*l<<endl;

}

Measured memory_bytes: 256
#include <stdio.h>
int main (void){
  
  int a,sum;
  
  scanf("%d",&a);
  if(a<1||a>10){
    return 1;
  }
    
  sum = a + a*a + a*a*a;

  printf("%d",sum);
  
  return 0;
  
}

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

int n, m;
vector<vector<int>> vv;
int cnt;
vector<int> pv;

void dfs(int depth, string str){

    if(depth == n){
        //cout << str << endl;
        vector<bool> bv;
        for(int i =0; i < n; i++){
            if(str[i] == '0')bv.push_back(0);
            else bv.push_back(1);
        }

        for(int i = 0; i < m; i++){
            int num_on = 0;
            for(int j = 0; j < vv[i].size(); j++){
                
                //cout << "vv[i][j] " << vv[i][j] << "  bv :" << bv[vv[i][j]] << endl;
                if(bv[vv[i][j]-1])num_on++; 
            }
            //cout << "num_on : "<< num_on << endl;
            if(num_on%2 != pv[i])break;
            if(i == m - 1)cnt++;
        }

        return;
    }

    for(int i = 0; i <  2; i++){
        if(i == 0)dfs(depth + 1, str + '0');
        else dfs(depth + 1, str + '1');
    }
}

int main(){
    cin >> n >> m;
    
    for(int i = 0; i < m; i++){
        int k; cin >> k;
        vector<int> v;
        vv.push_back(v);
        for(int j = 0; j < k;j++){
            int a; cin >> a;
            vv[i].push_back(a);
        }
    }

    for(int i = 0; i < m; i++){
        int p;cin>>p;
        pv.push_back(p);
    }
    dfs(0,"");
    cout << cnt << endl;
}

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

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> city(n);
  for(int i = 0;i < m;i++){
    int a, b;
    cin >> a >> b;
    city.at(a-1)++;
    city.at(b-1)++;
  }
  for(int i = 0;i < n;i++){
    cout << city.at(i) << endl;
  }
}


Measured memory_bytes: 3620
N = int(input())
P = [int(i) for i in input().split()]
ans = 0
for i in range(N - 2):
    if P[i] < P[i + 1] < P[i + 2] or P[i] > P[i + 1] > P[i + 2]:
        ans += 1
print(ans)


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

int main() {
  int N;
  int count;
  cin >> N;
  
  for(int i = 0; i < N; i++){
    int A;
    int tmp = 0;
    cin >> A;
    
    while(A % 2 == 0){
      tmp++;
      A /= 2;
    } 
    
    if(i == 0 || tmp <= count){
      count = tmp;
    }    
  } 
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cstdint>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(ll i=(x);i<(y);i++)
#define disp(a) cout << a << endl;
typedef long long ll;
using namespace std;

bool comp(const int& a, const int& b) {
	return a > b;
}

int main()
{
	string s;
	cin >> s;
	if (s=="AAA"||s=="BBB") {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
int main() {
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	
	ll num1,num2,num3,x,y;
	if(a%c == 0)
	{
	    x = a;
	}
	else
	{
	    x = (a/c + 1)*c;
	}
	y = (b/c)*c;
	if(y>=x)
	num1 = 1 + (y-x)/c;
	else
	num1 = 0;
	
	
	if(a%d == 0)
	{
	    x = a;
	}
	else
	{
	    x = (a/d + 1)*d;
	}
	y = (b/d)*d;
	if(y>=x)
	num2 = 1 + (y-x)/d;
	else
	num2 = 0;
	
	ll lcm = (c*d)/gcd(c,d);
	if(a%lcm == 0)
	{
	    x = a;
	}
	else
	{
	    x = (a/lcm + 1)*lcm;
	}
	y = (b/lcm)*lcm;
	if(y>=x)
	num3 = 1 + (y-x)/lcm;
	else
	num3 = 0;

	cout<< (b-a+1) - (num1+num2-num3);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<int> a(3);
    rep(i, 0, 3) cin >> a[i];
    sort(all(a));
    reverse(all(a));
    rep(i, 1, 3) a[i] = a[0] - a[i];
    int ans = a[1] / 2 + a[2] / 2;
    if(a[1] % 2 && a[2] % 2) ans++;
    else if(a[1] % 2 || a[2] % 2) ans += 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

int main(){
  ll N,M,A[500],B[500],C[500],ans=0;
  cin >> N >> M;
  rep(i,M){
    cin >> A[i] >> B[i];
  }
  vector<vector<ll>> V(57);
  rep(i,M){
    rep(j,N+1){
      C[j]=0;
      V[j].clear();
    }
    rep(j,M){
      if(i!=j){
        V[A[j]].pb(B[j]);
        V[B[j]].pb(A[j]);
      }
    }
    queue<ll> Q;
    C[1]=1;
    Q.push(1);
    ll co=0;
    while(!Q.empty()){
      co++;
      auto T=Q.front();
      Q.pop();
      rep(k,V[T].size()){
        if(C[V[T][k]]==0){
          C[V[T][k]]=1;
          Q.push(V[T][k]);
        }
      }
    }
    if(co!=N){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printv(x) for(int i = 0; i < x.size(); i++){ cout << (x[i]) << " "; } cout << endl; 
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printaa(x) for(int i = 0; i < (sizeof(x)/sizeof(x[0])); i++){ for(int j = 0; j < (sizeof(x[0])/sizeof(x[0][0])); 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);
    string S;
    ll K;
    cin >> S >> K;
    int n = S.size();
    char tt[101];
    rep(i,0,101){
        tt[i] = '0';
    }
    rep(i,0,n){
        if(S[i] == '1'){
            tt[i] = '1';
        }else{
            rep(j,i,100){
                tt[j] = S[i];
            }
            break;
        }
    }
    if(K <= 100){
        print(tt[K-1]);
    }else{
        print(tt[99]);
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

//true->Yes
//false->No
inline bool ask(LL x)
{
	cout << "? " << x << endl;
	char c[2];
	cin >> c;
	return c[0] == 'Y';
}

inline void answer(LL x)
{
	cout << "! " << x << endl;
	exit(0);
}

int main(void)
{
	if (ask(10000000000LL))
	{
		//N = 10^k
		LL ten = 1;
		for (int k = 1; true; ++k)
		{
			ten *= 10;
			bool ret = ask(ten - 1);
			if (ret)
			{
				answer(ten / 10);
			}
		}
	}
	else
	{
		//N ≠ 10^k
		LL ten = 1;
		LL up = -1;
		for (int k = 1; true; ++k)
		{
			ten *= 10;
			bool ret = ask(ten);
			if (!ret)
			{
				up = ten;
				break;
			}
		}
		LL dn = up / 10;
		while (dn + 1 < up)
		{
			LL mid = (up + dn) / 2;
			if (ask(mid * 10))
			{
				up = mid;
			}
			else
			{
				dn = mid;
			}
		}
		answer(up);
	}
	return 0;
}


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

int a[100005];
int main()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int k;
		cin >> k;
		a[k] = i;
	}
	for (int i = 1; i <= n; i++) {
		cout << a[i] << " ";
	}
	return 0;
}

Measured memory_bytes: 1152
S,Kstring = input().split()
K = int(Kstring)
lastZero = -1
segment = []
MOD = 998244353
N = len(S)

for i in range(N):
    if S[i] == '0':
        segment.append(i - lastZero - 1)
        lastZero = i

segment.append(N - 1 - lastZero)
M = len(segment)
No1 = N + 1 - M

partialSumSegment = []
for i in range(M):
    if partialSumSegment:
        partialSumSegment.append(segment[i] + partialSumSegment[-1])
    else:
        partialSumSegment.append(segment[i])

DP = []
DPSum = [] # Sum of DP i,j,k ~ i,j,a
for i in range(M):
    DP.append([])
    DPSum.append([])
    for j in range(No1 + 2):
        DP[i].append([])
        DPSum[i].append([])
        for k in range(No1 + 2):
            DP[i][j].append(0)
            DPSum[i][j].append(0)

# Initialize on the last segment

for j in range(No1 - partialSumSegment[M-2] + 1):
    DP[M-1][j][partialSumSegment[M-2] + j] = 1
for j in range(No1 - partialSumSegment[M-2] + 1):
    for k in range(partialSumSegment[M-2] + j,-1,-1):
        DPSum[M-1][j][k] = DPSum[M-1][j][k+1] + DP[M-1][j][k]

for i in range(M-2,-1,-1):
    for j in range(No1 + 1):
        Kmin = partialSumSegment[i-1]
        if i == 0:
            Kmin = 0
        for k in range(No1, Kmin - 1, -1):
            DPCur = 0
            for l in range(1,segment[i] + 1):
                if j >= l and k + segment[i] - l <= No1 + 1:
                    DPCur += DP[i + 1][j - l][k + segment[i] - l]
            if k + segment[i] <= No1:
                DPCur += DPSum[i + 1][j][k + segment[i]]
            DP[i][j][k] = DPCur % MOD
            DPSum[i][j][k] = (DPSum[i][j][k+1] + DP[i][j][k]) % MOD 

# print(DP)
# print(DPSum)

AnsSum = 0
for j in range(min(K,No1) + 1):
    AnsSum += DP[0][j][0]

if M == 1:
    print(1)
else:
    print(AnsSum % MOD)


Measured memory_bytes: 143356
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
#define fi first
#define se second
#define show(x) cout << #x << " is " << x << "\n";
const ll inf = 9e18;
const ll mod = 1e9 + 7;
const ld pi = 3.141592653589793238462643383279502884;

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

//------------------------------------------------------------------------------------------

//const ll N = 1e5 + 1;
//vector<ll> adj[N];
//bool visited[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cout<<fixed<<setprecision(10);

	ll h, w;
	cin>>h>>w;
	ll mat[h][w];
	char x;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>x;
			if(x=='.') mat[i][j] = 0;
			else mat[i][j] = 1;
		}
	}
	ll dp[h][w];
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(i==0 && j==0) {
				dp[i][j] = mat[i][j];
			}
			else{
				if(mat[i][j] == 1){
					ll mi = INT_MAX;
					if(i>0 && j>0){
						if(mat[i-1][j]) mi = dp[i-1][j];
						else mi = dp[i-1][j] + 1;

						if(mat[i][j-1]) mi = min(mi, dp[i][j-1]);
						else mi = min(mi, dp[i][j-1] + 1);
						
						dp[i][j] = mi;
					}
					else if(i>0){
						if(mat[i-1][j]) dp[i][j] = dp[i-1][j];
						else dp[i][j] = dp[i-1][j] + 1;
					}
					else{
						if(mat[i][j-1]) dp[i][j] = dp[i][j-1];
						else dp[i][j] = dp[i][j-1] + 1;
					}
				}
				else{
					if(i>0 && j>0) dp[i][j] = min(dp[i-1][j], dp[i][j-1]);
					else if(i>0) dp[i][j] = dp[i-1][j];
					else dp[i][j] = dp[i][j-1];
				}
			}
		}
	}
	cout<<dp[h-1][w-1];

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
const long long INF = 1LL << 60;

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

int main()
{
    map<char,int> mp{{'A',1},{'T',1},{'G',1},{'C',1}};
    string a; cin >> a;
    int res = 0;
    for(int i=0;i<a.size();i++){
        int sum = 0;
        int j=i;
        while(mp[a[j]] && j<a.size()){
            sum++;j++;
        }
        res = max(sum,res);
    }
    cout << res << endl;
}
    

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)
#if DEBUG
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...) /* ... */
#endif

void solve();
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*================================*/
#if DEBUG
#define SIZE 100
#else
#define SIZE 123450
#endif

int N,X,Y;

void solve() {
    cin>>X>>Y;
    REP(t,X+1) {
        int k = X-t;
        if (t*2 + k*4 == Y) {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}



Measured memory_bytes: 3612