akhauriyash/Code-Regression huggingface dataset:
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
#define inf 4e10
using namespace std;

const int maxn = 210000;

int n,m,A,B;

ll f[maxn];
struct seg
{
	ll mn,flag;
}segd[maxn<<2],sega[maxn<<2];
void pushup(const int x)
{
	int lc=x<<1,rc=lc|1;
	segd[x].mn=segd[lc].mn<segd[rc].mn?segd[lc].mn:segd[rc].mn;
	sega[x].mn=sega[lc].mn<sega[rc].mn?sega[lc].mn:sega[rc].mn;
}
void pushdown(const int x)
{
	int lc=x<<1,rc=lc|1;
	if(segd[x].flag)
	{
		ll fl=segd[x].flag; segd[x].flag=0;
		segd[lc].mn+=fl,segd[rc].mn+=fl;
		segd[lc].flag+=fl,segd[rc].flag+=fl;
	}
	if(sega[x].flag)
	{
		ll fl=sega[x].flag; sega[x].flag=0;
		sega[lc].mn+=fl,sega[rc].mn+=fl;
		sega[lc].flag+=fl,sega[rc].flag+=fl;
	}
}
void build(const int x,const int l,const int r)
{
	if(l==r) { segd[x].mn=f[l]-l,sega[x].mn=f[l]+l; return; }
	int mid=l+r>>1,lc=x<<1,rc=lc|1;
	build(lc,l,mid); build(rc,mid+1,r);
	pushup(x);
}
void add(ll c){ segd[1].flag+=c; sega[1].flag+=c; }
int loc; ll c;
void upd(const int x,const int l,const int r)
{
	if(l==r) { segd[x].mn=c-l,sega[x].mn=c+l;return; }
	pushdown(x);
	int mid=l+r>>1,lc=x<<1,rc=lc|1;
	if(loc<=mid) upd(lc,l,mid);
	else upd(rc,mid+1,r);
	pushup(x);
}
int lx,rx;
ll queryd(const int x,const int l,const int r)
{
	if(rx<l||r<lx) return inf;
	if(lx<=l&&r<=rx) return segd[x].mn;
	pushdown(x);
	int mid=l+r>>1,lc=x<<1,rc=lc|1;
	return min(queryd(lc,l,mid),queryd(rc,mid+1,r));
}
ll querya(const int x,const int l,const int r)
{
	if(rx<l||r<lx) return inf;
	if(lx<=l&&r<=rx) return sega[x].mn;
	pushdown(x);
	int mid=l+r>>1,lc=x<<1,rc=lc|1;
	return min(querya(lc,l,mid),querya(rc,mid+1,r));
}
ll G(const int x,const int l,const int r)
{
	if(l==r) return segd[x].mn+(ll)l;
	pushdown(x);
	int mid=l+r>>1,lc=x<<1,rc=lc|1;
	return min(G(lc,l,mid),G(rc,mid+1,r));
}

int main()
{
	scanf("%d%d%d%d",&n,&m,&A,&B);
	int las=A; for(int i=1;i<=n;i++) f[i]=i==A?inf:abs(B-i);
	build(1,1,n);
	
	while(m--)
	{
		int x; scanf("%d",&x);
		if(x==las) continue;
		lx=rx=las; ll cc=queryd(1,1,n)+(ll)las;
		lx=1,rx=x; cc=min(cc,queryd(1,1,n)+(ll)x);
		lx=x,rx=n; cc=min(cc,querya(1,1,n)-(ll)x);
		add(abs(x-las));
		loc=las; c=cc; upd(1,1,n);
		loc=x; c=inf; upd(1,1,n);
		las=x;
	}
	printf("%lld\n",G(1,1,n));
	
	return 0;
}


Measured memory_bytes: 23936
def main():
    n = int(input())
    A = list(map(int, input().split()))
    tot = sum(A)
    s = 0
    ans = float('inf')
    for a in A[:-1]:
        s += a
        ans = min(ans, abs(2 * s - tot))
    print(ans)

if __name__ == '__main__':
    main()


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

#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;


int main(){
  string s;
  cin >> s;
  
  if(s == "AAA" || s == "BBB")
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  
  
  //cout << n << endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    rep(i, M) cin >> A[i];
    
    int sum = 0;
    rep(i, M) sum += A[i];
    
    if (sum > N) cout << -1 << endl;
    else cout << N - sum << endl;
    return 0;
}


Measured memory_bytes: 7216
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 998244353
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>


using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());




int main()
{

    ios_base::sync_with_stdio(false); cin.tie(0);
    int l,r,d;
    cin >> l >> r >> d;
    int res = 0;
    ff(i,l,r)if(i%d == 0)res++;
    cout << res << "\n";
    return 0;
}


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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

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

ll fact[200001];
const int mod = 1e9 + 7;

ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while(n > 0) {
        if(n & 1) res = res * x % mod;
            x = x * x % mod;
            n >>= 1;
    }
    return res;
}

void init() {
    fact[0] = 1;
    for(ll i = 1; i <= 200000; i++) {
        fact[i] = fact[i - 1] * i;
        fact[i] %= mod;
    }
}

ll inv(ll x) {
    return mod_pow(x, mod - 2, mod);
}

ll comb(ll n, ll r) {
    return ((fact[n] * inv(fact[n - r])) % mod * inv(fact[r])) % mod;
}

map<int, int> getfact(ll M) {
    map<int, int> fact;
    for(int i = 2; i * i <= M; i++) {
        if (M % i == 0) {
            while(M % i == 0) {
                M /= i;
                fact[i]++;
            }
        }
    }
    if (M > 1) fact[M]++;
    return fact;
}

void solve() {
    init();

    ll N, M;
    cin >> N >> M;

    map<int, int> fact = getfact(M);

    ll ans = 1;
    for(auto && f : fact) {
        ans *= comb(f.second + N - 1, N - 1);
        ans %= mod;
    }
    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 1792
N = int(input())

basis = [(-2) ** d for d in range(64)]
cs = [1, -2]
for i in range(2, len(basis)):
    cs.append(cs[i - 2] + basis[i])

S = ['0'] * len(basis)

n = N
max_i = 0
while n != 0:
    if n > 0:
        for i in range(0, len(basis), 2):
            if cs[i] >= n:
                S[i] = '1'
                n -= basis[i]
                max_i = max(max_i, i)
                break
    else:
        for i in range(1, len(basis), 2):
            if cs[i] <= n:
                S[i] = '1'
                n -= basis[i]
                max_i = max(max_i, i)
                break

print(''.join(S[:max_i + 1])[::-1])


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

int main() {
	int n ;
	cin >> n;
	map<string , int> mm;
	for(int i = 0 ;i < n;i ++ ) {
		string s; cin >> s;
		sort(begin(s) , end(s));
		mm[s]++;
	}
	long long ans = 0;
	
	for(auto i : mm) {
		int val = i.second;
		ans += (1ll*val * (val - 1)) / 2;
	}
	cout << ans;
}
		


Measured memory_bytes: 11136
N,M=map(int,input().split())
hlist=list(map(int,input().split()))
dic={}
for i in range(N):
    dic[i+1]=hlist[i]
#print(dic)
ablist=[]
for i in range(M):
    ablist.append(list(map(int,input().split())))

#print(ablist)
flist=[]
for i in range(M):
    if dic[min(ablist[i])] > dic[max(ablist[i])]:
        flist.append(max(ablist[i]))
    elif dic[min(ablist[i])] < dic[max(ablist[i])]:
        flist.append(min(ablist[i]))
    elif dic[min(ablist[i])] == dic[max(ablist[i])]:
        flist.append(min(ablist[i]))
        flist.append(max(ablist[i]))
        
    #print(dic[min(ablist[i])],dic[max(ablist[i])])
#print(flist)

flist=set(flist)
#print(flist)

print(N-len(flist))

Measured memory_bytes: 43048
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>
#include <list>
#include <iomanip>
#include <cctype>

#define for0(i, N)    for (int i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (int i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (int i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (int i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (int i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (int i = (x), a = 0; a < (N);  \
                              i = (i + 1) % (N), ++a)

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, int){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, int){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef vector<ll> vll;
typedef vector<ld> vld;


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

    int n;
    cin >> n;

    map<string, ll> m;

    for0(i, n){
        string a;
        cin >> a;
        ++m[a];
    }

    ll mx = 0;
    for (auto &x : m){
        mx = max(mx, x.second);
    }

    for(auto &x : m){
        if (x.second == mx) {
            cout << x.first << "\n";
        }
    }

    return 0;
}


Measured memory_bytes: 23808
n=int(input())
a=list(map(int,input().split()))

def cnt(p):
  s=d=0
  for i in range(n):
    c=(s+a[i])*p
    if c<=0:
      d+=(1-c)
      s=p
    else:
      s+=a[i]
    p*=(-1)
  return d

da=cnt(1)
db=cnt(-1)
print(min(da,db))

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

int n, k;

int main() {
  cin >> n >> k;
  if ((n - 1) * (n - 2) / 2 < k) {
    cout << -1 << endl;
    return 0;
  }
  int m = 0;
  vector<int> u, v;
  for (int i = 2; i <= n; i++) {
    u.push_back(1);
    v.push_back(i);
    m++;
  }
  int rst = (n - 1) * (n - 2) / 2 - k;
  int x = 2;
  while (rst > 0) {
    for (int y = x + 1; y <= n; y++) {
      u.push_back(x);
      v.push_back(y);
      m++;
      if (--rst == 0) break;
    }
    x++;
  }
  cout << m << endl;
  rep(i, m) printf("%d %d\n", u[i], v[i]);
  return 0;
}

Measured memory_bytes: 3700
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int N = scan.nextInt();
			int[]C = new int[N];
			int[]S = new int[N];
			int[]F = new int[N];
			
			for(int i  = 0;i<N-1;i++) {
				C[i] = scan.nextInt();
				S[i] = scan.nextInt();
				F[i] = scan.nextInt();
			}
			
			for(int i = 0;i<N-1;i++) {
				int time = 0;
				time+=S[i];
				time+=C[i];
				for(int j = i+1;j<N-1;j++) {
					if(S[j]<=time) {
						if((time-S[j])%F[j]==0) {
							time+=C[j];
						}else {
							int s = F[j]-(time-S[j])%F[j];
							time+=s;
							time+=C[j];
						}
					}else {
						time = S[j];
						time+=C[j];
					}
				}
				
				System.out.println(time);
				
				
			}
			
			System.out.println(0);
			
		}
		
		
	}
		

}


Measured memory_bytes: 26212
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <time.h>

#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;



void solve()
{
    int n;
    scanf("%d", &n);
    int i;
    int cnt = 0;
    int ans = 0;
    for (i = 0; i < n; i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        if (a == b) {
            cnt++;
            if (cnt == 3) ans = 1;
        }
        else {
            cnt = 0;
        }
    }
    if (ans) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }

    return;
}

int main()
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for (t = 0; t < T; t++) {
        //printf("Case #%d: ", t + 1);
        solve();
    }
#endif
    return 0;
}



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

int  main(){
  int W, H, N;
  cin >> W >> H >> N;
  vector<int> vec(3*N);
  for(int i = 0; i < 3*N; i++){
    cin >> vec[i];
  }
  
  int left  = 0;
  int right = W;
  int down = 0;
  int up = H;
 
  for(int i = 0; i < N; i++){
    if(vec.at(3*i+2) == 1){
      if(vec.at(3*i) > left) left = vec.at(3*i);
    }
    if(vec.at(3*i+2) == 2){
      if(vec.at(3*i) < right) right = vec.at(3*i);
    }
    if(vec.at(3*i+2) == 3){
      if(vec.at(3*i+1) > down) down = vec.at(3*i+1);
    }
    if(vec.at(3*i+2) == 4){
      if(vec.at(3*i+1) < up) up = vec.at(3*i+1);
    }
  }
      
  
  
  
  if(right - left < 0 || up - down < 0){
    cout << 0 << endl;
  }
  else{
    cout << (right - left)*(up - down) << endl;
  }
}
  




Measured memory_bytes: 256
n = int(input())
b = [int(x) for x in input().split(' ')]
c = [9999999] * n

cnt = 0 
ss = 0
for i in range(n-1) :
    if(c[i] > b[i]) :
        c[i] = b[i]
    c[i+1] = b[i]

print(sum(c))

Measured memory_bytes: 3064
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int n, m;

int main() {
	string s;
	cin >> s;
	string::size_type  pos = 0;
	while ((pos = s.find("eraser", 0)) != std::string::npos) {
		s.replace(pos, 6, "");
	}
	pos = 0;
	while ((pos = s.find("erase", 0)) != std::string::npos) {
		s.replace(pos, 5, "");
	}
	pos = 0;
	while ((pos = s.find("dreamer", 0)) != std::string::npos) {
		s.replace(pos, 7, "");
	}
	pos = 0;


	while ((pos = s.find("dream", 0)) != std::string::npos) {
		s.replace(pos, 5, "");
	}
	if (s.length() == 0) {
		cout << "YES" << endl;
	}

	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 512
def main():
    N, A, B, dmin, dmax = [int(n) for n in input().split()]
    diff = B - A
    i = N-1
    for i in range(N):
        plusmin = dmin*i
        plusmax = dmax*i#(pmin, pmax)
        minusmin = dmin * (N-1-i)
        minusmax = dmax*(N-1-i)#(-mmax, -mmin)
        left = plusmin - minusmax
        right = -minusmin + plusmax
        if left <= diff <= right:
            print("YES")
            return
    print("NO")
main()


Measured memory_bytes: 3060
import sys
h, w = map(int, input().split())
a = [input() for i in range(h)]
t = 0
for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            if j < t:
                print("Impossible")
                sys.exit()
            t = j
print("Possible")

Measured memory_bytes: 3060
import static java.lang.System.out;
import java.util.Scanner;
import java.util.Arrays;
public class Main{
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in); 
      int n = sc.nextInt();
      int m = sc.nextInt();
      out.println((m-n)*2+ n);
   } 
}
     

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e5 + 6;
int a[N];
signed main()
{
	int n, ans = 0;
	cin >> n;
	for(int i = 1; i <= n ; i++ )
	{
		cin >> a[i];
	}
	for(int i = 1; i <= n; i++ )
	{
		ans += a[i] / 2;
		a[i] %= 2;
		if(a[i + 1] > 0)
		{
			ans += a[i];
			a[i + 1] = a[i + 1] - a[i];
		}
	}
	cout << ans << '\n';
}

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

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

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

        if x == y:
            return

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

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

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

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

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

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

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

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

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



n,m=map(int,input().split())
edge=[]
for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    edge.append((a,b))

#基準
uf=UnionFind(n)
for i in range(m):
    uf.union(edge[i][0],edge[i][1])
groups=uf.group_count()

ans=0

#全探索
for i in range(m):
    uf=UnionFind(n)
    for j in range(m):
        if j!=i:
            uf.union(edge[j][0],edge[j][1])
    if uf.group_count()>groups:
        ans+=1

print(ans)

    



Measured memory_bytes: 9160
#[test]
fn test_solve() {
   assert_eq!(solve("3 3\n1 2\n1 3\n2 3\n"), "2\n");
   assert_eq!(solve("7 7\n1 3\n2 7\n3 4\n4 5\n4 6\n5 6\n6 7\n"), "1\n");
}
fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let n: usize = sc.read();
    let m: usize = sc.read();
    let mut ngb = vec![Vec::new(); n];
    for _ in 0..m {
        let a: usize = sc.read();
        let b: usize = sc.read();
        ngb[a-1].push(b-1);
        ngb[b-1].push(a-1);
    }
    let mut cnt = 0;
    let mut vsd = vec![false; n];
    dfs(0, &mut cnt, &mut vsd, &ngb);
    format!("{}\n", cnt)
}
fn dfs(v: usize, cnt: &mut usize, vsd: &mut Vec<bool>, ngb: &Vec<Vec<usize>>) {
    vsd[v] = true;
    if vsd.iter().all(|&b| b) {
        *cnt += 1;
    }
    for &w in &ngb[v] {
        if !vsd[w] {
            dfs(w, cnt, vsd, ngb);
        }
    }
    vsd[v] = false;
}
fn main() {
    let mut buf = String::new();
    use std::io::{Read, Write};
    std::io::stdin().read_to_string(&mut buf).unwrap();
    std::io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}
struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
}

Measured memory_bytes: 4352
N = int(input())
a = list(map(int, input().split()))

min_color = 0
max_color = 0

cnt = 0

color = [0] * 8

for i in a:
    if i < 400 and color[0] == 0:
        min_color += 1
        max_color += 1
        color[0] = 1

    elif 400 <= i and i < 800 and color[1] == 0:
        min_color += 1
        max_color += 1
        color[1] = 1

    elif 800 <= i and i < 1200 and color[2] == 0:
        min_color += 1
        max_color += 1
        color[2] = 1

    elif 1200 <= i and i < 1600 and color[3] == 0:
        min_color += 1
        max_color += 1
        color[3] = 1

    elif 1600 <= i and i < 2000 and color[4] == 0:
        min_color += 1
        max_color += 1
        color[4] = 1

    elif 2000 <= i and i < 2400 and color[5] == 0:
        min_color += 1
        max_color += 1
        color[5] = 1

    elif 2400 <= i and i < 2800 and color[6] == 0:
        min_color += 1
        max_color += 1
        color[6] = 1

    elif 2800 <= i and i < 3200 and color[7] == 0:
        min_color += 1
        max_color += 1
        color[7] = 1

    elif i >= 3200:
        max_color += 1
        cnt += 1

if cnt == N:
    min_color = 1

print(min_color, max_color)


Measured memory_bytes: 3064
L, R = map(int, input().split())
mod = []
for i in range(L, R+1):
    if i % 2019 not in mod:
        mod.append(i % 2019)
    else:
        break

ans = mod[0] * mod[1] % 2019
for i in range(len(mod)):
    for j in range(i+1, len(mod)):
        if mod[i] * mod[j] % 2019 <= ans:
            ans = mod[i] * mod[j] % 2019
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) (v).begin(), (v).end()
#define fr(i, a, b) for (int i = (a); i <= (b); ++i)

void solve();

signed main () {
    clock_t beg = clock();
    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    #endif 
    int t = 1; 
    // cin >> t;    
    int tt = t;
    while (t--) {
        // cout << "Case #" << tt - t << ": "; 
        solve();
    }
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
    return 0;
}
const int N = 2e5 + 5;  
int a[N], b[N];
int n;
void solve() {
    auto beg_time = clock();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    cin >> n; 
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; ++i) {
        cin >> b[i];
    }
    int mx = 0, mn = 1e18;
    for (int i = 1; i <= n; ++i) {
        if (a[i] == b[i]) {
            mn = min(mn, i);
            mx = max(mx, i);
        }
    }
    if (mn == (int)1e18) {
        cout << "Yes\n";
        for (int i = 1; i <= n; ++i) {
            cout << b[i] << ' ';
        }
        return;
    }
    reverse(b + 1, b + n + 1);
    mx = 0, mn = 1e18;
    for (int i = 1; i <= n; ++i) {
        if (a[i] == b[i]) {
            mn = min(mn, i);
            mx = max(mx, i);
        }
    }
    if (mn == (int)1e18) {
        cout << "Yes\n";
        for (int i = 1; i <= n; ++i) {
            cout << b[i] << ' ';
        }
        return;
    }
    int te_mx = mx, te_mn = mn;
    reverse(b + 1, b + te_mx + 1);
    mx = 0, mn = 1e18;
    for (int i = 1; i <= n; ++i) {
        if (a[i] == b[i]) {
            mn = min(mn, i);
            mx = max(mx, i);
        }
    }
    if (mn == (int)1e18) {
        cout << "Yes\n";
        for (int i = 1; i <= n; ++i) {
            cout << b[i] << ' ';
        }
        return;
    }
    reverse(b + 1, b + te_mx + 1);
    reverse(b + te_mn, b + n + 1);
    mx = 0, mn = 1e18;
    for (int i = 1; i <= n; ++i) {
        if (a[i] == b[i]) {
            mn = min(mn, i);
            mx = max(mx, i);
        }
    }
    if (mn == (int)1e18) {
        cout << "Yes\n";
        for (int i = 1; i <= n; ++i) {
            cout << b[i] << ' ';
        }
        return;
    }    
    while (clock() - beg_time < 1.9 * CLOCKS_PER_SEC) {
        bool found = false;
        for (int i = 1; i <= n; ++i) {
            if (a[i] == b[i]) {
                swap(b[i], b[rng() % n + 1]);
                found = true;
                break;
            }
        }
        if (!found) {
            cout << "Yes\n";
            for (int i = 1; i <= n; ++i) {
                cout << b[i] << ' ';
            }
            return;
        }
    }
    cout << "No";
}

Measured memory_bytes: 6704
#include <iostream>
#include <algorithm>
using namespace std;
long long v[100005],A;
int n,i,cnt;
int main()
{
    cin>>n;
    for(i=1;i<=n;i++)  cin>>v[i];
    sort(v+1,v+n+1);
    A=1;
    for(i=n;i>=1;i--)
    {
        if(v[i]==v[i+1])
        {
            if(cnt<2)
            {
                A=1LL*A*v[i];
                v[i]=0;
                cnt++;
            }
        }
    }
    if(cnt==0||cnt==1) A=0;
    cout<<A;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long
#define endl "\n"
signed main()
{
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);
		cout.tie(NULL);
		int x;
		cin>>x;
		if(x>=400&&x<=599)
				cout<<8;
		else if(x>=600&&x<=799)
				cout<<7;
		else if(x>=800&&x<=999)
				cout<<6;
		else if(x>=1000&&x<=1199)
				cout<<5;
		else if(x>=1200&&x<=1399)
				cout<<4;
		else if(x>=1400&&x<=1599)
				cout<<3;
		else if(x>=1600&&x<=1799)
				cout<<2;
		else if(x>=1800&&x<=1999)
				cout<<1;
				 








		return 0;	
}


Measured memory_bytes: 3648
#include<iostream>
using namespace std;
int main(){
	long long int n,m,p=0;
	
	cin>>n>>m;
	
	if(2*n <= m){
		p = n;
		p += (m-2*n)/4;
	}else{
		p = m/2;
	}
	
	cout<<p<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define vl vector<ll>
#define el '\n'
#define pll pair<ll, ll>
#define mll map<ll,ll>
#define vpll vector<pll>
#define vvll vector<vector<ll> >
#define vvpll vector< vector<pll> >
#define ff first
#define ss second
#define fastio() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
using namespace std;
typedef long long ll;

int main() 
{
    fastio();
 
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0 ; i<n ; i++)
        cin>>a[i];
        
    ll dp[n];
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    
    for(ll i=2 ; i<n ; i++)
        dp[i] = min(dp[i-1] + abs(a[i] - a[i-1]), dp[i-2] + abs(a[i-2] - a[i]));
        
    cout<<dp[n-1];
        
    return 0;
}

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

int dp[200009];
int n,x;

int main()
{
    scanf("%d",&n);
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&x);
        dp[x]=dp[x-1]+1;
        ans=max(ans,dp[x]);
    }
    ans=n-ans;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1024
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N, K = map(int, input().split())
    R, S, P = map(int, input().split())
    T = input()

    score = {'r': P, 's': R, 'p': S}
    ans = 0
    for i in range(K):
        prev = ''
        while i <= N - 1:
            if T[i] != prev:
                ans += score[T[i]]
                prev = T[i]
            else:
                prev = ''
            i += K
    print(ans)


main()


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

using namespace std;
using ll = long long;


int main()
{
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++)cin >> a[i];
    int num = 0;
    for(int i = 0; i < n; i++)num^= a[i];
    for(int i = 0; i < n; i++) {
        cout << (a[i]^num) << endl;
    }
}

Measured memory_bytes: 4044
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;
#include <functional>

int main(void){
    Cin(string, s, t);
    int ns = s.size();
    int nt = t.size();
    vc<vc<int>> next(ns*2, vc<int>(26, -1));
    
    string ss = s + s;
    For(i, ns*2){
        int k = ss[i] - 'a';
        for(int j = i-1; j >= 0 && next[j][k] == -1; j --){
            next[j][k] = i-j;
        }
    }
    
    ll ans = -1;
    For(i, nt){
        int j = (ans + ns) % ns;
        int k = t[i] - 'a';
        if(next[j][k] == -1){
            Cout(-1);
            return 0;
        }
        ans += next[j][k];
    }
    Cout(ans+1);
}


Measured memory_bytes: 27264
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
using namespace std;

const long long MAX_N = 1e4 + 4;
long long n, ans;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for (long long i = 1; i * i < n; i++)
		if (n % i == 0) {
			long long a = i;
			long long b = n / i;
			b--;
			if (a >= b)
				continue;
			
			ans += b;
		}

	cout << ans;
	return 0;
}

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

int G[MAX][MAX];

void arrayInit(int n) {
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			G[i][j] = 0;
		}
	}
}

void input(int n) {
	int m, g, k;
	for (int i = 0; i < n; i++) {
		cin >> m >> k;
		--m;
		for (int j = 0; j < k; j++) {
			cin >> g;
			--g;
			G[m][g] = 1;
		}
	}
}

void output(int n) {
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (j)cout << " ";
			cout << G[i][j];
		}
		cout << endl;
	}
}

int main() {
	int size;
	cin >> size;
	arrayInit(size);
	input(size);
	output(size);
	return 0;
}

Measured memory_bytes: 1200
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << 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...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

int solve(vector<ii>& a) {
  int n = a.size();
  vector<ii> L(n), R(n);
  L[0] = a[0];
  for (int i = 1; i < n; ++i) {
    L[i] = L[i - 1];
    L[i].first = max(L[i].first, a[i].first);
    L[i].second = min(L[i].second, a[i].second);
  }
  R[n - 1] = a[n - 1];
  for (int i = n - 2; i >= 0; --i) {
    R[i] = R[i + 1];
    R[i].first = max(R[i].first, a[i].first);
    R[i].second = min(R[i].second, a[i].second);
  }
  int ret = 0;
  for (int i = 0; i < n - 1; ++i) {
    int X = max(0, L[i].second - L[i].first + 1);
    int Y = max(0, R[i + 1].second - R[i + 1].first + 1);
    // trace(i, X, Y);
    ret = max(ret, X + Y);
  }
  return ret;
}

int main() {
  int n;
  scanf("%d", &n);
  vector<ii> a(n);
  int ret = 0;
  set<ii> A, B;
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &a[i].first, &a[i].second);
    A.insert({a[i].first, i});
    B.insert({a[i].second, i});
  }
  for (int i = 0; i < n; ++i) {
    int cur = a[i].second - a[i].first + 1;
    A.erase({a[i].first, i});
    B.erase({a[i].second, i});
    cur += max(0, B.begin()->first - A.rbegin()->first + 1);
    ret = max(ret, cur);
    A.insert({a[i].first, i});
    B.insert({a[i].second, i});
  }
  sort(a.begin(), a.end());
  ret = max(ret, solve(a));
  sort(a.begin(), a.end(), [](const ii& u, const ii& v) {
                             return u.first + u.second < v.first + v.second;
                           });
  ret = max(ret, solve(a));
  for (auto& it : a) {
    it.first = -it.first;
    it.second = -it.second;
    swap(it.first, it.second);
  }
  sort(a.begin(), a.end());
  ret = max(ret, solve(a));
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 12032
# coding: utf-8
# Your code here!

# Sを abc を並び替えて作ることができるなら Yes を、そうでないなら No を出力せよ。

S = input()

# print(S)

# print(S.find('a') >= 0)
# print(S.find('b') >= 0)
# print(S.find('c') >= 0)

# print('a' in S)
# print('b' in S)
# print('c' in S)

if ('a' in S) and ('b' in S) and ('c' in S):
    print('Yes')
else:
    print('No')

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

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	void main() {
		int a = sc.nextInt();
		int b = sc.nextInt();
		println(6 - a - b);
	}
}


Measured memory_bytes: 21204
//
//  main.cpp
//  atcoder
//
//  Created by Hisaki Kobayashi on 2020/04/14.
//  Copyright © 2020 Hisaki Kobayashi. All rights reserved.
//

#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
const int MAX_N = 200000;


int main(int argc, const char * argv[]) {
    
    int N;
    cin >> N;
    
    set<string> st;
    
    for(int i=0;i<N;i++){
        string temp;
        cin >> temp;
        st.insert(temp);
    }
    
    cout << st.size() << endl;
    
    return 0;
    
}




Measured memory_bytes: 19180
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL H, A; cin >> H >> A;
		cout << ((H - 1) / A + 1) << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


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

int Max(int a, int b)
{
	if(a>b) return a;
	return b;
}

int main()
{
	int i,j,k,R,C,a[10][10000],b,w,a1[10][10000],s,p,s_max;
	
	while(1)
	{
	   cin >> R;
	   cin >> C;
	   if(R==0) break;
	   s_max=0;
	   for(i=0;i<=R-1;i++)
	   {
		   for(j=0;j<=C-1;j++)
		   {
		    	cin >> a[i][j];
		   }
	   }
	   for(i=0;i<=pow(2,R)/2-1;i++)
	   {
		   s=0;
		   p=i;
		   for(j=0;j<=R-1;j++)
		   {
			   if(p%2==1)
			   {
				   for(k=0;k<=C-1;k++)
				   {
					   if(a[j][k]==0) a1[j][k]=1;
					   else a1[j][k]=0;
				   }
			   }
			   else
			   {
				   for(k=0;k<=C-1;k++)
				   {
					   a1[j][k]=a[j][k];
				   }
			   }
			   p/=2;
		   }
		   for(j=0;j<=C-1;j++)
		   {
			   b=0;
			   w=0;
			   for(k=0;k<=R-1;k++)
			   {
				   if(a1[k][j]==0) b++;
				   else w++;
			   }
			   s+=Max(b,w);
		   }
		   if(s_max<s) s_max=s;
	   }
	   printf("%d\n",s_max);
	}
	return 0;
}

Measured memory_bytes: 4068
// need
#include <iostream>
#include <algorithm>
// data structure
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
//#include <deque>
#include <valarray>
#include <unordered_map>
#include <array>
// stream
//#include <istream>
#include <sstream>
//#include <ostream>
#include <fstream>
// etc
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
//#include <chrono>
#include <random>
#include <numeric>
using namespace std;
int odd(int n)
{
  return 3*n+1;
}
int even(int n)
{
  return n/2;
}

int main()
{
  int s, s2;
  int answer[1000005];
  cin >> s;
  answer[0] = s;
  for(int i = 1;; i++){
    if(s % 2 == 0)
      s = even(s);
    else
      s = odd(s);
    for(int j = 0; j < i; j++){
      if(s == answer[j]){
        cout << (i+1) << endl;
        return 0;
      }
      answer[i] = s;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Yes":"No");
}

int main() {
  int h,w;cin>>h>>w;
  vector<string> m(h);
  rep(i,h){
    cin>>m[i];
  }
  vector<vector<int>> dp(h,vector<int>(w,INT_MAX));
  rep(i,h){
    rep(j,w){
      if(i==0&&j==0){
        dp[0][0]=(m[0][0]=='#');
      }
      if(i>0){
        int cur=(m[i][j]=='#')&&(m[i-1][j]=='.');
        dp[i][j]=min(dp[i][j],dp[i-1][j]+cur);
      }
      if(j>0){
        int cur=(m[i][j]=='#')&&(m[i][j-1]=='.');
        dp[i][j]=min(dp[i][j],dp[i][j-1]+cur);
      }
    }
  }
#ifdef yskshi
  rep(i,h){
    rep(j,w){
      cout<<dp[i][j]<<" ";
    }
    cout<<endl;
  }
#endif
  cout<<dp[h-1][w-1]<<endl;
  return 0;
}

Measured memory_bytes: 256
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

A, B = map(int, input().split())
print((B - 1 + A - 2) // (A - 1))



Measured memory_bytes: 38256
def main():
	'''
	メイン関数
	'''
	# a
	N = int(input())
	
	SPList_reverse = []

	for n in range(0,N):
		SP = input().split()
		sp_tuple_reverse = SP[0], (100-int(SP[1]))
		SPList_reverse.append(sp_tuple_reverse)


	sortedSPList = sorted(SPList_reverse)


	for ssp in sortedSPList :
		ori = ssp[0], int(ssp[1])
		print(SPList_reverse.index(ori)+1)



if __name__ == '__main__':
	main()


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

int main(){
  int grade[9]={0};
  int N;
  cin>>N;
  int tmp=0;
  for(int i =0;i<N;i++){
    cin>>tmp;
    if(tmp<3200) grade[tmp/400]++;
    else grade[8]++;
  }
  int colors=0;
  for(int i=0;i<8;i++){
    if(grade[i]>0) colors++;
  }
  int minans,maxans;
  maxans=colors+grade[8];
  if(colors==0) minans=1;
  else minans=colors;
  cout<<minans<<" "<<maxans<<endl;
  return 0;
}

Measured memory_bytes: 256
def Knapsack1(W,w,v): # n個のナップザック(重さw[i],価値v[i]) 総重量W以内での価値の最大化
    n=len(w)
    # dp[i][j] : i番目の品物で重さj以下の価値の最大値
    dp=[[0 for _ in range(W+1)] for _ in range(n+1)]
    for i in range(1,n+1):
        for j in range(W+1):
            dp[i][j]=max( dp[i][j],dp[i-1][j] )
            if j >= w[i-1]:
                dp[i][j]=max(dp[i][j],dp[i-1][j-w[i-1]]+v[i-1])
    print(max(dp[n]))

def main():
    n,W = map(int,input().split())
    w=[0 for _ in range(n)]
    v=[0 for _ in range(n)]
    for i in range(n):
        w[i],v[i] = map(int,input().split())
    Knapsack1(W,w,v)
if __name__ == "__main__":
    main()


Measured memory_bytes: 171528
r,c=[int(x) for x in input().split()]
s_row=[0 for x in range(c+1)]
for i in range(r):
	row=[int(x) for x in input().split()]
	row.append(sum(row))
	print(" ".join([str(x) for x in row]))
	s_row=[x+y for x,y in zip(s_row,row)]
print(" ".join([str(x) for x in s_row]))


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void ans1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j;
  ll n; cin>>n;
  //ll a,b,c,d,e,f; cin>>a>>b;
  //ll a,b,c,d,e,f; cin>>a>>b>>c;
  //ll a,b,c,d,e,f; cin>>a>>b>>c>>d;
  //string s; cin >> s;
  ll result = 0;
  ll buf = 0;
  bool judge = true;
  cout<<48-n<<endl;

  /*
  vector<ll> a(n);
  for(i=0;i<n;i++){
    cin>>a[i];
  }
  for(i=0;i<n;i++){

  }
  */

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
using namespace std;


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

int main(){
    int X, N;
    unordered_set<int> u_s;
    cin >> X >> N;
    for(int i = 0; i < N; ++i){
        int tmp;
        cin >> tmp;
        u_s.insert(tmp);
    }
    if(u_s.find(X) == u_s.end()){
        cout << X << endl;
        return 0;
    }
    int dif = 1;
    while(1){
        if(u_s.find(X-dif) == u_s.end()){
            cout << X-dif << endl;
            break;
        }

        if(u_s.find(X+dif) == u_s.end()){
            cout << X+dif<< endl;
            break;
        }
        ++dif;
    }

    return 0;
}

Measured memory_bytes: 3568
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
#define MAX ((int)1e9+10)

vector<vector<int>> d;
vector<vector<int>> d1;
vector<vector<int>> d2;
void warshall_floyd(int n, int x) {
    for (int k = 0; k < n; k++){       // 経由する頂点
        for (int i = 0; i < n; i++) {    // 始点
            for (int j = 0; j < n; j++) {  // 終点
                switch (x) {
                    case 0: d[i][j] = min(d[i][j], min(d[i][k] + d[k][j], MAX));break;
                    case 1: d1[i][j] = min(d1[i][j], min(d1[i][k] + d1[k][j], MAX));break;
                    case 2: d2[i][j] = min(d2[i][j], min(d2[i][k] + d2[k][j], MAX));break;
                }
            }
        }
    }
}
int main(){
    int n,m,l;
    cin >> n >> m >> l;
    d = vector<vector<int>>(n, vector<int>(n, MAX));
    d1 = vector<vector<int>>(n, vector<int>(n,MAX));
    d2 = vector<vector<int>>(n, vector<int>(n,MAX));
    for(int i = 0; i < n;i++){
        d[i][i] = 0;
        d1[i][i] = 0;
        d2[i][i] = 0;
    }
    for(int i =  0;i < m;i++){
        int a,b, c;
        cin >> a >> b >> c;
        d[a-1][b-1] = c;
        d[b-1][a-1] = c;
    }
    warshall_floyd(n,0);
    for(int i  = 0; i < n-1; i++) {
        for (int j = i + 1; j < n; j++) {
            if (d[i][j] <= l){
                d1[i][j] = 1;
                d1[j][i] = 1;
            }
        }
    }

    warshall_floyd(n,1);

    int q;
    cin >> q;
    for(int i = 0; i < q; i++){
        int  s,t;
        cin >> s >> t;
        if(d1[s-1][t-1] == MAX){
            cout << -1 << endl;
        }else {
            cout << d1[s - 1][t - 1]-1 << endl;
        }
    }
}

Measured memory_bytes: 4708
import java.util.*;

public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] p = new int[N];
        int[] a = new int[N+1];
        for(int i = 0; i < N; i++){
            p[i] = sc.nextInt();
            if(p[i] == i+1)
                a[i] = 1;
        }
        sc.close();
        int i = 0;
        int ans = 0;
        while(i < N){
            if(a[i] == 1){
                int count = 0;
                while(a[i] == 1){
                    count++;
                    i++;
                }
                ans += (count+1)/2;
            }
            i++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 60536
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
    int x;
    char c;
    int f=1;
    while((c=getchar())!='-' && (c>'9' || c<'0'));
    if(c=='-') f=-1,c=getchar();
    x=c^'0';
    while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
    return x*f;
}
inline ll readll(){
    ll x;
    char c;
    int f=1;
    while((c=getchar())!='-' && (c>'9' || c<'0'));
    if(c=='-') f=-1,c=getchar();
    x=c^'0';
    while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
    return x*f;
}
const int maxn=2e5+10;
int a[maxn];
ll sum[maxn];
int main(){
	int n=read(),m=read();
	ll ans=1e18;
	REP(i,1,n) a[i]=read(),sum[i]=sum[i-1]+a[i];
	REP(i,1,n){
		ll res=0;
		REP(j,1,n/i+1){
			res+=(sum[n-(j-1)*i]-sum[max(n-j*i,0)])*(j==1?5:(j+1)*2-1);
			if(res>ans) break;
		}
		res+=(ll)i*m;
		chkmin(ans,res);
	}
	printf("%lld\n",ans+(ll)n*m);
    return 0;
}

Measured memory_bytes: 2560
# ABC142E - Get Everything
def main():
    N, M = map(int, input().split())
    p = 1 << N
    dp = [float("inf")] * p
    dp[0] = 0
    for _ in range(M):
        a, _ = map(int, input().split())
        x = sum(1 << (i - 1) for i in map(int, input().split()))
        for y in range(p):
            if dp[x | y] > dp[y] + a:
                dp[x | y] = dp[y] + a
    ans = dp[-1] if dp[-1] != float("inf") else -1
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 47448
#include <stdio.h>

int main(){
  int i,f=1;
  char s[105],c[2]={'L','R'};
  scanf("%s",&s);
  for(i=0;s[i]!=0;i++){
    if(s[i]==c[i&1]) break;
  }
  if(s[i]==0){
    printf("Yes");
  }else{
    printf("No");
  }
  return(0);
}


Measured memory_bytes: 128