akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main() {
	
	int n;
	cin >> n;
	vector<int>a, b;
	for (int i = 0; i < n; i++) {

		int t;
		cin >> t;
		if (i % 2)b.push_back(t);
		else a.push_back(t);
	}
	map<int, int>c, d;
	for (int i = 0; i < a.size(); i++)c[a[i]]++;
	for (int i = 0; i < b.size(); i++)d[b[i]]++;

	vector<pair<int, int>>x, y;
	for (int i = 0; i < a.size(); i++) {
		if (c[a[i]]) {
			x.push_back(make_pair(c[a[i]], a[i]));
			c[a[i]] = 0;
		}
	}

	for (int i = 0; i < b.size(); i++) {
		if (d[b[i]]) {
			y.push_back(make_pair(d[b[i]], b[i]));
			d[b[i]] = 0;
		}
	}
	//cout << x.size() << " " << y.size() << endl;
	sort(x.rbegin(), x.rend());
	sort(y.rbegin(), y.rend());
	//reverse(x.begin(), x.end());
	//reverse(y.begin(), y.end());

	if (x[0].second != y[0].second) {
		cout << n - x[0].first - y[0].first << endl;
		return 0;
	}
	if (x.size() == 1 && y.size() == 1) {
		cout << n / 2 << endl;
		return 0;
	}	int ans = 999999999;
	for (int i = 0; i < 2 && i < x.size(); i++) {
		for (int j = 0; j < 2 && j < y.size(); j++) {
			if(x[i].second==y[j].second)continue;
			ans = min(ans, n - x[i].first - y[j].first);
		}
	}
	
	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 6520
#include<bits/stdc++.h>
using namespace std; 
typedef long long int ll;
typedef unsigned long long int ull;
const long long int m=pow(10,9)+7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ull n,a,b;
    cin>>n>>a>>b;
    ll d,x;
    d=(b-a);
    if(d%2==0)
        cout<<d/2<<endl;
    else 
    {
        x=min(min(a-1,n-a),min(b-1,n-b));
        x+=(b-a)/2+1;
        cout<<x<<endl;
    }
    return 0;
}


Measured memory_bytes: 3604
//デバッグ用オプション：-fsanitize=undefined,address

//コンパイラ最適化
#pragma GCC optimize("Ofast")

//インクルードなど
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;

// vector set 等
#include <map>
#include <set>
#include <vector>

//マクロ
// forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
// FORAは範囲for文(使いにくかったら消す)
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto& i : I)
// xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size())
//定数
#define INF 1000000000000  // 10^12:∞
#define MOD 1000000007     // 10^9+7:合同式の法
#define MAXR 100000        // 10^5:配列の最大のrange
//略記
#define PB push_back  //挿入
#define MP make_pair  // pairのコンストラクタ
#define F first       // pairの一つ目の要素
#define S second      // pairの二つ目の要素

// 負の数にも対応した % 演算
ll mod(ll x) {
  ll res = x % MOD;
  while (res < 0) res += MOD;
  return res;
}

ll mpow(ll x, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}
// a^{-1} mod を計算する
ll minv(ll a) { return mpow(a, MOD - 2); }

signed main() {
  //入力の高速化用のコード
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  ll n, ans = 0;

  cin >> n;
  ans = mod(mpow(10, n) - mpow(9, n) - mpow(9, n) + mpow(8, n));

  ans = (ans + MOD) % MOD;
  cout << ans << endl;

  return 0;
}

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

#define FILE
#define fr first
#define se second

using namespace std;

const long long N = 2e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

string s;
int main()
{
    #ifdef FILEs
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF (1LL<<57)
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define whoami(x) cerr<<#x<<" "<<x<<"\n";
#define mp make_pair
#define ins insert
#define sz size

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	ll k,n;
	cin>>k>>n;
	if((500LL * k) >= n)
	cout<<"Yes\n";
	else cout<<"No\n";
	return;	
}

int main(void)
{
	FLASH();
	int T;
	T = 1;

// #ifndef ONLINE_JUDGE
// 	time_t time_t1, time_t2;
// 	time_t1 = clock();
// #endif

	while(T--)
	solve(T);

// #ifndef ONLINE_JUDGE
// 	time_t2 = clock();
// 	SETF();
// 	cout<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
// 	UNSETF();
// #endif

	return 0;
}

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

int main(){
  char c; cin >> c;
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <tuple>
#include <climits>
#include <sstream>
using namespace std;

static const unsigned long long int MOD = 1000000007LL;

int main()
{
    int n, l, x, d = 0, res = 1;

    cin >> n >> x;

    for (int i = 0; i < n; i++)
    {
        cin >> l;
        d += l;
        if (d <= x)
        {
            res++;
        }
    }

    cout << res;

    return 0;
}


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

int main(){
  int n; cin>>n;
  string s; cin>>s;
  int red=0;
  for(int i=0;i<n;i++){
    if(s[i]=='R'){
      red++;
    }
  }
  if(red<=n-red){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>

using namespace std;

int grid[3001][3001];
long long DP[3001][3001][4];

int main()
{
    int R, C, i, j, k, K, r, c, v;
    long long maximum;

    scanf("%d%d%d", &R, &C, &K);
    memset(grid, 0, sizeof grid);
    while(K--){
        scanf("%d%d%d", &r, &c, &v);
        grid[r][c] = v;
    }

    for(i = 1; i <= R; ++i)
        for(j = 1; j <= C; ++j){
            DP[i][j][0] = 0;
            if(i > 1)
                DP[i][j][0] = max(DP[i][j][0], DP[i - 1][j][3]);
            if(j > 1)
                DP[i][j][0] = max(DP[i][j][0], DP[i][j - 1][0]);

            for(k = 1; k <= 3; ++k){
                DP[i][j][k] = grid[i][j];
                if(i > 1)
                    DP[i][j][k] = max(DP[i][j][k], DP[i - 1][j][3] + grid[i][j]);
                if(j > 1){
                    DP[i][j][k] = max(DP[i][j][k], DP[i][j - 1][k]);
                    DP[i][j][k] = max(DP[i][j][k], DP[i][j - 1][k - 1] + grid[i][j]);
                }

                DP[i][j][k] = max(DP[i][j][k], DP[i][j][k - 1]);
            }
        }

    printf("%lld", DP[R][C][3]);

    return 0;
}


Measured memory_bytes: 318252
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    N, K = NMI()
    A = NLI()
    ng = 0
    ok = 10**10

    for i in range(100):
        mid = (ok + ng) // 2
        if mid == 0:
            break
        tmp = 0
        for a in A:
            if a % mid == 0:
                tmp += a // mid - 1
            else:
                tmp += a // mid
        if tmp <= K:
            ok = mid
        else:
            ng = mid

    print(ok)


if __name__ == "__main__":
    main()

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

int main() {
  int N;
  cin >> N;
  double n = N;
  if (N % 2 == 0) {
    cout << 0.5 << endl;
  } else {
    N /= 2;
    double result = (N + 1) / n;
    cout.precision(10);
    cout << result << endl;
  }
}


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

int main(){
	int N, n;
	cin >> N;
	n = 0;
	for(int i=N; i>0; i=i/10){
		n += i%10;
	}
	string ans;
	if(N%n==0)
		ans =  "Yes";
	else
		ans = "No";
	cout << ans << endl;
}


Measured memory_bytes: 256
/// 2222 by 1 february, thx

#include<bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int n, v[100002], dp[100002];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for(int i = 1; i <= n; ++i)
        cin >> v[i];
    for(int i = 2; i <= n; ++i)
    {
        dp[i] = dp[i-1] + abs(v[i] - v[i-1]);
        if(i > 2)
            dp[i] = min(dp[i], dp[i-2] + abs(v[i] - v[i-2]));
    }
    cout << dp[n] << '\n';
    return 0;
}


Measured memory_bytes: 1024
n = int(input())
L = []
ans = 0
for i in range(n):
    a,b = map(int,input().split())
    L.append([a,b,i])
P = []
L.sort()
for i in range(n-1):
    dist = min(abs(L[i][0]-L[i+1][0]),abs(L[i][1]-L[i+1][1]))
    P.append([dist,L[i][2],L[i+1][2]])
L = sorted(L, key = lambda x:x[1])
for i in range(n-1):
    dist = min(abs(L[i][0]-L[i+1][0]),abs(L[i][1]-L[i+1][1]))
    P.append([dist,L[i][2],L[i+1][2]])
P.sort()
par = [i for i in range(n)]
rank = [0]*n
def find(x,par):
    if x == par[x]:
        return par[x]
    else:
        return find(par[x],par)
def unite(x,y,par,rank):
    x = find(x,par)
    y = find(y,par)
    if x != y:
        if rank[x] < rank[y]:
            par[x] = y
        else:
            par[y] = x
            if rank[x] == rank[y]:
                rank[x] += 1
for i in range(len(P)):
    if find(P[i][1],par) != find(P[i][2],par):
        ans += P[i][0]
        unite(P[i][1],P[i][2],par,rank)
print(ans)

Measured memory_bytes: 56196
#include <algorithm>
#include <cstdio>
#include <ctype.h>
#include <functional>
#include <iostream>
#include <cassert>
#include <cfloat>
#include <climits>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
int main() {
	string S;
	cin >> S;
	S.insert(4," ");
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb(a) push_back(a)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vv = vector<vi>;
using P  = pair<int,int>;
using vP = vector<P>;
const int INF = 1001001001;

int main(){
    int n;
    cin>>n;
    
    vi a(n);
    map<int,ll> m;
    
    rep(i,n){
        cin>>a[i];
        m[a[i]]++;
    }
    
    ll ans = 0;
    
    for(auto p: m){
        ans += p.second*(p.second-1)/2;
    }
    
    for(int i=0; i<n; i++){
        cout << ans -( m[a[i]] - 1 ) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 10240
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long
struct AB{
  int a;
  int b;

  bool operator<(const AB &r) const{
    return a==r.a ? b<r.b : a<r.a;
  }
};

int main(){
  int N;
  LINT K;
  cin >> N >> K;
  AB ab[N];
  REP(i, N){
    cin >> ab[i].a >> ab[i].b;
  }
  sort(ab, ab+N);
  LINT count=0;
  int j = 0;
  while(count<K){
    count += ab[j].b;
    ++j;
  }
  cout << ab[j-1].a << endl;


  return 0;
}


Measured memory_bytes: 1024
# for #!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion
class union_find:
    def __init__(self, n):
        self.n = n
        self.rank = [0]*n
        self.parent = [int(j) for j in range(n)]
    
    def union(self,i,j):
        i = self.find(i)
        j = self.find(j)
        if self.rank[i] == self.rank[j]:
            self.parent[i] = j
            self.rank[j] += 1

        elif self.rank[i] > self.rank[j]:
            self.parent[j] = i
        else:
            self.parent[i] = j

    def find(self, i):
        temp = i
        if self.parent[temp] != temp:
            self.parent[temp] = self.find(self.parent[temp])
        return self.parent[temp]
from math import log2, ceil
def main():
# Enter your code here. Read input from STDIN. Print output to STDOUT
    # for t in range(int(input())):
        n = int(input())
        # n,k  =[int(j) for j in input().split()]
        if(n>=30):
            print("Yes")
        else:
            print("No")

        # print(m)
        


        # n,k,z  =[int(j) for j in input().split()]
        



if __name__ == "__main__":
    main()

Measured memory_bytes: 62984
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define show(x) cout<< #x << " = " << x << endl
using namespace std;

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

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

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

const ll mod=998244353;
const int INF=INT_MAX/2;
const int N_MAX=100010;
const double PI=3.14159265359;

int main(){
	ll n,a,b;
	cin>>n>>a>>b;
	cout<<a*(n/(a+b))+min(a,n%(a+b))<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const int nmax = 8;
bool graph[nmax][nmax];
const ll INF = 1e9;
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}



int main()
{
    ll dp[100010];
    for(int i = 0; i < 100010; i++)
    {
        dp[i] = 1000000;
    }
    
    long long N;
    scanf("%lld", &N);
    dp[0] = 0;
    for (int i = 1; i <= N; i++)
    {
        dp[i] = min(dp[i], dp[i - 1] + 1);

        for (int j = 6; j <= i; j *= 6)
        {
            dp[i] = min(dp[i], dp[i - j] + 1);
        }

        for (int j = 9; j <= i; j *= 9)
        {
            dp[i] = min(dp[i], dp[i - j] + 1);
        }
    }
    cout << dp[N] << endl;
    return 0;
}


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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#define TIME cout << "Time elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms" << endl;

int n, m;
VI A;
void solve()
{
	int sum = accumulate(ALL(A), 0);

	int p, x;
	cin >> m;
	for(int i = 0; i < m; ++i)
	{
		cin >> p >> x;

		cout << sum - A[p] + x << '\n';
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
//	freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	cin >> n;

	A.resize(n + 1);
	REP(i, 1, n + 1) cin >> A[i];

	solve();

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define ll long long
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    ll INF = 1e10;
    ll n, w;
    cin >> n >> w;
    vector<vector<ll> >data(n + 1, vector<ll>(2));
    for(int i = 1; i <= n; i++){
        cin >> data.at(i).at(0) >> data.at(i).at(1);
    }
    ll sum = 0;
    ll V = 100010;
    vector<vector<ll> >dp(n + 1, vector<ll>(V + 1));
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= V; j++){
            dp.at(i).at(j) = INF;
        }
    }
    dp.at(0).at(0) = 0;
    for(int i = 1; i <= n; i++){
        sum += data.at(i).at(1);
        for(int j = 0; j <= V; j++){
            if(data.at(i).at(1) >= j) dp.at(i).at(j) = min(dp.at(i - 1).at(j), dp.at(i - 1).at(0) + data.at(i).at(0));
            else dp.at(i).at(j) = min(dp.at(i - 1).at(j), dp.at(i - 1).at(j - data.at(i).at(1)) + data.at(i).at(0));
            if(dp.at(i).at(j) > w) dp.at(i).at(j) = INF;
        if(j == sum) break;
        }
    }
    for(int i = V; i >= 0; i--){
        if(dp.at(n).at(i) != INF){
            cout << i << endl;
            break;
        }
    }
    return 0;
}



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

const int N = 100005;

int n, m;
int par[N + N];

int anc(int p) { return p == par[p] ? p : par[p] = anc(par[p]); }
void join(int p, int q) { par[anc(p)] = anc(q); }

int main() {
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n + m; ++i) par[i] = i;

	for (int i = 1; i <= n; ++i) {
		int k; scanf("%d", &k);
		while(k--) {
			int x; scanf("%d", &x); join(i, x + n);
		}
	}

	int p = anc(1);
	for (int i = 1; i <= n; ++i) if (anc(i) != p) {
		cout << "NO\n"; return 0;
	}
	cout << "YES\n";
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int a[3],b;
    for(int i=0;i<3;i++){
        cin>>a[i];
    }
    sort(a,a+3);
    cin>>b;
    for(int i=0;i<b;i++){
        a[2]=a[2]*2;
    }
    b=a[0]+a[1]+a[2];
    cout<<b<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF (1e9)
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

template<typename T>
T gcd(T a,T b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a * b / g;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}


ll table[100001];
int main()
{
	table[0]=0;
	REP(i,1,100001){
		if(i%2==1&&IsPrime(i)&&IsPrime((i+1)/2)){
			table[i]=table[i-1]+1;
		}else{
			table[i]=table[i-1];
		}
	}
	int Q;
	cin>>Q;
	ll ans[Q];
	REP(i,0,Q){
		int l,r;
		cin>>l>>r;
		ans[i]=table[r]-table[l-1];
		
	}
	REP(i,0,Q){
	
		cout<<ans[i]<<endl;
	}

	

	
	
	
	

	return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        "\n"
#define fast        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int         long long int
#define mod         1000000007
#define test        int t;cin>>t;while(t--)
#define REP(i,a,b)  for(int i=a,i<=b;i++)
#define MAXN        200001
#define INF         INT_MAX

int32_t main(){

	int n;
	cin>>n;
	map<int,int>mp;
	for(int i=1;i<=n;i++){
		mp[i]=0;
	}
	int arr[n-1];
	for(int i=0;i<n-1;i++){
		cin>>arr[i];
		mp[arr[i]]++;
	}

	for(auto x:mp){
		cout<<x.S<<endl;
	}
	return 0;
}

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

//      DEEP

using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) v.begin(),v.end()
#define pb push_back
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
typedef pair<long long,long long> pll;
typedef set<int> si;
const ll mod = 1e9 + 7;
const ll modl=998244353;
const double pie=3.1415926535;
                                                    //power
ull power(ull x,ull y){
   if(y==0) return 1;
   else{
     if(y%2==0) return power(x*x,y/2);
     else return x*power(x*x,(y-1)/2);
   }
}

                        //                    Modular Exponentiation

ll mod_power(ll x, ll y, ll m)
{
    ll r = 1;     // Initialize result

    x = x % m; // Update x if it is more than or equal to m

    if (x == 0) return 0; // In case x is divisible by m;

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

        // y must be even now
        y = y/2;
        x = (x*x) % m;
    }
    return r;
}

                                                      //GCD
ll gcd(ll x,ll y){
   if(y==0)return x;
   return gcd(y,x%y);
}
                                              // SIEVE

/*
bool isPrime[100001];
void sieve(int N) {

        for(int i = 0; i <= N;++i) {
            isPrime[i]=true;
        }
        isPrime[0]=false;
        isPrime[1]=false;

        for(int i = 2; i * i <= N; ++i) {
             if(isPrime[i] == true) {
                 for(int j = i * i; j <= N ;j += i)
                     isPrime[j] = false;
            }
        }
    }
*/
void transpose(int xl,int xr,int yl,int yr){

}
int main(){
    boost;
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
      int s,w;
      cin>>s>>w;
      if(w>=s)cout<<"unsafe"<<endl;
      else cout<<"safe"<<endl;
    }

  }












Measured memory_bytes: 3636
#include <iostream>
#include <atomic>
#include <thread>
#include <mutex>
#include <string>
#include <string.h>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#define rep(i,n) for(int i=0;i<n;i++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define ll long long
#define INF LLONG_MAX/3
#define P std::pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
signed main() {
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(a, b) << " " << max((ll)0, a + b - n) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
 
int main() {
int n;
    cin >> n;
    int arr[n];
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
    }
    sort(arr, arr + n);
    int b[n];
    int mid;
    if (n % 2 == 1) {
        mid= (n + 1) / 2 - 1;
        b[0] = arr[mid];
        if (arr[mid] - arr[mid - 1] < arr[mid + 1] - arr[mid]) {
            for (int i = 0; i < mid; ++i) {
                b[(i + 1) * 2] = arr[i];
                b[i * 2 + 1] = arr[n - 1 - i];
            }
        } else {
            for (int i = 0; i < mid; ++i) {
                b[(i + 1) * 2] = arr[n - 1 - i];
                b[i * 2 + 1] = arr[i];
            }
        }
    } else {
        mid= n / 2;
        for (int i = 0; i < mid; ++i) {
            b[i * 2 + 1] = arr[i];
            b[i * 2] = arr[mid + i];
        }
    }
 
    long long ans = 0;
    for (int i = 1; i < n; ++i) {
        ans += (long long)abs(b[i - 1] - b[i]);
    }
 
    cout << ans ;
 
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
    long long n, sum=0;
    scanf("%lld", &n);
    for(int i=1; i<=n; i++)
    {
        if(i%3!=0 && i%5!=0)
        sum=sum+i;
    }

        printf("%lld\n", sum);
    return 0;
}


Measured memory_bytes: 1732
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
constexpr int inf=1e9+7;
constexpr ll longinf=1LL<<60 ;
constexpr ll mod=1e9+7 ;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    ll x,y,Xor=0;
    cin>>x>>y;
    rep(i,n-2){
        ll z;cin>>z;
        Xor^=z;
    }
    if(x+y<Xor){
        cout<<-1<<endl;
        return 0;
    }
    ll And = x + y - Xor;
    if(And % 2){
        cout<<-1<<endl;
        return 0;
    }
    And >>= 1;
    if(x<And){
        cout<<-1<<endl;
        return 0;
    }
    if(Xor & And){
        cout<<-1<<endl;
        return 0;
    }
    ll ans = And;
    for(ll b=1ll<<40;b>=1;b>>=1){
        if(Xor & b && ans + b <=x)ans+=b;
    }
    if(ans==0){
        cout<<-1<<endl;
        return 0;
    }
    cout<<x-ans<<endl;
    return 0;
}

Measured memory_bytes: 3600
def main():
    N, W = map(int, input().split())
    wv = [tuple(map(int, input().split())) for i in range(N)]

    dp = [-1]*(W+1)
    dp[0] = 0
    for w, v in wv:
        for j in range(W-1, -1, -1):
            if dp[j] >= 0 and j+w <= W:
                dp[j+w] = max(dp[j+w], dp[j] + v)

    print(max(dp))


main()


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

int main(){
  int H,W;

  while(1){
    cin>>H>>W;
    if(H==0 && W==0){
      break;
    }
    for(int i=0; i<H; i++){
      for(int j=0; j<W; j++){
        cout<<"#";
      }
      cout<<endl;
    }
    cout<<endl;
  }

  return 0;
}

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

string Ans;
int cnt = 0;

void chmin(int& a, int b){
    a = min(a, b);
}

int editdist(string& A, string& B){
    int N = A.size(), M = B.size();
    vector<vector<int>> dp(N+1, vector<int>(M+1, 1e9));
    dp[0][0] = 0;
    for(int i=0; i<=N; i++) for(int j=0; j<=M; j++){
        if(i<N) chmin(dp[i+1][j], dp[i][j]+1);
        if(j<M) chmin(dp[i][j+1], dp[i][j]+1);
        if(i<N && j<M) chmin(dp[i+1][j+1], dp[i][j] + (A[i] != B[j]));
    }
    return dp[N][M];
}

int ask(string S){
    cnt++;
    cout << "? " << S << endl;
    int res;
    cin >> res;
    //res = editdist(S, Ans);
    return res;
}

int main(){
    const int L = 128;
    vector<char> C;
    for(int i=0; i<26; i++){
        C.push_back('a'+i);
        C.push_back('A'+i);
    }
    for(int i=0; i<10; i++) C.push_back('0'+i);

    // mt19937 rnd;
    // for(int i=0; i<L; i++) Ans.push_back(C[rnd()%62]);

    typedef pair<int, string> P;
    priority_queue<P, vector<P>, greater<P>> que;
    int len = 0;
    for(char c : C){
        string S(L, c);
        int res = L - ask(S);
        if(res > 0) que.emplace(res, string(res, c));
        len += res;
    }
    while(que.size() > 1){
        string A = que.top().second; que.pop();
        string B = que.top().second; que.pop();
        int ptA = 0;
        for(char c : B){
            bool done = false;
            while(ptA < A.size()){
                string S = A;
                S.insert(S.begin()+ptA, c);
                int res = len - ask(S);
                if(res == S.size()){
                    A = S;
                    ptA++;
                    done = true;
                    break;
                }else{
                    ptA++;
                }
            }
            if(!done){
                A.insert(A.end(), c);
                ptA++;
            }
        }
        que.emplace(A.size(), A);
    }
    string ans = que.top().second;
    cout << "! " << ans << endl;

    // cerr << cnt << endl;
    // assert(ans == Ans);
    return 0;
}


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

#define DEBUG(x) cerr << #x << ": " << x << endl;

int main() {
    int a, b;
    char c;
    cin >> a >> c >> b;
    if (c == '+') {
        cout << a + b << endl;
    } else {
        cout << a - b << endl;
    }

    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
H = list(map(int, input().split()))
H = sorted(H)
X = sum(H)
if X == 0:
  print(sum(H))
elif N >= K:
  list = H[N-K:N+1]
  print(sum(H)-sum(list))
else:
  print(0)
  
  
  

Measured memory_bytes: 26020
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }
int longest_increasing_subsequence(const vector<int> &v) {
	int ans = 1;
	int l = 0;
	rep(i, 1, v.size()) {
		if (v[i - 1] <= v[i]) {
			chmax(ans, i - l + 1);
		}
		else {
			l = i;
		}
	}
	return ans-1;
}
signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	vector<int>v(N); rep(i, 0, N) { cin >> v[i]; }
	reverse(all(v));
	cout << longest_increasing_subsequence(v) << endl;

	return 0;
}


Measured memory_bytes: 1024
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define LL long long
#define MOD 1000000007
#define INF 2000000000000
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
ll N, M, K, H, W, L, R, l, r, u, sum, Q;
LL ans=0;
LL no;

string s, t;

LL gcd(int p, int q) {
	if (p % q == 0)return q;
	return gcd(q, p % q);

}
vector<LL> a(51), b(51), c(51), d(51);
void dfs(vector<LL> V) {

	if (V.size() == N) {
		LL now = 0;
		for (int i = 0; i < Q; i++) {
			if (V[b[i]-1] - V[a[i]-1] == c[i])now += d[i];
		}
		ans = max(ans, now);
		return;
	}
	V.push_back(V.back());
	while (V.back() <= M ) {
		dfs(V);
		V.back()++;
	}
}

int main() {
	cin >> N >> M >> Q;
	
	for (int i = 0; i < Q; i++) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}
	vector<LL> v = {1};
	dfs(v);
	cout << ans<<endl;
	return 0;
}



Measured memory_bytes: 3628
from itertools import product

N, M = map(int, input().split(' '))
image = [tuple(input()) for _ in range(N)]
template = [tuple(input()) for _ in range(M)]


def is_matched(template, image, offset_y, offset_x):
    for y, x in product(range(M), range(M)):
        if template[y][x] != image[offset_y + y][offset_x + x]:
            return False
    return True


for y, x in product(range(N - M + 1), range(N - M + 1)):
    if is_matched(template, image, y, x):
        print('Yes')
        break
else:
    print('No')


Measured memory_bytes: 9204
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

std::vector<int> pos[10];

bool find(int a, int b, int c, int n) {
  auto lower_bound = [&](int x, int min) -> int {
    auto iter = std::lower_bound(pos[x].begin(), pos[x].end(), min);
    if (iter == pos[x].end()) return n;
    return *iter;
  };
  
  int cur = lower_bound(a, 0);
  cur = lower_bound(b, cur + 1);
  cur = lower_bound(c, cur + 1);
  return cur < n;
}

int solve(const std::string &str, int n) {
  for (int i = 0; i < n; ++i) {
    pos[str[i] - '0'].emplace_back(i);
  }
  int res = 0;
  for (int i = 0; i < 10; ++i) {
    for (int j = 0; j <10; ++j) {
      for (int k = 0; k < 10; ++k) {
        if (find(i, j, k, n)) ++res;
      }
    }
  }
  return res;
}

int main() {
  int n;
  std::cin >> n;
  std::string str;
  std::cin >> str;
  std::cout << solve(str, n) << std::endl;
  return 0;
}


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

#define int long long

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

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

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static final long MOD = 998244353;

	public static void main(String[] args) {
		int N = sc.nextInt();
		int X = sc.nextInt();
		long[][][] dp = new long[2][512][X + 1];
		for (int i = 0; i <= X; i++) {
			dp[0][i][i] = 1;
		}
		int t = 1;
		for (int i = 1; i < N; i++, t = 1 - t) {
			for (int j = 0; j < 512; j++) {
				Arrays.fill(dp[t][j], 0);
			}
			for (int j = 0; j < 512; j++) {
				long sum = 0;
				for (int k = 0; k <= X; k++) {
					sum += dp[1 - t][j][k];
					dp[t][j ^ k][k] += sum;
					dp[t][j ^ k][k] %= MOD;
				}
			}
		}
		long ans = 0;
		for (int i = 0; i <= X; i++) {
			ans += dp[1 - t][X][i];
		}
		System.out.println(ans % MOD);
	}
}



Measured memory_bytes: 32040
#include "bits/stdc++.h"
using namespace std;
int a[100000];
int main()
{
	int n, total = 0;
	scanf("%d", &n);
	for(int i = 0; i < n; ++i)
	{
		scanf("%d", &a[i]);
		--a[i];
	}
	for(int i = 1; i < n; ++i)
	{
		if(a[i - 1] == i - 1 && a[i] == i)
		{
			swap(a[i - 1], a[i]);
			++total;
		}
	}
	for(int i = 1; i < n; ++i)
	{
		if(a[i - 1] == i - 1 || a[i] == i)
		{
			if(a[i - 1] != i && a[i] != i - 1)
			{
				swap(a[i - 1], a[i]);
				++total;
			}
		}
	}
	printf("%d\n", total);
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;

int main() {
	int x;
	cin >> x;
	int ans = x;
	bool frag = true;
	while (frag) {
		frag = false;
		for (int i = 2; i*i <= ans; i++) {
			if (ans%i == 0) frag = true;
		}
		if (frag) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
 
typedef long long ll;
typedef vector<int> vi;
typedef unsigned long ul;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef set<int> si;
typedef multiset<int> mi;
 
const ll INF = 1e18;
const int MOD = 1e9+7;

int main() {
	
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
	
	int a, b;
	cin >> a >> b;
	cout << a*b << "\n";
	
	return 0;
}


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

int main(){
    long int x, k;
    cin >> k >> x;
    for(int i = x-k+1; i < x; i++){
        if(i >= -1000000){
            cout << i << " ";
        }
    }

    cout << x;
    for(int i = x+1; i < x+k; i++){
        if(i <= 1000000){
            cout << " " << i;
        }
    }

    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;


int main() {
	bool f=true;
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++){
		if(i%2==0){
			if(s.substr(i,1)=="L")f=false;
		}else{
			if(s.substr(i,1)=="R")f=false;
		}
	}
	if(f==true){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
#define fi first
#define sec second
using namespace std;
typedef pair<int,int> P;
 
int n, m, p, q, r;
int ans;
vector<P> v;
vector<P>::iterator it;
 
void solve(){
    ans = 0;
    v.clear();
    v.push_back(P(1,n));
    scanf("%d%d%d%d", &m, &p, &q, &r);
    int pst;
    for(int i = 0; i < m; i++){
        int x, y; scanf("%d%d", &x, &y);
        pst = 0;
        int cnt = 0;
        for(it = v.begin(); it != v.end(); it++){
            cnt++;
            pst += (*it).sec-(*it).fi+1;
            if(pst < x) continue;
            if(pst == x){
                x = cnt-1;
                break;
            }
            int in = (*it).sec;
            (*it).sec = (*it).sec-(pst-x);
            v.insert(it+1,P((*it).sec+1,in));
            x = cnt-1;
            break;
        }
        pst = 0;
        cnt = 0;
        /*
        for(int j = 0; j < v.size(); j++){
            printf(" %d %d\n", v[j].fi, v[j].sec);
        }
        */
        for(it = v.begin(); it != v.end(); it++){
            cnt++;
            pst += (*it).sec-(*it).fi+1;
            if(pst < y) continue;
            if(pst == y){
                y = cnt-1;
                break;
            }
            int in = (*it).sec;
            (*it).sec = (*it).sec-(pst-y);
            v.insert(it+1,P((*it).sec+1,in));
            y = cnt-1;
            break;
        }
        vector<P> tmp;
        for(int j = y+1; j < v.size(); j++) tmp.push_back(v[j]);
        for(int j = x+1; j <= y; j++) tmp.push_back(v[j]);
        for(int j = 0; j <= x; j++) tmp.push_back(v[j]);
        v = tmp;
        /*
        printf("\n");
        for(int j = 0; j < v.size(); j++){
            printf("%d %d\n", v[j].fi, v[j].sec);
        }
        */
    }
    /*
    for(int j = 0; j < v.size(); j++){
            printf("%d %d\n", v[j].fi, v[j].sec);
        }*/
    pst = 0;
    for(int i = 0; i < v.size(); i++){
        pst += v[i].sec-v[i].fi+1;
        int s = pst-(v[i].sec-v[i].fi), dif = 0;
        if(v[i].fi > r) continue;
        if(pst < p) continue;
        if(s > q) continue;
        if(s < p) dif = p-s;
        if(pst <= q){
            if(r >= v[i].sec) ans += v[i].sec-v[i].fi+1-dif;
            else ans += r-v[i].fi+1-dif;
        } else{
            if(r >= v[i].fi+q-s) ans += q-s+1-dif;
            else ans += r-v[i].fi+1-dif;
        }
        //printf("%d\n", ans);
    }
    printf("%d\n", ans);
}
 
int main(){
    while(scanf("%d", &n),n) solve();
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long N;
    cin >> N;
    vector<string> S(N);
    for(int i = 0; i < N; i++) cin >> S[i];
    map<string,long long> mp;
    for(int i = 0; i < N; i++) mp[S[i]] = 1;
    long long ans = 0;
    for(auto p : mp){
        ans += p.second;
    }
    cout << ans << endl;
}


Measured memory_bytes: 25084
n = int(input())
a = list(map(int, input().split()))
q = int(input())
count = dict()
ans = 0
for i in a:
  ans += i
  if(str(i) in count):
    count[str(i)] += 1
  else:
    count[str(i)] = 1

for i in range(q):
  b, c = input().split()
  now_n = 0
  if(b in count):
    now_n = count[b]
    count.pop(b)
    
  if(c in count):
    count[c] += now_n
  else:
    count[c] = now_n
    
  ans += now_n*(int(c) - int(b))
  print(ans)

Measured memory_bytes: 25572
/*
[dp] C - Vacation
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 1e5;

int N;
int abc[MAX_N + 1][3];
int dp[MAX_N + 1][3];

ll solve() {
    dp[0][0] = dp[0][1] = dp[0][2] = 0;
    for (int i = 1; i <= N; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (k == j) {
                    continue;
                }
                dp[i][j] = max(dp[i][j], dp[i - 1][k] + abc[i][j]);
            }
        }
    }
    int ans = max(dp[N][0], max(dp[N][1], dp[N][2]));
    return ans;
}

int main() {
    cin >> N;
    for (int i = 1; i <= N; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> abc[i][j];
        }
    }
    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    string T;
    cin>>T;
    if(T[0]=='?') T[0]='D';
    rep1(i, T.size()-1){
        if(T[i]=='?') T[i]='D';
    }
    cout<<T<<endl;
    return 0;
}


Measured memory_bytes: 3752
import sys
from collections import deque

read = sys.stdin.buffer.read


def main():
    N, D, A, *XH = map(int, read().split())
    monster = [0] * N
    for i, (x, h) in enumerate(zip(*[iter(XH)] * 2)):
        monster[i] = (x, (h + A - 1) // A)

    monster.sort()

    dq = deque([])
    damage = 0
    ans = 0

    for x, h in monster:
        while dq and dq[0][0] < x:
            damage -= dq.popleft()[1]

        if h > damage:
            dq.append((x + 2 * D, h - damage))
            ans += h - damage
            damage += h - damage

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 135656
#include<cstdio>

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

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

  if(a>b){
    int t = a;
    a = b;
    b = t;
  }

  printf("%d\n",a+w<b?b-a-w:0);

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef pair<int,int> pii;

const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
const char typ[5] = "DURL";

int h, w, n, sx, sy;
char a[200005], b[200005];

int main()
{
	scanf("%d%d%d%d%d",&h,&w,&n,&sx,&sy);
	scanf("%s%s",a+1,b+1);
	for(int i=1;i<=n;i++) {
		for(int j=0;j<4;j++) {
			if(typ[j] == a[i]) {
				a[i] = j;
				break;
			}
		}
		for(int j=0;j<4;j++) {
			if(typ[j] == b[i]) {
				b[i] = j;
				break;
			}
		}
	}
	int XS = 1, XE = h, YS = 1, YE = w;
	for(int i=n;i>=1;i--) {
		if(b[i] == 0) XS = max(XS - 1, 1);
		if(b[i] == 1) XE = min(XE + 1, h);
		if(b[i] == 2) YS = max(YS - 1, 1);
		if(b[i] == 3) YE = min(YE + 1, w);
		if(a[i] == 0) XE--;
		if(a[i] == 1) XS++;
		if(a[i] == 2) YE--;
		if(a[i] == 3) YS++;
		if(XS > XE || YS > YE) {
			puts("NO");
			return 0;
		}
	}
	puts(XS <= sx && sx <= XE && YS <= sy && sy <= YE ? "YES" : "NO");
}


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

int main() {
  string s;
  cin>>s;
  string a="abcdefghijklmnopqrstuvwxyz";
  int vec[26]={0};
  for(int i=0;i<s.size();i++){
    for(int j=0;j<26;j++){
      if(s[i]==a[j]){
        vec[j]++;
      }
    }
  }
  for(int i=0;i<26;i++){
    if(vec[i]==0){
      cout<<a[i]<<endl;
      return 0;
    }
  }
  cout<<"None"<<endl;
  return 0;
}

Measured memory_bytes: 512