akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int a[100007];
int b[100007];
int c[100007];
int n;
int x[100007];
int y[100007];
int z[100007];
int main()
{
    cin>>n;
    int i;
    for(i=1;i<=n;i++)
        cin>>a[i]>>b[i]>>c[i];
    x[1]=a[1];
    y[1]=b[1];
    z[1]=c[1];
    for(i=2;i<=n;i++)
    {
      x[i]=max(y[i-1],z[i-1])+a[i];
      y[i]=max(x[i-1],z[i-1])+b[i];
      z[i]=max(y[i-1],x[i-1])+c[i];
    }
    cout<<max(max(x[n],y[n]),z[n]);
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <utility>
using namespace std;

int N, A, B;

int main(){
	cin >> N >> A >> B;
	int ans = 0;
	
	for(int i=1; i<=N; i++){
		int digsum = 0; int j = i;
		
		do{
			digsum += j%10;
			j  /= 10;
		}while(j != 0);
		
		if(A<=digsum && digsum <=B){ans += i;}
	}
	
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<double,double> P;

class Point {
public:
	double x, y;
	Point() {}
	Point(double xx, double yy) {
		x = xx;
		y = yy;
	}
	Point operator +(Point p) {
		return Point(x + p.x, y + p.y);
	}
	Point operator -(Point p) {
		return Point(x - p.x, y - p.y);
	}
	Point operator *(double a) {
		return Point(a * x, a * y);
	}
	Point operator /(double a) {
		return Point(x / a, y / a);
	}

	double abs() {
		return sqrt(norm());
	}
	double norm() {
		return x * x + y * y;
	}
};

int n,d;
double l[101],r[101],t[101];
Point p;
double dir;

void solve(){
	p=Point(0,0);
	dir=0.0;
	for(int i=0;i<n;i++){
		if(l[i]==r[i]){
			p.x+=(double)l[i]*t[i]*cos(dir+M_PI/2);
			p.y+=(double)l[i]*t[i]*sin(dir+M_PI/2);
		}else if(l[i]==0){
			double lx=p.x-d*cos(dir);
			double ly=p.y-d*sin(dir);
			dir+=r[i]*t[i]/(2.0*d);
			p.x=lx+d*cos(dir);
			p.y=ly+d*sin(dir);
		}else if(r[i]==0){
			double rx=p.x+d*cos(dir);
			double ry=p.y+d*sin(dir);
			dir-=(double)l[i]*t[i]/(2.0*d);
			p.x=rx-d*cos(dir);
			p.y=ry-d*sin(dir);
		}else if(l[i]<r[i]){
			if(l[i]>0){
				double cd=(double)(r[i]-l[i])*t[i]/(2.0*d);
				double rv=(double)(2.0*d*l[i])/(r[i]-l[i]);
				double lx=p.x-(d+rv)*cos(dir);
				double ly=p.y-(d+rv)*sin(dir);
				dir+=cd;
				p.x=lx+(d+rv)*cos(dir);
				p.y=ly+(d+rv)*sin(dir);
			}else if(r[i]>0){
				double mid=(double)fabs(l[i])/(fabs(l[i])+fabs(r[i]));
				double cd=(double)-l[i]*t[i]/(mid*d*2.0);
				double mx=p.x+(mid-0.5)*2.0*d*cos(dir);
				double my=p.y+(mid-0.5)*2.0*d*sin(dir);
				dir+=cd;
				p.x=mx-(mid-0.5)*2.0*d*cos(dir);
				p.y=my-(mid-0.5)*2.0*d*sin(dir);
			}else{
				double cd=(double)(l[i]-r[i])*t[i]/(2.0*d);
				double rv=(double)(2.0*d*r[i])/(l[i]-r[i]);
				double lx=p.x+(d+rv)*cos(dir);
				double ly=p.y+(d+rv)*sin(dir);
				dir-=cd;
				p.x=lx-(d+rv)*cos(dir);
				p.y=ly-(d+rv)*sin(dir);
			}
		}else{
			if(r[i]>0){
				double cd=(double)(l[i]-r[i])*t[i]/(2.0*d);
				double rv=(double)(2.0*d*r[i])/(l[i]-r[i]);
				double lx=p.x+(d+rv)*cos(dir);
				double ly=p.y+(d+rv)*sin(dir);
				dir-=cd;
				p.x=lx-(d+rv)*cos(dir);
				p.y=ly-(d+rv)*sin(dir);
			}else if(l[i]>0){
				double mid=(double)fabs(l[i])/(fabs(l[i])+fabs(r[i]));
				double cd=(double)-l[i]*t[i]/(mid*d*2.0);
				double mx=p.x+(mid-0.5)*2.0*d*cos(dir);
				double my=p.y+(mid-0.5)*2.0*d*sin(dir);
				dir+=cd;
				p.x=mx-(mid-0.5)*2.0*d*cos(dir);
				p.y=my-(mid-0.5)*2.0*d*sin(dir);
			}else{
				double cd=(double)(r[i]-l[i])*t[i]/(2.0*d);
				double rv=(double)(2.0*d*l[i])/(r[i]-l[i]);
				double lx=p.x-(d+rv)*cos(dir);
				double ly=p.y-(d+rv)*sin(dir);
				dir+=cd;
				p.x=lx+(d+rv)*cos(dir);
				p.y=ly+(d+rv)*sin(dir);
			}
		}
	}
	printf("%.9f\n%.9f\n",p.x,p.y);
}

int main(void){
	while(1){
		scanf("%d%d",&n,&d);
		if(n==0 && d==0)break;
		for(int i=0;i<n;i++){
			scanf("%lf%lf%lf",&l[i],&r[i],&t[i]);
			l[i]/=180.0;
			r[i]/=180.0;
			l[i]*=M_PI;
			r[i]*=M_PI;
		}
		solve();
	}
	
	return 0;
}


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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    string nums;
    cin >> nums;
    
    int a = nums[0]-'0',b = nums[1]-'0',c = nums[2]-'0',d = nums[3]-'0';
    
    if(a-b-c-d == 7){
        printf("%d-%d-%d-%d=7\n",a,b,c,d);
    }
    else if(a-b-c+d == 7){
        printf("%d-%d-%d+%d=7\n",a,b,c,d);
    }
    else if(a-b+c+d == 7){
        printf("%d-%d+%d+%d=7\n",a,b,c,d);
    }
    else if(a+b-c-d == 7){
        printf("%d+%d-%d-%d=7\n",a,b,c,d);
    }
    else if(a+b+c-d==7){
        printf("%d+%d+%d-%d=7\n",a,b,c,d);
    }
    else if(a+b+c+d == 7){
        printf("%d+%d+%d+%d=7\n",a,b,c,d);
    }
    else if(a+b-c+d == 7){
        printf("%d+%d-%d+%d=7\n",a,b,c,d);
    }
    else if(a-b+c-d == 7){
        printf("%d-%d+%d-%d=7\n",a,b,c,d);
    }
    return 0;
}

Measured memory_bytes: 256
//17D8103015J Kobayashi Ikuko Mingwon23 C++
    #include <iostream>
    #include <vector>

using namespace std;
    int main(){
    int n,v=0,i,j=0;
    std::vector<int> a;

    cin >> n;

    for(i=0;i<n;i++){
        cin >> v;
        a.push_back(v);
    }

    for(j=0;j<n;j++)cout <<a[j] << (j==n-1?'\n':' ');

    for(i=1;i<n;i++){
        v=a[i];   
        j=i-1;       
        while((j>=0) && (a[j]>v)){      
        a[j+1]=a[j];
        j--;
        a[j+1]=v;
        }

        for(j=0;j<n;j++)cout <<a[j] << (j==n-1?'\n':' ');
    }

    return 0;
    }


Measured memory_bytes: 3168
/*

This Submission is to determine how many 120/240 min const. delivery point there are.

//info
120 req. steps <= 5
*/
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define MOD 998244353LL
#define seg_size 262144*4
#define REP(a,b) for(long long a = 0;a < b;++a)

unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(min((double)1.0, max((double)-1.0, cosine)));
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		double now_length = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa - now_min >= eps || (abs(goa - now_min) <= eps && (abs(a[i] - a[starter]) - now_length) >= eps)) {
					now_min = goa;
					now_go = i;
					now_length = abs(a[i] - a[starter]);
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
int main() {
	int n;
	cin >> n;
	vector<int> eated;
	REP(i, n) {
		int a;
		cin >> a;
		a--;
		eated.push_back(a);
	}
	vector<pair<int, int>> inputs;
	REP(i, n) {
		int a;
		cin >> a;
		inputs.push_back(make_pair(a, 0));
	}
	REP(i, n-1) {
		cin >> inputs[i].second;
	}
	int ans = 0;
	REP(i, n) {
		ans += inputs[eated[i]].first;
		if (i != 0 && eated[i] == eated[i - 1] + 1) {
			ans += inputs[eated[i - 1]].second;
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
def linear_search(target_array, value)
  target_array.each do |arr_value|
    return 1 if arr_value == value
  end
  0
end

n = gets.to_i
s = gets.chomp.split ' '
q = gets.to_i
t = gets.chomp.split ' '
count = 0
t.each do |value|
  count += linear_search s, value
end

puts count


Measured memory_bytes: 7088
/*
for (int i = 0; i < N; ++i){}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
 bool Sosuu(ll x){
 	if (x<2) return false;
	for (ll i = 2; i < x; ++i){
		if (x%i==0)return false;
	}
	return true;
 }

bool NitaKazu(ll x){
	if (x<2) return false;
	if (x%2==0) return false;
	if (!Sosuu(x)) return false;
	if (!Sosuu((x+1)/2)) return false;
	return true;
}

int main() {
	// 入力
	ll Q;
	cin >> Q;
	ll l[Q], r[Q];
	REP(i, Q)cin>>l[i]>>r[i];
 
	// 解法
	// エラトステネスの篩
	// M 以下の数に対してエラトステネスの篩を適用した時のオーダーは O(Mlog(logM))
	bool f[100001]; // 素数かどうかの判別リスト, falseなら素数、もしくは未確認
	for (ll i=2; i<=100001; i++){ // 2-10000までの整数に対し
		if (!f[i]){ 
			// f[i]=0ならばiはまだ見ていない=iは素数である。
			// !f[i]: iが素数であるなら
			for (ll j = i+i; j<=100001; j+=i){// iの倍数jに対し
				f[j]= true ; // iの倍数jが素数でないことを記録する。
			}
		}
	}
	// 2017に似た数かの判定
	ll c[100002]={0}; // 各値が2017に似た数かの判定リスト
	for (ll i=3; i<=100001; i+=2){ 
		if (!f[i] && !f[(i+1)/2]){ // 条件を満たすなら
			c[i]++; // フラグを立てる
		}
	}
	for (ll i=3; i<=100000; i++){
		c[i] += c[i-1]; // 累積和
	} 

	REP(i, Q){
		ll x = c[r[i]] - c[l[i]-1];
		printf("%lld\n", x);
	}

}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define MP make_pair
#define pb push_back

using namespace std;

typedef pair<int, int> P;
typedef pair<P, int> i_P;
typedef long long LL;

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

static const int INF = INT_MAX;
static const int MIN = INT_MIN;
static const LL L_INF = LLONG_MAX;
static const int MOD = 1000000000 + 7;
static const int SIZE = 1005;

int bfs();

int h, w;
int mp[SIZE][SIZE];

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

    cin >> h >> w;
    for( int i = 0; i <= h + 1; ++i ) {
        for( int j = 0; j <= w + 1; ++j ) mp[i][j] = -1;

    }
    for( int i = 1; i <= h; ++i ) {
        for( int j = 1; j <= w; ++j ) {
            char c;
            cin >> c;
            if( c == '#' ) {
                mp[i][j] = 1;

            } else {
                mp[i][j] = 0;

            }

        }
    }

    cout << bfs() << endl;

    return 0;
}

int bfs() {
    queue< i_P > q;
    int res = 0;
    for( int i = 1; i <= h; ++i ) {
        for( int j = 1; j <= w; ++j ) {
            if( mp[i][j] ) q.push( MP( MP( i, j ), 0 ) );

        }
    }

    while( !q.empty() ) {
        i_P p = q.front(); q.pop();

        for( int i = 0; i < 4; ++i ) {
            if( mp[p.F.F + dx[i]][p.F.S + dy[i]] == 0 ) {
                mp[p.F.F + dx[i]][p.F.S + dy[i]] = 1;
                q.push( MP( MP( p.F.F + dx[i], p.F.S + dy[i] ), p.S + 1  ) );
                res = max( p.S + 1, res );

            }
        }
    }

    return res;
}



Measured memory_bytes: 16272
#include <iostream>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if (a == 1) {
        a = 14;
    }
    if (b == 1) {
        b = 14;
    }
    if (a == b) {
        cout << "Draw\n";
    } else if (a > b) {
        cout << "Alice\n";
    } else {
        cout << "Bob\n";
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
 
int main(){
	string a,b,s;
	int n,m;

	cin >> a >> b;

	s = a + b;
	n = stoi(s);
	m = (int)sqrt(n);

	if((m * m) == n){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3464
#include <iostream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdint>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>

#define rep(i, n) for(ll (i) = 0;(i) < (n);(i)++)
#define mp(a, b) make_pair((a),(b))
#define bs(n) ((ull)1<<(ull)n)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

constexpr ll inf = INT64_MAX / 4;
constexpr double pi = asin(1) * 2;
constexpr ll mod = 1000000007;
constexpr double eps = 0.000000001;

int n, v[2000][2][2], x[4000], y[4000], m[4000][4000];

int main() {
    cin >> n;
    rep(i, n) {
        cin >> v[i][0][0] >> v[i][0][1] >> v[i][1][0] >> v[i][1][1];
        x[i * 2] = v[i][0][0];
        x[i * 2 + 1] = v[i][1][0];
        y[i * 2] = v[i][0][1];
        y[i * 2 + 1] = v[i][1][1];
    }
    sort(x, x + (n * 2));
    sort(y, y + (n * 2));
    rep(i, n) {
        v[i][0][0] = (int) (lower_bound(x, x + (2 * n), v[i][0][0]) - x);
        v[i][1][0] = (int) (lower_bound(x, x + (2 * n), v[i][1][0]) - x);
        v[i][0][1] = (int) (lower_bound(y, y + (2 * n), v[i][0][1]) - y);
        v[i][1][1] = (int) (lower_bound(y, y + (2 * n), v[i][1][1]) - y);
    }
    for (auto &e:m)for (auto &f:e)f = 0;
    rep(i, n)for (int j = v[i][0][0]; j < v[i][1][0]; j++) for (int k = v[i][0][1]; k < v[i][1][1]; k++) m[j][k] = 1;
    ll r = 0;
    rep(i, n * 2)rep(j, 2 * n) if (m[i][j])r += (x[i + 1] - (ll)x[i]) * (y[j + 1] - y[j]);
    cout << r << endl;
}


Measured memory_bytes: 65704
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ARainySeason solver = new ARainySeason();
        solver.solve(1, in, out);
        out.close();
    }

    static class ARainySeason {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            char[] s = in.next().toCharArray();
            int j = -1;
            int answer = 0;
            for (int i = 0; i < s.length; i++) {
                if (s[i] == 'R') {
                    answer = Math.max(answer, i - j);
                } else {
                    j = i;
                }
            }

            out.println(answer);
        }

    }

    static class InputReader {
        public final BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<" ";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<ll> a(n);
    ll ans=0;
    ll cnt=0;
    for(int i=0; i<n; i++){ 
        cin >> a[i]; 
    }
    auto it = (find(a.begin(), a.end(), 1));
    if (it == a.end()) {
        ans = -1;
    } else {
        for(int i=1; i<n; i++) {
            for(int j=cnt+i-1; j<n; j++) {
                if(a[j]!=i){
                    cnt++;
                }else if (a[j]==i){
            
                    break;
                }
            }
        }
        ans = cnt;
    }

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


Measured memory_bytes: 1792
#include<string>
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
using LL=long long;
using namespace std;
typedef long long int llint;
#define pub push_back
#define mp make_pair
#define fir first
#define sec second
#define res resize
const int big=((llint)1<<30);
int main(void){
	vector<int> kaz;
	string ans="YES";
	int i,n,q,m;
	cin>>n;cin>>m;
	kaz.resize(n);
	for(i=0;i<m*2;i++){cin>>q;q--;kaz[q]++;}
	for(i=0;i<n;i++){ if(kaz[i]%2==1){ ans="NO"; } }
	cout<<ans<<endl;
	return 0;
}


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

int main(){
	int x;
	scanf("%d",&x);
	if(x<100){
		cout<<0;
		return 0;
	}
	int now=x/100;
	int now2=x%100;
	int a1=now2/5;now-=a1;now2-=a1*5;	if(now<0){cout<<0;return 0;}
	int a2=now2/4;now-=a2;now2-=a2*4;	if(now<0){cout<<0;return 0;}
	int a3=now2/3;now-=a3;now2-=a3*3;   if(now<0){cout<<0;return 0;}
	int a4=now2/2;now-=a4;now2-=a4*2;   if(now<0){cout<<0;return 0;}
	now-=now2;if(now<0){cout<<0;return 0;}
	cout<<1;
	return 0;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

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

    ll N, x;
    cin >> N >> x;

    vector<ll> a(N);
    rep (i, N) {
        cin >> a[i];
    }

    ll ans = 0;
    rep (i, N-1) {
        if (a[i]+a[i+1] > x) {
            ll tmp = a[i]+a[i+1]-x;
            if (a[i+1] - tmp > 0) {
                a[i+1] -= tmp;
            } else {
                a[i+1] = 0;
            }
            ans += tmp;
        }
    }

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

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

int main() {
	vector<char> C = {'L', 'R', 'U', 'D'};
	string S;
	cin >> S;

	int flag = 0;
	for(int i = 0; i < (int)S.size(); i++) {
		if (i % 2 == 0) {
			for (int j = 0; j < 4; j++) {
				if (C.at(j) == S.at(i) && j == 0) {
					flag = 1;
				}
			}
		}
		else {
			for (int j = 0; j < 4; j++) {
				if (C.at(j) == S.at(i) && j == 1) {
					flag = 1;
				}
			}
		}
	}
	if (flag == 0) cout << "Yes" << endl;
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES // M_PI
#include<cmath>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rREP(i,a,n) for(int (i)=(n)-1; (i)>=(a);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 2147483647;
constexpr ll mod = 1000000007;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N, K, S; cin >> N >> K >> S;
	vector<int>ans(N, S - 1);
	if (S == 1) {
		rep(i, N)ans[i]+=2;
	}
	rep(i, K)ans[i] = S;
	rep(i, N) {
		cout << ans[i] << (i == N - 1 ? "\n" : " ");
	}
	
	return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <queue>
using namespace std;

char ch[10][10];

int main()
{
    scanf("%s",ch[0]);
    scanf("%s",ch[1]);
    if(ch[0][0]==ch[1][2]&&ch[0][1]==ch[1][1]&&ch[0][2]==ch[1][0])
        printf("YES\n");
    else printf("NO\n\n");
    return 0;
}


Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/aising2019/tasks/aising2019_c

//参考
//https://betrue12.hateblo.jp/entry/2019/01/13/030527

//マスをグラフの頂点、色の異なるマス同士に辺がかかっている
//森だとみなすと考えやすい

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL H,W;
string S[1000];

LL ans = 0;

void solve(){
	int white_remain = 0;
	queue<pair<int,int>> q;
	for(int h=0;h<H;h++){
		for(int w=0;w<W;w++){
			if(S[h][w]=='.') white_remain++;
			else q.push(pair<int,int>(h,w));
		}
	}

	for(ans=0;white_remain>0;ans++){
		int n = q.size();
		for(int i=0;i<n;i++){
			int y = q.front().first;
			int x = q.front().second;
			q.pop();

			int ret = 0;
			if(y+1<H){
				if(S[y+1][x]=='.'){
					S[y+1][x] = '#';
					ret++;
					q.push(pair<int,int>(y+1,x));
				}
			}
			if(y-1>=0){
				if(S[y-1][x]=='.'){
					S[y-1][x] = '#';
					ret++;
					q.push(pair<int,int>(y-1,x));
				}
			}
			if(x+1<W){
				if(S[y][x+1]=='.'){
					S[y][x+1] = '#';
					ret++;
					q.push(pair<int,int>(y,x+1));
				}
			}
			if(x-1>=0){
				if(S[y][x-1]=='.'){
					S[y][x-1] = '#';
					ret++;
					q.push(pair<int,int>(y,x-1));
				}
			}
			white_remain -= ret;
		}
	}
}
 
int main(){
    cin >> H >> W;
    for(int h=0;h<H;h++){
    	cin >> S[h];
    }
 
    solve();

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

Measured memory_bytes: 9488
//
//  main.cpp
//  C
//
//  Created by 黄宇凡 on 2017/3/18.
//  Copyright © 2017年 黄宇凡. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

bool a,b;
char s[3],s1[3];

int main(int argc, const char * argv[]) {
    scanf("%s",s);
    scanf("%s",s1);
    a = s[0] == s1[0];
    if(a) printf("H\n");
    else printf("D\n");
    return 0;
}


Measured memory_bytes: 256
//2020年4月17日現在

#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>
#include <cstdio>

using namespace std;

template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }

namespace {
    // printElems(&a[0], &a[n]);　みたいな感じで使う。
    void printElems(const int* begin, const int* end)
    {
        for (const int* p = begin; p != end; ++p) {
            std::cout << *p << ' ';
        }
        std::cout << std::endl;
    }
}

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define FOR(i,j,n) for(int i=j; i < n; i++)
#define souatari(i,j,n) rep1(i,n-1)rep(j,i)
#define souatari1(i,j,n) for(int i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef array<int,3> arr3;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;
const ll BIG = 1LL<<60;



ll takasa[15];


int main(){
	ll n,k;
	cin >> n >> k;
	rep(i,n) cin >> takasa[i];

	ll ans = BIG;
	rep(itr,1<<n){
		if(itr%2==0) continue;
		ll cnttmp = 0;
		rep(i,n) if((itr&1<<i))cnttmp++;
		if (cnttmp < k) continue;
		ll anstmp = 0;
		ll htmp = takasa[0]-1;
		//prints("itr is ",itr);
		rep(i,n){
			if((itr&1<<i)){
				if(htmp<takasa[i]){htmp = takasa[i];}
				else{htmp+=1;anstmp+=htmp-takasa[i];}
				//prints(i,htmp,anstmp);
			}
			htmp = max(takasa[i],htmp);

		}
		ans = min(ans,anstmp);
	}

	prints(ans);


	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int a;
    cin >> a;
    if(a == 7 || a == 5 || a == 3) puts("YES");
    else puts("NO");
    return 0;
}

Measured memory_bytes: 256
use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.trim().split_whitespace();
    let n: i32 = iter.next().unwrap().parse().unwrap();
    let mut ans = 0;
    for i in 1..(n+1) {
    	let mut temp = 0;
        for j in 1..(i+1) {
        	if i%j==0 {
            	temp += 1;
            }
		}
        if temp == 8 && i%2==1 {
			ans += 1;
        }
    }
    println!("{}",ans);
}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long 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 = 1000000000;

int main(){
    ll n, k;
    cin >> n >> k;

    vector<ll> p(n+1, 0);
    for(int i = 1; i <= n; i++){
        cin >> p[i];
    }

    vector<ll> sum_list(1001, 0);
    sum_list[1] = 1;
    for(int i = 2; i <= 1000; i++){
        sum_list[i] = sum_list[i-1] + i; 
    }

    vector<double> dp(n+1, 0);
    for(int i = 1; i <= k; i++){
        dp[1] += (double)sum_list[p[i]] / p[i];
    }

    double ans = dp[1];
    for(int i = 2; i <= n - k + 1; i++){
        dp[i] = dp[i-1] - (double)sum_list[p[i-1]] / p[i-1] + (double)sum_list[p[i+k-1]] / p[i + k - 1];
        if(ans < dp[i]){
            ans = dp[i];
        }
    }

    cout << fixed <<  setprecision(10) << ans << endl;

    return 0;
}


Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {

	public static int gcd (int a, int b) {
		if (a == b) return a;
		if (a < b) {
			int temp = a;
			a = b;
			b = temp;
		}
		return gcd(b, a - b);
	}

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while (sc.hasNext()) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int gcd = gcd(a, b);
			long lcm = a * (b / gcd);
			System.out.println(gcd + " " + lcm);
		}

	}

}

Measured memory_bytes: 17284
#!/usr/bin/env python3
#AGC20 B

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def f(x):
    for i in a:
        if x < i:
            x = 0
            break
        x = x - (x % i)
    return x
k = I()
a = LI()
high,low = 10**20,0
while (high - low) > 1:
    mid = (high + low) // 2 
    if f(mid) >= 2:
        high = mid
    else:
        low = mid
ans1 = high
high,low = 10**20,0
while (high - low) > 1:
    mid = (high + low) // 2
    if f(mid) > 2:
        high = mid
    else:
        low = mid
ans2 = low
if ans1 > ans2:
    print(-1)
else:
    if f(ans1) != 2 or f(ans2) != 2:
        print(-1)
    else:
        print(ans1,ans2)


Measured memory_bytes: 59632
#!/usr/bin/env python3

n, m = list(map(int, input().split()))

ab = [list(map(int, input().split())) for _ in range(n)]

ab = sorted(ab, key=lambda x: x[0])

ans = 0
for i in range(m):
    a, b = ab[i]
    if b-m >= 0:
        ans += a*m
        print(ans)
        exit()
    else:
        m -= b
        ans += a*b


Measured memory_bytes: 29796
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		if(N.charAt(0) == N.charAt(2) )System.out.println("Yes");
		else System.out.println("No");
	}

}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const long double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int n,m,l;
    cin >> n >> m >> l;
    vector<long double> p(n),t(n),v(n);
    rep(i,0,n){
        cin >> p[i] >> t[i] >> v[i];
        if(v[i]==0) v[i]=1e-12;
    }

    ll comb[51][51]={};
    rep(i,0,51){
        comb[i][i]=1;
        comb[i][0]=1;
    }
    rep(i,1,51) rep(j,1,i){
        if(i>0 and i>j) comb[i][j]+=comb[i-1][j];
        if(j>0) comb[i][j]+=comb[i-1][j-1];
    }

    vector<map<int,long double>> x(n);
    rep(i,0,n) rep(j,0,m+1) x[i][t[i]*j]+=powl((100-p[i])/100,m-j)*comb[m][j]*powl(p[i]/100,j);
    rep(i,0,n){
        long double s1=0;
        for(const auto& p1:x[i]){
            long double tmp=p1.second;
            rep(j,0,n){
                if(j==i) continue;
                long double s2=0;
                for(const auto& p2:x[j]) if(p2.first+l/v[j]>p1.first+l/v[i]) s2+=p2.second;
                tmp*=s2;
            }
            s1+=tmp;
        }
        cout << fixed << setprecision(8) << s1 << endl;
    }
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 3872
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
 
typedef long long ll;
typedef pair<int, int> ii;

int main() {
	
	ll n;
	cin >> n;
	map<int, int> mp;
	rep(i, n){
		ll a, b;
		cin >> a >> b;
		mp[a]++;
		mp[b] += 0;
		mp[b+1]--;
	}
	
	int ans = 0;
	int tmp = 0;
	for(auto it : mp){
		tmp += it.second;
		if(tmp >= it.first-1) ans = max(ans, it.first-1);
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 7492
from collections import deque


def main():
    row, col = map(int, input().split())
    S = [list(input()) for _ in range(row)]
    ans = 0

    for r in range(row):
        for c in range(col):
            if S[r][c] == "#":
                continue
            q = deque()
            q.append((r, c))
            dist = [[-1 for _ in range(col)] for _ in range(row)]
            dist[r][c] = 0

            while q:
                r, c = q.popleft()
                for dr, dc in ((-1, 0), (1, 0), (0, -1), (0, 1)):
                    nr, nc = r + dr, c + dc
                    if not(0 <= nr < row and 0 <= nc < col):
                        continue
                    if S[nr][nc] == "#":
                        continue
                    if dist[nr][nc] != -1:
                        continue
                    q.append((nr, nc))
                    dist[nr][nc] = dist[r][c] + 1
                    ans = max(ans, dist[nr][nc])

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9324
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	srand(time(NULL));
	int n; cin >> n;
	vector<pi> v;
	rep(i, n){
		int x, y; cin >> x >> y;
		/*
		int x = rand() % 2000001 - 1000000;
		int y = rand() % 2000001 - 1000000;
		*/
		if(x == 0 && y == 0) continue;
		v.emplace_back(x, y);
	}
	n = v.size();
	
	sort(all(v),[]
		(pi a, pi b){
			return arg(complex<double>(a.first, a.second)) < arg(complex<double>(b.first, b.second));
		});
	
	ll ans = 0;
	rep(i, n){
		ll x = 0, y = 0;
		rep(j, n){
			x += v[(i + j) % n].first;
			y += v[(i + j) % n].second;
			ans = max(ans, x * x + y * y);
		}
	}
	printf("%.20f\n", sqrt(1.0 * ans));
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////


int main(){fastio
    
    ll m1,d,m2;cin>>m1>>d>>m2;
    if(m1!=m2){
        cout<<1;
    }else{
        cout<<0;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<algorithm>
#include<iterator>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#define lli long long int
#define mp make_pair
#define ULTRA_INSTINCT ios_base::sync_with_stdio(false); cin.tie(0)
#define PI  3.141592653589793
#define fo(i,n) for(lli i=0;i<(n);i++)
#define FO(i,x,n) for(lli i=(x);i<(n);i++)
#define pb push_back
#define FI first
#define SE second
#define vi vector<lli>
#define pi pair<lli,lli>
#define vii vector<pi >
#define Endl endl
#define ITA 200005
#define ROH 100005
#define deb(x) cout<<(#x)<<" "<<x<<endl
using namespace std;
lli mod = 1e9 +7,test; 
lli max(lli a,lli b){return a>b?a:b;}
lli min(lli a,lli b){return a>b?b:a;}

lli gcd(lli a, lli b) { 
   if (b == 0) return a; 
   return gcd(b, a % b);  
} 

string s;
lli d;

lli dp[10001][2][101];

lli f(lli idx , lli chk , lli sum){
    if(idx == s.length()){
        return sum %d == 0;
    }
    if(dp[idx][chk][sum] !=-1){return dp[idx][chk][sum];}
    lli here = 0;
    lli lmt = s[idx] - '0';
    if(chk){lmt = 9;}
    for(lli i = 0;i<=lmt;i++){
        lli next =chk;
        if(i < s[idx]- '0'){next = true;}
        here += (f(idx + 1, next , (sum + i)%d));
        here %= mod;
    } 
    dp[idx][chk][sum] = here;
    return here;
}

void solve(){
    cin>>s>>d;
    fo(i,10001){
        fo(j,2){
            fo(k,d+1){
                dp[i][j][k] =-1;
            }
        }
    }
    cout<< (f(0 , false , 0) - 1 + mod)%mod<<endl;
}

int main(){
    ULTRA_INSTINCT;
    lli t =1;
    fo(i,t){
        solve();
    }
    return 0;

}

Measured memory_bytes: 16896
n,k=map(int,input().split())
pl=list(map(int,input().split()))
cl=[0]*2*n
order=[]
next=0
for i in range(k):
  if cl[next]==0:
    cl[next]=1
    next=pl[next]-1
  elif cl[next]==1:
    cl[next]=2
    order.append(next+1)
    next=pl[next]-1
  else:
    kk=len(order)
    hasuu=cl.count(1)
    newk=k-hasuu
    ans=newk%kk
    print(order[ans])
    break
else:
  print(next+1)


Measured memory_bytes: 32348
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

int main(){
    int n; cin >> n;
    int o = n / 15;
    int x = 800 * n; 
    int y = o * 200;
    cout << x - y << endl;
}

Measured memory_bytes: 256
using System;

namespace ABC176.Problems
{
    class A
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            string[] ss1 = Console.ReadLine().Split(" ");
            int n = int.Parse(ss1[0]);
            int x = int.Parse(ss1[1]);
            int t = int.Parse(ss1[2]);

            Console.WriteLine((n + x - 1) / x * t);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27520
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)


int main(){
    int N,X,rs=0,goukei=0;
    cin >> N >> X;
    vector<int> L(N);
    for(int i = 0;i < N;i++)
        cin >> L.at(i);

    for(int i = 0;i < N;i++){
        rs++;
        goukei += L.at(i);
        if(goukei > X)
            break;
    }

    if(goukei <= X)
        rs++;

    cout << rs << endl;

}

Measured memory_bytes: 3584
A,B,C,D = map(int,input().split())

x = 0
while C > 0 and A > 0:
    if x == 0:
        C = C - B
        x = 1
    else:
        A = A - D
        x = 0

if C < A:
    print('Yes')
else:
    print('No')

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

int main() {
  int N;
  cin >> N;
  
  vector<int> d(N);
  for (int i=0;i<N;i++){
    cin >> d.at(i);
  }
  
  sort(d.begin(), d.end());
  
  int ans = 0, temp = 0;
  for(int i=0; i<N; i++){
    if(temp == d.at(i)) continue;
    ans += 1;
    temp = d.at(i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	int N;
	cin >> N;

	if (N >= 1000)
	{
		cout << "ABD";
	}
	else
	{
		cout << "ABC";
	}

	return 0;
}


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

int m[30][30],a,b,c,x,y,i,j;

int main(){
	scanf("%d %d",&a,&b);
	while(a!=0 && b!=0){
		memset(m,0,sizeof(m));
		scanf("%d",&c);
		for(i=0;i<c;i++)scanf("%d%d",&x,&y),m[x][y]=1;
		m[1][0]=1;
		for(i=1;i<=a;i++){
			for(j=1;j<=b;j++){
				m[i][j]=m[i][j]?0:(m[i-1][j]+m[i][j-1]);
			}
		}
		printf("%d\n",m[a][b]);
		scanf("%d %d",&a,&b);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main(){
  int w,a,b;
  cin>>w>>a>>b;
  if(a<b+w && b<a+w) cout<<'0';
  else{
    if(a<b) cout<<b-w-a;
    else cout<<a-w-b;
  }
  return 0;
}


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

int main(){
  string str;
  int len=0,maxlen=0;
  cin>>str;
  for(int i=0;i<=str.length();i++){
    switch(str[i]){
      case 'A':case 'T':case 'G':case 'C':
        len++;break;
      default:maxlen=max(len,maxlen);len=0;
    }
  }
  cout << maxlen << endl;
  return 0;
}

Measured memory_bytes: 256
//ABC082C
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main() {
    int n;
	cin >> n;
    map<long long int, int> a;
   for(int i=0;i<n;i++){
        long long int  x;
		cin >> x;
        a[x]++;
    }
    int ans = 0;
    for (auto e : a) {
		if(e.first <= e.second){
			ans += e.second - e.first;
		}else{
			ans += e.second;
		}
    }
    cout << ans << endl;
}

Measured memory_bytes: 6272
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)998244353 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

ll modPow(ll base, ll ex, ll m) {
	ll ret = 1;
	while(ex){
		if(ex & 1){
			ret = ret * base % m;
		}
		ex >>= 1;
		base = base * base % m;
	}
	return ret;
}

ll modFact(ll n, ll m){
	if(!n){ return 1; }
    static vector<ll> memo = {1, 1};
    if(n < (ll)memo.size()){ return memo[n]; }
    for(int i=memo.size();i<=n;i++){
        memo.push_back(memo.back() * i % m);
    }
    return memo[n];
}


pair<ll, pair<ll, ll>> exGCD(ll a, ll b){
	bool inv = false;
	if(a < b){
		swap(a, b);
		inv = true;
	}
	vector<ll> r = {a, b}, ks;
	while(b){
		ks.push_back(a / b);
		r.push_back(a = a % b);
		swap(a, b);
	}
	ll gcd = a;

	ll x = 0, y = 1, u = 1, v = -ks[0];
	for(unsigned long i=1;i<ks.size();i++){
		ll k = ks[i];
		ll x2 = u, y2 = v,
		   u2 = x - k * u, v2 = y - k * v;
		x = x2; y = y2; u = u2; v = v2;
	}

	if(inv){
		swap(x, y);
	}
	return {gcd, {x, y}};
}

ll modInv(ll n, ll m){
	return modPow(n, m-2, m);
	auto p = exGCD(n, m);
	return (p.second.first + m) % m;
}

ll modC(ll n, ll k, ll m){
	return modFact(n, m) * modInv(modFact(k, m) * modFact(n-k, m) % m, m) % m;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, a, b, k;
    cin >> n >> a >> b >> k;
    ll ans = 0;
    for(int i = 0; i <= n; i++){
        // for(int j = 0; j <= n; j++){
        int j = (k - a * i) / b;
        if(0 <= j && j <= n){
            if(a * i + b * j == k){
                ans += modC(n, i, M) * modC(n, j, M);
                ans %= M;
            }
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 6512