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

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

    string s;
    cin >> s;
    bool ok = true;
    rep(i,s.size()){
        if((i+1)%2==0){
            if(s[i]=='R') {ok =false;break;}
        }
        else{
            if(s[i]=='L') {ok =false;break;}
        }

    }
    if(ok){Yes}
    No
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long inf = 10000000000000;
int main()
{
    int A, B, Q; cin >> A >> B >> Q;
    vector<long long> S(A + 2), T(B + 2), ans(Q);
    vector<pair<long long, int>> query(Q);
    S[0] = T[0] = -inf;
    for (int i = 1; i <= A; i++) cin >> S[i];
    for (int i = 1; i <= B; i++) cin >> T[i];
    S[A+1] = T[B+1] = inf;
    for (int i = 0; i < Q; i++) {
        cin >> query[i].first;
        query[i].second = i;
    }
    sort(begin(query), end(query));
    long long s = 0, t = 0;
    for (int i = 0; i < Q; i++) {
        long long x = query[i].first;
        while (S[s] < x) s++;
        while (T[t] < x) t++;
        long long sr = S[s] - x, sl = x - S[s-1];
        long long tr = T[t] - x, tl = x - T[t-1];
        ans[query[i].second] = min({
            max(sr, tr),
            max(sl, tl),
            sl + tr + min(sl, tr),
            sr + tl + min(sr, tl),
        });
    }
    for (int i = 0; i < Q; i++) {
        cout << ans[i] << '\n';
    }
    return 0;
}

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

int main(){
    string S;
    cin >> S;
    if (S.at(2)==S.at(3) && S.at(4)==S.at(5)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
} 

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

int main() {
	string s;
  	cin >> s;
  	sort(s.begin(), s.end());
  	if (s[0]==s[1] && s[2]==s[3] && s[0]!=s[2]) {
      	cout << "Yes" << endl;
      	return 0;
    }
  	cout << "No" << endl;
  	return 0;
}


Measured memory_bytes: 256
n = int(input())
p_lis = list(map(int, input().split()))
min_p = n + 1
cnt = 0
for idx, p in enumerate(p_lis):
#     i = idx + 1
    if min_p > p:
        cnt += 1
    min_p = min(min_p, p)
print(cnt)

Measured memory_bytes: 24744
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
int a,b;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	in(a);in(b);
	if(a>8||b>8)printf(":(\n");
	else printf("Yay!\n");
	return 0;
}


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


int main(){
  int n,a,b;
  cin >> n >> a >> b;
  int ans=0;
  for(int i=1;i<=n;++i){
    int tmp=i;
    int cal=0;
    while(tmp>0){
      cal+=tmp%10;
      tmp=tmp/10;
    }
    if(cal>=a && cal<=b){
      ans+=i;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
  return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))

#################

Q = I()
l,r = Line(Q)

def is_prime_all(n):
  is_prime = [True]*(n+1)
  is_prime[0] = False
  is_prime[1] = False
  for i in range(2, int(n**0.5+1)):
    if not is_prime[i]:
      continue
    for j in range(i*2,n+1,i):
      is_prime[j] = False
  return is_prime

prime_judge = is_prime_all(10**5)

a = []
for i in range(10**5):
  if i==0 or i==1 or i==2:
    a.append(0)
  else:
    if i%2==0:
      a.append(a[-1])
    else:
      if (prime_judge[i]==True) and (prime_judge[(i+1)//2]==True):
        a.append(a[-1]+1)
      else:
        a.append(a[-1])

for i in range(Q):
  print(a[r[i]]-a[l[i]-1])

Measured memory_bytes: 69852
// DPL_1_B.cpp
// 0-1ナップサック問題
#include <bits/stdc++.h>
using namespace std;

const int MAX_N=100, MAX_W=10000;
int dp[MAX_N+1][MAX_W+1];
int v[MAX_N],w[MAX_N];

int solve(int N, int W){
  fill(&dp[0][0],&dp[MAX_N+1][0],0);

  for(int i=0;i<N;++i){
    for(int j=0;j<=W;++j){
      if(j<w[i]) dp[i+1][j]=dp[i][j];
      else dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
    }
  }
  return dp[N][W];
}

int main() {
  int N,W;
  cin>>N>>W;
  for(int i=0;i<N;++i)
    cin>>v[i]>>w[i];
  cout<<solve(N,W)<<endl;
  return 0;
}



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

int main(){
    int n;
    cin>>n;
    long long a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    long long v[n];

    for(int i=0;(n-1)/2-i>=0;i+=2){
        v[(n-1)/2-i]=a[n-1-i];
    }
    for(int i=0;(n-1)/2-1-i>=0;i+=2){
        v[(n-1)/2-1-i]=a[1+i];
    }
    for(int i=0;(n-1)/2+1+i<n;i+=2){
        v[(n-1)/2+1+i]=a[i];
    }
    for(int i=0;(n-1)/2+2+i<n;i+=2){
        v[(n-1)/2+2+i]=a[n-2-i];
    }
    

    reverse(a,a+n);
    long long vv[n];

    for(int i=0;(n-1)/2-i>=0;i+=2){
        vv[(n-1)/2-i]=a[n-1-i];
    }
    for(int i=0;(n-1)/2-1-i>=0;i+=2){
        vv[(n-1)/2-1-i]=a[1+i];
    }
    for(int i=0;(n-1)/2+1+i<n;i+=2){
        vv[(n-1)/2+1+i]=a[i];
    }
    for(int i=0;(n-1)/2+2+i<n;i+=2){
        vv[(n-1)/2+2+i]=a[n-2-i];
    }


    long long ans=0,ans2=0;

    for(int i=1;i<n;i++) ans+=abs(v[i]-v[i-1]),ans2+=abs(vv[i]-vv[i-1]);



    cout<<max(ans,ans2)<<endl;

}

Measured memory_bytes: 2560
import sys
input = sys.stdin.readline

def ceil(a, b):
    if a%b == 0:
        return a//b
    else:
        return (a//b) + 1

def main():
    D, G = map(int, input().split())
    pc = [list(map(int, input().split())) for i in range(D)]

    ans = int(1e9)
    for i in range(2**D):
        score = 0
        count = 0
        check = [False] * D
        for j in range(D):
            p, c = pc[j]
            if i&1:# 問題jを全て解く
                score += 100 * (j+1) * p + c
                count += p
                check[j] = True
            i >>= 1
        if score < G:
            for j in range(D):
                if not check[D-1-j]:
                    check[D-1-j] = True
                    p, c = pc[D-1-j]
                    tmp = ceil(G - score, (D-j) * 100)
                    if tmp < p:
                        count += tmp
                        score += tmp * (D-j) * 100
                    break
        if score >= G:
            # print(score, check, count)
            ans = min(ans, count)
    
    print(ans)




if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cmath>
#include<complex>
using namespace std;
typedef complex<double> p;
int main()
{
	double x1,y1,x2,y2,xq,yq;
	while(scanf("%lf,%lf,%lf,%lf,%lf,%lf",&x1,&y1,&x2,&y2,&xq,&yq)!=EOF)
	{
		p p1(x1,y1),p2(x2,y2),q(xq,yq);
		p2-=p1; q-=p1; //始点を原点にする
		q/=p2; //実軸となす角度を求める
		q=conj(q); //実軸と対象な点がRとなる
		q*=p2; q+=p1;

		printf("%.9lf %.9lf\n",q.real(),q.imag());
	}
  return 0;
}

Measured memory_bytes: 1248
///╔══╗
///╚╗╔╝
///╔╝╚(¯`v´¯)
///╚══╝`.¸.´farzin


#include <bits/stdc++.h>

#define int int64_t
#define pb push_back
#define ibsws ios_base::sync_with_stdio
#define gcd __gcd
#define s second
#define f first
typedef std::pair<int,int> pii ;

using namespace std;

const int N=1e5+1e2;
int n,dp[N],h[N],k;

int32_t main(){
	ibsws(true==false);
	cin>>n>>k;
	for(int i=0;i<n;i++){
        cin>>h[i];
        dp[i]=1e15;
	}
	dp[0]=0;
	for(int i=1;i<n;i++){
        for(int j=1;j<=k;j++){
            if(i-j+1>0){
                dp[i]=min(dp[i],dp[i-j]+abs(h[i-j]-h[i]));
                //cout<<i<<' '<<i-j<<'\n';
            }
        }
	}
	cout<<dp[n-1];
}


Measured memory_bytes: 1792
if __name__ == '__main__':
    H, W = map(int, input().split())
    S = [None]*H
    for i in range(H):
        S[i] = list(str(input()))
    S_num = [[0]*W for _ in range(H)]

    for h in range(H):
        for w in range(W):
            if S[h][w] == '#':
                if h-1 >= 0:
                    S_num[h-1][w] += 1
                    if w-1 >= 0:
                        S_num[h-1][w-1] += 1
                    if w+1 <= W-1:
                        S_num[h-1][w+1] += 1
                if h+1 <= H-1:
                    S_num[h+1][w] += 1
                    if w-1 >= 0:
                        S_num[h+1][w-1] += 1
                    if w+1 <= W-1:
                        S_num[h+1][w+1] += 1
                if w-1 >= 0:
                    S_num[h][w-1] += 1
                if w+1 <= W-1:
                    S_num[h][w+1] += 1
    for h in range(H):
        for w in range(W):
            if S[h][w] == '.':
                S[h][w] = str(S_num[h][w])
    for s in S:
        print(''.join(s))

Measured memory_bytes: 3188
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int a, b;
    cin >> a >> b;
    cout << a*b << " " << 2*a+2*b << endl;
}



Measured memory_bytes: 3136
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	try {
    		final int N = sc.nextInt();
    		int K = sc.nextInt();
    		StringBuilder S = new StringBuilder(sc.next());
    		boolean firstTime = true;
    		int step = 1;

    		while (K > 0) {
    			StringBuilder T = new StringBuilder(S.toString());
    			T.reverse();
    			StringBuilder revU = new StringBuilder(S.toString() + T.toString());
    			revU.reverse();
    			String sDash = S.toString();
    			for (int i=N; i>=0; i-=step) {
    				String tmp = revU.substring(i, i+N);
    				if (sDash.compareTo(tmp) > 0) {
    					sDash = tmp;
    				} else {
    					if (!firstTime) {
        					break;
    					}
    				}
    			}
				if (firstTime) {
					firstTime = false;
					if (Math.pow(2, K) > N) {
						char c = sDash.charAt(0);
						for (int i=0; i<N; i++) {
							System.out.print(c);
						}
						System.out.println();
						System.exit(0);
					}
				} else {
					step += step;
				}

    			K--;
    			S = new StringBuilder(sDash);
    			S.reverse();
    		}
    		System.out.println(S.reverse());

    	} finally {
    		sc.close();
    	}
    }
/*
    public static int compareTo(String value, String anotherString, int step) {
        int len1 = value.length();
        int len2 = anotherString.length();
        int lim = Math.min(len1, len2);
        char v1[] = value.toCharArray();
        char v2[] = anotherString.toCharArray();

        int k = 0;
        while (k < lim) {
        	System.out.print(lim + " / ");
        	System.out.println(k);
            char c1 = v1[k];
            char c2 = v2[k];
            if (c1 != c2) {
                return c1 - c2;
            }
            k+=step;
        }
        return len1 - len2;
    }
    */
}



Measured memory_bytes: 50900
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
#include<vector>
#define MAX_V 1001
#define INF 11111111
using namespace std;
struct edge { int to , cost; };
typedef pair<int , int> P;

int V;   /* 島の数 */
vector<edge> G[MAX_V];
int d[MAX_V];

int Dijkstra(int s,int m);

main(){
  edge DATA1,DATA2;
  long long  k,data,a,b,sum;
  while(1){
  cin >> V >> k;
  if(!V && !k)break;
  memset( G , 0 , sizeof(G));
  for(int i=0;i<k;i++){
    cin >> data;
    if(data == 1){
      cin >> a >> b >> sum;
      DATA1.to   = a;
      DATA1.cost = sum;
      DATA2.to   = b;
      DATA2.cost = sum;
      // 入れる
      G[DATA1.to].push_back( DATA2 );
      G[DATA2.to].push_back( DATA1 );
    }else {
      cin >> a >> b;
      if(Dijkstra( a , b) != INF)cout << d[b]  << endl;
      else cout << -1 << endl;
    }
  }
  }
}

int Dijkstra(int s,int m){
  priority_queue< P , vector<P> , greater<P> > que;
  fill( d , d + V + 1, INF );
  d[s] = 0;
  que.push(P(0,s));

  while(!que.empty()){
    P p = que.top();que.pop();
    int v = p.second;
    if(d[v] < p.first)continue;
    for(int i=0;i<G[v].size();i++){
      edge e = G[v][i];
      if(d[e.to] > d[v] + e.cost){
	d[e.to] = d[v] + e.cost;
	que.push(P(d[e.to] , e.to ));
      }
    }
  }
  return d[m];
}

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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define PI (acos(-1.0))
#define MODN 1000000007
#define MODN2 998244353
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int main(){

    string s;
    cin >> s;
    int size = s.size();

    map<char, int> m;

    rep(i, size){
        m[s[i]]++;
    }

    bool ans = true;

    for(auto x : m){
        if(x.second % 2 == 1){
            ans = false;
            break;
        }
    }

    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {



	public static void main(String[] args) {

	Scanner sca = new Scanner(System.in);
	// 入力

	int n = sca.nextInt();
	int m = sca.nextInt();

	if(n == m) {
		System.out.println("Yes");
	}
	else {
		System.out.println("No");
	}

	// 後始末
	sca.close();
	}
}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<int,int>
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,i,j,k,l,m,a,b,t,sum,sum1,flag;
    cin>>n;
    m=n%1000;
    if(m==0){
        cout<<0<<endl;
        return 0;
    }
    cout<<1000-m<<endl;

}



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

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  ll n;cin>>n;
  vector<ll> as(n);
  for(int i=0;i<n;i++){
    cin>>as[i];
    if(as[i]==0){
      puts("0");
      return 0;
    }
  }
  ll ans=1;
  for(int i=0;i<n;i++){
    ll a=as[i];
    ld t1 = ans;
    ld t2 = pow(10,18);
    t2 /= a;
    if(t1>t2 || ans>pow(10,18)){
      puts("-1");
      return 0;
    }
    ans*=a;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3964
//a
#include <iostream>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <functional>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>

#define REP(i,b,n) for(int i=b;i<n;i++)
#define REPR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define EACH(i, c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define BIT(n, b) ((n>>b) & 1)
#define PB push_back
#define MP make_pair

using namespace std;

static const double PI = acos(-1.0);
static const double EPS = 1e-9;
typedef long long ll;
typedef pair<int, int> pii;



int main(){
	
	int c;
	int x,y,w,h,n;
	
	cin >> c;
	
	while(c--){
		cin >> x >> y >> w >> h;
		cin >> n;
		
		int res = 0;
		
		for(int i=0; i<n; ++i){
			int a, b;
			cin>>a>>b;	
			res += (x<=a&&a<=x+w&&y<=b&&b<=y+h);
		}
		
		cout << res << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
		Scanner pw = new Scanner(System.in);
		String S = pw.next();
		String T = pw.next();
		int count = 0;
		for(int i=0;i<S.length();i++)
		{
			if(S.charAt(i)==T.charAt(i)){count++;}
		}
		System.out.println(count);
		
		
	}
	

}


Measured memory_bytes: 23632
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

if a < 0:
    if b <= 0:
        print((b - a) * c)
    else:
        print(- a * c + d + b * e)
else:
    print((b - a) * e)


Measured memory_bytes: 5592
import java.util.Scanner;

// https://atcoder.jp/contests/abc159/tasks/abc159_c
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		double l = sc.nextDouble();
		sc.close();

		System.out.println(l*l*l/27);


	}
}


Measured memory_bytes: 22612
/*
    Problem 37
    https://onlinejudge.u-aizu.ac.jp/problems/DPL_1_A
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N, M;
    cin >> N >> M;
    vector<int> w(N);
    for (int i = 0; i < M; i++) cin >> w[i];
    vector<int> dp(N+1, INF);
    dp[0] = 0;
    for (int i = 0; i < M; i++) {
        for (int j = w[i]; j <= N; j++) {
            dp[j] = min(dp[j], dp[j-w[i]] + 1);
        }
    }
    cout << dp[N] << '\n';
}


Measured memory_bytes: 3228
import scala.io.StdIn.readInt

object Main extends App {
  val n = readInt()
  var cnt = 0
  for (_ <- 1 to n) {
    if (isPrime(readInt())) {
      cnt += 1
    }
  }
  println(cnt)

  def isPrime(x: Int): Boolean = {
    if (x <= 1) return false
    if (x == 2) return true
    if (x % 2 == 0) return false
    for (i <- 3 to Math.sqrt(x).toInt by 2) {
      if (x % i == 0) return false
    }
    true
  }
}



Measured memory_bytes: 51128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int , int>
#define fast ios_base::sync_with_stdio(0)
#define mx 10004
#define mod 1000000007
ll dp[mx][102][2][2];
string str;
int d, sz;
ll fun(int pos, int rem, bool isSmall, bool isStart)
{
    if(pos==sz) return (rem==0 && isStart);
    ll& ret = dp[pos][rem][isSmall][isStart];
    if(ret==-1){
        ret = 0;
        int lim = (isSmall) ? 9 : str[pos] - '0';
        for(int i=0; i<=lim; i++){
            ret+=fun(pos+1,(rem+i)%d, isSmall | i<(str[pos]-'0'), isStart | i>0);
            ret%=mod;
        }
    }
    return ret;
}
int main()
{
    fast;
    cin>>str;
    sz = str.size();
    cin>>d;
    memset(dp, -1, sizeof dp);
    cout<<fun(0,0,0,0)<<endl;
}



Measured memory_bytes: 33152
from collections import defaultdict
import sys
input = sys.stdin.readline

class UnionFind:
    def __init__(self, N):
        self.parent = list(range(N))
        self.rank = [0] * N
        self.size = [1] * N

    def find(self, x):
        if self.parent[x] != x:
            self.parent[x] = self.find(self.parent[x])
        return self.parent[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
            self.size[y] += self.size[x]
        else:
            self.parent[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def get_size(self, x):
        return self.size[self.find(x)]

N, K, L = map(int, input().split())
uf1 = UnionFind(N+1)
for _ in range(K):
    p, q = map(int, input().split())
    uf1.unite(p, q)
uf2 = UnionFind(N+1)
for _ in range(L):
    r, s = map(int, input().split())
    uf2.unite(r, s)
cnt = defaultdict(int)
for i in range(1, N+1):
    cnt[(uf1.find(i), uf2.find(i))] += 1
ans = [cnt[(uf1.find(i), uf2.find(i))] for i in range(1, N+1)]
print(*ans)

Measured memory_bytes: 119384
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class CDominoQuality {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      if (n==2) {
        cout << -1 << endl;
        return;
      }
      if (n==3) {
        cout << "a.." << endl;
        cout << "a.." << endl;
        cout << ".bb" << endl;
        return;
      }
      vector<string> dp4(4);
      dp4[0] = "abgg";
      dp4[1] = "abhh";
      dp4[2] = "ccef";
      dp4[3] = "ddef";

      vector<string> dp5(5);
      dp5[0] = "aabbc";
      dp5[1] = "dde.c";
      dp5[2] = "g.eff";
      dp5[3] = "ghi..";
      dp5[4] = ".hijj";

      vector<string> dp6(6);
      dp6[0] = "aabee.";
      dp6[1] = "c.b..f";
      dp6[2] = "cdd..f";
      dp6[3] = "ee.aab";
      dp6[4] = "..fc.b";
      dp6[5] = "..fcdd";

      vector<string> dp7(7);
      dp7[0] = ".aa.bbc";
      dp7[1] = "d..e..c";
      dp7[2] = "d..eg..";
      dp7[3] = ".ff.ghh";
      dp7[4] = "k.ll..i";
      dp7[5] = "k..n..i";
      dp7[6] = "mm.njj.";

      vector<vector<char>> ans(n, vector<char>(n, '.'));
      int tmp = n;
      while (tmp>7) {
        int k = n-tmp;
        for(int i=k; i<k+4; i++) {
          for(int j=k; j<k+4; j++) {
            ans[i][j] = dp4[i-k][j-k];
          }
        }
        tmp -= 4;
      }



      int k = n-tmp;
      for(int i=k; i<n; i++) {
        for(int j=k; j<n; j++) {
          if (tmp==7) {
            ans[i][j] = dp7[i-k][j-k];
          } else if (tmp==6) {
            ans[i][j] = dp6[i-k][j-k];
          } else if (tmp==5) {
            ans[i][j] = dp5[i-k][j-k];
          } else if (tmp==4) {
            ans[i][j] = dp4[i-k][j-k];
          }
        }
      }

      rep(i, n) {
        rep(j, n) {
          cout << ans[i][j];
        }
        cout << '\n';
      }

    }
};

signed main() {
  CDominoQuality solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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


Measured memory_bytes: 256
#C - Many Requirements
#再帰関数(n重のfor文)
N,M,Q = map(int,input().split())
abcd = []
for _ in range(Q):
    a,b,c,d = map(int,input().split())
    abcd.append((a,b,c,d))
max_score = 0
def dfs(A):
    global max_score
    if len(A) == N:
        #処理
        score = 0
        for ai,bi,ci,di in abcd:
            if A[bi-1] -A[ai-1] == ci:
                score += di
        return score
    #一つ前の値を保持
    if len(A) >= 1:
        prev_last = A[-1]
    else:
        prev_last = 1
    #1つ前の値より大きい値の範囲
    for i in range(prev_last,M+1):
        A.append(i)
        max_score = max(max_score,dfs(A))
        A.pop()
    return max_score#ループの途中のdfs (len(A) != N のとき) に値を返す
dfs([])
print(max_score)

Measured memory_bytes: 9268
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

#define MOD 1000000007;//1e9+7

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

    cout << N*N*N;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define pb push_back
#define r1 rt<<1
#define r2 rt<<1|1
#define fi first
#define se second
#define ri register int
#define rep(i,a,b) for(ri i=(a);i<=(b);++i)
#define rep2(i,a,b,c) for(ri i=(a);i<=(b);i+=(c))
#define REP(i,a,b) for(ri i=(a);i>=(b);--i)
#define REP2(i,a,b,c) for(ri i=(a);i>=(b);i-=(c))
using namespace std;

inline ll read(){
	ll x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^'0'),c=getchar();
	return x*f;
}
inline void write(ll x){
	if(x<0) putchar('-'),x=-x;
	if(x>9) write(x/10);
	putchar(x%10+'0');
}
const int N=50005;
char s[N];
int a[N],n,b[20];
int main()
{
	n=read();scanf("%s",s+1);
	rep(i,1,n)a[i]=s[i]^48;ri ans=0;
	rep(c,0,9)rep(d,0,9)rep(e,0,9){
		b[1]=c;b[2]=d;b[3]=e;ri x=0;
		rep(i,1,n){
			if(a[i]==b[x+1])++x;
			if(x==3)break;
		}
		if(x==3)++ans;
	}cout<<ans;
	return 0; 
}

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

int main() {
	// your code goes here
	map<int,int> hash;
	int N,M;
	cin>>N>>M;
	while(M--)
	{
		int s,c;
		cin>>s>>c;
		if(hash.find(s)!=hash.end() && hash[s]!=c){
			cout<<-1;
			return 0;
		}
      hash[s]=c;
	}
	int res=0;
	if(hash.find(1)!=hash.end())
	{
		if(hash[1]==0 && N!=1)
		{
			cout<<-1;
			return 0;
		}
		res=hash[1];
      
	}
	N--;
    if(N==0)
    {
		cout<<res<<endl;
      	return 0;
    }
  	if(res==0)
      res=1;
	int pos=2;
	while(N--)
	{
		res=res*10;
		if(hash[pos])
			res+=hash[pos];
		pos++;
	}
	cout<<res;
	return 0;
}

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

const int64_t INF = 1e+15;

int main() {
    int64_t H,N;
    cin >> H >> N;
    vector<int64_t> A(N),B(N);
    for ( int64_t i = 0; i < N; ++i){
        cin >> A.at(i) >> B.at(i);
    }
    
    vector<int64_t> dp(H+1,INF);
    dp[0] = 0;
    for ( int64_t i = 0; i <= H; ++i){
        for ( int64_t k = 0; k < N; ++k){
            if ( i + A[k] >= H ){
                dp[H] = min(dp[H],dp[i] + B[k]);
            } else {
                dp[i+A[k]] = min(dp[i+A[k]],dp[i]+B[k]);
            }
        }
    }
    
    cout << dp[H] << endl;
    
    return 0;
}


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

int main(){
    int N;
    int left=0,right=0;
    string S;
    stack <char> stk;


    cin >> N;
    cin >> S;

    for(int i=0;i<N;i++){
        switch(S[i]){
            case '(':
                stk.push('(');
                break;
            case ')':
                if(stk.empty()){
                    left++;
                }
                else{
                    stk.pop();
                }
                break;
        }
    }
    right = stk.size();

    for(int i=0;i<left;i++){
        S = '(' + S;
    }
    for(int i=0;i<right;i++){
        S = S + ')';
    }

    cout << S << "\n";

    return 0;
}

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

int main(){
  int N,A,B;
  cin>>N>>A>>B;
  string S;
  cin>>S;
  int cnta=0,cntb=0,cntc=0,pas=0;
  
  for(int i=0;i<S.length();i++){
    /*if(S.at(i)=='a'){
      cnta++;
    }*/
    if(S.at(i)=='b'){
      cntb++;
    }      
    /*if(S.at(i)=='c'){
      cntc++;
    }  */  
    if(S.at(i)=='a'){
      if(pas<A+B){
        cout<<"Yes"<<endl;
        pas++;
      }
      else {
        cout<<"No"<<endl;
      }
    }
    if(S.at(i)=='b'){
      if(pas<A+B && cntb<=B){
        cout<<"Yes"<<endl;
        pas++;
      }
      else{
        cout<<"No"<<endl;
      }
    }    
    if(S.at(i)=='c'){
      cout<<"No"<<endl;
    }      
    
  }
  
}


Measured memory_bytes: 3708
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,avx2,fma,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(0),cin.tie(0), cout.tie(0)
typedef long long ll;


ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

//#######################################


int main(){
  boost;
  
  
  int n,x,t;
  cin>>n>>x>>t;
  cout<<(n/x)*t+(n%x>0)*t;
}



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

typedef ll Weight;
struct Edge{
    ll src,dst;
    Weight w;
    Edge(ll source,ll destination, Weight weight) {
        src=source;dst=destination;w=weight;
    }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

int main() {
    ll n;
    cin>>n;
    Graph g(n);
    rep(i,n-1){
        ll a,b;
        cin>>a>>b;
        g[a-1].push_back(Edge(a-1,b-1,0));
        g[b-1].push_back(Edge(b-1,a-1,0));
    }
    vector<ll> c(n);
    rep(i,n)cin>>c[i];
    sort(c.begin(),c.end(),greater<ll>());
    vector<ll> ver(n,-1);
    vector<bool> cango(n,false);
    ver[g[0][0].src]=c[0];
    ver[g[0][0].dst]=c[1];
    for(Edge ee:g[g[0][0].src]){
        if(ver[ee.dst]==-1){
            cango[ee.dst]=true;
        }
    }
    for(Edge ee:g[g[0][0].dst]){
        if(ver[ee.dst]==-1){
            cango[ee.dst]=true;
        }
    }
    for(ll k=1;k<n-1;k++){
        rep(i,n){
            if(cango[i]){
                cango[i]=false;
                ver[i]=c[k+1];
                for(Edge ee:g[i]){
                    if(ver[ee.dst]==-1){
                        cango[ee.dst]=true;
                    }
                }
                break;
            }
        }
    }
    ll sum=0;
    rep(i,n){
        sum+=c[i];
    }
    cout<<sum-c[0]<<endl;
    rep(i,n){
        cout<<ver[i]<<" ";
    }
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,H,W;
  cin >> N >> H >> W;
  vector<int>A(N);
  vector<int>B(N);
  int count = 0;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i) >> B.at(i);
    if (A.at(i) >= H && B.at(i) >= W){
      count++;
    }
  }
  cout << count << endl;
}
    
 

Measured memory_bytes: 3556
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<climits>
using namespace std;
#define rep(i, j) for(int i = 0; i < j; i++)
#define f(i, k, j) for(int i = k; i < j; i++)
#define P pair<int, int>
const int INF = INT_MAX;
const int MOD = 100000;
const int MAX_WH = 110;

int main(){
    int w, h;
    while(cin >>w >>h && w && h){
        //0 ... 北, 1 ... 東
        int dp[2][MAX_WH][MAX_WH] = {0};
        dp[0][1][0] = 1; dp[1][0][1] = 1;

        rep(i, h){
            rep(j, w){

                dp[0][i][j] %= MOD;
                dp[1][i][j] %= MOD;

                if(i == h - 1 && j == w - 1) continue;

                dp[0][i + 1][j] += dp[0][i][j];
                dp[1][i][j + 2] += dp[0][i][j];
                dp[1][i][j + 1] += dp[1][i][j];
                dp[0][i + 2][j] += dp[1][i][j];
            }
        }

        cout <<(dp[0][h - 1][w - 1] + dp[1][h - 1][w - 1] + dp[0][h][w - 1] + dp[1][h - 1][w]) % MOD <<endl;
    }
    return 0;
}

Measured memory_bytes: 1260
S = input()
l = len(S)
A = [0] * (l+1)

count = 0
for i, s in enumerate(S):
    if s == '>':
        count = 0
    else:
        count += 1
        A[i+1] = count

count = 0
for i in range(l-1, -1, -1):
    s = S[i]
    if s == '<':
        count = 0
    else:
        count += 1
        A[i] = max(A[i], count)

print(sum(A))

Measured memory_bytes: 23336
#include <stdio.h>
int main(){
	int n,a;
	scanf("%d",&n);
	a=n%10;//找出个位上的数
	if(a==2||a==4||a==5||a==7||a==9)printf("hon\n");
	else if(a==0||a==1||a==6||a==8)printf("pon\n");
	else if(a==3)printf("bon\n");
	return 0;
}
 

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

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

    for (int i = 0; i < N; i++) {
        string S;
        cin >> S;

        if (S == "Y") {
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 6e2 + 10;
vector <int> e[N];
double f[N], g[N];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= m; ++i)
    {
        int u, v;
        cin >> u >> v;
        e[u].emplace_back(v);
    }
    for (int i = n; i; --i)
        for (int j : e[i])
            f[i] += (f[j] + 1.) / e[i].size();
    double ans = f[1];
    for (int i = n; i; --i)
    {
        if (e[i].size() > 1)
        {
            int del = -1;
            for (int j : e[i])
                if (del == -1 || f[del] < f[j])
                    del = j;
            g[i] = 0;
            for (int j : e[i])
                if (j != del)
                    g[i] += (g[j] + 1.) / (e[i].size() - 1);
            for (int j = i - 1; j; --j)
            {
                g[j] = 0;
                for (int k : e[j])
                    g[j] += (g[k] + 1.) / e[j].size();
            }
            ans = min(ans, g[1]);
        }
        g[i] = f[i];
    }
    cout << fixed << setprecision(7) << ans;
}


Measured memory_bytes: 1408
#include <iostream>

int main() {
	int n;
	for (std::cin >> n; n > 0; --n) {
		int a = 0, b = 0;
		bool f = true;
		for (int i = 0; i < 10; ++i) {
			int x; std::cin >> x;
			if (x > a) { a = x; }
			else if (x > b) { b = x; }
			else { f = false; }
		}
		std::cout << (f ? "YES" : "NO") << std::endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

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

ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}

int main(void){
    ios::sync_with_stdio(false);
    int k,s,x,y;
    int ans=0;
    cin >> k >> s;
    for (int x=0;x<=k;x++){
        for(int y=0;y<=k;y++){
            int z=s-x-y;
            if(0<=z and z<=k) ans++;
        }
    }
    cout << ans  << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

const int N=5005;
ll m=998244353,f[50005],inv[50005],dp[N][N];

//ll p(ll a,ll b)
//{
//	ll r=1;
//	while(b)
//	{
//		if(b%2)r=(r*a)%m;
//		a=(a*a)%m;
//		b/=2;
//	}
//	return r;
//}
//
//ll ncr(ll n,ll r)
//{
//	if(r<0||r>n)
//	return 0;
//	ll res=(f[n]*inv[r])%m;
//	return (res*inv[n-r])%m;
//}
//
//ll get(ll a,ll b,ll k)
//{
//	if(k==0)return 1ll;
//	if(k>min(a,b))return 0ll;
//	ll ans=(f[a]*inv[a-k])%m;
//	ans=(ans*f[b])%m;
//	ans=(ans*inv[b-k])%m;
//	return ans;
//}

void solve()
{
	ll a,b,c,d,row,col;
	cin>>a>>b>>c>>d;
	row=c-a,col=d-b;
	ll ans=0;
	dp[0][0]=1;
	rep(i,1,row)
	{
		dp[i][0]=(dp[i-1][0]*b)%m;
		ll sum=dp[i-1][0];
		rep(j,1,col)
		{
			sum=(sum*(a+i-1))%m;
			dp[i][j]=(sum+dp[i-1][j]*(b+j))%m;
			sum=(sum+dp[i-1][j])%m;
		}
	}
	ll mul=1;
	ren(i,col,0)
	{
		ans=(ans+dp[row][i]*mul)%m;
		//o2(i,dp[row][i]*mul);on;
		mul=(mul*c)%m;
	}
	ol(ans);
}

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

//f[0]=1;
//rep(i,1,50004)f[i]=(f[i-1]*i)%m;
//inv[50004]=p(f[50004],m-2);
//ren(i,50003,0)inv[i]=(inv[i+1]*(i+1))%m;

int t=1;
while(t--)
{
	solve();
}
return 0;
}



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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int _i=(first);_i<(last);++_i){cout<<#a<<"["<<_i<<"] = "<<(a)[_i]<<endl;}
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#define dprintf(...) printf(__VA_ARGS__)
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTI(a,i)
#define dprintf(...)
#endif

#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 pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define MOD 1000000007
//#define MOD 998244353

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

template <class T, class U>
std::ostream& operator<<(std::ostream &os, const std::pair<T, U> &p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}
 
template <class T>
std::ostream& operator<<(std::ostream &os, const std::vector<T> &v) {
    os << "[";
	for (int i = 0; i < v.size(); ++i) {
        if (i) {
            if (i % 5 == 0) {
                os << ",\n ";
            } else {
                os << ", ";
            }
        }
		os << v[i];
	}
	os << "]";
	return os;
}

template <class T>
using vec2 = vector<vector<T>>;

template <class T>
using vec3 = vector<vector<vector<T>>>;

template <class T>
vec2<T> vec2_init(int n0, int n1, T x = 0) {
    return vec2<T>(n0, vector<T>(n1, x));
}

template <class T>
vec3<T> vec3_init(int n0, int n1, int n2, T x = 0) {
    return vec3<T>(n0, vec2_init(n1, n2, x));
}

/*
 *           U P
 *           - x
 *            ^
 *            |
 * LEFT -y <--+--> +y RIGHT
 *            |
 *            v
 *           + x
 *         D O W N
 */

const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

enum {
    DOWN,
    RIGHT,
    UP,
    LEFT,
};

constexpr double inf = numeric_limits<double>::infinity();

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

    string S;
    cin >> S;
    int N = S.size();
    cout << S;
    if (S[N - 1] == 's') {
        cout << 'e';
    }
    cout << 's' << endl;
    return 0;
}


Measured memory_bytes: 3640
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            divisors.append(n//i)

    # divisors.sort()
    return divisors

def F(a, b):
    list_A = list(str(a))
    list_B = list(str(b))
    num = max(len(list_A), len(list_B))

    return num

n = int(input())
list_N = make_divisors(n)
h = len(list_N)
list_ANS = []

for i in range(0, h, 2):
    list_ANS.append(F(list_N[i], list_N[i+1]))

print(min(list_ANS))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  string ans = "";
  while(n!=0){
    if(n%2!=0){
      ans = "1" + ans;
      --n;
    }
    else ans = "0" + ans;
    n /= (-2);
  }
  
  if(ans == "") ans = "0";
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
N,L = map(int,input().split())

apples = []

abs_min = 10**10
isPlus = True
for i in range(1,N+1):
    now = i+L-1
    apples.append(i+L-1)
    if abs_min > abs(now):
        abs_min = min(abs_min,abs(now))
        if now>=0:
            isPlus = True
        else:
            isPlus = False


if not isPlus:
    abs_min *= -1
    
print(sum(apples) - abs_min)
    



Measured memory_bytes: 3060
<?php

function getPair($x) {
    $a = $x % 10;
    $b = ((string)$x)[0];
    return [$a, $b];
}

$n = (int)trim(fgets(STDIN));

$map = [];
for ($i = 1; $i <= $n; ++$i) {
    $pair = getPair($i);
    $key = $pair[0]*10 + $pair[1];
//    echo "check $key\n";
    $map[$key] += 1;
}

// echo json_encode($map)."\n";
$ans = 0;
for ($i = 1; $i <= $n; ++$i) {
    $pair = getPair($i);
    $key = $pair[1]*10 + $pair[0];
//    echo "check $key\n";
    $ans += $map[$key];
}

echo "$ans\n";

Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
int a[4];
int main()
{
	for(int i=1;i<=3;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+4);
	if(a[1]+a[2]==a[3])
		printf("Yes\n");
	else printf("No\n");
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define REV(v) reverse(v.begin(), v.end());
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, start, stop) for (ll i = start; i < stop; i++)
#define FORR(i, start, stop) for (ll i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define SORTR(v, n) sort(v, v + n,greater<ll>());
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<ll>());
#define REMOVE(v,n) remove(vector<ll> v,v+v.size(),ll n)
#define ERASE(v,n) v.erase(v.begin()+n);
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
#define V(v,i,j) vector(v.begin() + i, v.begin() + j)
#define INSERT(va,vb) va.insert(va.end(), vb.begin(), vb.end())
using namespace std;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
const int MOD = 1000000007;
void chmin(int &a, int b) { if (a > b) a = b; }

//vector< vector<int> > v (size1, vector<int>(size2) );



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

    ll H,W;
    cin>>H>>W;
    vector<string> field(H); 
    
    string s;
    FOR(i,0,H){
        cin>>s;
        field[i]=s;
    }

    ll cnt=0;

    FOR(i,0,H){
        FOR(j,0,W){
            if(field[i][j]=='.'){
                cnt=0;
                FOR(x,-1,2){
                    FOR(y,-1,2){
                        if(!(x==0 && y==0) && 0<=i+y && i+y<=H-1 &&
                        0<=j+x && j+x<=W-1 && (field[i+y][j+x]=='#'))
                        cnt++;
                    }
                }
                cout<<cnt;
            }else cout<<'#';
            if(j==W-1) cout<<endl;
        }
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<int> a(3);
	rep(i,3) cin >> a.at(i);
	sort(a.begin(),a.end());
	if(a.at(0)==5 && a.at(1)==5 && a.at(2)==7) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	const int mod=1000000007;
	static int[] a;
	static void Main(){
		Sc sc=new Sc();
		int n=sc.I,q=0;
		a=sc.Ia;
		long[] r=new long[n+2];
		long[] ans=new long[n+1];
		int[] h=new int[n+1];
		r[0]=1;
		for(int i=1;i<n+2;i++){r[i]=(r[i-1]*i)%mod;}
		for(int i=0;i<=n;i++){
			if(h[a[i]]!=0){q=i+1-h[a[i]];break;}
			h[a[i]]=i+1;
		}
		for(int i=0;i<=n;i++){
			ans[i]=(r[n+1]*Mi((r[i+1]*r[n-i])%mod))%mod;
			if(i<=n-q){ans[i]=(mod+ans[i]-((r[n-q]*Mi((r[i]*r[n-q-i])%mod))%mod))%mod;}
		}
		Console.WriteLine(String.Join("\n",ans));
	}
	static long Mi(long a){
		long b=mod,u=1,v=0;
		while(b>0){
			long t=a/b;
			a-=t*b;a^=b;b^=a;a^=b;
			u-=t*v;u^=v;v^=u;u^=v;
		}
		u%=mod;
		if(u<0){u+=mod;}
		return u%mod;
	}
}

class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

Measured memory_bytes: 29020