akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

using i32 = int32_t;
using u32 = uint32_t;
using f32 = float;
using f64 = double;
using i64 = int64_t; 
using u64 = uint64_t; 

#define SELECTER(_1, _2, _3, _4, _5, _6, _7, _8, SELECT, ...) SELECT

#define _FC1(func, type, _1)      func(type, _1);
#define _FC2(func, type, _1, ...) func(type, _1); _FC1(func, type, __VA_ARGS__);
#define _FC3(func, type, _1, ...) func(type, _1); _FC2(func, type, __VA_ARGS__);
#define _FC4(func, type, _1, ...) func(type, _1); _FC3(func, type, __VA_ARGS__);
#define _FC5(func, type, _1, ...) func(type, _1); _FC4(func, type, __VA_ARGS__);
#define _FC6(func, type, _1, ...) func(type, _1); _FC5(func, type, __VA_ARGS__);
#define _FC7(func, type, _1, ...) func(type, _1); _FC6(func, type, __VA_ARGS__);
#define _FC8(func, type, _1, ...) func(type, _1); _FC7(func, type, __VA_ARGS__);

#define _FCN(func, type, ...) SELECTER(__VA_ARGS__, _FC8, _FC7, _FC6, _FC5, _FC4, _FC3, _FC2, _FC1)(func, type, __VA_ARGS__);

constexpr const char *type2fmt(const char *fmt) {
  if(strcmp(fmt, "i32") == 0) return "%d";
  if(strcmp(fmt, "u32") == 0) return "%u";
  if(strcmp(fmt, "f32") == 0) return "%f";
  if(strcmp(fmt, "f64") == 0) return "%lf";
  if(strcmp(fmt, "i64") == 0) return "%lld";
  if(strcmp(fmt, "u64") == 0) return "%llu";
  return "";
}

#define _R(type, _1) type _1; { type _t; scanf(type2fmt(#type), &_t); _1 = _t; }
#define _P(type, _1) { const type _t = (_1); printf(type2fmt(#type), _t); putchar('\n'); }

#define RI(...)   _FCN(_R, i32, __VA_ARGS__);
#define RUI(...)  _FCN(_R, u32, __VA_ARGS__);
#define RF(...)   _FCN(_R, f32, __VA_ARGS__);
#define RD(...)   _FCN(_R, f64, __VA_ARGS__);
#define RLL(...)  _FCN(_R, i64, __VA_ARGS__);
#define RULL(...) _FCN(_R, u64, __VA_ARGS__);

#define PI(...)   _FCN(_P, i32, __VA_ARGS__);
#define PUI(...)  _FCN(_P, u32, __VA_ARGS__);
#define PF(...)   _FCN(_P, f32, __VA_ARGS__);
#define PD(...)   _FCN(_P, f64, __VA_ARGS__);
#define PLL(...)  _FCN(_P, i64, __VA_ARGS__);
#define PULL(...) _FCN(_P, u64, __VA_ARGS__);

#define REP(n) for (int _i = 0; _i < n; _i++)

const u64 mod = 1000000007;

int main() {
  i32 m, d;
  scanf("2019/%d/%d", &m, &d);

  if (m < 4 || (m == 4 && d <= 30)) cout << "Heisei" << endl;
  else cout << "TBD" << endl;
}


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

int main()
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  
  int n = 0, m = 0;
  std::cin >> n >> m;
  std::vector<std::pair<bool, int>> b;
  b.push_back(std::make_pair(true, 1));
  for(int i = 1; i < n; ++i)
  {
    b.push_back(std::make_pair(false, 1));
  }
  
  for(int i = 0; i < m; ++i)
  {
    int x, y;
    std::cin >> x >> y;
    --x; --y;
    if(b[x].second > 0)
    {
      --(b[x].second);
      ++(b[y].second);
      b[y].first = b[x].first || b[y].first;
      if(b[x].second == 0)
      {
        b[x].first = false;
      }
    }
  }
  
  int suspect = 0;
  for(auto &item : b)
  {
    if(item.first)
    {
      ++suspect;
    }
  }
  
  std::cout << suspect;
      
  return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int num[] = {3, 5, 7};
vector<ll> v;

void f(ll n, int ok) {
    if (n >= 1e9) return;
    if (ok == 7) v.pb(n);
    fore(i,0,3) {
        f(n*10+num[i], ok|(1<<i));
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    f(0, 0);
    sort(v.begin(), v.end());
    int n;
    cin >> n;
    int ans = upper_bound(v.begin(), v.end(), n)-v.begin();
    cout << ans << endl;
}


Measured memory_bytes: 640
import std.stdio;
import std.string;
import std.conv;
import std.range;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;

int calc(int x,int r){
	return x * (r+100) / 100;
}

void main() {
	while(true) {
		string[] cin;
		cin=split(readln());
		int a=to!int(cin[0]),b=to!int(cin[1]),x=to!int(cin[2]);
		if(!(a||b||x)) break;
		int ans=0;
		for(int i=1; i<x; i++) {
			for(int j=1; j<x; j++) {
				if(calc(i,a)+calc(j,a)==x) {
					int z=calc(i,b)+calc(j,b);
					if(ans<z) ans=z;
				}
			}
		}
		writeln(ans);
	}
}


Measured memory_bytes: 1044
using System;

namespace ABC149C
{
	class Program
	{
		static void Main(string[] args)
		{
			long a = long.Parse(Console.ReadLine());
			double sqrt = Math.Sqrt(a);
			bool flag = false;
			while (!flag)
			{
				if (a == 2) break;
				if (a % 2 == 0)
				{
					a++;
					continue;
				}
				for(int i = 3; i <= sqrt; i += 2)
				{
					flag = true;
					if (a % i == 0) 
					{
						flag = false;
						break;
					}
				}
				if (!flag) a++;
			}
			Console.WriteLine(a);
		}
	}
}


Measured memory_bytes: 11092
from decimal import Decimal

def dist(x1, y1, x2, y2):
    return ((x1 - x2)**2 + (y1 - y2)**2)**Decimal('0.5')

N = int(raw_input())
while (N):
    N -= 1
    xa, ya, ra, xb, yb, rb = map(Decimal, raw_input().split())
    d = dist(xa, ya, xb, yb)
    sr = ra + rb
    dr = abs(ra - rb)
    if d > sr:
        s = 0
    elif d < sr and dr < d:
        s = 1
    elif dr > d:
        s = 2 if ra > rb else -2
    else:
        s = 1
    print s

Measured memory_bytes: 5900
// author: hjy
// Problem:
#include<bits/stdc++.h>
//#pragma GCC optimize(2)
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define rep(i,n) for(register int i=0; i<(int)(n); ++i)
#define per(i,n) for(register int i=(int)(n)-1; i>=0; --i)
#define rep1(i,n) for(register int i=1; i<=(int)(n); ++i)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<"="<<x<<'\n'

inline int read() {
	int x=0,ng=0;
	char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-') ng=1; ch=getchar(); }
	while(ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return ng?-x:x;
}

const int mod=1e9+7;
const int inf=0x3f3f3f3f;
const int seed=20040305;

int n,k;
vector<int> vec[100100];
pii t[100100];
int visit[100100];
int root;
int res[100100];

void dfs(int a,int p,int l,int r)
{
	t[a]=mp(l,r);
	for(int i=0;i<vec[a].size();i++)
	{
		int u=vec[a][i];
		if(u==p) continue;
		if(visit[u])
		{
			if((abs(t[u].fi)%2)!=(1-(abs(l)%2))) 
			{
				puts("No");
				exit(0);
			}
			if((t[u].fi<l-1)||(t[u].se>r+1)) 
			{
				puts("No");
				exit(0);
			}
			dfs(u,a,t[u].fi,t[u].se);
		}
		else dfs(u,a,l-1,r+1);
	}
}

void dfs2(int a,int p)
{
	for(int i=0;i<vec[a].size();i++)
	{
		int u=vec[a][i];
		if(u==p) continue;
		dfs2(u,a);
		if((abs(t[a].fi)%2)!=(abs(t[u].fi-1)%2))
		{
			puts("No");
			exit(0);
		}
		if((abs(t[a].se)%2)!=(abs(t[u].se-1)%2)) 
		{
			puts("No");
			exit(0);
		}
		t[a].fi=max(t[a].fi,t[u].fi-1);
		t[a].se=min(t[a].se,t[u].se+1);
		if(t[a].fi>t[a].se)
		{
			puts("No");
			exit(0);
		}
	}
}

void getans(int a,int p,int v)
{
	res[a]=v;
	rep(i,vec[a].size())
	{
		int u=vec[a][i];
		if(u==p) continue;
		if((t[u].fi<=v-1)&&(v-1<=t[u].se)) getans(u,a,v-1);
		else getans(u,a,v+1);
	}
}

int main()
{
	scanf("%d",&n);
	rep(i,n-1)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		vec[a].pb(b);
		vec[b].pb(a);
	}
	scanf("%d",&k);
	rep(i,k)
	{
		int v,p;
		scanf("%d%d",&v,&p);
		t[v]=mp(p,p);
		root=v;
		visit[v]=1;
	}
	dfs(root,0,t[root].fi,t[root].se);
	dfs2(root,0);
	getans(root,0,t[root].fi);
	puts("Yes");
	rep1(i,n) printf("%d\n",res[i]);
}
/*
5
1 2
3 1
4 3
3 5
2
2 -6
5 -7
*/

Measured memory_bytes: 15744
n =int(input())
l = [int(d) for d in str(n)]


found = False
while len(l) >1 and not found:
    st = l.pop()
    end = l.pop(0)
    if st==end:
        found = False
    else:
        found = True

if not found:
    print('Yes')
else:
    print('No')
        
    

Measured memory_bytes: 3060
def resolve():
    N,M = map(int,input().split())
    LL,RR = [],[]
    for i in range(M):
        L,R = map(int,input().split())
        LL.append(L)
        RR.append(R)

    bool_id = [1]*N
    lmin = -1
    rmax = 10**10
    for i in range(M):
        lmin = max(lmin,LL[i])
        rmax = min(rmax,RR[i])
    print(max(rmax-lmin+1,0))

resolve()

Measured memory_bytes: 11784
#include <stdio.h>

int main(void){
	int a[5];
	int k;

	for(int i=0; i<5; i++){
		scanf("%d",&a[i]);
	}
	scanf("%d",&k);

	for(int i=0; i<4; i++){
		for(int j=i+1; j<5; j++){

			if(a[j]-a[i]>k){
				printf(":(\n");
				return 0;
			}
		}
	}
	printf("Yay!\n");
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define Endl endl
#define mod  1000000007
#define mkp make_pair
#define pb push_back
#define cin(n) scanf("%d",&n)
#define cout(n) printf("%d ",n)
#define sf(n) scanf("%d",&n)
#define pf(n) printf("%d ",n)
#define bitget(n) __builtin_popcountll(n)
#define maxi 500111

ll dx[] = {1,1,0,-1,-1,-1,0,1};
ll dy[] = {0,-1,-1,-1,0,1,1,1};
ll dxx[] = {1,-1,0,0};
ll dyy[] = {0,0,-1,1};
ll modexpo(ll x,ll y){if(y==0)return 1;if(y%2){ll viky=modexpo(x,y/2);
return (((x*viky)%mod)*viky)%mod;}else{ll viky=modexpo(x,y/2);return (viky*viky)%mod;
}}
ll intpoint(ll x1, ll y1, ll x2, ll y2) { return ( __gcd(abs(x1-x2),abs(y1-y2))+1); }
bool isvalid(ll x,ll y,ll n,ll m) { return (x>=0&&x<n&&y>=0&&y<m); }
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// int pp = uniform_int_distribution<int>(0, kk-1)(rng);
// ---------------------///////////////---------------------------------
// ---------------------///////////////----------------------------------
// -------------/////////////////---------------------------------///////

ll ap[1900];

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

    ll n,m;

    cin>>n>>m;
    ll k;
    for(ll i=0;i<n;i++){
      cin>>k;
      for(ll j=0;j<k;j++){
        ll l;
        cin>>l;
        ap[l]++;
      }
    }
    ll ans = 0;
    for(ll i = 1;i<=m;i++){
      if(ap[i] == n){
        ans++;
      }
    }

    cout<<ans;

    return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    int ans = 0;
    for(int i = 1; i <= N; i += 2) {
        int count = 0;
        for(int j = 1; j <= i; j++) {
            if(i % j == 0) {
                count++;
            }
        }
        if(count == 8) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define each(it,o) for(auto it= (o).begin(); it != (o).end(); ++ it)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define inrep int t;cin>>t; while(t--)
#define pb emplace_back
using namespace std;
using namespace __gnu_pbds; 


typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii > vpii;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll > vpll; 
typedef vector<string> vs;
typedef long double ld;
const ll MOD = 1e9+7;
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {

    for ( unsigned   i=0; i<v.size(); i++ )
        in>>v[i];
    return in;
}

ll power(ll x, ll y,ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2,m)%m; 
    p = (p * p)%m; 
  
    return (y%2 == 0)? p : (x * p)%m ; 
} 

ll modInverse(ll a, ll m) 
{ 
        // If a and m are relatively prime, then modulo inverse 
        // is a^(m-2) mode m 
    return power(a, m-2,m); 
} 
  
// To compute x^y under modulo m 
int n,m;
vector<int> a[100001];
int dp[100001];
int comp[100001]={0};

int dfs(int i)
{
    if(a[i].size()==0)
    {
        return 0;
    }
    if(dp[i]!=-1)
    {
        return dp[i];
    }
    int maxi = INT_MIN;
    for(int j=0;j<a[i].size();j++)
    {
        maxi = max(maxi,1+dfs(a[i][j]));
    }
    return dp[i] = maxi;
}
int main()
{
  
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int u,v;
        cin>>u>>v;
        a[u].pb(v);
        comp[v] = 1;
    }
    mset(dp,-1);
    for(int i=1;i<=n;i++)
    {
        if(comp[i]==0)
        {
            dfs(i);
        }
    }int ans = 0;
    for(int i=1;i<=n;i++)
    {
        ans = max(ans,dp[i]);
    }
    cout<<ans;
   
    
    return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,i,j,ans;ans=0;
    scanf("%lld",&n);n=n+1;
    ans=(n-1)/11;
    if((n-1)%11!=0)
    {
        if((n-1)%11<=6)
            ans=ans*2+1;
        else
            ans=ans*2+2;
    }
    else
        ans=ans*2;
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 256
n=int(input())
if(n%2==0 or n%5==0):
    print(-1)
else:
    a=7 
    ans=1
    flag=1  
    while(flag):
        if(a%n==0):
            print(ans)
            flag=0
            break 
        else:
            ans+=1 
            s=str(a)
            s1='7'
            s2=int(s+s1)
            a=(int(s2))%n 
            

Measured memory_bytes: 9100
N = gets.to_i
S = gets.chomp

right = [0]*N
left = [0]*N
list = []
N.times{|i|
    next if i == 0
    if S[i-1] == 'W'
        right[i] = right[i-1] + 1
    else
        right[i] = right[i-1]
    end
}
N.downto(1){|i|
    next if i == N
    if S[i] == 'E'
        left[i-1] = left[i] + 1
    else
        left[i-1] = left[i]
    end
}
N.times{|i|
    list[i] = right[i] + left[i]
}

puts list.min


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

int main(){
  long long N;
  cin >> N;
  int ans=12;
  for(long long i=1; i*i<=N; i++){
    if(N%i!=0) continue;
    long long temp= max(i, N/i);
    int cnt=0;
    while(temp>0){
      temp/=10;
      cnt++;
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
}

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

#define ll long long

using namespace std;


int m,Nmin,Nmax;

int P[205]={};


int main(){

    while(1){
        int ans = 0;
        scanf("%d %d %d",&m,&Nmin, &Nmax);
        if(m == 0 && Nmin == 0 && Nmax == 0) break;

        for(int i=0;i<m;i++){
            scanf("%d",&P[i]);
        }
        int max_gap = 0;
        for(int i=Nmin-1;i<Nmax;i++){
            int gap = P[i] - P[i+1];
            if(max_gap <= gap){
                max_gap = gap;
                ans = i+1;
            }
        }
        printf("%d\n",ans);
    }


}


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

using namespace std;

int main(){
  string s;
  cin >> s;
    for(int i= 0; i<s.length(); i++)
      s[i] = (s[i] + 23 - 'A')% 26 + 'A';
  cout << s << endl;
  
  return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define FS              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll              long long int
#define ld              long double
#define pb              push_back
#define bp              __builtin_popcount
#define sz              size()
#define ff              first
#define ss              second
#define vll             vector<ll>
#define vbool           vector<bool>
#define vpll            vector<pair<ll,ll>>
#define pll             pair<ll,ll>
#define vllv            vector<vector<ll>>
#define setpri(x)       cout<<setprecision(x)<<fixed;
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){return (n-1)/x+(n>0);}

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

ll pow1(ll n,ll m ,ll mod=MOD );
ll pow2(ll n,ll k);

ll modinv(ll n,ll mod=MOD){  return pow1(n,mod-2,mod);}

bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
        if(a.ff != b.ff)return a.ff < b.ff;
        return a.ss > b.ss;
}

ll const N=(ll)3e5+11;
ll const LG=(ll)log2(N)+1;


void solve(){
        ll i,j,k,l,n,m,x,y,z,r;
                ll x1,x2,y1,y2;
                cin>>x1>>y1>>x2>>y2;
              string s1,s2,s3,s4;
              s1="";
              s2="";
              s3="";
              s4="";
              for(i=y1;i<y2;i++){
                      s1+='U';
                      s2+='D';
              }
              for(i=x1;i<x2;i++){
                      s3+='R';
                      s4+='L';
              }
              cout<<s1<<s3<<s2<<s4<<"L"<<s1<<"U"<<s3<<"RDRD"<<s2<<s4<<"LU";
              
              
        
        
}       
int main(){
        FS;
        
        ll i,j,k,n,m,x,y,z,q;
        q=1;
        // cin>>q;
        for(ll tc=1;tc<=q;tc++){
                // cout<<"Case #"<<tc<<": ";
                solve();
        }
        return 0;
}


ll pow1(ll n,ll m,ll mod){
        if(m==0)return 1;
        
        if(m%2==0)return pow1((n*n)%mod,m/2,mod);
    	
    	return (pow1((n*n)%mod,m/2,mod)*n)%mod;
}

ll pow2(ll n,ll k){
        ll ans=1;
            while(k>0){
                if(k%2==1)ans=ans*n;
                n=n*n;
                k/=2;
            }
            return ans;
}


Measured memory_bytes: 3608
# verified: ABC014-D
# calculate LCA O(logN) for each query

# prev[i][k]: 2^k parent of node i 
# Depth[i]: Depth of node i from 0

class LCA():
    def __init__(self, graph, rootNode=0):
        self.graph = graph
        self.N = len(graph)
        self.Log_N = (self.N-1).bit_length()
        self.rootNode = rootNode
        # BFS
        self.prev = [None]*self.N
   
        self.Depth = [-1]*self.N
        q = [self.rootNode]
        self.Depth[self.rootNode] = 0
        d = 0
        while q:
            qq = []
            d += 1
            for p in q:
                for np in self.graph[p]:
                    if self.Depth[np] == -1:
                        self.prev[np] = p
                        self.Depth[np] = d
                        qq.append(np)
            q = qq

        # construct
        self.kprev = [self.prev]
        S = self.prev
        for k in range(self.Log_N):
            T = [None]*self.N
            for i in range(self.N):
                if S[i] is None:
                    continue
                T[i] = S[S[i]]
            self.kprev.append(T)
            S = T

    # LCA
    def query(self, u, v):
        dd = self.Depth[v] - self.Depth[u]
        if dd < 0:
            u, v = v, u
            dd = -dd
        
        # set same Depth
        for k in range(self.Log_N+1):
            if dd & 1:
                v = self.kprev[k][v]
            dd >>= 1
        
        if u == v:
            return u
        
        for k in reversed(range(self.Log_N)):
            pu = self.kprev[k][u]
            pv = self.kprev[k][v]
            if pu != pv:
                u, v = pu, pv
        
        return self.kprev[0][u]

"""
if __name__ == "__main__":
    import sys
    input = sys.stdin.readline

    N = int(input())
    graph = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        graph[a-1].append(b-1)
        graph[b-1].append(a-1)
    
    Q = int(input())
    Query = [list(map(int, input().split())) for _ in range(Q)]

    lca = LCA(graph)
    for a, b in Query:
        r = lca.query(a-1, b-1)
        d = lca.Depth[a-1] + lca.Depth[b-1] - 2*lca.Depth[r]
        print(d+1)
"""

import sys
input = sys.stdin.readline
from bisect import bisect_right

N = int(input())
A = list(map(int, input().split()))
L = int(input())
Q = int(input())
Query = [list(map(int, input().split())) for _ in range(Q)]

graph = [[] for _ in range(N)]
for i, a in enumerate(A):
    j = bisect_right(A, a+L)-1
    graph[j].append(i)
    graph[i].append(j)


lca = LCA(graph, rootNode=N-1)
for a, b in Query:
    d = 0
    a -= 1; b-= 1
    if b < a:
        a, b = b, a
    for k in reversed(range(lca.Log_N)):
        nextnode = lca.kprev[k][a]
        if nextnode is None:
            continue
        else:
            if nextnode == b:
                d += 1<<k
                break
            elif A[nextnode] < A[b]:
                d += 1<<k
                a = nextnode
    if nextnode != b:
        d += 1
    print(d)

Measured memory_bytes: 109976
N = int(input())
arr = list(map(int, input().split()))
cnt = 0
cnt_list = []

for i in range(N-1):
  if arr[i] >= arr[i+1]:
    cnt += 1
  else:
    cnt_list.append(cnt)
    cnt = 0

cnt_list.append(cnt)
print(max(cnt_list))

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

using namespace std;

#define long long long

bool next(vector<int> &a) {
    for (int &i : a) {
        if (i == 0) {
            i = 1;
            return true;
        }
        i = 0;
    }
    return false;
}

int count(vector<int> a) {
    int ans = 0;

    for (int aa : a) ans += aa == 1;

    return ans;
}

int main() {

    int n;
    cin >> n;
    vector<int> a(n, 0);

    vector<set<int>> unkind(n);
    vector<set<int>> honest(n);

    for (int i = 0; i < n; i++) {
        int m;
        cin >> m;

        for (int j = 0; j < m; j++) {
            int x, y;
            cin >> x >> y;

            if (y == 0) {
                unkind[i].insert(x - 1);
            } else {
                honest[i].insert(x - 1);
            }
        }
    }

    int ans = 0;

    do {
        bool state = true;
        for (int i = 0; i < n; i++) {
            if (a[i] == 1) {
                for (int j = 0; j < n; j++) {
                    if (a[j] == 1 && unkind[i].count(j) == 1
                        || a[j] == 0 && honest[i].count(j) == 1) {
                        state = false;
                    }
                }
            }
        }

        if (state) {
            ans = max(ans, count(a));
        }
    } while (next(a));


    cout << ans;
    return 0;
}


Measured memory_bytes: 256
import heapq as hp
n, m = (int(x) for x in input().split())
a = [int(x)*(-1) for x in input().split()]
hp.heapify(a)
for _ in range(m):
    min = hp.heappop(a)
    hp.heappush(a, (-1)*(-min//2))
print(-sum(a))

Measured memory_bytes: 14180
#include<stdio.h>
#include<stdlib.h>

int gcd1(int a, int b){
  	int d;
  	if(b > a){
    	d = b;
        b = a;
        a = d;
    }
	if(a % b == 0){
    	return b;
    }else{
		return gcd1(b, a % b);
	}
}

int gcd2(int a, int b, int c){
	int d = gcd1(a, b);
    return gcd1(c, d);
}

int main(int argc, char** argv){
  	
  	int k;
  	scanf("%d", &k);
  	int sum = 0;

  	for(int i = 1; i <= k; i++){
    	for(int j = 1; j <= k; j++){
        	for(int l = 1; l <= k; l++){
            	sum += gcd2(i, j, l);
            }
        }
    }
  	printf("%d\n", sum);
	return 0;
}




Measured memory_bytes: 1736
#include <iostream>

using namespace std;

int main() {
    int n, m;

    cin >> n >> m;

    int x, y, z;
    bool flag = false;
    for (x = 0; x <= n; x++) {
        for (y = 0; x+y <= n; y++) {
            z = n - x - y;
            if (x*10000 + y*5000 + z*1000 == m) { 
                  flag = true;
                  break;
            }
        }
        if (flag) { break; }
    }

    if (flag) {
        cout << x << " " << y << " " << z << endl;
    } else {
        cout << "-1 -1 -1" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define MAXN (int)(2*1e5 + 1)
#define F first
#define S second
#define endl "\n"
#define MOD (lli)(1e9 + 7)
#define lli long long int
#define sz(a) int(a.size())
#define DEBUG if(0) cout << "aqui" << endl;
#define PI 2 * acos(0.0)
typedef pair<int,int> ii;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

int dddx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dddy[] = {0, 0, 1, -1, 1, -1, 1, -1};

string s;
int k;

int dp[101][3][9];
// int vis[101][3][9];

lli solve(int pos, bool can, int kk) {

  if(pos == s.size()){
    return (kk == k ? 1 : 0);
  }
  if(kk > k) return 0;

  if(dp[pos][can][kk] != -1) return dp[pos][can][kk];

  int atual = s[pos] - '0';
  lli ans = 0;

  for(int i=0;i<=9;i++){
    if(can or i <= atual) {
      bool pode = can;
      if(i < atual) pode = true;
      ans += solve(pos+1, pode, i > 0 ? (kk+1) : kk);
    } 
  }

  return dp[pos][can][kk] = ans;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  cin >> s;
  cin >> k;

  memset(dp, -1, sizeof dp);

  cout << solve(0, 0, 0) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int gcd(int a, int b){return b ? gcd(b, a%b) : a;}
int lcm(int a, int b){return a*b / gcd(a, b);}



int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    if(n == 1){
        if(a != b) cout << 0 << endl;
        else cout << 1 << endl;
    }
    else{
        if(a > b) cout << 0 << endl;
        else cout << (n-2)*(b-a)+1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
using namespace std;
 
#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back
 
typedef long long ll;
typedef pair<ll, int> ll_i;

int main() {
    ll A1, A2, A3;
    cin >> A1 >> A2 >> A3;
    ll cost = abs(A2-A1) + abs(A3-A2);
    cost = min(cost, abs(A3-A1) + abs(A2-A3));
    cost = min(cost, abs(A1-A2) + abs(A3-A1));
    cost = min(cost, abs(A3-A2) + abs(A1-A3));
    cost = min(cost, abs(A3-A1) + abs(A1-A2));
    cost = min(cost, abs(A3-A2) + abs(A2-A1));
    cout << cost << endl;
	return 0;
}

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

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define int ll

#ifdef HNO2
#define IOS
#else
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#endif // HNO2

int cnt[10000007];

int32_t main()
{
    IOS
    for (int i=1;i<=10000000;i++)
        for (int j=i;j<=10000000;j+=i)
            cnt[j]++;
    int n;
    cin>>n;
    int ans=0;
    for (int i=1;i<=n;i++) ans+=i*cnt[i];
    cout<<ans<<endl;
}



Measured memory_bytes: 81772
#include <bits/stdc++.h>
using namespace std;
#define ll  long long
struct triple{ll   x=0;ll   y=0;ll   z=0;void mt(ll   a,ll   b, ll   c){x=a;y=b;z=c;} void holify(){x=69;y=420;z=911;}};
#define pb push_back
#define x first 
#define y second
#define vec vector
#define pf(vec,val) vec.insert(vec.begin(),val)
#define mp make_pair
#define pii pair<ll  ,ll  >
#define maxll  69696991169
#define minll  -69696942069
#define sz(vec) (ll )vec.size()
#define speedup ios_base::sync_with_stdio(0); cin.tie(NUll ); cout.tie(NUll );
#define loop(mep) for(auto it = mep.begin();it!=mep.end();++it)
//#define usaco_crap(str)ifstream cin((string)str + (string)".in"); ofstream cout ((string)str+(string)".out");
#define range(n) =0;i<(n);i++
#define prll  (vec) for(auto it=vec.begin();it!=vec.end();++it)cerr<<*it<<" ";cerr<<endl;
// mt make triple // triple.mt(a,b,c) //
int main(){
	ll  n,m; cin>>n>>m;
	priority_queue<ll >q;
	for(ll  i = 0 ; i < n ; i++){
		ll  a; cin>>a;
		q.push(a);
	}
	//if(n==1){cout<<q.top()/(pow(2,m))<<endl;return 0;}
	while(m){
		ll  b = q.top();
		q.pop();
		/*ll  a = q.top();
		ll  c = 1+floor(log2((b/(a*1.0))));
		//cout<<c<<endl;
		b/=pow(2,min(c,m));
		m-=min(c,m);*/
		q.push(b/2);
		m--;
	}
	ll  res = 0;
	while(q.size()){
		res+=q.top();
		q.pop();
	}
	cout<<res<<endl;
}



Measured memory_bytes: 1400
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define _GLIBCXX_DEBUG
#define ll long long
#define rep(i,n) for (ll i = 0; i < n; i++)
#define vl vector<ll>
#define vpl vector<pair<ll,ll>>
#define vvl vector<vector<ll>> //a(縦行,vector<ll>(横列));
#include<algorithm>//__gcd(a,b)
#include <iostream>
#include <vector>
#include <cstdlib>
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; }

const long long INF = 1LL << 60;

int main(){
   long double pi=3.1415926535897932;
    long double a,b,h,m;cin>>a>>b>>h>>m;
    long double k=0;
    k=30*h+30*m/60-6*m;
    if(k>=180)k=360-k;

cout<<fixed<<setprecision(15);
    cout<<sqrt(a*a+b*b-2*a*b*cos(k*pi/180));
    
    
    
    
    
    
    
    }


Measured memory_bytes: 4164
N = int(input())
T, A = map(int, input().split())
H = [int(i) for i in input().split()]

def a(x):
    return T - x * 0.006

ans = 0
tmp = float('inf')
for i, v in enumerate(map(a, H)):
    i += 1
    if abs(v - A) < tmp:
        tmp = abs(v-A)
        ans = i
print(ans)

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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cerr << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const int B = 32000;

int main() {
	int N; cin >> N;
	int xo = 0;

	rep(i, N) {
		int A, K;
		cin >> A >> K;
		int x = -1;

		while (true) {
			if (A % K == 0) {
				x = A / K;
				break;
			} else {
				int dec = (A / K + 1);
				int num = (A % K + dec - 1) / dec;
				A -= dec * num;
			}
		}
		xo ^= x;
	}

	puts(xo ? "Takahashi" : "Aoki");

	return 0;
}

Measured memory_bytes: 256
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

char S[500005];
int pre[500005];
int front[500005];

int back[500005];

int main()
{
	scanf("%s", S);
	int len = strlen(S);
	{
		int allSame = 1;
		for (int i = 1; i < len; i++) {
			if (S[0] != S[i]) allSame = 0;
		}
		if (allSame) {
			printf("%d\n1\n", len);
			return 0;
		}
	}

	int now = -1;
	pre[0] = -1;
	for (int i = 1; i < len; i++) {
		while (now != -1 && S[i] != S[now + 1]) {
			now = pre[now];
		}
		if (S[i] == S[now + 1]) pre[i] = now = now + 1;
		else pre[i] = now = -1;
		if (now != -1) {
			int last = (i + 1) % (i - now);
			if (last == 0) front[i] = 1;
		}
	}

	reverse(S, S + len);
	now = -1;
	pre[0] = -1;
	for (int i = 1; i < len; i++) {
		while (now != -1 && S[i] != S[now + 1]) {
			now = pre[now];
		}
		if (S[i] == S[now + 1]) pre[i] = now = now + 1;
		else pre[i] = now = -1;
		if (now != -1) {
			int last = (i + 1) % (i - now);
			if (last == 0) back[i] = 1;
		}
	}

	if (front[len - 1] == 0) {
		printf("1\n1\n");
		return 0;
	}
	else {
		int ans = 0;
		for (int i = 0; i <= len - 2; i++) {
			if (front[i] == 0 && back[len - i - 2] == 0)
				ans++;
		}
		printf("2\n%d\n", ans);
		return 0;
	}

	return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll lcm(ll x, ll y) {
    return x / GCD(x, y) * y;//先に割り算をして掛けられる数を小さくして掛け算を行う
}
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M), b(M);
  set<pair<int, int>> s;
  for (int i = 0; i < M; i++)
  {
      cin >> a[i] >> b[i];
      a[i]--; b[i]--;
      s.insert({a[i], b[i]});
  }
  
    bool hantei = false;
  
  for (int i = 0; i < N; i++)
  {
      if(s.count({0, i}) && s.count({i, N - 1})) {
          hantei = true;
      }
  }
  
  
    if (hantei)
    {
        cout << "POSSIBLE" << endl;
    }else
    {
        cout << "IMPOSSIBLE" << endl;
    }
    
    

  

    
    return 0;

}

Measured memory_bytes: 14296
#include <stdio.h>
#include <string.h>

#define N 131072

typedef struct {
  int parent;
  int child;
  int sibling;
  int depth;
} node_t;

void dfs(node_t *array, int id, int d) {
  int child;

  if (id == -1)
    return;
  array[id].depth = d;
  for (child = array[id].child; child != -1; child = array[child].sibling)
    dfs(array, child, d+1);
}

int main(void) {
  int i, j, n, left, pid, cid, k;
  char *type;
  node_t array[N];
  memset(array, -1, sizeof(array));

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &pid);
    scanf("%d", &k);
    for (j = 0; j < k; j++) {
      scanf("%d", &cid);
      array[cid].parent = pid;
      if (!j)
	array[pid].child = cid;
      else
	array[left].sibling = cid;
      left = cid;
    }
  }

  // calulate depths
  for (i = 0; i < n; i++) {
    if (array[i].parent == -1) {
      dfs(array, i, 0);
      break;
    }
  }
  
  for (i = 0; i < n; i++) {
    // determination a node type
    if (array[i].parent == -1)
      type = "root";
    else if (array[i].child == -1)
      type = "leaf";
    else
      type = "internal node";
    
    printf("node %d: parent = %d, depth = %d, %s, ["
  	   , i, array[i].parent, array[i].depth, type);

    // print child nodes
    int id = i;
    for (k = 0; id != -1; k++) {
      if (!k && array[id].child != -1) {
	printf("%d", array[id].child);
	id = array[id].child;
      }
      else if (k && array[id].sibling != -1){
   	printf(", ");
      	printf("%d", array[id].sibling);
	id = array[id].sibling;
      }
      else
	break;
    }
    printf("]\n");
  }

  return 0;
}

Measured memory_bytes: 2668
#include<iostream>
#include<math.h>
using namespace std;
#define N 1010
#define inf 0x3f3f3f3f
int n;
double a,t;
double h[N];
int main()
{
    ios::sync_with_stdio(false);
    while(cin>>n>>t>>a)
    {
        double temp;
        int ans=1;
        double min_abs=inf;
        for(int i=1;i<=n;i++)
        {
            cin>>temp;
            h[i]=fabs(t-temp*0.006-a);
            //cout<<h[i]<<endl;
            if(h[i]<min_abs)
            {
                ans=i;
                min_abs=h[i];
            }
        }
        cout<<ans<<endl;
    }
}

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
map<char, vector<int>> mp;
int main()
{
    string s,t;
    cin >> s >> t;
    int n = s.length();
    int m = t.length();
    vector<vector<int> > is(26);
    rep(i,n)
    {
        is[s[i] - 'a'].push_back(i+1);
    }
    rep(i, n)
    {
        is[s[i] - 'a'].push_back(i+n+1);
    }
    ll ans = 0;
    int p = 0;
    rep(i,m)
    {
        int c = t[i]-'a';
        if(sz(is[c]) == 0)
        {
            cout << -1 << endl;
            return 0;
        }
        p = *upper_bound(is[c].begin(), is[c].end(), p);
        if (p>=n)
        {
            p -= n;
            ans+= n;
        }
    }
    ans += p;
    cout << ans << endl;
}

Measured memory_bytes: 1724
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'

typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
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; }
const Int INF = (1<<20);
int main(){
    int H,N;cin >> H >> N;
    int sum = 0;
    rep(i,N){
        int a;cin >>a;
        sum+=a;
    }
    if(sum>=H) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,m,x,y,ans,f1[300000],f2[300000],sum;
int read(){
	char c=getchar();while (c!='-'&&(c<'0'||c>'9'))c=getchar();
	int kk=1,k=0;if (c=='-')kk=-1,c=getchar();
	while (c>='0'&&c<='9')k=k*10+c-'0',c=getchar();return kk*k;
}void putit1(int x,int y){for (;x<=200000;x+=x&(-x))f1[x]+=y;}
void putit2(int x,int y){for (;x<=200000;x+=x&(-x))f2[x]+=y;}
int findit1(int x){int ans=0;for (;x;x-=x&(-x))ans+=f1[x];return ans;}
int findit2(int x){int ans=0;for (;x;x-=x&(-x))ans+=f2[x];return ans;}
void doit(int x,int y){ 
	if (x>y){
		doit(x,m);doit(1,y);putit1(1,m-x+1),putit1(y+1,-m+x-1); 
	}else{
		putit2(x,1);putit2(y+1,-1);putit1(x,-x);putit1(y+1,x);
	}
}void doit1(int x,int y){
	if (x<y)sum+=y-x;else sum+=y+m-x;
	x=x%m+1;if (x==y)return;doit(x,y);
}
signed main(){
	n=read();m=read();x=read();ans=1e15;
	for (int i=1;i<n;i++)y=read(),doit1(x,y),x=y;
	for (int i=1;i<=m;i++)ans=min(ans,sum-findit1(i)-findit2(i)*i);
	cout<<ans<<endl;
}


Measured memory_bytes: 3072
MOD = 10**9 + 7
def main():
    s = input()
    dp = [[0]*3 for _ in range(len(s)+1)]
# dp[idx][A, AB, ABC]
    tmp = 1
    for i in range(len(s)):
        c = s[i]
        if c == "A":
            dp[i][0] += tmp
            dp[i][0] %= MOD
        elif c == "B":
            dp[i][1] += dp[i][0]
            dp[i][1] %= MOD
        elif c == "C":
            dp[i][2] += dp[i][1]
            dp[i][2] %= MOD
        else:
            pre = [v for v in dp[i]]
            dp[i] = [0, 0, 0]
# ? = A
            dp[i][0] += pre[0] + tmp
            dp[i][1] += pre[1]
            dp[i][2] += pre[2]
# ? = B
            dp[i][0] += pre[0]
            dp[i][1] += pre[0] + pre[1]
            dp[i][2] += pre[2]
# ? = C
            dp[i][0] += pre[0]
            dp[i][1] += pre[1]
            dp[i][2] += pre[1] + pre[2]
            tmp *= 3
            tmp %= MOD
            dp[i][0] %= MOD
            dp[i][1] %= MOD
            dp[i][2] %= MOD
        dp[i+1][0] = dp[i][0]
        dp[i+1][1] = dp[i][1]
        dp[i+1][2] = dp[i][2]
#        print(dp[i])
    print(dp[len(s)][2] % MOD)

if __name__ == "__main__":
    main()

Measured memory_bytes: 22888
def MAP(): return list(map(int,input().split()))

n,m,c = MAP()
b = MAP()
ans=0
for i in range(n):
    sm=0
    a = MAP()
    for j in range(m):
        sm += a[j]*b[j]
    if sm+c>0:
        ans+=1

print(ans)

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

namespace AtCoder {
    class Program {
        static void Main(string[] args) {

            var arr1 = Console.ReadLine().Split(' ').Select(n => int.Parse(n)).ToArray();
            var N = arr1[0];
            var M = arr1[1];
            var X = arr1[2];
            var Y = arr1[3];

            var max_x = Math.Max(Console.ReadLine().Split(' ').Select(n => int.Parse(n)).Max(), X);
            var min_y = Math.Min(Console.ReadLine().Split(' ').Select(n => int.Parse(n)).Min(), Y);

            Console.WriteLine(max_x < min_y ? "No War" : "War");
        }
    }
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char , char> pcc;
#define pb push_back
#define mp make_pair
#define ft first
#define se second
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
#define rep0(i,l,r) for(int i=l;i<r;++i)

vector <ll> gf[100005];
ll dp[100005];
ll vis[100005];
ll ans;

ll dfs(ll index)
{
	ll len=gf[index].size();
	vis[index]=1;
	if(len==0)
	{
		dp[index]=0;
		return 0;
	}
	for(ll i=0;i<len;i++)
	{
		if(vis[gf[index][i]]==1)
		{
			dp[index]=max(dp[index],dp[gf[index][i]]+1);
		}
		else 
		{
			ll val=dfs(gf[index][i]);
			dp[index]=max(dp[index],val+1);
		}
	}
	ans=max(ans,dp[index]);
	return dp[index];
}

int main()
{
	ios_base::sync_with_stdio(0);
  	cin.tie(0);
  	ll n,m;
  	cin >> n >> m;
  	ll x,y;
  	for(ll i=0;i<m;i++)
  	{
  		cin >> x >> y;
  		gf[x].pb(y);
  	//	gf[y].pb(x);
  	}
  	for(ll i=1;i<=n;i++)
  	{
  		if(vis[i]==0)
  		{
  			dfs(i);
  		}
  	}
  	// for(ll i=1;i<=n;i++)
  	// {
  	// 	cout << dp[i] << endl;
  	// }

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

Measured memory_bytes: 9344
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int a, b, c, d; cin >> a >> b >> c >> d;

    if((abs(a-b) <= d && abs(c-b) <= d) || abs(c-a) <= d ) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void) {
	int D,L;
	scanf("%d%d", &D, &L);
	if (D%L == 0) {
		printf("%d\n", D / L);
	}
	else {
		printf("%d\n", D / L + D%L);
	}
	return 0;
}


Measured memory_bytes: 2076
import sys
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return input().rstrip().decode()
def II(): return int(input())
def FI(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()


def main():
	n=RD()[::-1]
	N=list(map(int,n))+[0]
	#print(N)

	ans=0

	for i in range(len(n)+1):
		if N[i]<=4:
			ans+=N[i]
		elif N[i]>=6:
			ans+=10-N[i]
			N[i+1]+=1
		else:
			if N[i+1]<=4:
				ans+=N[i]
			else:
				ans+=N[i]
				N[i+1]+=1

	print(ans)









if __name__ == "__main__":
	main()


Measured memory_bytes: 126688
use proconio::input;
use proconio::marker::Chars;
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused)]
const ALPHA_SMALL: [char; 26] = [
    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
    't', 'u', 'v', 'w', 'x', 'y', 'z',
];
#[allow(unused)]
const ALPHA: [char; 26] = [
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
    'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
];
macro_rules! maxs {
    ($x:expr, $($y:expr), *) => {{
        let mut ret = $x;
        $(
            ret = max(ret, $y);
        )*
        ret
    }};
}

const MOD: usize = 1_000_000_000 + 7;
fn main() {
    input!(S: usize);
    let N = 2000 + 100;
    let mut dp = vec![0; N + 1];
    dp[0] = 1;
    for i in 0..N + 1 {
        for j in 3..N + 1 {
            if i + j > N {
                continue;
            }

            dp[i + j] += dp[i];
            dp[i + j] %= MOD;
        }
    }

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


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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;

int dist1[330][330];
int dist2[330][330];

signed main() {
    int N, M, L;
    cin >> N >> M >> L;
    rep(i, N)rep(j, N)dist1[i][j] = INF;
    rep(i, N)dist1[i][i] = 0;
    rep(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        --a, --b;
        dist1[a][b] = c;
        dist1[b][a] = c;
    }
    //ワーシャルフロイドで1回も給油せず行ける地点を調べる
    rep(k, N) {
        rep(i, N) {
            rep(j, N) {
                dist1[i][j] = min(dist1[i][j], dist1[i][k] + dist1[k][j]);
            }
        }
    }
    rep(i, N)rep(j, N)dist2[i][j] = INF;
    rep(i, N)dist2[i][i] = 0;
    rep(i, N) {
        rep(j, N) {
            if (dist1[i][j] <= L)dist2[i][j] = 1;
        }
    }
    rep(k, N) {
        rep(i, N) {
            rep(j, N) {
                dist2[i][j] = min(dist2[i][j], dist2[i][k] + dist2[k][j]);
            }
        }
    }
    int Q;
    cin >> Q;
    rep(i, Q) {
        int s, t;
        cin >> s >> t;
        --s, --t;
        int ans = dist2[s][t] - 1;
        if (ans >= 10000)ans = -1;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 2048
import java.util.Scanner;

class Main{

	static char[][] map;
	static int H;
	static int W;

	public static void main(String[] args) {



		Scanner sc = new Scanner(System.in);			//文字の入力
		String a =sc.next(); 
		int N = Integer.parseInt(a);
		int keta = String.valueOf(N).length();
		int S  = 0;
		for(int i =0;i < a.length();i++){
			S += Character.getNumericValue(a.charAt(i)); 
		}
		if(N%S==0){
			System.out.println("Yes");
		}else{
			System.out.println("No");

		}
			
			
			
			
	}
}




class Pair implements Comparable{
	String from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}





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

int main(){
    ll x, n; cin >> x >> n;
    ll ans = 0, len = 1e5;
    vector<ll> c;
    set<ll> p;
    rep(i,n){
        ll tmp; cin >> tmp;
        p.insert(tmp);
    }

    for(long long i = 0; i <= 120; i++){
        c.push_back(x-i);
        c.push_back(x+i);
    }

    for(long long i = 0; i < c.size(); i++){
        if(p.find(c[i]) == p.end()){
            put(c[i]);
            return 0;
        }
    }
}

Measured memory_bytes: 3608