akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pb push_back
#define INF (ll)1e9
#define deb(x) cerr<<#x<<" "<<x<<"\n"
using namespace std;
using ll = long long;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	vector<int> v(n);
	vector<int> pos[n+1];
	for(int i=1;i<=n;i++){
		pos[i].pb(0);
	}
	for(int i =0;i<n;i++){
		cin>>v[i];
		pos[v[i]].pb(i+1);
		pos[v[i]][0]++;
	}
	int start =0;
	int current =0;
	for(int i=1;i<=n;i++){
		if(pos[i][0] == 0){
			break;
		}
		else{
			bool cond = false;
			for(int j=1;j<=pos[i][0];j++){
				if(pos[i][j]>current){
					current = pos[i][j];
					start++;
					cond = true;
					break;
				}
			}
			if(!cond){
				break;
			}
			
		}
	}
	if(start == 0){
		cout<<"-1";
	}
	else{
		cout<<n - start;
	}
	
	
}




Measured memory_bytes: 13180
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

template<class T>
class sg_tree : public vector<T>{
    private:
    lli n;
    T default_value;
    T _query(lli a,lli b,lli k,lli l,lli r){
        if(r <= a || b <= l) return default_value;
        if(a <= l && r <= b) return (*this)[k];
        else {
            T vl = _query(a,b,k*2+1,l,(l+r)/2);
            T vr = _query(a,b,k*2+2,(l+r)/2,r);
            return func(vl,vr);
        }
    }
    public:
    sg_tree():vector<T>(){

    }
    sg_tree(lli n,T d = (1ll << 31) - 1):vector<T>(n*4,d){
		this->n = 1;
        while(n > this->n) this->n <<= 1;
        this->default_value = d;
    }
    void update(lli i,lli x){
        i += n - 1;
        (*this)[i] = x;
        while(i > 0){
            i = (i - 1) / 2;
            (*this)[i] = func((*this)[i * 2 + 1],(*this)[i * 2 + 2]);
        }

    }
    T query(lli a,lli b){
        return _query(a,b,0,0,n);
    }
    T func(T a,T b){
        return min(a,b);
    }
};

sg_tree<lli> sg;
lli n,q;
lli com,x,y;

int main(){
    cin >> n >> q;
    sg = sg_tree<lli>(n);
    for(lli i = 0;i < q;i++){
        cin >> com >> x >> y;
        if(com == 0){
            sg.update(x,y);
        }else if(com == 1){
            cout << sg.query(x,y+1) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 5976
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    string s;
    ll ans=0;
    cin>>s;
    for(int i=0;i<s.length();i++){
        ans+=s[i]-'0';
    }
    if(ans%9==0){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
}

Measured memory_bytes: 3656
n = int(input())

if n == 1:
    c = 0
else:
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    z = []
    for i in arr:
        for j in range(1,i[1]+1):
            z.append(i[0]**j)
    z = sorted(set(z))
    c = 0
    for i in z:
        if n%i == 0:
            c += 1
            n = int(n/i)
print(c) 

Measured memory_bytes: 9504
#include<iostream>
using namespace std;
int main(){
  string a;
  cin>>a;
  int k=0,h=0,g=0;
  for(int i=0;i<3;i++){
    if(a.at(i)=='a')
      k++;
    else if(a.at(i)=='b')
      h++;
    else if(a.at(i)=='c')
      g++;
  }
  if(k==1&&h==1&&g==1)
    cout<<"Yes";
  else
    cout<<"No";
    return 0;
}


Measured memory_bytes: 3160
Q = int(input())
LR = [list(map(int, input().split())) for _ in range(Q)]
R = [r for l,r in LR]
maxR = max(R)

def primes_upto(m):
    _l = list(range(2, m+1))
    primes=[]
    while _l:
        p = _l[0]
        if p > m**0.5:
          primes.extend(_l)
          return primes
        primes.append(p)
        _l=[n for n in _l if n%p]
    return primes

primes = set(primes_upto(maxR))

from itertools import accumulate

like2017s = [1 if n in primes and (n+1)//2 in primes else 0 for n in range(3,maxR+1,2)]
# 3, 5, 7, ...
n_like2017s = [0] + list(accumulate(like2017s)) + [0]
# 1, 3, 5, 7, ...

for l, r in LR:
  print(n_like2017s[(r-1)//2] - n_like2017s[(l-1)//2-1])

Measured memory_bytes: 33908
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

n, m, k = map(int, input().split())
a = [0] + [int(x) for x in input().split()]
b = [0] + [int(x) for x in input().split()]

from itertools import accumulate

a = list(accumulate(a))
b = list(accumulate(b))
ans = 0
import bisect
for i in range(n + 1):
    now = a[i]
    if k - now >= 0:
        j = bisect.bisect_right(b, k - now)
        ans = max(ans, i + j - 1)
print(ans)




Measured memory_bytes: 129924
#include<stdio.h>
int N,F[101][6][3],P[101][11];
int max(int x, int y)
{
  return x > y ? x : y;
}
int daynum(int n,int day[11])
{
  int i,j,res=0;
  for(i=1;i<=5;i++)
    for(j=1;j<=2;j++)
      res += day[2*(i-1)+j]*F[n][i][j];
  return res;
}

int isZero(int day[11])
{
  int i;
  for(i=1;i<=10;i++)
    if(day[i] != 0)
      return 0;
  return 1;

}

int rieki(int day[11],int date){
  if(date == 11){
    int n,res=0;
    if(isZero(day))
      return -2000000000;
    for(n=1;n<=N;n++)
      res += P[n][daynum(n,day)];
    return res;
  }else{
    int i,d1[11],d2[11];
    for(i=1;i<=10;i++)
      d1[i] = d2[i] = day[i];
    d1[date] = 1;
    d2[date] = 0;
    return max(rieki(d1,date+1),rieki(d2,date+1));
  }
}

int main()
{
  int day[11],i,j,k,res;
  scanf("%d",&N);
  for(i=1;i<=N;i++)
    for(j=1;j<=5;j++)
      for(k=1;k<=2;k++)
        scanf("%d",&F[i][j][k]);
  for(i=1;i<=N;i++)
    for(j=0;j<=10;j++)
      scanf("%d",&P[i][j]);
  for(i=0;i<=10;i++)
    day[i] = 0;
  printf("%d\n",rieki(day,1));
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
int main() {
	ll k;
	scanf("%lld", &k);
	ll n = 50;
	printf("%lld\n", n);
	ll r = k % n;
	for (int i = 0; i < n; ++i) {
		printf("%lld ", i + k / n + (i >= n - r) );
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define Rep1(i,k,n) for(int i=k ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;


int main(){
    int n,m; cin >> n >> m;
    vector<vector<pair<int,int>>> edge;
    vector<bool> visited(n+1,false);
    //vector<bool> wb(n+1, false);
    
    int ans = 0;
 
    rep(i,n+1) edge.emplace_back();
    rep(i,m){
        int a,b,c; cin >> a >> b >> c;
        edge[a].emplace_back(b,c);
        edge[b].emplace_back(a,c);
    }

    //int path = 0;
    
    rep1(i,n){
        if(visited[i]) continue;
        ans++;
        queue<int> bfs;
        bfs.push(i);

        while(!bfs.empty()){
            int tmp = bfs.front();
            bfs.pop();
            
            rep(i,edge[tmp].size()){
                int next = edge[tmp][i].first;
                if(!visited[next]) {
                    bfs.push(next);
                    visited[next] = true;

                }
                //path++;
            }
        }
        

        //allvisit = true;
        //rep1(i,n) if(!visited[i]) allvisit = false;
    }
    cout << ans << endl;
    
}

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

int main() {
    int a, b, c;

    cin >> a >> b >> c;    

    if ((a==b && b!=c) || (b==c && c!=a) || (c==a && a!=b)) {
        cout << "Yes" << endl;
    }

    else {
        cout << "No" << endl;
    }   

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here! 
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        char[] c = str.toCharArray();
        int n = c.length;
        
        Set<String> set = new HashSet<String>();
        
        boolean ok = true;
        for (int i = 0; i < n; i++) {
            int old = set.size();
            String tmp = String.valueOf(c[i]);
            set.add(tmp);
            
            if (set.size() == old) ok = false;
        }
        
        if (ok) {
            System.out.println("yes");
        } else {
            System.out.println("no");
        }
    }
}

Measured memory_bytes: 35656
#include <stdio.h>

int main(void)
{
	int cnt = 0;
	int n;
	scanf("%d", &n);
	int x[n];
	for(int i = 0; i < n; i++){
		scanf("%d", &x[i]);
	}
	for(int i = 0; i < n; i++){
		int minj = i;
		for(int j = i; j < n; j++){
			if(x[j] < x[minj]){
				minj = j;
			}
		}
		if(minj != i){
			int temp = x[i];
			x[i] = x[minj];
			x[minj] = temp;
			cnt++;
		}
	}
	for(int i = 0; i < n - 1; i++){
		printf("%d ", x[i]);
	}
	printf("%d\n%d\n", x[n - 1], cnt);
	return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n;i>=0;i--)
#define For(i,m,n) for(int i=m;i<n;i++)
#define Forr(i,m,n) for(int i=m;i>n;i--)
#define Sort(a) sort(a.begin(),a.end())
#define pb push_back
#define vl vector<ll>
#define vll vector<vector<ll>>
#define INF 999999999999

int main(){
 int A[100],N; double den=0;
 cin>>N;
 rep(i,N){
   cin>>A[i];
   den+=1.0/A[i];
 }
 cout<<fixed<<setprecision(10)<<1.0/den<<endl;
return 0;
}


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

int main(){
    int N, A, B;
    cin >> N >> A >> B;
    printf("%d\n", min(N*A, B));
    return 0;
}

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

typedef long long ll;
#define pii pair<int, int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int t , n , x;
int a[MAXX];

int main()
{
    _FastIO;
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <math.h>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <numeric>
#include <list>
#include <deque>
#include <map>
#include <set>

using namespace std;

typedef long long LL;
typedef pair<int, int>PII;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), rend()
#define PB pushback
#define SORT(c) sort((c).begin(),(c).end())

const LL INF = 1LL << 60;

//priority_queue<int> p;

int i, j, k, tmp, ans, cnt, N, M;
string s;

//scanf("%d",&N);

//printf("%d", ans);

//cout <<  << endl;


int main(void) {
	vector<LL> A;
	vector<int> a;
	cnt = 0;
	scanf("%d %d", &N, &M);
	if (M == 0) {
		a.push_back(0);
	}
	REP(i, M) {
		scanf("%d", &tmp);
		a.push_back(tmp);
	}
	REP(i, N+1) {
		A.push_back(0);
	}
	tmp = 0;
	A.at(0) = 1;
	if(a.at(cnt) != 1){
		A.at(1) = 1;
		
	}
	else {
		cnt++;
	}
	
	for (int i = 2; i < N+1; i++) {

		if (a.size() > cnt && i == a.at(cnt)) {
			cnt++;
			A.at(i) = 0;
		}
		else {
			A.at(i) = (A.at(i - 1) + A.at(i - 2)) % 1000000007LL;
			if (A.at(i) == 0) {
				printf("0\n");
				return 0;
			}
		}		
	}


	printf("%lld", A.at(N) % 1000000007);
	return 0;
}

Measured memory_bytes: 1784
import java.io.*;
import java.util.*;

class Main{
  public static void main(String[] args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String data;
    List<String> rectangle_list = new ArrayList<String>();
    while(true){
      data = br.readLine();
      if(data.equals("0 0")){
        break;
      }
      rectangle_list.add(data);
    }

    int height = 0;
    int width  = 0;
    String[] tmp = new String[2];
    for(String rectangle: rectangle_list){
      tmp = rectangle.split(" ");
      height = Integer.parseInt(tmp[0]);
      width  = Integer.parseInt(tmp[1]);
      for(int i = 0; i < height; i++ ){
        for(int j = 0; j < width; j++){
          System.out.print("#");
        }
        System.out.println();
      }
      System.out.println();
    }
  }
}



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

using namespace std;

bool checkFirst(string* str, int no)
{
	bool ret = true;
	string word = str[no];

	for (int i = 0; i < no; i++) {
		if (str[i] == word) {
			ret = false;
			break;
		}
	}

	return ret;
}

int main()
{
	int N;
	int len;
	bool tmp;
	bool result = true;

	cin >> N;

	string* W = new string[N];
	for (int i = 0; i < N; i++) cin >> W[i];

	for (int i = 1; i < N; i++) {
		len = W[i - 1].length();

		if (W[i - 1].substr(len - 1, 1) != W[i].substr(0, 1)) {
			result = false;
			break;
		}

		tmp = checkFirst(W, i);

		if (!tmp) {
			result = false;
			break;
		}
	}

	if (result) cout << "Yes" << endl;
	else cout << "No" << endl;

	delete[] W;

	return 0;
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

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

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

ll ngcd(vector<ll> a) {
  ll res = a[0];
  for(ll i=1; i<a.size() && res!=1; i++) res = gcd(a[i], res);
  return res;
}
ll nlcm(vector<ll> a){
  ll res = a[0];
  for(ll i=1; i<a.size(); i++) res = lcm(a[i], res);
  return res;
}
bool is_prime(ll n) {
  if(n < 2) return false;
  for (ll i = 2; i * i <= n; i++) if (n % i == 0) return false;
  return true;
}
ll digsum(ll n) {
  ll res=0;
  while(n) res += n%10, n /= 10;
  return res;
}
ll digcnt(ll n){
  ll res=0;
  while(n) res++, n /= 10;
  return res;
}
vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}
map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) ++res[i], n /= i;
  }
  if (n != 1) res[n] = 1;
  return res;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n,k; cin>>n>>k;
  ll sum=0;
  vll a(n);
  rep(i,n){
    cin>>a[i];
    sum+=a[i];
  }
  ll ans=1;
  auto div=divisor(sum);
  for(auto e: div){
    ll cnt=LINF;
    vll b(n);
    rep(i,n) b[i]=a[i]%e;
    vsort(b);
    ll plus=0, minus=0;
    rep(i,n) plus+=e-b[i];
    rep(i,n){
      minus+=b[i];
      plus-=(e-b[i]);
      if(plus==minus){
        if(plus<=k) chmax(ans,e);
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a,b,c,cul,count1;
  scanf("%d %d %d",&a,&b,&c);

  cul=a*c;
  if(cul>b){
  count1 = b/a;
  printf("%d",count1);
  }else{
  printf("%d",c);
  }
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

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

  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      if(s[i][j]=='#'){
        count++;
        ans[i][j] = count;

        for (int k = j-1; k >= 0; k--){
          if(ans[i][k]!=0 || s[i][k]=='#') break;
          ans[i][k] = count;
        }

        for (int k = j+1; k < W; k++){
          if(ans[i][k]!=0 || s[i][k]=='#') break;
          ans[i][k] = count;
        }
      }
    }
  }

  for (int i = 0; i < H; i++){
    if(ans[i][0]!=0){

      for (int j = i-1; j >= 0; j--){
        if(ans[j][0]!=0) break;
        for (int k = 0; k < W; k++) ans[j][k] = ans[i][k];
      }

      for (int j = i+1; j < H; j++){
        if(ans[j][0]!=0) break;
        for (int k = 0; k < W; k++) ans[j][k] = ans[i][k];
      }
      
    }
  }
  
  

  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      printf("%d ",ans[i][j]);
    }
    printf("\n");
  }
  
}


Measured memory_bytes: 4204
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()



int main(void){
	int W, H, x, y;
    cin >> W >> H >> x >> y;

    double s;
    int a = 0;

    if(W == 2*x && H == 2*y){
        a = 1;
    }

    s = (double)W*(double)H/2;

    cout << s << " " << a << endl;

    return 0;
}


Measured memory_bytes: 256
M, K = map(int, input().split())
A = iter(range(2**19))
S = set()
D = []
if K==0:
    for i in range(2**M):
        D += [i, i]
    print(*D)
    exit()
while True:
    while True:
        a = next(A)
        if K^a not in S: break
    S |= {a}
    while True:
        b = next(A)
        if K^b not in S: break
    S |= {b}
    if b >= 2**M or K^b >= 2**M or K^a >= 2**M:
        print(-1)
        exit()
    D += [a, K^a, b, K^b, K^a, a, K^b, b]
    if len(D)==2**(M+1):
        break
print(*D)

Measured memory_bytes: 106032
using System;
using System.Linq;

class D
{
	static void Main()
	{
		Console.ReadLine();
		var s = Console.ReadLine();
		int i;
		Console.WriteLine(Enumerable.Range(0, 1000).Select(x => $"{x:D3}").Count(p => (i = s.IndexOf(p[0])) > -1 && (i = s.IndexOf(p[1], i + 1)) > -1 && s.IndexOf(p[2], i + 1) > -1));
	}
}


Measured memory_bytes: 13396
#include<set>
#include<iostream>
#include<ctime>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<random>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<functional>
#include<string.h>
#include<limits.h>
#define int long long
using namespace std;

int a[100000], b[100000];
int n, k;
int MAX(int c) {
	int ans = 0;
	for (int i = 0; i < n; i++) {
		bool S = true;
		for (int j = 1ll << 50; j >= 1; j >>= 1) {
			if ((a[i] & j) && (c&j) == 0)S = false;
		}
		if (S)ans += b[i];
	}
	return ans;
}
signed main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		scanf("%lld%lld", &a[i], &b[i]);
	}
	if (k == 0) { 
		int ans = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] == 0)ans += b[i];
	}
		cout << ans << endl;
		return 0;
	}
	int S = 0;
	int t = 0;
	int ans = 0;
	int o = 0;
	for (int j = 1ll << 50; j >= 1; j >>= 1) {
		if (k&j) {
			ans = max(ans, MAX(o + j - 1));
			o += j;
		}
	}
	cout << max(ans, MAX(k)) << endl;
}

Measured memory_bytes: 2424
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;

ll gcd( ll a, ll b){
    if( a==0 )return b;
    else return gcd(b%a, a);
}
vector<ll> yaku(ll a){
    vector<ll> res;
    for(ll i=1;i*i<=a;i++){
	if( a%i != 0 )continue;
	res.push_back( i );
	if( i != a/i ) res.push_back( a/i );
    }
    sort( res.begin() , res.end() );
    return res;
}

int main(){
    ll a,b;
    cin>>a>>b;
    ll d = gcd(a,b);
    vector<ll> res = yaku( d );
    //for(auto i:res)cout<<i<<endl;
    ll cnt = 1;
    for(ll i=1;i<res.size();i++){
	bool f = true;
	for(ll j=1;j<i;j++){
	    if( res[i]%res[j] == 0 ){
		f = false;
		break;
	    }
	}
	if( f ) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 384
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)
 
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
 
ll pwr(ll base, ll p, ll mod=MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}
 
 
ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}


const int N = 1000*10000;
int n, arr[102], sz, match[1002], sieve[N+2];
bool visited[1002];
bool marked[N+2];
vector<int> evens, odds, adj[1002];


int cost(int n){
	if(n < 3)	return -1;
	if(sieve[n] == 0)	return 1;
	if(n % 2 == 0)	return 2;
	return 3;
}

bool dfs(int v){
	for(auto vv : adj[v])
		if(!visited[vv]){
			visited[vv] = true;
			if(match[vv] == -1 || dfs(match[vv])){
				match[vv] = v;
				return true;
			}
		}
	return false;
}


int bipartite_matching(){
	int ans = 0;
    memset(visited, 0, sizeof(visited));
    memset(match, -1, sizeof(match));
    for(int i=1;i<=(int)odds.size();i++)
        if(dfs(i)){
            ans++;
            memset(visited, 0, sizeof(visited));
        } 
    return ans;
}


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

    cin>>n;
    for(int i=1;i<=n;i++){
    	cin>>arr[i];
    	marked[arr[i]] = true;
    }

    sieve[1] = 1;
    for(int i=2;i<=1000*10000+1;i+=2)
    	sieve[i] = 1;
    for(int i=3;i<=1000*10000+1;i+=2)
    	if(!sieve[i])
    		for(int j=i;1LL*i*j<=1000*10000+1;j+=2)
    			sieve[i*j] = 1;
    
    for(int i=1;i<=N+1;i++)
    	if(marked[i] != marked[i-1]){
    		if(i % 2 == 0)
    			evens.pb(i);
    		else
    			odds.pb(i);
    	}

// cout<<"odds: ";for(auto it : odds)	cout<<it<<" ";cout<<endl;
// cout<<"evens: ";for(auto it : evens)	cout<<it<<" ";cout<<endl;

    for(int i=0;i<(int)odds.size();i++)
    	for(int j=0;j<(int)evens.size();j++)
    		if(cost(abs(odds[i] - evens[j])) == 1){
// cout<<"added edge from "<<i+1<<" to "<<j+1<<endl;
    			adj[i+1].pb(j+1);
    		}

    int singles = bipartite_matching();
    int ans = singles*1 + (((int)odds.size()-singles)/2)*2 + (((int)evens.size()-singles)/2)*2 + (((int)odds.size()-singles)%2)*3;
    cout<<ans;
    return 0;
}
 




Measured memory_bytes: 47232
k,s=map(int,input().split())
x=0
b=0
while x<=k and x<=s//3:
  y=x
  while x+y<=s and y<=k and y<=(s-x)//2:
    z=s-x-y
    if z>=0 and z<=k:
      if x==y and y==z:
        b=b+1
      elif x==y:
        b=b+3
      elif y==z:
        b=b+3
      else:
        b=b+6
    y=y+1
  x=x+1
print(b)
      


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	string Botan[9] = { ".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz" };
	int N; cin >> N;
	for (int i = 0; i < N;i++) {
		string str; cin >> str;
		int now = -1;
		int cnt = -1;
		for (int j = 0; j < str.length();j++) {
			if (str[j] == '0') {
				if (now == -1) continue;
				cout << Botan[now][cnt%Botan[now].size()];
				now = cnt = -1;
			}
			else {
				now = str[j] - '1';
				cnt++;
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 3228
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/detail/standard_policies.hpp>
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define pli pair<long long , int>
#define pil pair<int ,long long>
#define pi acos(-1)
#define pb push_back
#define mkp make_pair
#define all(a) a.begin(), a.end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define MAX 300005
#define INF 0x3f3f3f3f
template <class T> inline T bigmod(T p,T e,T M){ll ret = 1LL;for(; e > 0LL; e >>= 1LL){if(e & 1LL) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}

using namespace std;
using namespace __gnu_pbds;

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update>pref_trie;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;




int main(){
    IOS
    //freopen("output.txt","w",stdout);
    ll a,b,k;
    cin>>a>>b>>k;

    cout<<max(0LL,a-k)<<" "<<max(0LL, b-(k-min(k,a)))<<"\n";
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
	long long n,i=0;
	long long h;
	scanf("%lld",&n);
	while(n!=0)
	{
		n=n/2;
		i++;
	}
	h=pow(2,i)-1;
	printf("%lld",h);
	return 0;
}



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

typedef long long LL;
typedef unsigned long long ULL;

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define __m  int mid=l+(r-l)/1

const int maxn   = 4e5 + 7;
const LL  inf_LL = 9e18   ;
const int inf    = 2e9 + 7;
const int mod    = 1e9 + 7;

map<int,int>have;
int main() {
#ifdef LOCAL
    freopen("sample.in", "r", stdin);
#endif
    //ios::sync_with_stdio(false);

    int n,Min=inf,Max=0;
    scanf("%d",&n);
    while(n--)
    {
        int k;
        scanf("%d",&k);
        have[k]++;
        have[k-1]++;
        have[k+1]++;
    }
    map<int,int>::iterator p;
    for(p=have.begin();p!=have.end();p++)
    {
        Max=max(Max,p->second);
    }
    printf("%d\n",Max);

    
    return 0;
}


Measured memory_bytes: 4736
#include<cstdio>
#define LL long long
#define N 310
int n;
LL g[N][N];
signed main()
{
	scanf("%d",&n);LL ans(0);
	for(register int i(1);i<=n;i++)
		for(register int j(1);j<=n;j++)
			scanf("%lld",&g[i][j]);
	for(register int i(1);i<=n;i++)
		for(register int j(1);j<=i;j++)
		{
			bool f(1);
			for(register int k(1);k<=n;k++)
				if(g[i][j]>g[i][k]+g[k][j])
					return puts("-1"),0;
				else if(i-k&&j-k&&g[i][j]==g[i][k]+g[k][j])
					f=0;
			ans+=g[i][j]*f;
		}
	return printf("%lld\n",ans),0;
}

Measured memory_bytes: 896
(ns Atcoder.ABC085-C)
(defn otoshidama [n y]
  (for [a (range 0 (inc n)) b (range (- (inc n) a))
        :let [c (- n a b)]
        :when (= (+ (* 10000 a) (* 5000 b) (* 1000 c)) y)]
    (format "%d %d %d" a b c)))

(defn main []
  (let [res (first (otoshidama (read) (read)))]
    (if (nil? res)
      (println "-1 -1 -1")
      (println res))))

(main)

Measured memory_bytes: 185132
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define rrep(i,j,n) for(ll i = (ll)(j); i < (ll)(n); i++)
#define mrep(i,n) for (ll i = (ll)(n); i > 0; i--)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;
ll modn = 998244353;

int main() {
	int n,k; cin >> n >> k;
	vint p(n);
	rep(i,n) cin >> p[i];
	sort(be(p));
	int ans=0;
	rep(i,k) {
		ans+=p[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 3628
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<iostream>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
int main()
{

    int a, b, c; 
    scanf("%d%d%d",&a,&b,&c);
    if(c >= a && c <= b)
        printf("Yes\n");
    else
    {
        printf("No\n");
    }
    return 0;
}



Measured memory_bytes: 888
#include<stdio.h>
#include<iostream>
#include<algorithm>

using namespace std;

char tile[30][30];
int W, H;
int ix, iy;
int cnt;
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

void dfs(int x, int y)
{
	tile[y][x] = '#';

	cnt++;

	for (int i = 0; i < 4; i++)
	{
		int X = x + dx[i];
		int Y = y + dy[i];
		if (0 <= X&&X < W && 0 <= Y&&Y < H&&tile[Y][X] != '#')
		{
			dfs(X,Y);
		}
	}
}

int main()
{
	while (cin >> W >> H, W + H != 0)
	{
		for (int y = 0; y < H; y++)
		{
			for (int x = 0; x < W; x++)
			{
				cin >> tile[y][x];

				if (tile[y][x]=='@')
				{
					ix = x;
					iy = y;
				}
			}
		}

		dfs(ix,iy);
		
		cout << cnt << endl;

		cnt = 0;
	
	
	}

	return 0;
}


Measured memory_bytes: 3044
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {

        new Main().solve();
    }

    void solve(){

        String stations;
        Scanner sc = new Scanner(System.in);
        stations = sc.next();
        sc.close();

        char[] arr = new char[stations.length()];
        boolean exist = false;

        for(int i=0; i < stations.length(); i++){
            arr[i] = stations.charAt(i);
            if(arr[i] != arr[0]){
                exist = true;
                break;
            }
        }
        
        if(exist){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
        
    }
}

Measured memory_bytes: 21716
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater <>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
using namespace std;
using ll = long long;
typedef std::pair<ll,ll> P;
//#include <boost/multiprecision/cpp_int.hpp>
//using bint = boost::multiprecision::cpp_int;



int n;
void dfs(string s, char m){
    if (s.size() == n) cout << s << endl;
    else{
        for(char c = 'a'; c <= m; c++){
            dfs(s+c,m);
            if (c == m) dfs(s+(char) (m+1),(char) (m+1));
            
        }
    }
}
int main(){
    cin >> n;
    dfs("a",'a');
}


Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
using namespace std;
int main(){
int n;int dig;int sum1=0;int sum2=0;
cin >> n;
int ans=100000000;
int ma=n/2;
for(int i=1;i<=ma;i++){
  int a=i;int b=n-i;
  while(a){
    dig = a % 10;
    sum1 = sum1 + dig;
    a = a / 10;
  }
  while(b){
    dig = b % 10;
    sum2 = sum2 + dig;
    b = b / 10;
  }
  ans=min(ans,sum1+sum2);
  sum1=0;sum2=0;
}
cout <<ans <<endl;
}


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

namespace AtCoder_Cs
{
    public class Program
    {
        public static void Main()
        {
            decimal[] vs = Console.ReadLine().Split().Select(decimal.Parse).ToArray();
            decimal ans = 0;
            if (vs[1] > 1)
            {
                ans = 1;
            }
            if (vs[0] < vs[1])
            {
                ans = 1 + Math.Ceiling((vs[1] - vs[0]) / (vs[0] - 1));
            }
            Console.WriteLine(  ans);
        }
    }

}


Measured memory_bytes: 13396
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;
using System.Text;
using static System.Math;

class MainClass
{


    public static void Main(string[] args)
    {
        var _ = LnStrs();
        var A = Convert.ToDecimal(_[0]);
        var B = Convert.ToDecimal(_[1]);
        print(Floor(A * B));
    }


    public static long SumAtoB(long a, long b) { var length = b - a + 1; return (a + b) * (length / 2) + (length % 2 == 1 ? (a + b) / 2 : 0); }
    public static long PowLite(long n, long p, long mod = (long)1e9 + 7) { long ans = 1; long now = n; for (; p > 0; p >>= 1) { if ((p & 1) == 1) { ans *= now; ans %= mod; } now *= now; now %= mod; } return ans; }
    public static void print(object obj) { Console.WriteLine(obj); }
    public static long Gcd(long a, long b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int Gcd(int a, int b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int[] LnInts() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new int[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = int.Parse(vs[i]); return ins; }
    public static int LnInt() { var vs = Console.ReadLine().Trim(); return int.Parse(vs); }
    public static long[] LnLngs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var ins = new long[vs.Length]; for (int i = 0; i < vs.Length; i++) ins[i] = long.Parse(vs[i]); return ins; }
    public static long LnLng() { var vs = Console.ReadLine().Trim(); return long.Parse(vs); }
    public static string[] LnStrs() { var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); return vs; }
    public static string LnStr() { var vs = Console.ReadLine().Trim(); return vs; }
    public static List<T[]> AllPermutation<T>(params T[] array) where T : IComparable { var a = new List<T>(array).ToArray(); var res = new List<T[]>(); res.Add(new List<T>(a).ToArray()); var n = a.Length; var next = true; while (next) { next = false; int i; for (i = n - 2; i >= 0; i--) { if (a[i].CompareTo(a[i + 1]) < 0) break; } if (i < 0) break; var j = n; do { j--; } while (a[i].CompareTo(a[j]) > 0); if (a[i].CompareTo(a[j]) < 0) { var tmp = a[i]; a[i] = a[j]; a[j] = tmp; Array.Reverse(a, i + 1, n - i - 1); res.Add(new List<T>(a).ToArray()); next = true; } } return res; }
}


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

int main() {

  int h,n,a,ans=0;
  cin >> h >> n;
  for(int i=0;i<n;i++){
    cin >> a;
    ans+=a;
  }
  if(h>ans)cout << "No" << endl;
  else cout << "Yes" << endl;
}


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

using namespace std;

int main(){
  int N, ruijou=1;
  cin >> N;
  while(1){
    
    if(N < ruijou){
      ruijou = ruijou / 2;
      break;
    }else if(N == ruijou){
      
      break;
    }else {
      ruijou *=2;
    }
    
  }
  cout << ruijou << endl;
  
  return 0;
}



Measured memory_bytes: 3108
#include<stdio.h>
#include <stdlib.h>
int int_cmp(const int *a, const int *b){
  if (*a < *b)
    return (-1);
  else if (*a > *b)
    return (1);
  return (0);} 
int main () {
int f[1001];
int F[1001];
int N,i,V,d,count;
N=1001;
f[0]=2;
f[1]=3;
for(i=2;i<1001;i++){f[i]=f[i-1]+f[i-2];f[i]=f[i]%N;}
for(;~scanf("%d %d",&V,&d);){
  count = 1;
  for(i=0;i<V;i++)F[i]=f[i];
  qsort(F,V,sizeof(int),(int(*)(const void*, const void*))int_cmp);
  for(i=1;i<V;i++)
    if( F[ i] - F[ i - 1] > d - 1)
      count++;
  printf( "%d\n" , count);
 }
 return 0;
}

Measured memory_bytes: 648
N,M=map(int,input().split())
AC =[0]*(N+1)
WA =[0]*(N+1)

for i in range(M):
    p,q = input().split()
    p = int(p)
    if q == 'AC':
        AC[p]=1
    elif q =='WA'and AC[p]==0:
        WA[p]+=1

for m in range(N+1):
    if AC[m]==0:
        WA[m]=0
print(sum(AC),sum(WA))

Measured memory_bytes: 4596
#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

fn solve(s: &Vec<char>, t: &Vec<char>) -> bool {
    let n = s.len();
    for i in 0..n {
        let mut flag = true;
        for j in 0..n {
            if s[j] != t[(i + j) % n] {
                flag = false;
                break;
            }
        }
        if flag {
            return true;
        }
    }
    false
}

fn main() {
    input! {
        s: String,
        t: String,
    }

    if solve(&s.chars().collect(), &t.chars().collect()) {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2140
n,m=map(int,input().split())
s=list(map(int,input().split()))
t=list(map(int,input().split()))
dp=[[0]*(m+1) for _ in range(n+1)]
sum=[[0]*(m+1) for _ in range(n+1)]
mod=10**9+7
ans=0
for i in range(n):
  for j in range(m):
    if s[i]==t[j]:
      dp[i+1][j+1]=(sum[i][j]+1)%mod
    else:
      dp[i+1][j+1]=0
    sum[i+1][j+1]=(sum[i][j+1]+sum[i+1][j]-sum[i][j]+dp[i+1][j+1])%mod
    ans+=dp[i+1][j+1]
    ans%=mod
print((ans+1)%mod)

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

const int mxn = 1e7;

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

    int k, x = 7; cin>>k;

    if(k&1^1) return cout<<"-1\n", 0;
    
    x = x%k;
    for(int i = 1; i<mxn; i++){
        if(!x) return cout<<i<<"\n", 0;

        x = (10*x + 7)%k;
    }
    cout<<"-1\n";
    return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

#define all(collection) (collection).begin(), (collection).end()  // begin to end
#define ceil(a, b) ceil((ld) a / (ld) b);                         // div ceiling
#define each(e, collection) for(auto& e: collection)              // for each
#define rep(i, begin, end) for (ll i = begin; i < end; i++)       // repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)      // repeat reverse
#define size(collection) ((ll) (collection).size())               // collection size

int main(void)
{
	string s; cin >> s;

	vector<ll> ans(size(s) + 1);
	repr(i, size(s)-1, -1)
	{
		if (s[i] == '>')
			ans[i] = max(ans[i], ans[i + 1] + 1);
	}

	rep(i, 0, size(s))
	{
		if (s[i] == '<')
			ans[i + 1] = max(ans[i + 1], ans[i] + 1);
	}

	ll sum = 0;
	each(e, ans)
		sum += e;
	cout << sum << endl;
	return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  
  vector<vector<char>> a(H, vector<char>(W));
  vector<bool> rowEnable(H, false);
  vector<bool> columnEnable(W, false);
  
  // 入力
  for( int i=0; i<H; i++ ){
    for( int j=0; j<W; j++ ){
      cin >> a.at(i).at(j);
      if( a.at(i).at(j) == '#' ){
        rowEnable.at(i) = true;
        columnEnable.at(j) = true;
      }
    }
  }
  
  // 出力
  for( int i=0; i<H; i++ ){
    if( rowEnable.at(i) ){
      for( int j=0; j<W; j++ ){
        if( columnEnable.at(j) ){
          cout << a.at(i).at(j);
        }
      }
      cout << endl;
    }
  }
}


Measured memory_bytes: 3584
#include <stdio.h>

int main(void) {
	int a,b;
	scanf("%d %d",&a,&b);
	if(a<b){
		printf("a < b\n");
	}
	else if(a>b){
		printf("a > b\n");
	}else {
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <string>
using namespace std;

int main(void)
{
    int a, b;
    cin >> a >> b;
    if(a <= b){
        for(int i = 0; i < b; i++){
            cout << a;
        }
    }else{
        for(int i = 0; i < a; i++){
            cout << b;
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
// AtCoder Beginner Contest 156 C.cpp

#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;

int main()
{
	int n, answer = INT_MAX, temp = 0;
	cin >> n;
	vector<int>x(n);
	for (auto& i : x) {
		cin >> i;
	}
	sort(x.begin(), x.end());
	for (int i = x[0]; i <= x[x.size() - 1]; i++) {
		temp = 0;
		for (auto j : x) {
			temp += abs(j - i) * abs(j - i);
		}
		answer = min(temp, answer);
	}
	cout << answer << endl;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);

int n;
int x[MAX_N], y[MAX_N];

/////////////////////////////////////////////////////////
// node in { 0, ... }
class UnionFind {
 public:
  static const int MAX_N_LIB = (int)(2e5 + 100);

  int uf_par[MAX_N_LIB];
  int uf_rank[MAX_N_LIB];
  int uf_size[MAX_N_LIB];

  UnionFind(int n) { init(n); }

  void init(int n) {
    for (int i = 0; i < n; ++i) {
      uf_par[i] = i;
      uf_rank[i] = 0;
      uf_size[i] = 1;
    }
  }

  int find(int x) {
    if (uf_par[x] == x)
      return x;
    else {
      return uf_par[x] = find(uf_par[x]);
    }
  }

  void unite(int leaf_x, int leaf_y) {
    int x = find(leaf_x);
    int y = find(leaf_y);

    if (x == y) return;

    if (uf_rank[x] < uf_rank[y]) {
      uf_par[x] = y;
      uf_size[y] += uf_size[x];
    } else if (uf_rank[x] > uf_rank[y]) {
      uf_par[y] = x;
      uf_size[x] += uf_size[y];
    } else {
      uf_par[y] = x;
      uf_size[x] += uf_size[y];
      uf_rank[x] += 1;
    }
  }

  bool same(int x, int y) { return find(x) == find(y); }

  int size(int x) { return uf_size[find(x)]; }
};
/////////////////////////////////////////////////////////

int main(void) {
  // Here your code !

  scanf("%d", &n);

  for (int i = 0; i < n; ++i) {
    scanf("%d %d", &(x[i]), &(y[i]));
  }

  UnionFind uf(MAX_N * 2 + 20);

  for (int i = 0; i < n; ++i) {
    int node_x = x[i];
    int node_y = y[i] + MAX;

    uf.unite(node_x, node_y);
  }

  unordered_map<int, int> conn2edgenum;

  for (int i = 0; i < n; ++i) {
    int node_x = x[i];
    conn2edgenum[uf.find(node_x)] += 1;
  }

  unordered_set<int> xs;
  for (int i = 0; i < n; ++i) {
    int node_x = x[i];
    xs.insert(x[i]);
  }

  unordered_map<int, ll> conn2xnodenum;
  for (auto &e : xs) {
    conn2xnodenum[uf.find(e)] += 1LL;
  }

  unordered_set<int> ys;
  for (int i = 0; i < n; ++i) {
    int node_y = y[i] + MAX;
    ys.insert(node_y);
  }

  unordered_map<int, ll> conn2ynodenum;
  for (auto &e : ys) {
    conn2ynodenum[uf.find(e)] += 1LL;
  }

  ll ans = 0LL;

  for (auto &e : conn2edgenum) {
    int key = e.first;

    ans += (ll)(conn2xnodenum[key] * conn2ynodenum[key]) - (ll)(conn2edgenum[key]);
  }

  printf("%lld\n", ans);

  return 0;
}


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

int main(){
    vector<long long int> ruka(87);
    ruka[0] = 2;
    ruka[1] = 1;
    for(int i=2; i<=86; i++){
        ruka[i] = ruka[i-1] +ruka[i-2];
    }
    int n;
    cin >> n;
    cout << ruka[n] << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def io_generator():
	return input()

#+++++++++++++++++++

def main(io):
	s=list(io())
	s.sort()
	t=list(io())
	t.sort(reverse = True)
	return 'Yes' if s < t else 'No'

#++++++++++++++++++++

if __name__ == "__main__":
	io= lambda : io_generator()
	print (main(io))

Measured memory_bytes: 3060
Q = int(input())
lr = [list(map(int,input().split())) for _ in range(Q)]
def prime(x):
    for i in range(2,int(x**0.5)+1):
        if x%i==0:
            return False
    return True

number2017 = [0]+[0]*10**5
for i in range(3,10**5):
    if prime(i):
        if prime((i+1)//2):
            number2017[i]=1
import itertools
acc2017=list(itertools.accumulate(number2017))
for i in lr:
    print(acc2017[i[1]]-acc2017[i[0]-1])

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

using namespace std;

int main(){
  string s;
  cin >> s;
  string a="";
  string b="";
  for(int i=0;i<s.length();i++){
    if(i%2==0){
      a+='0';
      b+='1';
    }
    else{
      a+='1';
      b+='0';
    }
  }
  int count_1=0;
  int count_2=0;
  for(int i=0;i<s.length();i++){
    if(s[i]!=a[i]){
      count_1++;
    }
    else{
      count_2++;
    }
  }
  cout << min(count_1,count_2) << endl;
      
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 10;
const int MAX = 1e5 + 10;
const double exps = 1e-8;
#define endl '\n'

inline int max(int a, int b) { return a > b ? a : b; }
inline int min(int a, int b) { return a > b ? b : a; }

int main() {
    // ios::sync_with_stdio(false);
    string str;
    cin >> str;
    if (str.find("7") != str.npos)
        cout << "Yes";
    else
        cout << "No";
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long N,K;
    cin>>N>>K;
    long long ans1 = N%K;
    long long ans2 = abs(ans1-K);
    if(ans1>ans2)
    {
        cout<<ans2<<endl;
    }
    else
        cout<<ans1<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main(){
string s;cin>>s;
if(s=="Cloudy"){
    cout<<"Rainy";
}
if(s=="Sunny"){
    cout<<"Cloudy";
}
if(s=="Rainy"){
    cout<<"Sunny";
}

}


Measured memory_bytes: 256