akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            int N = int.Parse(line);
            int uresisa = 0;
            uresisa += (N / 500) * 1000;
            N -= (N / 500) * 500;
            uresisa += (N / 5) * 5;
            Console.WriteLine(uresisa);
        }
    }
}


Measured memory_bytes: 13140
import sys

text = sys.stdin.read()

counts = {chr(code): 0 for code in range(ord('a'), ord('z')+1)}

for letter in text:
    letter = letter.lower()
    if letter in counts.keys():
        counts[letter] += 1

for key, val in counts.items():
    print(key + ' : ' + str(val),end='\n')


Measured memory_bytes: 5568
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#include <complex>
#define ll long long
#define INF 1000000000000000001
#define MOD 998244353
using namespace std;


int main(){
    int a,b;
    cin >> a >> b;
    if(a<=9 && b<=9){
        cout<<a*b<<endl;
    }else{
        cout<<-1<<endl;
    }
    return 0;
}


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

nums=[]
now=1
seq_count=0
for char in S:
        if char == str(now):
            seq_count+=1
        else:
            now=1-now
            nums.append(seq_count)
            seq_count=1
nums.append(seq_count)
if len(nums)%2==0:
    nums.append(0)
sums=[0]*(len(nums)+1)
for i in range(len(nums)):
    sums[i+1]=sums[i]+nums[i]

ans=0
for i in range(1,len(sums),2):
    left=i-1
    right = min(i+2*k,len(sums)-1)
    ans=max(ans,sums[right]-sums[left])
print(ans)


Measured memory_bytes: 7884
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

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

    multiset<int> m;
    REP(i, 0, N) {
        int a; cin >> a;
        auto itr = m.lower_bound(a);
        if (itr != m.begin()) m.erase(--itr);
        m.insert(a);
    }
    cout << m.size() << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int right=0;
	char S[2], T[2];
	cin >> S;
	cin >> T;
	for (int i = 0; i < 3; i++)
		if(S[i]==T[i])
		right++;
	cout << right;

}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < static_cast<int>(n); ++i)
#define per(i, n) for(int i = static_cast<int>(n)-1; i >= 0; --i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl); 
#define cop(a) for(auto x:(a)){cout << x << endl;}

using ll = long long;

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

constexpr char sp = ' ';
constexpr ll MOD = 1e9+7;
constexpr ll Mod = 998244353;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;
inline ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
inline ll inverse(ll n, ll m=MOD){ll a=n,b=m,x=1,y=0;while(b){ll t=a/b;a-=t*b;swap(a,b);x-=t*y;swap(x,y);}return (a%m+m)%m;}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll m=MOD){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    s<<'[';for(size_t i=0;i<v.size();++i){s << v[i];if(i < v.size()-1) s << ", ";}s<<']';return s;
}
struct __{ __(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15); } };

int main(){

    int n, k, s;
    cin >> n >> k >> s;


    if(s != 1e9){
        rep(i, k){
            cout << s << ' ';
        }
        rep(i, n-k){
            cout << s+1 << ' ';
        }
    }
    else{
        rep(i, k){
            cout << s << ' ';
        }
        rep(i, n-k){
            cout << 1 << ' ';
        }
    }
    cout << endl;



    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int A, B;

	cin >> A >> B;

	if (A <= 9 && B <= 9) cout << A * B << endl;
	else cout << -1 << endl;

	return 0;
}

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

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

    int counter = 0;
    for (int i = 1; i <= s.length(); i++) {
        auto c = s[i - 1];
        if (i % 2 == 1) {
            if (c == 'R' || c == 'U' || c == 'D')
                counter++;
        } else {
            if (c == 'L' || c == 'U' || c == 'D')
                counter++;
        }
    }

    cout << (counter == s.length() ? "Yes" : "No");
    return 0;
}


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

// https://atcoder.jp/contests/abc128/tasks/abc128_c

#include <iostream>
#include <vector>
#include <bitset>

struct Light
{
    int switches;
    int p;
};

bool isLightOn(const Light& light, int sw)
{
    int c = (sw & light.switches);
    int bits = bitset<32>(c).count();
    return bits % 2 == light.p;
}

int main(int argc, const char* argv[])
{
    int n, m;
    cin >> n >> m;

    vector<Light> lights(m);
    for(int i = 0; i < m; ++i)
    {
        int k;
        cin >> k;

        int switches = 0;
        for(int j = 0; j < k; ++j)
        {
            int si;
            cin >> si;
            si--;
            switches |= (1 << si);
        }
        lights[i].switches = switches;
    }

    for(int i = 0; i < m; ++i)
    {
        cin >> lights[i].p;
    }

    int swPatCount = 1 << n;
    int count = 0;
    for(int i = 0; i < swPatCount; ++i)
    {
        bool allOn = true;
        for(int j = 0; j < m; ++j)
        {
            if(!isLightOn(lights[j], i))
            {
                allOn = false;
                break;
            }
        }
        if(allOn)
        {
            count++;
        }
    }
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.*;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = 
            new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().trim().split(" ", 0);
        int a = Integer.parseInt(str[0]);
        int b = Integer.parseInt(str[1]);
        System.out.println((a + b) % 24);
    }
}

Measured memory_bytes: 20564
import sys
def input():
    return sys.stdin.readline()[:-1]
N=int(input())
l=[None]*N
for i in range(N):
    X,L=map(int,input().split())
    l[i]=(X-L,X+L)
l.sort(key=lambda x: x[1])
t=-10**12
a=0
for i in l:
    if t<=i[0]:
        a+=1
        t=i[1]
print(a)

Measured memory_bytes: 49884
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)x.size()
#define f first
#define s second
#define MAXN 2010
ll MOD = 1e9+7;

deque<int> A,B;
string S;
int N;
vi targets;
vpi left_right;

int main(){
	cin>>S;
	N = SZ(S);
	for (auto i:S)A.pb(i == '1');
	cin>>S;
	for (auto i:S)B.pb(i == '1');
	int ans = INT_MAX;
	for (int k=0;k<2;++k){
		targets.clear();
		targets.pb(-1);
		for (int i=0;i<N;++i)if (B[i])targets.pb(i);
		targets.pb(INT_MAX);
		//cout<<"Targets: ";for (auto x:targets)cout<<x<<' ';cout<<'\n';
		
		for (int i=0;i<=N;++i){
			// Total number of left shifts in the end
			left_right.clear();
			int wrong = 0;
			bool block = 0;
			
			for (int j=0;j<N;++j){
				int val = A[j];
				int new_ind = (j+N-i)%N;
				if (B[new_ind] == val)continue; // Already correct, no need to change anything
				++wrong;
				int first_intersect = *(--ub(ALL(targets), j));
				if (first_intersect == -1)first_intersect = targets[SZ(targets) - 2];
				if (first_intersect == -1){
					block = 1;
					break;
				}
				int ds = (j+N-first_intersect)%N;
				if (ds <= i)continue; // Already covered
				// Finding the first thing on the right
				int first_right = *(lb(ALL(targets), j));
				if (first_right == INT_MAX)first_right = targets[1];
				int rds = (first_right + N - j)%N;

				left_right.pb(mp(ds-i,rds));
			}
			if (block)continue;
			sort(ALL(left_right));
			int min_extra = MAXN;
			int min_right = 0;
			for (int left_weight = N;left_weight >= 0; --left_weight){
				while (SZ(left_right) && left_right.back().f > left_weight){
					min_right=max(min_right,left_right.back().s);
					left_right.pop_back();
				}
				min_extra = min(min_extra, left_weight + min_right);
			}
			int res = 2*min_extra + i + wrong;
			ans = min(ans,res);
			//cout<<"Shift "<<i<<" result "<<res<<'\n'; 
		}
		reverse(ALL(A));reverse(ALL(B));
	}
	if (ans == INT_MAX)cout<<-1;
	else cout<<ans;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>

#pragma region _define

#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_vO(v,n) f(i,0,n)cout<<v[i]<<endl;
#define all(a) a.begin(),a.end()
#define size(s) s.size()
#define endl "\n"
#define y() cout<<"Yes"<<endl
#define Y() cout<<"YES"<<endl
#define n() cout<<"No"<<endl
#define N() cout<<"NO"<<endl

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vs = vector<st>;
using vb = vector<bool>;
using si = stack<LL>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using v_pi = 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

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

/************************************************************************/
int n, m;
LL ans = 0;
void dfs(int v) {
	visited[v] = true;
	f(i, 0, n) {
		if (graph[v][i] == false)continue;
		if (visited[i] == true)continue;
		dfs(i);
	}
	return;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);

	cin >> n >> m;
	vi a(m), b(m);
	link(a, b, m);
	f(i, 0, m) {
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
		f(j, 0, n) {
			visited[j] = false;
		}
		dfs(0);
		bool bridge = false;
		f(j, 0, n) {
			if (visited[j] == false) {
				bridge = true;
			}
		}
		if (bridge)ans++;
		graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int>a(n);
	repp(i, 0, n)cin >> a[i];
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		if ((k-1) * i + 1 >= n) {
			ans = i;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fr first
#define sc second
void solve(){
    int n; 
    cin>>n; 
    long long sum = 0;
    for(int i=1;i<=n;i++){
        if(i%3==0 or i%5==0)continue;
        sum+=i;
    }
    cout<<sum<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
//    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;

int main(void){
    string str;
    cin >> str;
    long long c[26];
    fill(c,c+26,0);
    long long n = str.length();
    for(int i=0; i<n; i++){
        c[str[i]-'a']++;
    }
    
    long long sum;
    sum = n*(n-1)/2;
    for(int i=0; i<26;i++){
        sum -= c[i]*(c[i]-1)/2;
    }
    cout << sum+1 << endl;

    return 0;
}

Measured memory_bytes: 640
import numpy as np
import sys
input = sys.stdin.readline

N = int(input())

arr = np.empty((N, 3), dtype='int64')
for i in range(N):
    arr[i, 0], arr[i, 1] = input().split()
    arr[i, 2] = arr[i, 0] + arr[i, 1]

arr = arr[np.argsort(arr[:, 2])][::-1]

print(np.sum(arr[::2, 0]) - np.sum(arr[1::2, 1]))

Measured memory_bytes: 17848
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<utility>
using namespace std;
#define mp make_pair
#define X first
#define Y second
const int N=108;
int n,b[N],f[N];
pair<int,int>pa[N],pb[N];
vector<int>a[N];
bool findx(int x)
{
	int i;
	for(i=0;i<(int)a[x].size();i++)if(!b[a[x][i]])
	{
		b[a[x][i]]=1;
		if(!f[a[x][i]]||findx(f[a[x][i]]))return f[a[x][i]]=x,1;
	}
	return 0;
}
int main(void)
{
	int i,j;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d%d",&pa[i].X,&pa[i].Y);
	for(i=1;i<=n;i++)scanf("%d%d",&pb[i].X,&pb[i].Y);
	for(i=1;i<=n;i++)
	for(j=1;j<=n;j++)if(pa[i].X<pb[j].X&&pa[i].Y<pb[j].Y)a[i].push_back(j);
	for(j=1;j<=n;j++)f[j]=0;
	int ans=0;
	for(i=1;i<=n;i++){for(j=1;j<=n;j++)b[j]=0;if(findx(i))ans++;}
	printf("%d",ans);
	return 0;
}

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main()
{
    ll N,K,S;
    cin >> N >> K >> S;
    vector<ll> ans(N,S);

    if( S == 1000000000 )
    {
        if( K == 0 )
        {
            vector<ll> ans2(N,S-1);
            rep(i,ans2.size())
            {
                cout << ans2[i];
                if( i + 1 != ans2.size()) cout << " ";
            }
            cout << endl;
            return 0;
        }
        else
        {
            ll key = 0;
            ll tmp = 0;
            for( ll i = 0;i < N;i++ )
            {
                key++;
                if( tmp == N-K )
                {
                    break;
                }
                if( key == S )
                {
                    key = 0;
                    continue;
                }
                ans[i] = 3;
                tmp++;
            }
        }
    }
    else if( K == 0 )
    {
        rep(i,N) ans[i] = S+1;
    }
    else if( S != 2 )
    {
        rep(i,N-K) ans[i] = S+1;
    }
    else
    {
        rep(i,N-K) ans[i] = S-1;
    }

    rep(i,ans.size())
    {
        cout << ans[i];
        if( i + 1 != ans.size()) cout << " ";
    }
    cout << endl;
}


Measured memory_bytes: 2816
using System;

namespace AtCoder.Company.SoundHound
{
    class a
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Trim();
            var spl = line.Split(' ');
            var a = int.Parse(spl[0]);
            var b = int.Parse(spl[1]);
            Console.WriteLine(a + b == 15 ? "+" : a * b == 15 ? "*" : "x");
        }
    }
}


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

int main()
{
string s ;
cin >> s ;
string t ;
cin >> t ;
rep(i,s.size()){
  if(s[i]!=t[i])ans++;
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 3920
#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template<typename T> void swap(T *t1, T *t2){ T* tmp=t1; t1=t2; t2=tmp;}
Int tmpi = 0;
double tmpd = 0.0;


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

    char s[100001];
    cin >> s;
    Int len = strlen(s);
    char marker = '0';
    Int min = 1000000000;
    
    for(Int i=0; i<2; i++){
        Int sum = 0;
        if(i==1){
            marker = '1';
        }
        for(Int j=0; j<len; j++){
            if(j%2==0){
                sum += s[j]==marker ? 0 : 1;
            }else{
                sum += s[j]!=marker ? 0 : 1;
            }
        }
        min = sum < min ? sum : min;
    }
    cout << min << endl;
    return 0;
}

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

int main(){
  
  int k,n;
  cin >> k >> n;
  
  int first,a,next,saidai = 0;
  cin >> first;
  a = first;

  for ( int i = 1; i < n; i++){
    cin >> next;
    saidai = max(saidai,next-a);
    a = next;
  }
  
  saidai = max(saidai,k-a+first);
  
  cout << k - saidai << endl;
    

}

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

int n,k;
int a[200005];

bool check(int x){
    long long res=0;
    for(int i=1;i<=n;i++){
        res+=(a[i]-1)/x;
    }
    return res<=k;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int l=1,r=1e9,m,res;
    while(l<=r){
        m=l+r>>1;
        if(check(m)){
            r=m-1;
            res=m;
        }else{
            l=m+1;
        }
    }
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 4372
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=[S() for _ in range(n)]
  return len(set(l))

# main()
print(main())


Measured memory_bytes: 37232
import math
def prime_factorization(n):
    # s * s <= n
    s = math.floor(math.sqrt(n)) # 平方根を小数点切り捨て

    ans = [] # [素数, 指数]のリスト

    # 2からsまでの素因数を求める
    for i in [2] + list(range(3, s + 1, 2)):
        if n < i:
            break
        if n % i == 0:
            r = 0 # 指数カウンタクリア
            while n % i == 0:
                r += 1
                n //= i
            ans.append([i, r])

    # 残った素数を追加
    # if n > s:
    if n >= s:  # n = 1でもよいように
        ans.append([n, 1])

    return(ans)

N = int(input())
pf = prime_factorization(N)
# print(pf)
ans = 0
for p, e in pf:
    if p == 1: break
    for i in range(1, 50):
        if e < i: break
        e -= i
        ans += 1

print(ans)

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintStream out = new PrintStream(System.out);
        int a, b;

        a = sc.nextInt();
        b = sc.nextInt();

        out.println((a+b < 10)? a+b: "error");
        
        sc.close();
    }
}

Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
#define lc "\n"
#define fast_io ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define int long long
#define c(a,n) for(int i = 0; i < n; i++) cin >> a[i];
#define ffor(n) for(int i = 0; i < n; i++)
#define float long double
typedef vector<int> vi;
typedef vector<float> vf;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef map<string,int> msi;
typedef map<int,int> mii;
typedef unordered_map<string,int> umsi;
 
 
int32_t main()
{
    fast_io;
    int n,w;
    cin>>n>>w;
    vector<pair<int,int>>a(n);
    int sumval=0;
    for(int i=0;i<n;i++){
        cin>>a[i].first>>a[i].second;
        sumval+=a[i].second;

    } 
    
    vi dp(sumval+1,LLONG_MAX);
    dp[0]=0;

    for(int i=0;i<n;i++)
    {
        for(int curval=sumval-a[i].second;curval>=0;curval--)
        {
            if(dp[curval]!=LLONG_MAX)
            dp[curval+a[i].second]=min(dp[curval+a[i].second],dp[curval]+a[i].first);
        }
    }
    int ans=0;
    for(int i=0;i<=sumval;i++)
    {
        if(dp[i]<=w)ans=i;
    }
    cout<<ans<<lc;

    return 0;
}

Measured memory_bytes: 3924
//#define MYDEBUG
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <cstdio>
#include <queue>
#include <stack>

#ifdef MYDEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define all(x) x.begin(), x.end()
#define umap unordered_map
using namespace std;

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last)
      out << ",";
  }
  out << "]";
  return out;
}

void solve() {
  string s[3];
  for (int i = 0; i < 3; ++i) {
    cin >> s[i];
    char c = s[i][0] + 'A' - 'a';
    cout << c;
  }
  cout << endl;
}

int main() {
  solve();
  return 0;
}



Measured memory_bytes: 256
import heapq
n = int(input())
g = [[] for i in range(n)]
for i in range(n-1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    g[a].append((b, c))
    g[b].append((a, c))

q, k = map(int, input().split())
k -= 1
hq = []
d = [10**18] * n
d[k] = 0
heapq.heappush(hq, (0, k))
while len(hq):
    dist, v = heapq.heappop(hq)
    if d[v] < dist:
        continue
    for e in g[v]:
        nv, l = e
        if d[nv] > d[v] + l:
            d[nv] = d[v] + l
            heapq.heappush(hq, (d[nv], nv))

for i in range(q):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    print(d[x] + d[y])


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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
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()))

#BinaryIndexedTree
def bit_add(i,w):
    x = i+1
    while x <= n:
        bit[x-1] += w
        x += x & -x
    return

def bit_sum(i):
    res = 0
    x = i+1
    while x > 0:
        res += bit[x-1]
        x -= x & -x
    return res

n,d,a = LI()
bit = [0]*(n+1)
xh = [LI() for _ in range(n)]
xh.sort()
X = [x for x,_ in xh]
lst = []
for i in range(n):
    x,h = xh[i]
    r = br(X,x+2*d)
    lst.append((i,h,r))

ans = 0
for i,h,r in lst:
    tmp = max(0,math.ceil((h - bit_sum(i))/a))
    ans += tmp
    bit_add(r,-tmp*a)
    bit_add(i,tmp*a)
print(ans)


Measured memory_bytes: 126384
# https://atcoder.jp/contests/aising2019/submissions/3986315
# 解説のように 連結成分を求めてから、bfsする
import sys
sys.setrecursionlimit(2 * 10 ** 5)

H, W = map(int, input().split())
s = [input() for _ in range(H)]

ans = 0

dx = [0, 0, 1, -1]
dy = [1, -1, 0, 0]

un_reached = [[True for i in range(W)] for j in range(H)]


def isIn(x, y):
    return 0 <= x < H and 0 <= y < W


def dfs(x, y):
    un_reached[x][y] = False
    if s[x][y] == '#':
        cc[1] += 1
    else:
        cc[0] += 1

    for i in range(4):
        nx = x+dx[i]
        ny = y+dy[i]
        if isIn(nx, ny) and s[nx][ny] != s[x][y] and un_reached[nx][ny]:
            dfs(nx, ny)


for i in range(H):
    for j in range(W):
        if un_reached[i][j]:
            cc = [0 for _ in range(2)]
            dfs(i, j)
            ans += cc[1]*cc[0]
print(ans)


Measured memory_bytes: 148212
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil, atan, pi
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')
import string
# string.ascii_lowercase
from bisect import bisect_left
MOD = int(1e9)+7
INF = float('inf')


def solve():
    # n, m = [int(x) for x in input().split()]
    a,b,x,y = [int(x) for x in input().split()]

    r = x - a
    u = y - b

    ans = ''

    ans += 'D'
    ans += 'R' * (r + 1)
    ans += 'U' * (u + 1)
    ans += 'L'
    ans += 'D' * u
    ans += 'L' * r

    ans += 'L'
    ans += 'U' * (u + 1)
    ans += 'R' * (r + 1)
    ans += 'D'
    ans += 'L' * r
    ans += 'D' * u

    print(ans)

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

azyxwvutsrqponmlkjihgfedcb

"""


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

int main(){

vector<vector<int>> bingo(3, vector<int>(3));

for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> bingo.at(i).at(j);
    }
  }

    int N;
  cin >> N;

for (int e = 0; e < N; e++){

    int b;
    cin >> b;

   for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      if (bingo.at(i).at(j) == b) {
          bingo.at(i).at(j) = 0;
      }
    }
 }

}

string ans;
if(bingo.at(0).at(0) == 0 && bingo.at(0).at(1) == 0 && bingo.at(0).at(2) == 0){
    ans = "Yes";
}
else if(bingo.at(1).at(0) == 0 && bingo.at(1).at(1) == 0 && bingo.at(1).at(2) == 0){
    ans = "Yes";
}
else if(bingo.at(2).at(0) == 0 && bingo.at(2).at(1) == 0 && bingo.at(2).at(2) == 0){
    ans = "Yes";
}
else if(bingo.at(0).at(0) == 0 && bingo.at(1).at(0) == 0 && bingo.at(2).at(0) == 0){
    ans = "Yes";
}
else if(bingo.at(0).at(1) == 0 && bingo.at(1).at(1) == 0 && bingo.at(2).at(1) == 0){
    ans = "Yes";
}
else if(bingo.at(0).at(2) == 0  && bingo.at(1).at(2) == 0  && bingo.at(2).at(2) == 0 ){
    ans = "Yes";
}
else if(bingo.at(0).at(0) == 0  && bingo.at(1).at(1) == 0  && bingo.at(2).at(2) == 0 ){
    ans = "Yes";
}
else if(bingo.at(2).at(0) == 0  && bingo.at(1).at(1) == 0  && bingo.at(0).at(2) == 0 ){
    ans = "Yes";
}
else{
ans = "No";
}
cout << ans << endl;
}

Measured memory_bytes: 256
a, b, c, x, y = map(int, input().split())
if x == y:
    ans = min(x * a + y * b, x * 2 * c)
elif x > y:
    ans = min(x * a + y * b, x * 2 * c, y * 2 * c + (x - y) * a)
else:
    ans = min(x * a + y * b, y * 2 * c, x * 2 * c + (y - x) * b)
print(ans)

Measured memory_bytes: 3064
N, K = map(int, input().split())
X = list(map(int, input().split()))

ans = 10**18
for i in range(N - K + 1):
    d1 = X[i + K - 1] - X[i] + abs(X[i])
    d2 = X[i + K - 1] - X[i] + abs(X[i + K - 1])
    # print('d', d)
    ans = min(ans, d1, d2)
print(ans)


Measured memory_bytes: 14384
#include <stdio.h>
#include <math.h>

int main(void) {
    int a[4], b[4], i, j, hit[4], cblow, chit;

    while (scanf("%d", &a[0]) != EOF) {
        for (i = 1; i < 4; i++) scanf("%d", &a[i]);
        for (i = 0; i < 4; i++) scanf("%d", &b[i]);
        for (i = 0; i < 4; i++) {
            hit[i] = 0;
        }

        for (i = 0, chit = 0; i < 4; i++) {
            chit += hit[i] = a[i] == b[i];
        }
        for (i = 0, cblow = 0; i < 4; i++) {
            if (hit[i]) continue;
            for (j = 0; j < 4; j++) {
                if (i == j) continue;
                if (a[i] == b[j]) cblow++;
            }
        }
        printf("%d %d\n", chit, cblow);
    }
    return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
using boost::multiprecision::integer_modulus;
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
const int MOD = 1000000007;

int main() {
    int N;
    cin >> N;
    cpp_int ablcm = 1, b = 0;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        int t = gcd(integer_modulus(ablcm, a), a);
        (b *= (a / t)) += ablcm /= t;
        ablcm *= a;
    }
    cout << integer_modulus(b, MOD) << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) (long long)((a).size())

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    
    ll x,i,j;
    cin>>x;
    i = 1;
    while((i*(i+1))/2 < x) i++;
    cout<<i;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  string tic;
  while(cin>>tic){
    char s = 'o';
    char ans = 'd';;
    for(int i=0;i<2;i++){
      if (tic[0]==s&&tic[1]==s&&tic[2]==s) ans = s;
      if (tic[3]==s&&tic[4]==s&&tic[5]==s) ans = s;
      if (tic[6]==s&&tic[7]==s&&tic[8]==s) ans = s;
      if (tic[0]==s&&tic[3]==s&&tic[6]==s) ans = s;
      if (tic[1]==s&&tic[4]==s&&tic[7]==s) ans = s;
      if (tic[2]==s&&tic[5]==s&&tic[8]==s) ans = s;
      if (tic[0]==s&&tic[4]==s&&tic[8]==s) ans = s;
      if (tic[2]==s&&tic[4]==s&&tic[6]==s) ans = s;
      s = 'x';
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int n;
  ll x[1000], y[1000];

  scanf("%d", &n);

  bool ok = true;

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

  if (!ok) {
    puts("-1");
    return 0;
  }

  for(int i=0;i<n;i++){
    ll tmp = x[i] + y[i];
    y[i] = x[i] - y[i];
    x[i] = tmp;
  }

  int m = !(x[0]%2) + 31;
  ll d[40];

  for(int i=0;i<31;i++){
    d[i] = 1LL << (30 - i);
  }

  if(m == 32) d[31] = 1;

  printf("%d\n", m);
  for(int i=0;i<m;i++)
    printf("%lld%c", d[i], " \n"[m==i+1]);

  for(int i=0;i<n;i++){
    bool ans1[40], ans2[40];
    ll X = x[i], Y = y[i];

    ll dX = 0, dY = 0;

    for(int j=0;j<m;j++){
      ans1[j] = X >= 0;
      ans2[j] = Y >= 0;

      if(ans1[j]) X -= d[j];
      else X += d[j];

      if(ans2[j]) Y -= d[j];
      else Y += d[j];
    }

    assert(X == 0 && Y == 0);

    for(int j=0;j<m;j++){
      printf("%c", "LDUR"[ans1[j]*2+ans2[j]]);
    }
    puts("");
    /*
    for(int j=0;j<m;j++){
      switch("LDUR"[ans1[j]*2+ans2[j]]){
      case 'R':
        dX += d[j];
        break;
      case 'L':
        dX += -d[j];
        break;
      case 'U':
        dY += d[j];
        break;
      case 'D':
        dY += -d[j];
        break;
      }
    }

    debug(dX);
    debug(dY);
    */
  }


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;

int main(){


    int X, Y;
    cin >> X >> Y;
    int ans = 0;
    if (X == 1) {
        ans += 300000;
    } else if (X ==2) {
        ans += 200000;
    } else if (X ==3) {
        ans += 100000;
    }

    if (Y == 1) {
        ans += 300000;
    } else if (Y ==2) {
        ans += 200000;
    } else if (Y ==3) {
        ans += 100000;
    }

    if ( X == 1 && Y == 1){
        ans += 400000;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from fractions import gcd

a, b, c, d = map(int, input().split())

lcm = int(c * d / gcd(c, d))

quotient_c = b // c - (a - 1) // c
quotient_d = b // d - (a - 1) // d
quotient_lcm = b // lcm - (a - 1) // lcm

print(b - a + 1 - quotient_c - quotient_d + quotient_lcm)

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

static class Program
{
  static void Main()
  {
    var S = Console.ReadLine();
    var T = Console.ReadLine();
    foreach (int i in Enumerable.Range(0, S.Length)) {
      var U = S.Substring(i) + S.Substring(0, i);
      if (T == U) {
        Console.WriteLine("Yes");
        return;
      }
    }
    Console.WriteLine("No");
  }
}

Measured memory_bytes: 11220
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

nei = []
ans = 0
color = []

def dfs(i, fr, hop):
    global nei, color, ans
    ans = max(ans, hop)
    color[i] = 1
    for k in nei[i]:
        if k != fr and color[k] == -1:
            dfs(k, i, hop+1)

def dijkstra(n, start, nbl):
    """n: 頂点数, start: 始点, nbl: 隣接リスト"""
    import heapq
    WHITE = 1<<5
    GRAY = 1<<10
    BLACK = 1<<15
    INF = 1<<20
    color = [WHITE] * n
    distance = [INF] * n
    # parent = [-1] * n
    q = []

    distance[start] = 0
    heapq.heappush(q, (0, start))
    while len(q) != 0:
        du, u = heapq.heappop(q)
        # print("u: {}, du: {}".format(u, du))
        color[u] = BLACK
        if distance[u] < du:
            continue
        for next, cost in nbl[u]:
            if color[next] != BLACK and distance[u] + cost < distance[next]:
                distance[next] = distance[u] + cost
                color[next] = GRAY
                heapq.heappush(q, (distance[next], next))
    for i, v in enumerate(distance[:]):
        if v == INF:
            distance[i] = -1
    return distance

def main():
    global nei, color
    h, w = list(map(int, input().strip().split()))
    G = [0] * h
    nei = [[] for _ in range(w*h)]
    color = [-1] * (w*h)
    for i in range(h):
        G[i] = input().strip()
    for i in range(h):
        for j in range(w):
            if G[i][j] == '.':
                if i != 0 and G[i-1][j] == '.':
                    nei[w*i+j].append((w*(i-1)+j, 1))
                if i != h-1 and G[i+1][j] == '.':
                    nei[w*i+j].append((w*(i+1)+j, 1))
                if j != 0 and G[i][j-1] == '.':
                    nei[w*i+j].append((w*i+j-1, 1))
                if j != w-1 and G[i][j+1] == '.':
                    nei[w*i+j].append((w*i+j+1, 1))
    ans = 0
    for i in range(h):
        for j in range(w):
            if G[i][j] == '.':
                # print(dijkstra(w*h, w*i+j, nei))
                ans = max(max(dijkstra(w*h, w*i+j, nei)), ans)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 60508
#include <iostream>
using namespace std;
int main(void){
    int H,W;
    while(1){
    cin>>H>>W;
    if(H == 0&&W == 0)break;
        for(int j = 1;j <= H;j++){
            for(int a = 1;a <= W;a++){
            cout<<"#";
            }
        cout<<endl;
        }
    cout<<endl;
    }
    return 0;
}



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

int main()
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    std::ifstream in("b.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int n, x;
    cin >> n >> x;

    int d = 0;
    int ans = 1;

    vector<int> l(n);
    rep(i, n) cin >> l[i];

    for (int i = 0; i < n ;i++)
    {
        d = d + l[i] ;
//        cout << "i:" << i << " l:" << l[i] << " d:" << d << endl;
        if (d > x)
        {
            break;
        }
        ans++;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner sc=new Scanner(System.in);
		boolean a[] =new boolean[10001];
		Arrays.fill(a, true);
		a[0]=a[1]=false;
		for(int i=2; i*i<=10000; i++)
		{
			if(!a[i])
				continue;
			for(int j=i*2; j<=10000; j+=i)
				a[j]=false;
		}
		while(sc.hasNext())
		{
			int n=sc.nextInt();
			if(n==0) return;
			int sum=0;
			int ans=0;
			for(int i=2; i<=n; i++)
			{
				sum =0;
				if(a[i])
					for(int j=i; j<=n; j++)
					{
						if(a[j])
						{
							sum+=j;
							if(n==sum)
								ans++;
						}
						if(sum>=n)
							break;
					}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 12000
#include<stdio.h>
int main(void)
{
 int a,b;

 scanf("%d %d\n",&a,&b);

 if(a>b)
{
 printf("a > b\n");
}

  if(a<b)
{
 printf("a < b\n");
}

  if(a==b)
{
 printf("a == b\n");
}

return 0;
}


Measured memory_bytes: 2680
#include <bits/stdc++.h>
using namespace std;
#define ll long long 

bool arr[109];

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	memset(arr, false, sizeof arr);
	int x, n, y;
	cin>>x>>n;
	for(int i = 0; i < n; i++) {
		cin>>y;
		arr[y] = true;
	}
	int ans = INT_MAX;
	for(int i = x; i <= 101; i++) {
		if(!arr[i]) {ans = i; break;}
	}
	for(int i = x; i >= 0; i--) {
		if(!arr[i] && abs(x - i) <= abs(ans - x)) {ans = i; break;}
	}
	cout<<ans<<endl;
}




Measured memory_bytes: 3620
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

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

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M = map(int, input().split())
path = [list(map(int, input().split())) for i in range(M)]
ans = 0
for i in range(M):
    flag = 1
    bridge = UnionFind(N)
    for j in range(M):
        if i != j:
            bridge.union(path[j][0]-1, path[j][1]-1)
    for j in range(N):
        if not(bridge.same(0, j)):
            
            flag = 0
    if not(flag):
        ans += 1
print(ans)
        


Measured memory_bytes: 42864
N=int(input())
list1 = list(map(int, input().split()))

list1.sort()
x=list1[0]
y=list1[-1]

s=0
list2=[]
while x+s<=y:
    list2.append(x+s)
    s=s+1

list3=[]
for j in list2:
    w=0
    for i in list1:
        w=w+(i-j)*(i-j)
    list3.append(w)

list3.sort()
print(list3[0])


Measured memory_bytes: 9184
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    static final FS sc = new FS();  // 封装输入类
    static final PrintWriter pw = new PrintWriter(System.out);

    public static void main(String[] args) {
        int l = sc.nextInt(), r = sc.nextInt(), d = sc.nextInt();
        int res = 0;
        for(int i = l;i <= r;i++) {
            if (i % d == 0) {
                res++;
            }
        }
        pw.println(res);
        pw.flush();
    }

    static class FS {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");
        String next() {
            while(!st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch(Exception ignored) {}
            }
            return st.nextToken();
        }
        int[] nextArray(int n) {
            int[] a = new int[n];
            for(int i = 0;i < n;i++) {
                a[i] = nextInt();
            }
            return a;
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 32880
#include<iostream>

using namespace std;

const static int MAX = 50;

char grid[MAX][MAX];
int H, W;

int main() {
  cin >> H >> W;

  for (int i = 0; i < H; i++) 
    cin >> grid[i];

  bool f = true;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (grid[i][j] == '#') {
        bool chk = false;
        if (i > 0)
          if (grid[i - 1][j] == '#') chk = true;
        if (i < H)
          if (grid[i + 1][j] == '#') chk = true;
        if (j > 0)
          if (grid[i][j - 1] == '#') chk = true;
        if (j < W)
          if (grid[i][j + 1] == '#') chk = true;

        if (chk == false) {
          f = false;
          break;
        }
      }
    }
    if (f == false) {
      break;
    }
  }

  if (f == true)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003,INF=1<<30;

int main(){
    
    int N;
    string S;cin>>N>>S;
    for(int i=0;i<S.size();i++){
        S[i]+=N;
        if(S[i]>'Z') S[i]-=26;
    }
    
    cout<<S<<endl;
}



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

constexpr bool all_differ(const int x, const int y, const int z) {
    return !(x == y || x == z || y == z);
}

constexpr bool is_triangle(const int x, const int y, const int z) {
    return x + y > z && x + z > y && y + z > x;
}

int count_triangles(const vector<int> &xs) {
    const int sz = xs.size();
    int ans = 0;

    for (int i = 0; i < sz - 2; ++i) {
        for (int j = i + 1; j < sz - 1; ++j) {
            for (int k = j + 1; k < sz; ++k) {
                if (all_differ(xs[i], xs[j], xs[k]) &&
                    is_triangle(xs[i], xs[j], xs[k])) {
                    ++ans;
                }
            }
        }
    }

    return ans;
}

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

    int sz;
    cin >> sz;
    vector<int> xs(sz, 0);
    for (auto &x : xs) cin >> x;

    cout << count_triangles(xs) << '\n';

    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;
#define FI first
#define SE second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))


int main()
{
    int A, B;
    cin >> A >> B;
    cout << max({A + B, A - B, A * B}) << endl;
}


Measured memory_bytes: 256
n , m = gets.chomp.split.map(&:to_i)
sarr = Array.new(m)
m.times do |i|
	sarr[i] = gets.chomp.split.map(&:to_i).map{|s| s- 1}
	sarr[i] = sarr[i].slice(1, sarr[i].length-1)
end 
parr = gets.chomp.split.map(&:to_i)


def check(sarr, parr, bits)
	sarr.length.times do |i|
		cnt = 0
		sarr[i].each do |ss|
			cnt += 1 if bits[ss]
		end
		return false if cnt.even? != parr[i].even? 
	end
	return true
end



ccnt = 0
[false, true].repeated_permutation(n) do |bits|
	ok = check(sarr, parr, bits)
	#p bits 
	#puts "ok:#{ok}"; puts
	ccnt += 1 if ok 
end

puts ccnt

Measured memory_bytes: 14304
N = int(input())
W = [input() for _ in range(N)]
l = [W[0]]
for i in range(N - 1):
  if W[i][-1] == W[i + 1][0] and not W[i + 1] in l:
    l.append(W[i + 1])
  else:
    break
print("Yes" if len(l) == N else "No")

Measured memory_bytes: 3060