akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pb          push_back
#define endl        '\n'
#define pll         pair<int,int>
#define vll          vector<int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define int	    int64_t
#define ios     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
int n,i,j,k,l,sum=0,flag=0,t,w[101],v[101],ans=0;
int dp[100001];
void solve(){
	int W;
    cin>>n>>W;
    for(int i=1;i<=n;i++){
    	cin>>w[i]>>v[i];
    }
    memset(dp,1,sizeof dp);
    dp[0]=0;
    int ans =0;
    for(int j=1;j<=n;j++){
    	for(int val = 100000;val>=1;val--){
    		if(val-v[j]>=0 && dp[val-v[j]]+w[j]<=W){
    			dp[val] = min(dp[val],dp[val-v[j]]+w[j]);
    		}
    		if(dp[val]<=W)	ans=max(ans,val);
    	}
    	
    }
    cout<<ans<<endl;
}
signed main()
{
    ios
    int test = 1;
    //cin>>test;
    while(test--){
    	solve();
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)

                    
using ll = long long;
using ull = unsigned long long;
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; }
const ll mod = 1e9+7;
void chmod(ll &M){
  if(M >= mod) M %= mod;
  else if(M < 0){
     M += (abs(M)/mod + 1)*mod;
    M %= mod;
}
}
ll modpow(ll x, ll n){
   if(n==0) return 1;
  ll res=modpow(x, n/2);
 if(n%2==0) return res*res%mod;
else return res*res%mod*x%mod;
}
int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };
long long GCD(long long a, long long b) {
  if (b == 0) return a;
  else return GCD(b, a % b);
}

using namespace std;
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
int main() 
{
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
}


Measured memory_bytes: 3588
n=int(input())
ans=[]
if n%2:
    for i in range(1,n):
        ans.append((i,n))
    for i in range(1,n):
        for j in range(i+1,n):
            if j!=n-i:
                ans.append((i,j))
else:
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            if j!=n+1-i:
                ans.append((i,j))
print(len(ans))
for a in ans:
    print(*a)

Measured memory_bytes: 43120
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for(auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n + 1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for(auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for(auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for(auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int>> name((h), vector<int>(w));
#define myCeil(dividend, divisor) ceil((double)(dividend) / (double)(divisor))
#define myFloor(dividend, divisor) floor((double)(dividend) / (double)(divisor))
#define calcDigits(num) floor(log10(num)) + 1

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl;
#define dv(name, value) cerr << (name) << " is " << (value) << endl;
#define da(v)                                                                                                          \
  cerr << "[";                                                                                                         \
  REPI(itr, v) { cerr << *itr << (itr != --v.end() ? ", " : ""); }                                                     \
  cerr << "]" << endl;
#define dpa(v)                                                                                                         \
  cerr << "[ " << endl;                                                                                                \
  REPI(itr, v) {                                                                                                       \
    cerr << "  [" << (*itr).first << ", " << (*itr).second << ']' << (itr != --v.end() ? "," : "") << endl;            \
  }                                                                                                                    \
  cerr << "]" << endl;

void solve(long long K, std::string S) {
  int len = S.size();

  REP(x, len) {
    if(x == K) {
      cout << "...";
      break;
    };

    cout << S.at(x);
  }
  cout << endl;
}

signed main() {
  long long K;
  scanf("%lld", &K);
  std::string S;
  std::cin >> S;
  solve(K, S);
}


Measured memory_bytes: 3704
N = int(input()) 
m = N
i = 0
sum = 0
while N >= 10**i:
    i += 1

for j in range(i):
    sub = N // 10 ** (i -1 - j) 
    sum = sum + sub
    N = N - sub * (10 **(i - 1 - j))

if m % sum == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<stdio.h>

int main(void)

{

 int a,b,c,i;

 int count=0;


 scanf("%d %d %d",&a,&b,&c);


 for(i=a; i<b+1; i++){


   if(c%i==0){


    count=count+1;


   }


 }


 printf("%d\n",count);


 return 0;


}

Measured memory_bytes: 596
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int count = 0;
        while(true){
            int n = sc.nextInt();
            int s = sc.nextInt();
            if(n == 0 && s == 0) break;
            count = sum(n, s, 0, 0, 0);
            System.out.printf("%d\n",count);
        }
    }

    public static int sum(int n,int s,int a,int b,int c){
        int x = 0;
        if(a==s && b==n && c==10)return 1;
        if(c==10)return 0;
        x += sum(n, s, a+c, b+1, c+1);
        x += sum(n, s, a, b, c+1);
        return x;
    }
}


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

int main() {
  int A, B;
  cin >> A >> B;
  if ((1 <= A && A <= 9) && (1 <= B && B <= 9)) {
    cout << A * B << endl;
  } else {
    cout << -1 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main()
{
    ll d,t,s;
    cin>>d>>t>>s;
    
    double t1=d/(double)s;
    
    if(t1<=t)
    {
        cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;
}

Measured memory_bytes: 3584
#include<stdio.h>
int main() {
	int n,i,min,max,data[10000];
	long sum = 0;
	scanf("%d",&n);
	if(0 < n && n <= 10000) {
		for(i = 0;i < n;i++) {
			scanf("%d",&data[i]);
		}
		min = data[0]; max = data[0];
		for(i = 0;i < n;i++) {
			if(data[i] < min) {
				min = data[i];
			} else if(data[i] > max) {
				max = data[i];
			}
			sum += data[i];
		}
	}
	printf("%d %d %ld\n",min,max,sum);
	return 0;
}

Measured memory_bytes: 1820
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main(int argc, char const *argv[])
{
    int N, C, K;
    int T[100000];
    cin >> N >> C >> K;
    for(int i=0; i<N; i++){
        cin >> T[i];
    }
    sort(T ,T+N);
    int bus_num = 1;
    int limit = T[0] + K;
    int c=1;
    for(int i=1; i<N; i++){
        if(c==C){
            bus_num++;
            c = 1;
            limit = T[i]+K;
            continue;
        }
        if(T[i] > limit){
            bus_num++;
            c = 1;
            limit = T[i]+K;
            continue;
        }
        c++;
    }
    cout << bus_num;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--) 
#define Rep(i,a) for(int i = 0; i < a; i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ab(x) ((x) < 0 ? -(x) : (x))
using namespace std;
typedef long long LL;
typedef map<int, int>::iterator mit;
typedef set<int>::iterator sit;
const int N = 1e5 + 10;
int n, m, f[N], r[N], c0, c1, c2, sz[N], szsum = 0;
bool mark[N];
void find(int x) {
	if (f[x] == x) return;
	else {
		find(f[x]);
		r[x] ^= r[f[x]];
		f[x] = f[f[x]];
	}
}
int main() {
	scanf("%d%d",&n,&m);
	rep(i,1,n) f[i] = i, r[i] = 0, sz[i] = 1;
	rep(i,1,m) {
		int a, b; scanf("%d%d",&a,&b);
		find(a), find(b);
		int fa = f[a], fb = f[b];
		if (fa != fb) f[fa] = fb, r[fa] = r[a] ^ r[b] ^ 1, sz[fb] += sz[fa];
		else if (r[a] ^ r[b] ^ 1) mark[a] = true;
	}
	rep(i,1,n) find(i), mark[f[i]] |= mark[i];
	rep(i,1,n) if (f[i] == i) {
		if (sz[i] == 1) c0++;
		else if (!mark[i]) c2++, szsum += sz[i];
		else c1++, szsum += sz[i];
	}
	LL ans = 1LL * c0 * c0 + 2LL * c0 * szsum + 1LL * (c1 + c2) * (c1 + c2) + 1LL * c2 * c2;
	cout <<ans<<endl; 
	return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include<string>
#include<vector>
#include <algorithm>
#include<set>
#include<array>
# define rep(x,n) for(int i=x; i<n; i++)

using namespace std;
int main() {
	int a;
	cin >> a;
	set<char>s;
	rep(0,a) {
		char b;
		cin >> b;
		s.insert(b);
	}
	if (s.size() == 4)
	{
		cout << "Four";
	}
	else
	{
		cout << "Three";
	}

}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
struct ab{
	long long j,t;
};
bool tmp(ab a,ab b){
	if(a.j<b.j) return true;
	else if(a.t<a.t) return true;
	return false;
}
int main(){
	long long n,i;
	cin>>n;
	ab a[n];
	for(i=0;i<n;i++){
		cin>>a[i].t>>a[i].j;
	}
	sort(a,a+n,tmp);
	for(i=0;i<n;i++){
		if(i!=0)
			a[i].t+=a[i-1].t;
		if(a[i].t>a[i].j){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}

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

int main() {
  int x, i = 2;
  cin >> x;
  for (;; x++) {
  	for (i = 2; x % i != 0 && i < x; i++);
    if (x == i)break;
  }
  cout << x << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i=0;i<(int)(n);++i)
template <typename T> ll gcd(T a, T b) {return b?gcd(b, a%b):a;}
template <typename T> ll lcm(T a, T b) {return a * b / gcd(a, b);};
template <typename T> inline void chmin(T &a, const T& b){if(a>b)a=b;}
template <typename T> inline void chmax(T &a, const T& b){if(a<b)a=b;}

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

ll grid[2][200000] = {0};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; ++i) {
    cin >> vec[i];
    ++(grid[0][vec[i]-1]);
  }
  ll memo = 0;
  for (int i = 0; i < n; ++i) {
    if (grid[1][vec[i]-1] == 0) {
      grid[1][vec[i]-1] = (ll)(choose(grid[0][vec[i]-1], 2));
      memo += grid[1][vec[i]-1];
    }
  }
  
  
  for (int i = 0; i < n; ++i) {
    cout << memo - grid[1][vec[i]-1] + grid[1][vec[i] - 1] * (grid[0][vec[i]-1] - 2) / grid[0][vec[i]-1] << '\n';
  }
  
}


Measured memory_bytes: 5504
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
using namespace std;

int main(){
    int T,d;
    cin>>T;
    int a[101];
    for(int i=0;i<101;i++){
        a[i]=0;
    }
    int cnt=0;
    while(T--){
        cin>>d;
        if(a[d]==0){
            cnt++;
            a[d]++;
        }

    }
    cout<<cnt;
}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll x; cin >> x;
  vector<bool> pr = prime_table(10000000);
  for(ll i=x;i<=10000000;++i) {
    if(pr[i]) {
      cout << i << endl;
      break;
    }
  }

}


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

typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define DECIM8  fixed<<setprecision(8) 
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

using namespace std;
int main(void)
{
  for(;;){
    int n;
    cin >> n;
    if(!n) return 0;
    int answer=0;
    int l=0,r=0;
    REP(i,n){
      string step;
      cin >> step;
      if(step=="lu") l=1;
      if(step=="ru") r=1;
      if(step=="ld") l=0;
      if(step=="rd") r=0;
      if(answer%2!=l&&answer%2!=r) answer++;
    }
    cout << answer << endl;
  }
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; 
	for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; 
	for(auto s:S) os<<s<<" ";  return os<<"}"; 
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
	os<<"{ ";for(auto m:M)os<<"("<<m.F<<":"<<m.S<<")";
	return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpii;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)


int main(){
	fio; cout<<fixed<<setprecision(25);	
	int n, m; cin >> n >> m;

	map<int,int> f;
	set<int> ac;
	for(int i = 0;i < m ; ++i){
		int p ;
		string s;
		cin >> p >> s;
		if(s == "AC")
			ac.I(p);
		if(ac.find(p) == ac.end() && s == "WA")
			f[p]++;
	}
	cout << ac.size() << " ";
	int z = 0;
	for(auto it : f){
		if(ac.find(it.F) != ac.end())
		z += it.S;
	}
	cout << z << endl;









	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
bool check(string s,char d[],int k){
for(int i=0;i<s.size();i++){
    for(int j=0;j<k;j++){
        if(s[i]==d[j]) return false;
    }
}
return true;
}
int main(){
    int n,k;
    cin>>n>>k;
    char d[k];
    for(char &c:d)cin>>c;
    while(true){
        string s=to_string(n);
        if(check(s,d,k)){
            cout<<n;
            return 0;
        }
        n++;
    }
return 0;
}


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

using namespace std;

typedef long long lint;
typedef vector<lint> vl;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) REP(i,0,b)
#define maxn 200010
lint v[maxn];

int main(){
	int n,t;
	while(cin>>n>>t){
		if(n==1){
			int ti;
			cin>>ti;
			cout<<t<<endl;
		}else{
			rep(i,n){
				cin>>v[i];
			}
			lint ans=0LL;
			REP(i,1,n){
				if(v[i]-v[i-1]>=t)ans+=t;
				else ans+=(v[i]-v[i-1]);
			}
			cout<<ans+t<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1792
#
# File    : C.rb
# Author  : Kazune Takahashi
# Created : 8/18/2018, 9:05:13 PM
# Powered by Visual Studio Code
#

s = gets.chomp
k = gets.to_i

if s[0] != "1"
  puts s[0]
else
  for i in 0...([k, s.size()].min)
    if s[i] != "1"
      puts s[i]
      exit
    end
  end
  puts "1"
end




Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n, ans = 1;
    cin >> n;
    vector<int> a(n);
    rep(i, n)cin >> a[i]; 
    reverse(all(a));
    map<int, int> mp;
    mp[a[0]]++;
    REP(i, n-1){
        auto it = mp.upper_bound(a[i]);
        if(it == mp.end()){
            mp[a[i]]++;
            ans++;
        }
        else{
            mp[it->first]--;
            if(mp[it -> first] == 0)mp.erase(it -> first);
            mp[a[i]]++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    ll n = s.size(), m = t.size();
    vector<vector<int>> index(30);
    for (ll i = 0; i < n; i++)
    {
        index[s[i] - 'a'].push_back(i + 1);
    }
    ll ans = 0;
    ll last = 0;

    for (ll i = 0; i < m; i++)
    {
        ll nch = t[i] - 'a';
        if ((ll)index[nch].size() <= 0)
        {
            cout << -1 << endl;
            return 0;
        }
        else
        {
            auto itr = upper_bound(ALL(index[nch]), last);
            if (itr == index[nch].end())
            {
                ans += n;
                itr = index[nch].begin();
            }
            last = *itr;
        }
    }
    ans += last;
    cout << ans << endl;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>

#define DIV 1000000007
using namespace std;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    int M = max(max(A, B), C);
    //cout << "M=" << M << endl;
    int ans;
    if (3 * M % 2 == (A + B + C)%2)ans = 3 * M - (A + B + C);
    else ans=3*(M+1) - (A + B + C);

    //cout << ans << endl;
    cout << ans/2 << endl;    
}


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

#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define vll vector<ll>
#define pll pair<ll , ll>
#define vpll vector<pair<ll, ll> >
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define N 100001
#define HOLE 1000000007

ll fn(ll x,ll rn[])
{
    if(rn[x]==x) return x;
    else return rn[x]=fn(rn[x],rn);
}

void un(ll x,ll y,ll rn[],ll sz[])
{
    x=fn(x,rn);
    y=fn(y,rn);
    if(x==y) return;
    if(sz[x]<sz[y]) swap(x,y);
    sz[x]+=sz[y];
    rn[y]=x;
    return;
}

ll power(ll x,ll y)
{
    ll res = 1; // Initialize result

    while (y > 0) {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res * x)%HOLE;

        // n must be even now
        y = y >> 1; // y = y/2
        x = (x * x)%HOLE; // Change x to x^2
    }
    return res;
}

vector <ll> adjl[N];
ll marked[N]={0};
vector <ll> order;

void dfs (ll x){

    if(marked[x])
        return;
    marked[x]=1;

    REP(i,0,adjl[x].size()){

    }

    return;
}

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

    ll q=1;
    //cin>>q;
    while(q--){

        string s;
        cin>>s;

        if(s[2]==s[3] && s[4]==s[5]){
            cout<<"Yes"<<endl;
        }
        else {
            cout<<"No"<<endl;
        }

        int flag=0;

    }

return 0;
}


Measured memory_bytes: 2560
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>

using namespace std;
 
typedef pair<int, int> paii;
typedef long long ll;

typedef	pair<int, paii> tupl;

int n;
string a, b;
int vtx[18][66000];

int solve(){
	
	int x = 0, y = 0, res = 100000;

	for(int i = 0; i < n; i++){
		x = x<<1; 
		y = y<<1;
		x += (a[i]=='W'?0:1);
		y += (b[i]=='W'?0:1);
	}
	
	for(int k = 0; k < n; ++k){
		
		for(int i = 0; i < n; ++i)
			for(int j = 0; j < 66000; ++j)
				vtx[i][j] = (j!=x?100000:0);
		
		priority_queue<tupl, vector<tupl>, greater<tupl> > qu;
		qu.push(make_pair(0, make_pair(k, x)));
		vtx[k][x] = 0;
		
		while(!qu.empty()){
			
			int m = qu.top().second.first;
			int w = qu.top().second.second;
			qu.pop();
			
			for(int i = 0; i < n; ++i){
				for(int j = i; j < n; ++j){
				
					if( i!=j && ((w>>i&1) != (w>>j&1))
							&& ((w>>i&1) != (y>>i&1)) && ((w>>j&1) != (y>>j&1)) ){
						
						int z = w^( (1<<i)|(1<<j) );
						int dsta = abs(j-m)+abs(i-j);
						int dstb = abs(i-m)+abs(j-i);
						
						if( vtx[i][z] > vtx[m][w] + dsta){
							
							vtx[i][z] = vtx[m][w] + dsta;
							qu.push(make_pair(vtx[i][z], make_pair(i, z)));
						}
						if( vtx[j][z] > vtx[m][w] + dstb){
							
							vtx[j][z] = vtx[m][w] + dstb;
							qu.push(make_pair(vtx[j][z], make_pair(j, z)));
						}
					}
				}
			}
		}
		
		for(int i = 0; i < n; ++i){
			res = min(res, vtx[i][y]);
		}
		
	}
	
	return res;
}

int main(){
	
	while(cin >> n, n){
	
		cin >> a;
		cin >> b;
		
		cout << solve() << endl;
	}
	
	return 0;
}

Measured memory_bytes: 10200
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Rep(i, N) for(int i = 0; i < N; i++)

const int LLINF = 1LL << 60;


signed main()
{
  int N;

  while(cin >> N, N) {
    int maxv = -LLINF, minv = LLINF;
    int sum = 0, A;
    Rep(i, N) {
      cin >> A; sum += A;
      maxv = max(maxv, A), minv = min(minv, A);
    }

    sum -= maxv + minv;

    cout << sum / (N - 2) << endl;
    
  }

  return 0;
}

Measured memory_bytes: 3048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
vector<pii> adj[20];
bool honest[20];
int dfs(int curr, int n) {
    if (curr == n + 1) {
        int cnt = 0;
        for (int i = 1; i <= n; ++i) {
            if (honest[i]) {
                ++cnt;
                for (int j = 0; j < adj[i].size(); ++j) {
                    int p = adj[i][j].first, t = adj[i][j].second;
                    if ((int)honest[p] + t == 1)
                        return 0;
                }
            }
        }
        return cnt;
    }
    int cur = 0;
    honest[curr] = 0;
    cur = max(cur, dfs(curr + 1, n));
    honest[curr] = 1;
    cur = max(cur, dfs(curr + 1, n));
    return cur;
}
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    for (int i = 1; i <= n; ++i) {
        int a, b, c; cin >> a;
        while (a--) {
            cin >> b >> c;
            adj[i].push_back(pii(b, c));
        }
    }
    cout << dfs(1, n) << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int gcd(int x,int y){
    if(y==0)return x;

    return gcd(y,x%y);
}
int lcm(int x,int y){
    return x*y/gcd(x,y);
}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){

    int A,B,C,D;
    cin>>A>>B>>C>>D;

    cout<<max(0,min(B,D)-max(A,C))<<endl;


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include <cstring>
#include<map>
#include<string>
#include<stack>
#include <algorithm>
#include <sstream>
#include<vector>
using namespace std;


int main(void){
	multimap<int,char,greater<int> > team;
	char t;
	int n;

	while(1)
	{
		cin>>n;
		if(!n) break;
		
		for(int j=0; j<n; j++)
		{
			cin>>t;
			int point=0,r;
			
			for(int i=0; i<n-1; i++)
			{
				cin>>r;
				if(r==0) point+=100;
				else if(r==1) --point;
			}
			team.insert( make_pair( point,t) );
		}

		for(multimap<int,char,greater<int> >::iterator it=team.begin(); it != team.end(); ++it)
			cout<<(*it).second<<endl;
		team.clear();
	}
	return 0;
}

Measured memory_bytes: 1180
#include<iostream>
#include<queue>
using namespace std;
#define inRange(x,a,b) (a <= x && x < b)

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

int main(){
    int w, h;
    while(cin >> w >> h, w+h){
        char mat[h][w];
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                cin >> mat[i][j];
            }
        }

        int black = 0, white = 0;
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(mat[i][j] != '.')    continue;
                queue<pair<int,int>> q;
                q.push({i,j});
                bool f = false, g = false;
                int area = 0;
                while(!q.empty()){
                    pair<int,int> now = q.front(); q.pop();
                    int y = now.first, x = now.second;
                    if(mat[y][x] != '.'){
                        if(mat[y][x] == 'W')    f = true;
                        if(mat[y][x] == 'B')    g = true;
                        continue;
                    }
                    area++;
                    mat[y][x] = 'x';
                    for(int k = 0; k < 4; k++){
                        int ny = y + dy[k];
                        int nx = x + dx[k];
                        if(inRange(ny, 0, h) && inRange(nx, 0, w) && mat[ny][nx] != 'x'){
                            q.push({ny,nx});
                        }
                    }
                }

                if(f && !g) white += area;
                if(g && !f) black += area;
            }
        }

        cout << black << " " << white << endl;

    }
    return 0;
}


Measured memory_bytes: 2972
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define CMAX(m, x)  m = max(m,x);
#define CMIN(m, x)  m = min(m,x);
#define itn int
typedef long long lint;
const int INF = 1e9;
const lint LINF = 1e18;
int main(){
    int n;
    cin >> n;
    double sum = 0;
    vector<vector<int>> data(n,vector<int>(2));
    REP(i,n)
        cin >> data[i][0] >> data[i][1];
    vector<int> v(n);
    int cnt = 0;
    iota(ALL(v),1);
    do{
        REP(i,n - 1){
            sum += sqrt(pow(data[v[i] - 1][0] - data[v[i + 1] - 1][0],2) + pow(data[v[i] - 1][1] - data[v[i + 1] - 1][1],2));
        }
        cnt++;
    }while(next_permutation(ALL(v)));
    printf("%.7f\n",sum/cnt);
    return 0;
}

Measured memory_bytes: 256
x = gets.to_i

y = x.times.map{gets.chomp.to_s}
ac = 0
wa = 0
tle = 0
re = 0
for i in 0..x-1 do
    if y[i] == "AC"
        ac += 1
    elsif y[i] == "WA"
        wa += 1
    elsif y[i] == "TLE"
        tle += 1
    else
        re += 1
    end
end

puts "AC x " + ac.to_s
puts "WA x " + wa.to_s
puts "TLE x " + tle.to_s
puts "RE x " + re.to_s

Measured memory_bytes: 21232
N = gets.to_i
A = N.times.map{ gets.to_i }
L = Array.new(N + 1, -1)
A.each do |a|
  i = L.bsearch_index do |v|
    a > v
  end
  L[i] = a
end
puts L.bsearch_index{|v| v < 0 } 

Measured memory_bytes: 3764
#include <iostream>
#include <vector>

template<class T>
using vec   = std::vector<T>;
using Graph = std::vector<vec<int>>; 

void set_num(int v, int c,
             vec<bool> &visited, vec<int> &num, const Graph &G)
{
    if (visited[v]) {
        return;
    }
    visited[v] = true;
    num[v] = c;

    for (int next : G[v]) {
        set_num(next, c, visited, num, G);
    }
}

int main()
{
    int N, M, K;
    std::cin >> N >> M >> K;
    
    vec<bool> visited(N, false);
    vec<int>  num(N, -1);
    Graph G(N);
    
    int res = 0;
    vec<int> r(K), a(K), b(K);
    for (int i = 0; i < K; i++) {
        std::cin >> r[i] >> a[i] >> b[i];
        a[i]--; b[i]--;
    }
    
    for (int i = 0; i < K; i++) {
        if (r[i] == 1) {
            G[a[i]].emplace_back(b[i]);
            G[b[i]].emplace_back(a[i]);

            if (num[a[i]] != -1) {
                set_num(b[i], num[a[i]], visited, num, G);
            }

            if (num[b[i]] != -1) {
                set_num(a[i], num[b[i]], visited, num, G);
            }

            if (num[a[i]] != num[b[i]] &&
                num[a[i]] != -1 && num[b[i]] != -1) {
                res = i + 1;
                break;
            }
        } else {
            if (num[a[i]] == -1) {
                set_num(a[i], b[i], visited, num, G);
            } else if (num[a[i]] != b[i]) {
                res = i + 1;
                break;
            }
        }
    }
    
    std::cout << res << std::endl;
    
    return 0;
}

Measured memory_bytes: 12308
#include <iostream>
#include <vector>

#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;

int main() {
    int n, x;
    cin >> n >> x;
    int l, L = 0, ans = 0;
    rep(i, n) {
        cin >> l;
        L += l;
        if (x >= L) {
            ans++;
        }
    }

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


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

int main(){
  int K,A,B,count=0;
  cin>>K>>A>>B;
  for(int i=A; i<=B; i++){
    if(i%K==0){
      count++;
    }
  }
  if(count>0){
    cout<<"OK"<<endl;
  }
  else{
    cout<<"NG"<<endl;
  }
}

Measured memory_bytes: 3632
import sys
#input = sys.stdin.readline
input = sys.stdin.buffer.readline

# mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np


def main():
	n,l=map(int,input().split())
	a=list(map(int,input().split()))

	for i in range(n-1):
		if a[i]+a[i+1]>=l:
			break
	else:
		print("Impossible")
		exit(0)
	i+=1
	print("Possible")
	for j in range(1,i):
		print(j)

	for j in range(n-1,i-1,-1):
		print(j)




if __name__ == "__main__":
	main()


Measured memory_bytes: 12528
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

auto g = make_vec<int>(0, 0);
vector<int> topolo;
vector<bool> seen;

void dfs(int v) {
    if (seen[v]) return;
    seen[v] = true;
    for (int u : g[v]) dfs(u);
    topolo.push_back(v);
}

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

    int n, m;
    cin >> n >> m;
    g.resize(n);
    rep(i, n-1+m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
    }
    seen.resize(n);
    rep(i, n) dfs(i);
    vector<int> ans(n);
    rep(i, n) {
        int v = topolo[i];
        for (int u : g[v]) if (ans[u] == 0) ans[u] = v+1;
    }
    rep(i, n) cout << ans[i] << endl;
}


Measured memory_bytes: 12872
#include<stdio.h>
int main(void)
{
	int n,k,p,i,x,a;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&k,&p);
		if(k>p){
			if(k%p==0){
				x=p;
			}
			else{
				x=k%p;
			}
		}
		else{
			x=k;
		}
		printf("%d\n",x);
	}
	return 0;
}


Measured memory_bytes: 2044
//============================================================================
// Name        : A.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;

int main() {
	int A, B;
	cin >> A >> B;
	if(A <= 8 && B <= 8){
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
import numpy as np
S=np.array([int(s) for s in input()])
N=len(S)

goal1=np.array([(i%2) for i in range(N)])
goal2=np.array([1-(i%2) for i in range(N)])

print(min(np.sum(np.logical_xor(S,goal1)),np.sum(np.logical_xor(S,goal2))))

Measured memory_bytes: 15584
x, k, d = list(map(int, input().split()))

minimum = x - d * k
maximum = x + d * k

if minimum >= 0:
    print(minimum)
elif maximum <= 0:
    print(-maximum)
else:
    c1 = maximum % (2*d)
    c2 = c1 - 2*d
    print(min(abs(c1), abs(c2)))


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

int main()
{
	int x;
	cin>>x;
	if(x<1200)
	{
		cout<<"ABC"<<endl;
		return 0;
	}
	if(x<2800)
	{
		cout<<"ARC"<<endl;
		return 0;
	}
	cout<<"AGC"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <complex>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 998244353;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;


ll powMod(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll t = powMod(x, n/2, mod);
  t = t * t % mod;
  if (n & 1) return t * x % mod;
  return t;
}



int main(void) {

  int x, y, a, b, c; ll t;
  cin >> x >> y >> a >> b >> c;
  vector< pair<ll, int> > rng;
  rep(i, a) {
    cin >> t;
    rng.push_back(make_pair(t, -1));
  }
  rep(i, b) {
    cin >> t;
    rng.push_back(make_pair(t, 0));
  }
  rep(i, c) {
    cin >> t;
    rng.push_back(make_pair(t, 1));
  }
  sort(rng.begin(), rng.end(), greater< pair<ll, int> > ());
  int r = 0, g = 0, n = 0;
  ll ans = 0;
  int i = 0;
  while (r + g + n < x + y && i < a + b + c) {
    if (rng[i].second == -1 && r < x) {
      r++;
      ans += rng[i].first;
    }
    else if (rng[i].second == 0 && g < y) {
      g++;
      ans += rng[i].first;
    }
    else if (rng[i].second == 1) {
      n++;
      ans += rng[i].first;
    }
    i++;
  }
  cout << ans << endl;
}


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

int main() {
	int n,x,l,s,i,X;
  s = x = 0;
  cin >> n>> X;
  for(int i = 0;i < n;i++){
    cin >> l;
    s += l;
    if(s <= X){
      x++;
	}
  }
    cout << ++x;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    string s;
    long long k;
    cin >> s >> k;
    int result;
    for (int i=0; i<k; i++) {
        if (s[i] != '1' || i == k-1) {
            result = s[i] - '0';
            break;
        }
    }
    cout << result << endl;
}

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

int main()
{
  ll N;
  cin >> N;
  vector<ll> x(N);
  vector<ll> y(N);
  for (int i=0; i<N; i++){
    cin >> x[i];
    cin >> y[i];
  }

  vector<ll> a;
  for (int i=0; i<N; i++) {
    a.push_back(i);
  }

  double ans = 0.0;
  do {
    for (int i=1; i<N; i++) {
      double tmp = pow(x[a[i]]-x[a[i-1]], 2) + pow(y[a[i]]-y[a[i-1]], 2);
      ans += sqrt((double)tmp);
    }
  } while(next_permutation(a.begin(), a.end()));

  for (int i=2; i<=N; i++) {
    ans /= i;
  }
  cout << setprecision(10) << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>
using namespace std;

int digitsum(int n) {
    int sum = 0;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main(int argc, const char * argv[]) {
    
    int N, K;
    cin >> N >> K;
    vector<int> length(N);
    for (int i = 0; i < N; i++) {
        cin >> length.at(i);
    }
    
    sort(length.begin(), length.end(), greater<int>());
    
    int ans = 0;
    for (int i = 0; i < K; i++) {
        ans += length.at(i);
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
signed main(void){
    int n,t; cin>>n>>t;
    vector <pair<int,int>> data(n);
    rep(i,n){
        int a,b; cin>>a>>b;
        data[i] = {a,b}; //a time, b value
    }
    sort(data.begin(),data.end());
    
    vector <vector<int>> dp(3020,vector <int>(6040));
    
    int ans = 0;
    int mae = 0;
    rep(i,n){
        chmax(ans, mae + data[i].S);
        //cout<<ans<<endl;
        int next = 0;
        rep(j,t){
            chmax(dp[i+1][j+data[i].F], dp[i][j] + data[i].S);
            chmax(dp[i+1][j], dp[i][j]);
        }
        rep(j, t){
            chmax(next , dp[i+1][j]);
        }
        mae = next;
    }
    
    cout<<ans<<endl;
}


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

int main(void){
  string s;
  cin >> s;
  int cnt = 0;
  char prev = s[0];
  for(int i=1;i<s.size();++i){
    if(s[i]!=prev) ++cnt;
    prev = s[i];
  }
  cout << cnt << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
using namespace std;
const long long int mod1=1000000007;
const long long int mod2 = -1;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pp pop_back                                       
#define ff first
#define ss second
#define ll long long int
#define ull unsigned long long int
#define inf mod1
ll gcd(ll a, ll b){
    ll c;
     while(b){
        c = b;
        b = a % b;
        a = c;
     }
     return a;
}
ll power1(ll a, ll b){
     if(b == 0) return 1;
     else if(b % 2) return a * power1(a, b - 1);
     else {
        ll temp = power1(a, b / 2);
        return temp * temp;
     }
}
ll power2(ll a, ll b, ll m){
     a %= m;
     if(b == 0) return 1;
     else if(b % 2) return (a * power2(a, b - 1, m)) % m;
     else{
        ll temp = power2(a, b / 2, m);
        return (temp * temp) % m;
     }
}
ll mod(ll x, ll p){
return (x % p + p) % p;
}
ll lcm(ll x, ll y){
return (x * y)/gcd(x, y);
}
int main(){
	fast;
	ll h = 1;
	//scanf("%lld", &h);
    while(h--){ 
            ll a, b;
            cin >> a >> b;
            char x = (a + '0');
            char y = (b + '0');
            string s1, s2;
            for(int i = 0; i < a; i++){
                s1 += y;
            }   
            for(int i = 0; i < b; i++){
                s2 += x;
            }   
            if(s1 < s2){
                cout << s1 << endl;
            }
            else{
                cout << s2 << endl;
            }
            
        }   
    }       

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define repm(i, m, n) for (int i = (m); i < (n); i++)
#define rep_rev(i, n) for (int i = int (n); i >= 0; i--)
typedef long long ll;
using namespace std;

int main() {
	int n;
	cin >> n;
	
	bool flag = false;
	rep1(i, n) {
		if (n % i == 0) {
			int a = n / i;
			if (i < 10 && a < 10) {
				flag = true;
				break;
			}
		}
	}

	if (flag || n == 1)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
s = input()
ans = [0] * len(s)
countR = countL = 0
#R探索
#Lを見つけるまでカウント
i = 0
while i <= len(s) - 1:
  if s[i] == "R":
    countR += 1
    i += 1
  else:
    v1 = countR //2
    v2 = countR - v1
    ans[i-1] += v2
    ans[i] += v1
    countR = 0
    while s[i] != "R" :
      tmp = s[i]
      i += 1
      if i == len(s):
        break


#L探索
i  =  len(s) - 1
while  0 <= i:
  if s[i] == "L":
    countL += 1
    i -= 1
  else:
    v1 = countL // 2
    v2 = countL - v1
    ans[i] += v1
    ans[i+1] += v2
    countL = 0
    while s[i] != "L":
      i -= 1
for i in range(len(s)):
  print(ans[i],end = " ")
  















"""
ans = [0] * len(s)
def Rcount(data,point):
  Rcount = 1
  global ans
  while True:
    if s[point] != "R":
      ans[point] += Rcount //2
      ans[point-1] += Rcount - (Rcount //2)
      break
    else:
      Rcount += 1
    point += 1
  
"""

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    int n;
    cin>>n;
    int res = 0;
    rep(i,n){
        int l,r;
        cin>>l>>r;
        res += r-l+1;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = int64_t;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "(" << p.first << "," << p.second << ")";
}

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "{";
    for (int i = 0; i < v.size(); ++i) {
        if(i) os << ",";
        os << v[i];
    }
    return os << "}";
}
int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (auto &&i : v) scanf("%d", &i), i--;
    vector<int> ans(n);
    for (int i = 0; i < n; ++i) {
        for (int j = n-i-1; j >= 0; --j) {
            if(v[j] == j){
                for (int k = j; k < n-i-1; ++k) {
                    v[k] = v[k+1];
                }
                v[n-i-1] = INF<int>;
                ans.emplace_back(j+1);
                break;
            }
        }
        if(v[n-i-1] != INF<int>){
            puts("-1");
            return 0;
        }
    }
    reverse(ans.begin(), ans.end());
    for (int i = 0; i < n; ++i) {
        cout << ans[i] << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
import copy

n,m=map(int,input().split())
D=list(map(int,input().split(" ")))
answer=-99999999999
for i in range(m+1):
    take=i
    trash=m-i
    #print("take",take,"trash",trash)
    for j in range(take+1):
        if take>=n:
            #print("A")
            goukei=copy.copy(D)
        else:
            left=j
            right=j-take
            leftjewel=D[:left]
            rightjewel=D[right:]
            if right==0:
                rightjewel=[]
            
            #print("left",left,"right",right,"j",j,"take",take,"trash",trash)
            #print(leftjewel,rightjewel)
            goukei=leftjewel+rightjewel
        goukei.sort()
        for i in range(trash):
            if goukei!=[]:
                if goukei[0]<0:
                    del goukei[0]
        #print("最終",sum(goukei))
        if sum(goukei)>answer:
            #print("更新")
            answer=sum(goukei)
print(answer)


Measured memory_bytes: 3572
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
AB = [LIST() for _ in range(N)]

ans = 0
cnt = 0
AB = sorted(AB, reverse=True)
while cnt < M:
    A, B = AB[-1]
    if cnt+B <= M:
        cnt += B
        ans += A*B
    else:
        ans += A * (M-cnt)
        cnt = M
    AB.pop()
print(ans)


Measured memory_bytes: 29024
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

int main() {
	fast;
	int n;
	cin>>n;
	int dp[n][3],energy[n][3];
	memset(dp,0,sizeof(dp));
	for(int i=0;i<n;i++) cin>>energy[i][0]>>energy[i][1]>>energy[i][2];
	dp[n-1][0]=energy[n-1][0],dp[n-1][1]=energy[n-1][1],dp[n-1][2]=energy[n-1][2];
	for(int i=n-2;i>=0;i--){
		dp[i][0]=max(dp[i][0],energy[i][0]+max(dp[i+1][1],dp[i+1][2]));
		dp[i][1]=max(dp[i][1],energy[i][1]+max(dp[i+1][0],dp[i+1][2]));
		dp[i][2]=max(dp[i][2],energy[i][2]+max(dp[i+1][0],dp[i+1][1]));
	}
	cout<<max(dp[0][0],max(dp[0][1],dp[0][2]))<<"\n";
	return 0;
}

Measured memory_bytes: 2560
F[501][501];
main(m,n,w,h,s,t,i,j,k,l){for(;scanf("%d",&n),n;printf("%d\n",n)){for(scanf("%d%d",&w,&h),memset(F,0,sizeof(F)),i=0;i<n;i++)scanf("%d%d",&k,&l),F[k][l]=1;for(scanf("%d%d",&s,&t),n=i=0;i<=w-s+1;i++)for(j=0;j<=h-t+1;n=n>m?n:m,j++)for(m=0,k=i;k<i+s;k++)for(l=j;l<j+t;l++)if(F[k][l])m++;}}

Measured memory_bytes: 1588