akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################
from fractions import gcd

# 最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)


A, B, C, D = map(int, input().split())

A -= 1

# a/b以下の条件を満たす数
nb = B - B//C - B//D + B//lcm(C, D)
na = A - A//C - A//D + A//lcm(C, D)

print(nb - na)


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n;
  cin >> n;

  vll d(n);
  REP(i, n)
    cin >> d[i];

  ll sum = 0;
  REP(i, n){
    for(int j = i+1; j < n; j++)
      sum += d[i]*d[j];

  }
  cout << sum << endl;
  
  
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>

#include <cstdio>

using namespace std;


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

	string S;
	string A = "";
	int w;
	cin >> S;
	cin >> w;

	for (int i = 0; i < S.size(); i++) {
		if (i % w == 0) {
			A += S[i];
		}
	}


	cout << A << '\n';


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}



main(){
  int n;
  cin>>n;
  vector<P> v(n);

  rep(i,n){
    cin>>v[i].F>>v[i].S;
  }

  sort(all(v));
  map<P,int> mp;

  rep(i,n){
    FOR(j,i+1,n){
      P p=P(v[i].F-v[j].F,v[i].S-v[j].S);
      mp[p]++;

    }
  }

  int res=0;
  for(auto m:mp){
    res=max(res,m.S);
  }

  cout<<n-res<<endl;
}


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

typedef struct List {
	struct List *prev, *next;
	int id;
} list;

int main()
{
	int i, N, A[100001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(A[i]));
	
	list *p, *hash[10007] = {}, data[100001];
	long long count = 0;
	for (i = 1; i <= N; i++) {
		for (p = hash[A[i] % 10007]; p != NULL; p = p->next) {
			if (p->id == A[i]) break;
		}
		if (p == NULL) {
			data[i].prev = NULL;
			data[i].next = hash[A[i] % 10007];
			if (data[i].next != NULL) (data[i].next)->prev = &(data[i]);
			data[i].id = A[i];
			hash[A[i] % 10007] = &(data[i]);
			count++;
		} else {
			if (p->prev != NULL) p->prev->next = p->next;
			else hash[A[i] % 10007] = p->next;
			if (p->next != NULL) p->next->prev = p->prev;
			count--;
		}
	}
	
	printf("%lld\n", count);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  int A,B,M;
  cin>>A>>B>>M;
  vector<ll> a(A);
  vector<ll> b(B);
  vector<ll> x(M);
  vector<ll> y(M);
  vector<ll> c(M);
  rep(i,A)cin>>a[i];
  rep(i,B)cin>>b[i];
  rep(i,M)cin>>x[i]>>y[i]>>c[i];
  ll amin=a[0];
  rep(i,A)amin=min(amin,a[i]);
  ll bmin=b[0];
  rep(i,B)bmin=min(bmin,b[i]);
  ll ans=amin+bmin;
  rep(i,M)
    ans=min(ans,a[x[i]-1]+b[y[i]-1]-c[i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4224
#include<iostream>
#include<string>
#include <algorithm>
using namespace std;
 
int main(){
    int x,y,i=0,res=0;

  	cin >> x >> y;
    for(i=0;i<=x;i++){
        if(y==(2*i+4*(x-i))){
            res = 1;
            break;
        }
    }
    if(res==1)
        cout << "Yes" << endl;
    else
        cout << "No" <<endl;
   return 0;
   
  
  
}

Measured memory_bytes: 3648
def solve():
    s = input()
    yy_or_mm = int(s[:2])
    mm_or_yy = int(s[2:])
    if is_month(yy_or_mm) and is_month(mm_or_yy):
        return "AMBIGUOUS"
    elif not is_month(yy_or_mm) and is_month(mm_or_yy):
        return "YYMM"
    elif is_month(yy_or_mm) and not is_month(mm_or_yy):
        return "MMYY"
    elif not is_month(yy_or_mm) and not is_month(mm_or_yy):
        return "NA"


def is_month(mm):
    return 1 <= mm <= 12


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int n; cin >> n;
  int a[n]; REP(i,n) cin >> a[i];
  sort(a,a+n);
  COUT(a[n-1]-a[0]);

  return 0;
}

Measured memory_bytes: 256
n , m  = map(int, input().split())
ans = [str(0) for _ in range(n)]
b = [0 for _ in range(n)]
for _  in range(m):
  st, ct = map(int, input().split())
  if(b[st-1] == 0 or ans[st-1] == str(ct)):
    ans[st-1] = str(ct)
    b[st-1] = 1
  else:
    print(-1)
    quit()
if(b[0] == 0 and n !=1):
  ans[0] = "1"
elif(b[0] == 0):
  print(0)
  quit()
ans = "".join(ans)

if len(str(int(ans))) < n:
  print(-1)
  quit()
else:
  print(ans)
  quit()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int N = 200005;
const int M = 1000 * 1000 * 1000 + 7;
using namespace std;
int gcd(int f , int s){if(s==0)return f;else return gcd(s,f%s);}
char grid[344][344];
int ans[323][445];
int main(){
	
	int r , c , k;
	cin >> r >> c >> k;
	for(int i = 0 ; i < r ; i++)
		for(int x = 0 ; x < c ; x++)cin >> grid[i][x];
	int counter = 0;
	for(int i = 0 ; i < r ; i++){
		for(int x = 0 ; x < c ; x++){
			if(grid[i][x] == '#'){
				ans[i][x] = ++counter;
				int p = x - 1;
				while(p >= 0 && ans[i][p] == 0 && grid[i][p] != '#'){
					ans[i][p] = counter;
					p--;
				}
				p = x + 1;
				while(p < c && ans[i][p] == 0 && grid[i][p] != '#'){
					ans[i][p] = counter;
					p++;
				}
			}
		}
	}
	for(int i = 0 ; i < r ; i++){
		if(ans[i][0] != 0){
			int p = i - 1;
			while(p >= 0 && ans[p][0] == 0){
				for(int x = 0 ; x < c ; x++){
					ans[p][x] = ans[i][x];
				}
				p--;
			}
			p = i + 1;
			while(p < r && ans[p][0] == 0){
				for(int x = 0 ; x < c ; x++){
					ans[p][x] = ans[i][x];
				}
				p++;
			}
		}		
	}
	for(int i = 0 ; i < r ; i++){
		for(int x = 0 ; x < c ; x++){
			cout << ans[i][x] << " ";
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
int main(){
    int A, B, K;
    scanf("%d %d %d", &A, &B, &K);
    int i, tmp;
    if(A>B){
        tmp = A;
        A = B;
        B = tmp;
    }
    int n[A];
    for(i=0;i<A;i++){
        if((A%(i+1)==0)&&(B%(i+1)==0)){
            n[i] = 1;
        }
        else{
            n[i] = 0;
        }
    }
    int count=0, ans=1;
    for(i=0;i<A;i++){
        if(n[A-1-i] == 1){
            count += 1;
        }
        if(count == K){
            ans = A-i;
            break;
        }
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 128
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define int_INF 1<<29
#define ll_INF 1LL<<60
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<LL>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using mll = map<LL, LL>;
using mcl = map<char, LL>;
using vpi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

void y_n(bool p) {
	p ? _y() : _n();
}

void Y_N(bool p) {
	p ? _Y() : _N();
}

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


LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}

#pragma endregion 




/*****************************************************************************/

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

	int n;
	cin >> n;
	vi h(n);
	f_vI(h, n);
	vi dp(n + 1, ll_INF);
	dp[0] = 0;
	f(i, 1, n) {
		dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
		if (i > 1) {
			dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
		}
	}
	cout << dp[n - 1];
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 2000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, m, x[51], y[51];
bool g[51][51], used[51];

bool dfs(int pos) {
    used[pos] = true;
    bool all_visited = true;
    rep(i, 0, n) {
        if (!used[i]) {
            all_visited = false;
            break;
        }
    }
    if (all_visited) return true;

    bool res = false;
    rep(i, 0, n) {
        if (!used[i] && g[pos][i]) 
            res = dfs(i);
    }
    return res;
}

int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n >> m;
    rep(i, 0, m) {
        cin >> x[i] >> y[i];
        x[i]--, y[i]--;
        g[x[i]][y[i]] = g[y[i]][x[i]] = true;
    }

    int ans = 0;
    rep(i, 0, m) {
        g[x[i]][y[i]] = g[y[i]][x[i]] = false;
        if (!dfs(0)) ans++;
        g[x[i]][y[i]] = g[y[i]][x[i]] = true;
        rep(j, 0, n) used[j] = false;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>

/*
わからなかったところ
- 逆元の使い方
- mintライブラリ　atcoderのMODライブラリ
- 繰り返し二乗法
*/
using namespace std;


typedef long long int ll; 
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint choose(int n,int a){
    mint x = 1;mint y = 1;
    for (int  i = 0; i < a; i++)
    {
        x *= n-i;
        y *= i+1;
    }
    
    return x/y;
}

int main(){
    ll n,a,b,tmp2;
    cin >> n >> a >> b;
    mint ans = 1;
    ans = mint(2).pow(n);
    ans -= 1;
    ans -=choose(n,a);
    ans -=choose(n,b);
     
    cout << ans.x;

    return 0;
}

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

typedef long long ll;
const int mod=1e9+7;

int tri[2005][2005];

int main(int argc,char **argv) {
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int n,k;
	cin>>n>>k;

	for(int i=0;i<=2000;i++)
		for(int j=0;j<=i;j++)
			if(j==0||j==i) tri[i][j]=1;
			else {
				tri[i][j]=tri[i-1][j-1]+tri[i-1][j];
				tri[i][j]%=mod;
			}
	for(int i=1;i<=k;i++) {
		ll ans=1;
		ans*=tri[n-k+1][i];
		ans*=tri[k-1][i-1];
		ans%=mod;
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 15104
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

void Main(){

  string S;
  cin>>S;

  rep(i,S.length()){
    if((i%2==1 and S[i]=='R')or(i%2==0 and S[i]=='L')){
      cout<< "No"<<"\n";
      return;
    }
  }
  cout<< "Yes"<<"\n";


}

  //-----------------------------------
  int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
  }
  //-----------------------------------


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define MAX(A,B) A>B?A:B
#define MIN(A,B) A<B?A:B
#define gcd(A,B) __gcd(A,B)
#define lcm(A,B) A/(__gcd(A,B))*B
#define MP make_pair
#define PB push_back
#define EPS 1e-12
#define ld long double
#define modulo 998244353
#define tmplarge (lli)1e4
using namespace std;

typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef pair<int,double> pid;



int main()
{
    int a=0;
    char c;
    while(scanf("%c",&c)!=EOF)
    {
        if (c=='+')
            a++;
        if (c=='-')
            a--;
    }
    printf("%d",a);
}

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

int main() {
  long long N,D;
  cin >> N >> D;
  long long D2;
  D2 = D * D;
  long long a,b,sum;
  sum = 0;
  rep(i, N) {
    cin >> a >> b;
    if(a * a + b * b <= D2) sum++;
  }
  cout << sum << endl;
  return 0;
}




Measured memory_bytes: 3632
#include <iostream>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;

int W, H;
char S[70][70];
string dp[70][70];

bool comp(string s, string t) {
  if(s.length() != t.length()) return s.length() < t.length();
  REP(i, 0, s.length()) if(s[i] != t[i]) return s[i] < t[i];
  return false;
}

int main(void) {
  while(cin >> W >> H, W && H) {
    REP(i, 0, H) cin >> S[i];
    REP(i, 0, H) REP(j, 0, W) dp[i][j] = "";
    string ans = "";
    REP(i, 0, H) REP(j, 0, W) {
      if('0' <= S[i][j] && S[i][j] <= '9') {
        if(S[i][j] == '0' && dp[i][j] == "") continue;
        dp[i][j] += S[i][j];
        if(comp(ans, dp[i][j])) ans = dp[i][j];
        if(i + 1 < H && comp(dp[i + 1][j], dp[i][j])) dp[i + 1][j] = dp[i][j];
        if(j + 1 < W && comp(dp[i][j + 1], dp[i][j])) dp[i][j + 1] = dp[i][j];
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3280
#include <stdio.h>
#include <unistd.h>

int map[21][21];
void debugPrint(int Y, int X, int n, char D, int M, int m) {
  int x,y;
  printf("Count:%d ----- %c:%d(%d)\n",n,D,M,m);
  for(y=20;y>=0;y--) {
    for(x=0;x<=20;x++) {
      if ((Y==y)&&(X==x)) printf("* ");
      else 
	printf("%c ", (map[y][x])? 'x':'.');
    }
    printf("\n");
  }
}

int main() {
  while(1) {
    int N,n,M,m;
    int x,y;

    scanf("%d\n",&N);
    if (N==0) break;

    for(y=20;y>=0;y--) {
      for(x=0;x<=20;x++) {
	map[y][x]=0;
      }
    }

    for(n=0;n<N;n++) {
      int X,Y;
      scanf("%d %d\n",&X,&Y);
      map[Y][X]=1;
    }

    scanf("%d\n",&M);

    y = 10; x = 10; n = N;
    for(m=0;m<M;m++) {

      char D;
      int  E,e;
      scanf("%c %d\n",&D,&E);

      if(!n) continue;

      //      debugPrint(y,x,n,D,E,m);
      //      sleep(1);

      for(e=0;e<E;e++) {
	if      (D=='N') y++;
	else if (D=='S') y--;
	else if (D=='E') x++;
	else if (D=='W') x--;
	if(map[y][x]) {
	  n--;
	  map[y][x]=0;
	}
      }
    }
    printf("%s\n", (n)? "No": "Yes");
  }

  return 0;
}

Measured memory_bytes: 588
#include <iostream>
#include <vector>
#include <stack>
#include <deque>
#include <map>
#include <cmath>
#include <algorithm>
#include <limits>
#include <utility>
#include <string>
#include <numeric>

//SFPA stands for Shortest Path Faster Algorithm, which is an improvement of the Bellman–Ford algorithm.

//if you would like this program to run faster, use pair or vector instead of map in Edge.
template<class T>
using Edge = std::pair<T, T>; //for this algorithm, an edge must have "successor" and "cost" keys.
template<class T>
using Graph = std::vector<std::vector<Edge<T> > >;

//V is the number of the vertices of the graph. The id of a vertex in the graph must be in [0,V).
template<class T>
std::pair<T, std::vector<T> > tsort(Graph<T> &graph){
    const T V = graph.size();

    std::vector<T> sorted;

    T pred, suc;
    std::stack<T> stack;
    std::vector<T> in(V,0);
    T remainder = 0;
    for(pred=0; pred<V; ++ pred){
        for(auto &edge : graph[pred]){
            suc = edge.first;
            ++in[suc];
            ++remainder;
        }
    }
    for(pred=0; pred<V; ++ pred){
        if(in[pred]==0){
            stack.emplace(pred);
        }
    }

    while(!stack.empty()){
        pred = stack.top();
        stack.pop();
        sorted.emplace_back(pred);
        for(auto &edge : graph[pred]){
            suc = edge.first;
            --in[suc];
            --remainder;
            if(in[suc] == 0){
                stack.emplace(suc);
            }
        }
    }

    return std::make_pair(remainder, sorted);
}

int main(int argc, char *argv[]){
    int N;
    std::cin >> N;

    auto id = [&N](int a,int b){
        if(a > b){
            using std::swap;
            swap(a,b);
        }
        return (a*(2*N-a-1))/2 + b - a -1;
    };

    int i,j;
    Graph<int> graph((N*(N-1))/2+1);
    int root = graph.size()-1;
    int pred, suc;
    for(i=0; i<N; ++i){
        pred = root;
        for(j=0; j<N-1; ++j){
            std::cin >> suc;
            suc = id(i,--suc);
            graph[pred].emplace_back(suc,1);
            pred = suc;
        }
    }

    auto result = tsort(graph);
    auto remainder = result.first;
    if(remainder > 0){
        std::cout << -1 << std::endl;
        return 0;
    }
    auto sorted = result.second;
    std::vector<int> D(graph.size(),0);
    int daysTmp, days;
    for(auto pred : sorted){
        for(auto &edge : graph[pred]){
            auto suc = edge.first;
            daysTmp = D[pred] + edge.second;
            if(daysTmp > D[suc]){
                D[suc] = daysTmp;
                if(daysTmp > days){
                    days = daysTmp;
                }
            }
        }
    }
    std::cout << days << std::endl;

    return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < static_cast<int>(b); i++)
#define FORR(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) FOR (i, 0, n)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
template <typename T>
void print(const vector<vector<T>> matrix);
template <typename T>
void print(const vector<T> vec);
template <typename Arg>
void print(const Arg arg);
template <typename Head, typename... Args>
void print(const Head head, const Args... args);
template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
using ll = long long;

typedef pair<int, int> P;

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

    int n;
    cin >> n;

    int ans = 0;
    for (int i = 1; i <= n; i += 2) {
        int cnt = 0;
        for (int j = 1; j <= i; j++) {
            if (i % j == 0) cnt++;
        }
        if (cnt == 8) ans++;
    }
    print(ans);

    return 0;
}

//---------------------------------------------
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    repall (i, vec)
        cout << i << ' ';
    cout << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define  clr(v,val)      memset(v,val,sizeof(v))
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
typedef  long long     ll ;
typedef  unsigned long long     ull ;
const double eps= (1e-9);
using namespace std;
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
ll setBit1(ll num, ll idx) {return num | (1ll<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
const int N=200000+9;
ll a[N],b[N];
vector<ll> v;
ll sum[N];
int main(){
    GO();
    ll n,m,k;
    cin>>n>>m>>k;
    ll sum2=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum[i]=(i?sum[i-1]:0)+a[i];
    }
    for(int i=0;i<m;i++){
        cin>>b[i];
        sum2+=b[i];
        v.pb(sum2);
    }

    ll mx=0;
    auto it=upper_bound(all(v),k);
    mx=it-v.begin();
    for(int i=1;i<=n;i++){
        if(sum[i-1]>k) continue;
        ll rem= k-sum[i-1];

        auto it=upper_bound(all(v),rem);
      //  if(it==v.begin()) continue;
       // it--;
        ll ans= i+(it-v.begin());
        mx=max(mx,ans);
    }
    cout<<mx<<"\n";
}

























































































































Measured memory_bytes: 9744
#include <stdio.h>

int dfs( int, int, int );

int ball[ 10 ];

int main( void ) {
	int i, n;

	for ( scanf( "%d", &n ); n--;  ) {
		for ( i = 0; i < 10; i++ )
			scanf( "%d", ball + i );

		if ( dfs( 1, ball[ 0 ], 0 ) )
			puts( "YES" );
		else
			puts( "NO" );
	}

	return 0;
}

int dfs( int d, int lTop, int rTop ) {
	if ( d == 10 )
		return 1;

	if ( ball[ d ] > lTop )
		if ( dfs( d + 1, ball[ d ], rTop ) )
			return 1;

	if ( ball[ d ] > rTop )
		if ( dfs( d + 1, lTop, ball[ d ] ) )
			return 1;

	return 0;
}

Measured memory_bytes: 580
import std.stdio,std.conv,std.string,std.math;

void main(){
    double money = 100000;
    while(true){
        char[] buf;
        stdin.readln(buf);
        double x = buf.chomp().to!double();
        if(0 <= x && x <= 100){
            for(int i = 0;i < x;i++){
                money *= 1.05;
                if(money - (money/1000).to!int() * 1000 != 0){
                    money = ((money/1000 + 1).to!int())*1000;
                }
            }
            break;
        }
    }
    writeln(money.to!int());
}

Measured memory_bytes: 2316
l1=[int(input()) for i in range(5)]
l2=[0 if item%10==0 else 10-item%10 for item in l1]

t=0
c=0
for i in range(5):
  if l2[i]==max(l2) and c==0:
    t+=l1[i]
    c+=1
  else:
    t+=(l1[i]+l2[i])
    
print(t)

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

int main() {
  //入力
  int n; cin >> n;
  queue<pair<int,int>> que[n+1];
  rep(i,n){
    int A; cin >> A;
    rep(j,A){
      int taisyou; cin >>taisyou;
      int b; cin >> b;
      que[i].push({taisyou,b});
    }
  }

  //rep(i,n) printf("%d says %d=>%d\n",i+1,que[i].front().first,que[i].front().second);
  //入力おわり

  int ans = 0, subans=0;
  int max_bit = pow(2,n);
  rep(i,max_bit){ //0000...から1111...までを用意する
    int count = 0;
    //cout << "now bit => " << bitset<3>(i) << endl;
    vector<int> h_or_u(n+1);
    vector<vector<int>> hantei(n+1);
    bool flag = true;
    rep(j,n){
      if(!(i>>j & 1)){//iの2進数表記のj桁目が0だったら
        h_or_u[j+1] = 0;
        continue; //人jは不親切なのでデータはスキップする
      }
      else{ //正直者の証言を抽出
        h_or_u[j+1] = 1;
        count++;
        queue<pair<int,int>> copy = que[j];
        while(!copy.empty()){
          hantei[copy.front().first].push_back(copy.front().second);
          copy.pop();
        }
      }
    }

    /*rep(j,n){
      printf("syougen to %d=> ",j+1);
      for(auto p : hantei[j+1]) cout << p << " ";
      printf(" %d is %d",j+1,h_or_u[j]);
      cout << endl;
    }*/

    //正直者だけのデータを取得しきったから矛盾があるか調べる
    //if(矛盾があったら) flag = false;
    rep(j,n){
      rep(k,hantei[j+1].size()){
        if(hantei[j+1][k] != h_or_u[j+1]) flag = false;
      }
    }
    if(flag){
      //cout << endl << bitset<3>(i) << endl;
      ans = max(count , ans);
    }
  }

  cout << ans << endl;
}


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

int check(string x, string y){
  int k=x.size();
  if(x.at(k-1)==y.at(0)){return 1;}
  else return 0;
}
  
int main(){
  int N; cin >> N;
  vector<string> MY(N);
  for (int i=0;i<N;i++){
    cin >> MY.at(i);
  }
  for (int i=0;i<N-1;i++){
    if(check(MY.at(i), MY.at(i+1))==0){
      cout << "No" << endl;
      return 0;
    }
  }
  sort(MY.begin(), MY.end());
  for (int i=0;i<N-1;i++){
    if(MY.at(i)==MY.at(i+1)){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;
int main()
{
    IOS
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// freopen("error.txt","w",stderr);
 	ll n,m;
 	cin>>n>>m;
 	pll s[m];
 	ll ans=-1;
 	for(ll i=0;i<m;i++)
 	{
 		cin>>s[i].first>>s[i].second;
 		if(s[i].first>n)
 		{
 			cout<<-1<<endl;
 			return 0;
 		}
 	}
 	ll lm=1;
 	for(ll p=0;p<n+1;p++)
 	{
 		lm*=10;
 	}
 	lm--;
 	for(ll i=0;i<=lm;i++)
 	{
 		ll dg=0;
 		ll temp=i;
 		vector<ll>v;
 		while(temp>0)
 		{
 			dg++;
 			v.push_back(temp%10);
 			temp/=10;
 		}
 		if(i==0)
 		{
 			dg++;
 			v.push_back(0);
 		}
 		reverse(v.begin(),v.end());
 		if(dg!=n)continue;
 		bool f=true;
 		for(ll j=0;j<m;j++)
 		{
 			if(v[s[j].first-1] != s[j].second)
 				f=false;
 		}
 		if(f)
 		{
 			cout<<i<<endl;
 			return 0;
 		}
 	}
 	cout<<ans<<endl;
    return 0;
}


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

const int N = 6;
char s[N][N + 1];
int n, m, k;

int main() 
{
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 0; i < n; ++i) {
		scanf("%s", s[i]);
	}
	int c = 0;
	for (int bit1 = 0; bit1 < (1 << n); ++bit1) 
		for (int bit2 = 0; bit2 < (1 << m); ++bit2) {
			int k_ = 0;
			for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) 
				if ((1 << i) & ~bit1 && (1 << j) & ~bit2 && s[i][j] == '#') ++k_;
			if (k_ == k) ++c;
		}
	printf("%d\n", c);
	return 0;
}


Measured memory_bytes: 1732
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();

		String t = T.substring(0, S.length());

		if(S.equals(t)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 35680
#include <bits/stdc++.h>
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  ll x,k,d;
  cin>>x>>k>>d;
  if(x==0){
    if(k%2==0) cout<<0<<endl;
    else cout<<d<<endl;
    return 0;
  }
  if(x<0) x=-x;
  if(x>0){
    if(x/d>=k){
      cout<<x-d*k<<endl;
    }
    else{
      if((k-x/d)%2==0) cout<<x-d*(x/d)<<endl;
      else cout<<abs(x-d*(x/d+1))<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define  rep(i,a,b)for(int i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const int INF=1000000000LL;
const ll r197=1000000007;
typedef pair<int,int>P;
typedef pair<int,P>Pa;

ll k=1;
string a;
int main() {
	int a;
	cin>>a;
	if(a==3||a==5||a==7)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int N = 1e5+5;
int a[N];
int main()
{
	int n,ma=0;
	int num;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&num);
		a[num]++;
		ma=max(a[num],ma);
		a[num-1]++;
		ma=max(a[num-1],ma);
		a[num+1]++;
		ma=max(a[num+1],ma);
	}
	printf("%d",ma);
} 

Measured memory_bytes: 640
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val (x, a, b) = listOfInt()
    println(when{
        // can't use Kotlin function :(
        Math.abs(x - a) < Math.abs(x - b) -> "A"
        else -> "B"
    })
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt()= listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 36232
#include<stdio.h>
#include<math.h>
#define PI 3.141592653589
int main(){
double a,b,C,S,L,h;
scanf("%lf%lf%lf",&a,&b,&C);
S=a*b*sin(C/180*PI)/2;
L=a+b+sqrt(a*a+b*b-2*a*b*cos(C/180*PI));
h=b*sin(C/180*PI);
printf("%lf\n%lf\n%lf\n",S,L,h);
}


Measured memory_bytes: 2072
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>

using namespace std;

int main(){
    int r,c;
    cin >> r >> c;
    vector<vector<int>> a;
    a = vector<vector<int>>(r+1,vector<int>(c+1,0));
    for(int i=0; i<r; i++){
        for(int j=0; j<c; j++){
            cin >> a[i][j];
        }
    }

    for(int i=0; i<r; i++){
        for(int j=0; j<c; j++){
            a[i][c] += a[i][j];
        }
    }

    for(int j=0; j<c; j++){
        for(int i=0; i<r; i++){
            a[r][j] += a[i][j];
        }
    }

    for(int i=0; i<r; i++){
        a[r][c] += a[i][c];
    }

    for(int i=0; i<=r; i++){
        for(int j=0; j<=c; j++){
            if(j==c){
                cout << a[i][c] << endl;
                break;
            }
            cout << a[i][j] << " ";
        }
    }

    return 0;
}



Measured memory_bytes: 3148
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
int A, B, T;
void solve() {
    cin >> A >> B >> T;
    cout << (((T * 10) + 5) / (A * 10) * (B * 10)) / 10 << endl;
    return;
}
//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
int main(int args, char* argv[]) {
    solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

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

int main(){
  ll A, B;
  cin >> A >> B;

  cout << lcm(A, B) << endl;
  
  return 0;
}



Measured memory_bytes: 256
T=int(input())
for TT in range(T):
	a,b,c,d=map(int,input().split(' '))
	l,x,y=(a+b)//(min(a,b)+1),0,0
	if a*l<=b:
		y=a+b
	elif b*l<=a:
		x=a+b
	else:
		x,y=(a*l-b)//(l-1),(b*l-a)//(l-1)
	out=""
	for i in range(c,d+1):
		if i<=x:
			out+="AB"[i%(l+1)==0]
		elif a+b-i+1<=y:
			out+="BA"[(a+b-i+1)%(l+1)==0]
		else:
			out+="AB"[a-x+x//(l+1)-y//(l+1)==0]
	print(out)

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

typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define ALL(s) (s).begin(),(s).end()
#define ALLn(s,n) s,s+n
#define F first
#define S second
#define pb push_back
#define tc(t) int t; cin >> t; while(t--)
#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);

const ll MOD = 1e9 + 7;
const ll MAXN = 1e6 + 7;
const ll INF = INT_MAX;

void solve() {
	ll n;
	cin >> n;
	ll cur = 100;

	int cnt = 0;

	while(cur < n) {
		cur += (cur/100);
		cnt++;
	}

	cout << cnt << "\n";
}

int32_t main() {_
	//tc(t)
		solve();
}



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

using namespace std;

struct Node {
	vector<int> from;
};

int lp(int i, const vector<Node> &nodes) {
	static vector<int> memo(nodes.size(), -1);
	if(memo[i] == -1) {
		memo[i] = -1;
		for(const auto &j : nodes[i].from) {
			memo[i] = max(memo[i], lp(j, nodes));
		}
		memo[i]++;
	}
	return memo[i];
}

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

	vector<Node> nodes(N);
	for(int i = 0; i < M; i++) {
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		nodes[y].from.push_back(x);
	}

	int result = -1;
	for(int i = 0; i < N; i++) {
		result = max(result, lp(i, nodes));
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 13380
#include<iostream>
#include<algorithm>
#define MAX_N 505
#define MAX_M 2 * 100001
#define MAX_Q 100001
using namespace std;

int grid[MAX_N][MAX_N];

int main() {
    int N, M, Q;
    cin >> N >> M >> Q;
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= N; j++) {
            grid[i][j] = 0;
        }
    }
    int L, R;
    for (int i = 0; i < M; i++) {
        cin >> L >> R;
        grid[L][R]++;
    }
    for (int i = 1; i <= N; i++) {
        for (int j = 2; j <= N; j++) {
            grid[i][j] += grid[i][j - 1];
        }
    }
    int p, q;
    for (int i = 0; i < Q; i++) {
        cin >> p >> q;
        int count = 0;
        for (int j = p; j <= q; j++) {
            count += grid[j][q] - grid[j][p - 1];
        }
        cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e6+10, mod = 1e9+7;
typedef long long ll;
ll fact[maxn], inv[maxn];
ll exp(ll a, ll b){
    ll res = 1LL;
    for(; b; b>>=1, a = (a*a)%mod) if(b&1) res = (res * a)%mod;
    return res;
}
void precalc(){
    fact[0] = 1LL;
    for(int i=1; i<maxn; i++) fact[i] = (fact[i-1] * i)%mod;
    inv[maxn-1] = exp(fact[maxn-1], mod - 2);
    for(int i=maxn-2; i>=0; i--) inv[i] = (inv[i+1] * (i+1))%mod;
}
ll ncr(ll n, ll r){
    if(n < r) return 0LL;
    return ((fact[n] * inv[n-r])%mod * inv[r])%mod;
}
int main(){
    precalc();
    ll k;
    cin >> k;
    string s;
    cin >> s;
    ll n = (int)s.size();
    ll l = n + k;
    ll ans = 0LL;
    for(ll i=n; i<=l; i++) ans = (ans + ((ncr(i - 1, n - 1) * exp(25, i - n))%mod * exp(26, l - i))%mod)%mod;
    cout << ans << "\n";
}


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

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

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

using namespace std;

int digit(long long x){
	int i = 1;
	for(long long j = 10;x/j > 0;j*=10) i++;
	return i;
}

int main(){
	long long n,m = 20;
	cin >> n;
	for(long long i = 1;i*i <= n;i++){
		if(n%i == 0){
			int x = max(digit(i),digit(n/i));
			if(m > x) m = x;
		}
	}
	cout << m << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int A[n];

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

	int MIN = 1000000000;
	int MAX = 0;

	for(int i=0;i<n;i++){
		if(A[i] < MIN)
			MIN = A[i];
		
		if(A[i] > MAX)
		MAX = A[i];
	}

	cout<< MAX - MIN <<endl;
}


Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N, K, Rock, Scissor, Paper;
  string T;
  cin >> N >> K >> Rock >> Scissor >> Paper >> T;

  enum Janken : int32_t { kRock, kScissor, kPaper };
  const int64_t janken[] = {'r', 's', 'p'};
  const int64_t score[] = {Rock, Scissor, Paper};

  int64_t result = 0;
  for (int64_t k = 0; k < K; ++k) {
    vector<vector<int64_t>> dp(N / K + 2, vector<int64_t>(3, 0));
    dp[0][0] = 0;
    dp[0][1] = 0;
    dp[0][2] = 0;
    int64_t last_index = -1;
    for (int64_t i = 1; k + (i - 1) * K < N; ++i) {
      const char enemy = T[k + (i - 1) * K];
      for (int64_t j = kRock; j <= kPaper; ++j) {
        bool win = false;
        if (janken[j] == 'r' && enemy == 's') {
          win = true;
        } else if (janken[j] == 's' && enemy == 'p') {
          win = true;
        } else if (janken[j] == 'p' && enemy == 'r') {
          win = true;
        }
        for (int64_t p = kRock; p <= kPaper; ++p) {
          if (j != p) {
            dp[i][j] = max(dp[i][j], dp[i - 1][p] + (win ? score[j] : 0));
          }
        }
      }
      last_index = i;
    }
    result += max(dp[last_index][0], max(dp[last_index][1], dp[last_index][2]));
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 8720
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair

int mod = 1e9+7;
int inf = 4e18;
const int N = 3e5+5;
int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
int dp[N+10];
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
        int a,b,m;
        cin>>a>>b>>m;
        map<int,int> mp1,mp2;
        int min1 = inf,min2 = inf;
        rep(i,1,a+1)
        {
            int x;
            cin>>x;
            min1 = min(min1,x);
            mp1[i] = x;
        }
        rep(i,1,b+1)
        {
            int x;
            cin>>x;
            min2 = min(min2,x);
            mp2[i] = x;
        }
        int minn = min1+min2;
        rep(i,0,m)
        {
            int x,y,z;
            cin>>x>>y>>z;
            minn = min(minn,mp1[x]+mp2[y]-z);
        }
        cout<<minn<<el;

    }
    return 0;
}


Measured memory_bytes: 12800
#include <math.h>
#include <assert.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <array>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define rep(i, a, b) for (int i=a; i<(b); i++)
#define forn(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define ford(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define int long long
#define ii pair<int,int>
#define ar array
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define sz(x) ((int)(x).size())
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
const int N = 5e3+7 ;
const int INF = 1e18 ;
//const int MOD = 1e9 + 7 ;
int p[N] , c[N] ;
void solve(){
	int n , k ;
	cin >> n >> k ;
	rep(i,1,n+1) cin >> p[i] ;
	rep(i,1,n+1) cin >> c[i] ;
	int ans = -INF ;
	rep(i,1,n+1){
		int sum = 0 ;
		int j = i ;
		int cnt = 0 ;
		do{
			cnt++ ;
			sum += c[j];
			j = p[j] ;
		}while(i!=j) ;
		int r = k >= cnt ? cnt + k%cnt : k;
		int base = ((k-r)/cnt) * max(sum,0LL), add = -INF ;
		sum = 0;
		rep(t,1,r+1) {
			sum += c[j], j = p[j];
			add = max(add,sum);
		}
		ans = max(ans, base+add);
	}
	cout << ans << endl ;
}


int32_t main(){
    FAST_IO ;
    int t = 1 ;
//    cin >> t ;
    while(t--){
        solve() ;
    }
}


Measured memory_bytes: 3728
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = Integer.parseInt(sc.next()) + 2;
		int w = Integer.parseInt(sc.next());
		StringBuffer s = new StringBuffer();
		for (int i = 0; i < w; i++)
			s.append("#");
		String t = s.toString();
		String[][] ans = new String[h][3];
		for (int i = 0; i < h; i++) {
			ans[i][0] = "#";
			ans[i][2] = "#";
			if (i == 0 || i == h - 1)
				ans[i][1] = t;
			else
				ans[i][1] = sc.next();
		}
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < 3; j++)
				System.out.print(ans[i][j]);
			System.out.println("");
		}
	}
}

Measured memory_bytes: 23760
use proconio::input;

fn main() {
    input! {
        mut a: i32,
        b: i32,
        mut c: i32,
        d: i32,
    }

    solve(a, b, c, d);
}

fn solve(mut a: i32, b: i32, mut c: i32, d: i32) {
    let mut flag = true;
    loop {
        if a <= 0 {
            println!("No");
            break;
        }
        if c <= 0 {
            println!("Yes");
            break;
        }

        if flag {
            c -= b;
        } else {
            a -= d;
        }
        flag = !flag;
    }
}


Measured memory_bytes: 2096
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int n, m, ans=1;

vector<P> G[100005];
int used[100005];
map<int,int> A;
int minx, maxx;

void dfs(int x){
  
  if(used[x]) return ;
  used[x]=1;
  
  for(int i=0;i<G[x].size();i++){
    int nx=G[x][i].first;
    int d=G[x][i].second;
    if(A.count(nx)&&A[nx]!=A[x]+d){
      ans=0;
      break;
    }
    A[nx]=A[x]+d;
  }
  
  for(int i=0;i<G[x].size();i++){
    int nx=G[x][i].first;
    dfs(nx);
  }
  
}

int main(){
  
  cin>>n>>m;
  
  for(int i=0;i<m;i++){
    
    int l, r, d;
    cin>>l>>r>>d;
    
    G[l].push_back(P(r,d));
    G[r].push_back(P(l,-d));
  }
  
  for(int i=1;i<=n;i++){
    if(!used[i]){
      minx=0;
      maxx=0;
      A[i]=0;
      dfs(i);
      if(maxx-minx>1e9+1){
	ans=0;
	break;
      }
    }
  }
  
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
  return 0;
}


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

#for分の繰り返し範囲
#A*B % B=0
#A*(B+1) % B=A
#→繰り返し範囲はA*Bまでで十分

for i in range(A,A*B+1,A):
  if i%B==C:
    print("YES")
    exit()
print("NO")

Measured memory_bytes: 2940