akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N; cin >> N;
  
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    int d; cin >> d;
    vec.at(i) = d;
  }
  
  vector<int> zero(N);
  
  int counter = 0;
  
  while (vec != zero) {
    
    int max = 0;
    
    for (int i = 0; i < N; i++) {
      if (max < vec.at(i)) max = vec.at(i);
    }
    
    for (int i = 0; i < N; i++) {
      if (max == vec.at(i)) vec.at(i) = 0;
    }
    
    counter++;
    
  }
  
  cout << counter << endl;
  
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef vector<int> vint;
#define rep(i,n) for(lint i = 0;i < n;i++)
#define all(x) x.begin(),x.end()
#define clr(a) memset(a,0,sizeof(a))
int main(void){
    lint N;
    cin >> N;
    if(N >= 100 && N <= 111)
        cout << "111";
    else if(N >= 112 && N <= 222)
        cout << "222";
    else if(N >= 223 && N <= 333)
        cout << "333";
    else if(N >= 334 && N <= 444)
        cout << "444";
    else if(N >= 445 && N <= 555)
        cout << "555";
    else if(N >= 556 && N <= 666)
        cout << "666";
    else if(N >= 667 && N <= 777)
        cout << "777";
    else if(N >= 778 && N <= 888)
        cout << "888";
    else if(N >= 889 && N <= 999)
        cout << "999";
    return 0;
}
/*
ループ for(lint i = 0;i < N;i++)
ソート sort(a,a+N);
*/

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

int func(vector<int>arr,int n,int k,int minv)
{
    vector<int>dp(k+1,1);

    for(int i=0;i<minv;i++)
    dp[i]=0;

    for(int i=minv;i<=k;i++)
    {
        for(int p=0;p<n;p++)
        {
           if(arr[p] <= i)
           {    
                int rem = i - arr[p];
                dp[i] = dp[i] & dp[rem];
                // if(dp[rem]==0) dp[i]=1;
           }
        }
        dp[i]=!dp[i];
    }

    return dp[k];
}

int main() {
    
    int n,k;  cin>>n>>k;
    vector<int>arr(n);
    for(int i=0;i<n;i++) cin>>arr[i];
    int minv = *min_element(arr.begin(),arr.end());
    int ans = func(arr,n,k,minv);
    if(ans==1) cout<<" First "<<endl;
    else cout<<" Second "<<endl;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
#include<string>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;
const ll mod = 1000000007;


int main() {
 ll N,A,B;
  in(N>>A>>B);
  if(A%2==B%2) out(abs(A-B)/2);
  else {
    ll M=max(A,B);
    ll m = min(A,B);
    ll k = min(N-M,m-1);
    out(k+(abs(B-A)/2)+1);
  }
  }


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define FOR(i,a,n) for(i=a;i<n;i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
int a[100000];
int main(void)
{
	int n,c,k,cnt,res=0,t,i;
	scanf("%d%d%d",&n,&c,&k);
	FOR(i,0,n) scanf("%d",&a[i]);
	qsort(a,n,sizeof(int),comp);
	for(i=0;;){
		t=a[i]+k;
		cnt=0,res++;
		while(i<n&&cnt<c&&a[i]<=t) i++,cnt++;
		if(i==n) break;
	}
	printf("%d\n",res);
	return 0;
}
    


Measured memory_bytes: 892
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define endl '\n'
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
using namespace std;
using namespace __gnu_pbds;

int32_t main() {
	int n;
	cin >> n;
	while(n--) {
		int x;
		cin >> x;
		if(x%2 == 0 && !(x%3 == 0 or x%5 == 0) ) { 
			cout << "DENIED" << endl;
			return 0;
		}
	}
	cout << "APPROVED" << endl;

}

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <queue>
#include <cctype>
#include <climits>
#include <stack>
#include <map>
#include <cstring>
 
using namespace std;

long long res;

void dfs(vector<long long> &a,int pos,long long p){
	if(pos==a.size()){
		res+=(p==0);
		return;
	}

	for(int i=-1;i<=1;i++){
		long long q=(p*(a[pos]+i))%2;
		dfs(a,pos+1,q);
	}

}

int main(){

	int n;
	cin>>n;

	vector<long long> a(n);
	for(int i=0;i<n;i++) cin>>a[i];

	dfs(a,0,1);
	cout<<res<<endl;

	return 0;
}


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

//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
typedef pair<int, int> P;
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;
#define ret() return 0;

bool contain(set<char> &s, char a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;

int main() {

    int n, m;
    cin >> n >> m;

    vector<vector<int>> code(n);

    rep(i, m) {
        int k;
        cin >> k;

        rep(j, k) {
            int s;
            cin >> s;
            s--;
            code[s].push_back(i);
        }
    }

    vector<int> ps(m);
    rep(i, m) cin >> ps[i];
    int ans = 0;
    for (int i = 0; i < (1 << n); i++) {

        vector<int> amp(m, 0);

        for (int j = 0; j < n; j++) {
            if ((i >> j) & 1) {

                for (int k : code[j]) {
                    amp[k]++;
                }

            }
        }

        [&] {
            for (int j = 0; j < m; j++) {
                if (amp[j] % 2 != ps[j]) {
                    return;
                }
            }
            ans++;
        }();

    }
    cout << ans << endl;
}



Measured memory_bytes: 256
while True:
    m, f, r = map(int, input().split())
    score = m + f
    if m == f == r == -1:
        break
    elif m == -1 or f == -1:
        print('F')
    elif score >= 80:
        print('A')
    elif score >= 65:
        print('B')
    elif score >= 50 or (score >= 30 and r >= 50):
        print('C')
    elif score >= 30:
        print('D')
    else:
        print('F')



Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
    int k=0;
    for(int i=1; i<=n; ++i){
        int a; cin >> a;
        if(a==k+1) ++k;
    }
	cout << (k==0 ? -1 : n-k) << endl;
}

Measured memory_bytes: 384
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 15, inf = 1e9;
char cn[cm], * ci = cn, ct;
bool kotae[100][100];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	fread(cn, 1, cm, stdin);

	int N = 0, M = 0;
	while ((ct = *ci++) >= '0') N = N * 10 + ct - '0';
	while ((ct = *ci++) >= '0') M = M * 10 + ct - '0';
	
	int E[100][100];
	rep(j, N) rep(i, j) E[i][j] = inf;

	rep(i, M) {
		int a = 0, b = 0, c = 0;
		while ((ct = *ci++) >= '0') a = a * 10 + ct - '0';
		while ((ct = *ci++) >= '0') b = b * 10 + ct - '0';
		while ((ct = *ci++) >= '0') c = c * 10 + ct - '0';
		a--;
		b--;
		E[a][b] = c;
		E[b][a] = c;
	}

	rep(k, N) {
		rep(j, k) {
			rep(i, j) {
				if (E[i][j] > E[i][k] + E[j][k]) {
					E[i][j] = E[i][k] + E[j][k];
					kotae[i][j] = 1;
				}
			}
		}
		for (int j = k + 1; j < N; j++) {
			rep(i, k) {
				if (E[i][j] > E[i][k] + E[k][j]) {
					E[i][j] = E[i][k] + E[k][j];
					kotae[i][j] = 1;
				}
			}
			for (int i = k + 1; i < j; i++) {
				if (E[i][j] > E[k][i] + E[k][j]) {
					E[i][j] = E[k][i] + E[k][j];
					kotae[i][j] = 1;
				}
			}
		}
	}

	int kazu = 0;
	rep(j, N) rep(i, N) kazu += kotae[i][j];

	printf("%d", kazu - N * (N - 1) / 2 + M);

	Would you please return 0;
}

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

using namespace std;


const int N = 100005;

int a[N];
int f[N];

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
  }
  if (k - 1 > n) {
    printf("%d\n", abs(a[0] - a[n - 1]));
    return 0;
  }
  f[0] = 0;
  for (int i = 1; i <= k && i < n; i++) {
    f[i] = abs(a[i] - a[0]);
  }
  for (int i = k + 1; i < n; i++) {
    f[i] = 1e9;
    for (int j = 1; j <= k; j++) {
      f[i] = min(f[i], f[i - j] + abs(a[i] - a[i - j]));
    }
  }
  printf("%d\n", f[n - 1]);
  return 0;
}

Measured memory_bytes: 1024
N, M = map(int, input().split())

l = []

for i in range(N):
    A = [int(x) for x in input().split()]

    for j in range(1, A[0] + 1):
        l.append(A[j])

ans = 0

for i in range(M + 1):
    if l.count(i) == N:
        ans += 1

print(ans)

Measured memory_bytes: 9184
A,B,C,D,E,F = map(int,input().split())
c_max = 0
sw_max = 0
s_max = 0

for a in range(F//100*A+1):
    for b in range((F-a*A*100)//100*B+1):
        water = 100*(a*A+b*B)
        limit = F-water
        for c in range(limit//C+1):
            for d in range((limit-c*C)//D+1):

                sugar = c*C + d*D
                
                if water == 0 or sugar == 0:
                    continue
                conc = sugar / (sugar + water)
                if water + sugar <= F and sugar/(water//100) <= E and conc > c_max:
                    c_max = conc
                    sw_max = sugar + water
                    s_max = sugar
if c_max ==0:
    sw_max = 100*A
    s_max=0
print(sw_max,s_max)

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int w,a,b,c,d;
	cin>>w;
	a=w/1000,b=(w%1000)/100,c=((w%1000)%100)/10,d=((w%1000)%100)%10;
	if(a+b+c+d==7){
		cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
	}else if(a+b+c-d==7){
		cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
	}else if(a+b-c+d==7){
		cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
	}else if(a+b-c-d==7){
		cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
	}else if(a-b+c+d==7){
		cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
	}else if(a-b+c-d==7){
		cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
	}else if(a-b-c+d==7){
		cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
	}else if(a-b-c-d==7){
		cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
//Finding Missing Cards

#include<stdio.h>

int main()
{
    int i=1, j=1;
    int max = 0, num=0;
    int S[14]={0};
    int H[14]={0};
    int C[14]={0};
    int D[14]={0};
//    char  str;
    char  str[1];
    
    scanf("%d ", &max);
//    printf("%d\n",max);
//    if(max>52) return 0;
    
    for(j=1; j<=max; j++){ //真ん中は終了条件
//        printf("%d\n",j);
//        printf("for start\n");
//        scanf("%c %d", &str, &num); //%cではだめ？ //0Sとか2文字入ってる
        scanf("%c %d ", &str, &num); 
//        printf("%c %d", str, num);//http://freeh.minim.ne.jp/minimini/develop/cscanf.html
        if(str[0]=='S'){
            S[num] = 1;
        }else if(str[0]=='H'){
            H[num] = 1;
        }else if(str[0]=='C'){
            C[num] = 1;
        }else if(str[0]=='D'){
            D[num] = 1;
        }
//        printf("for end\n");
    }
//    printf("\n");
    
    
    for(i=1; i<=13; i++){
        if(S[i] == 0) printf("S %d\n", i);
    }
    for(i=1; i<=13; i++){
        if(H[i] == 0) printf("H %d\n", i);
    }
    for(i=1; i<=13; i++){
        if(C[i] == 0) printf("C %d\n", i);
    }
    for(i=1; i<=13; i++){
        if(D[i] == 0) printf("D %d\n", i);
    }
    
    return 0;
}


Measured memory_bytes: 2040
#include "bits/stdc++.h"
using namespace std;
const int INF = 1001001001;
int main() {
	int N, M, R;
	cin >> N >> M >> R;
	vector<int> r(R);
	vector<vector<int>> dist(N, vector<int>(N, INF));
	for (int n = 0; n < R; ++n) {
		cin >> r[n];
		r[n]--;
	}
	for (int n = 0; n < M; ++n) {
		int a, b, c;
		cin >> a >> b >> c;
		--a;
		--b;
		dist[b][a] = c;
		dist[a][b] = c;
	}
	//わーしゃるふろいど
	for (int k = 0; k < N; ++k) {
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}

	int ans = 1e9;
	vector<int> v;
	for (int n = 0; n < R; ++n) {
		v.push_back(n);
	}
	map<vector<int>, int>mp;
	do {
		int memo = 0;
		for (int i = 0; i < R - 1; ++i) {
			memo += dist[r[v[i]]][r[v[i + 1]]];
		}
		ans = min(ans, memo);
	} while (next_permutation(v.begin(), v.end()));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3776
#include<bits/stdc++.h>
#define PI (3.14159265358979323846)
using namespace std;
typedef long long ll;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long double r;
    cin>>r;
    cout<<2*PI*r<<'\n';
    return 0;
}

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

ll powInt(ll n, ll p){
    if (p == 0) return 1;
    if (p % 2 == 0) {
        ll t = powInt(n, p / 2);
        return t * t;
    }
    return n * powInt(n, p - 1);
}

int main() {
    int n;
    cin >> n;
    if (n == 1) {
        cout << 1 << endl;
        return 0;
    }
    priority_queue<int> pq;
    for (int i = 2; i < n; ++i) {
        for (int j = 2; j < n; ++j) {
            int p = powInt(i, j);
            if (p <= n) pq.push(p);
            else break;
        }
    }
    cout << pq.top() << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = "";
        int n, score, hit, out;
        while((line = br.readLine()) != null) {
            n = Integer.parseInt(line);
            for(; n>0; n--) {
                score = 0;
                hit = 0;
                out = 0;
                while(out < 3) {
                    line = br.readLine();
                    if("HIT".equals(line)) {
                        if(hit == 3)
                            score++;
                        else
                            hit++;
                    } else if("HOMERUN".equals(line)) {
                        score++;
                        score += hit;
                        hit = 0;
                    } else if("OUT".equals(line)) {
                        out++;
                    }
                }
                System.out.println(score);
            }
        }
        br.close();
    }
}

Measured memory_bytes: 23812
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;

#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 all(x) x.begin(), x.end()

ll n, k, m, M = 1e9 + 7;

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

    int s;
    cin >> s;

    set<int> a;
    a.insert(s);
    while(true) {
        if(s % 2 == 0) s /= 2;
        else s = s * 3 + 1;

        if(a.count(s)) {
            return cout << a.size() + 1 << endl, 0;
        } else {
            a.insert(s);
        }
    }
}

Measured memory_bytes: 3648
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> hoge(n);
    for(int i=0;i<n;i++) cin>>hoge.at(i);
    int cnt=0;
    bool flag=true;
    
    while(flag){
        flag=false;
        
        for(int i=n-1;i>0;i--){
            if(hoge.at(i)<hoge.at(i-1)){
                int pre=hoge.at(i);
                hoge.at(i)=hoge.at(i-1);
                hoge.at(i-1)=pre;
                
                flag=true;
                cnt++;
            }
        }
    }
    
    for(int i=0;i<n;i++){
        cout<<hoge.at(i);
        if(i!=n-1) cout<<" ";
    }
    
    cout<<endl<<cnt<<endl;
    
    return 0;
}


Measured memory_bytes: 3120
#include<stdio.h>
#include<stdlib.h>
int main(){
long n,z,w;
scanf("%ld %ld %ld",&n,&z,&w);
long a[n];
for(int i=0;i<n;i++){
	scanf("%ld",&a[i]);
}

if(n==1){
printf("%d\n",labs(a[n-1]-w));
}else{
if(labs(a[n-1]-w)>labs(a[n-1]-a[n-2])){
	printf("%ld\n",labs(a[n-1]-w));
}else{
	printf("%ld\n",labs(a[n-1]-a[n-2]));
}
}

}

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

using namespace std;

using Matrix = vector<vector<int>>;

Matrix Generate(int rows, int cols, int min_rows, int min_cols)
{
    Matrix mat(rows, vector<int>(cols));
    for (int i = 0; i < cols; i += 1) {
        mat[0][i] = (i < min_rows ? 0 : 1);
    }

    for (int i = 1; i < rows; i += 1) {
        for (int j = 0; j < cols; j += 1) {
            mat[i][j] = mat[i - 1][j];
            if (i == min_cols) {
                mat[i][j] = 1 - mat[i][j];
            }
        }
    }
    return mat;
}

bool Correct(const Matrix &mat, int min_rows, int min_cols)
{
    vector<int> ones_rows(mat.size(), 0);
    vector<int> ones_cols(mat[0].size(), 0);

    for (size_t i = 0; i < mat.size(); i += 1) {
        for (size_t j = 0; j < mat[i].size(); j += 1) {
            ones_rows[i] += mat[i][j];
            ones_cols[j] += mat[i][j];
        }
    }

    for (const auto &ones : ones_rows) {
        int zeros = mat[0].size() - ones;
        if (min(ones, zeros) != min_rows) {
            return false;
        }
    }
    for (const auto &ones : ones_cols) {
        int zeros = mat.size() - ones;
        if (min(ones, zeros) != min_cols) {
            return false;
        }
    }
    return true;
}

int main()
{
    int rows, cols;
    cin >> rows >> cols;

    int min_rows, min_cols;
    cin >> min_rows >> min_cols;

    auto mat = Generate(rows, cols, min_rows, min_cols);
    if (!Correct(mat, min_rows, min_cols)) {
        cout << "-1\n";
        return 0;
    }

    for (const auto &row : mat) {
        for (const auto &num : row) {
            cout << num;
        }
        cout << "\n";
    }
    return 0;
}

Measured memory_bytes: 5120
X, Y = map( int, input().split() )
 
ret = True
if (4 * X  - Y) % 2 == 1:
  ret = False
if 4 * X  - Y < 0:
  ret = False
if (Y - 2 * X) % 2 == 1:
  ret = False
if Y - 2 * X < 0:
  ret = False
if ret:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9188
#include <iostream>
#include <cstdint>
#include <vector>

// by noshi91
template <std::uint_fast64_t Modulus> class modint {
    using u64 = std::uint_fast64_t;

public:
    u64 a;

    constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
    constexpr u64& value() noexcept { return a; }
    constexpr const u64& value() const noexcept { return a; }
    constexpr modint operator+(const modint rhs) const noexcept {
        return modint(*this) += rhs;
    }
    constexpr modint operator-(const modint rhs) const noexcept {
        return modint(*this) -= rhs;
    }
    constexpr modint operator*(const modint rhs) const noexcept {
        return modint(*this) *= rhs;
    }
    constexpr modint operator/(const modint rhs) const noexcept {
        return modint(*this) /= rhs;
    }
    constexpr modint& operator+=(const modint rhs) noexcept {
        a += rhs.a;
        if (a >= Modulus) {
            a -= Modulus;
        }
        return *this;
    }
    constexpr modint& operator-=(const modint rhs) noexcept {
        if (a < rhs.a) {
            a += Modulus;
        }
        a -= rhs.a;
        return *this;
    }
    constexpr modint& operator*=(const modint rhs) noexcept {
        a = a * rhs.a % Modulus;
        return *this;
    }
    constexpr modint& operator/=(modint rhs) noexcept {
        u64 exp = Modulus - 2;
        while (exp) {
            if (exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
};

using Mint = modint<(int)1e9 + 7>;

int main() {
    int r1, r2, c1, c2;
    std::cin >> r1 >> c1 >> r2 >> c2;

    std::vector<Mint> pow2(r2 + c2 + 2);
    pow2[0] = 1;
    for (int i = 1; i < pow2.size(); ++i)
        pow2[i] = pow2[i - 1] * 2;

    std::vector<Mint> fact(r2 + c2 + 2);
    fact[0] = 1;
    for (int i = 1; i < fact.size(); ++i)
        fact[i] = fact[i - 1] * i;

    auto comb = [&](int n, int k) {
        return fact[n] / fact[k] / fact[n - k];
    };

    auto triSum = [&](int x, int d) {
        Mint ret = 0;
        for (int i = 0; i < d; ++i)
            ret += comb(x + i, i) * (pow2[d - i] - 1);

        return ret;
    };

    auto rectSum = [&](int r, int c) {
        return pow2[r + c + 1] - 1 - triSum(r, c) - triSum(c, r);
    };

    std::cout << (rectSum(r2, c2) - rectSum(r2, c1 - 1) - rectSum(r1 - 1, c2) + rectSum(r1 - 1, c1 - 1)).a << std::endl;
}

Measured memory_bytes: 31488
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int siz,time;
    string name;
    while(true){
        cin>>name;
        if(name[0]=='-')break;
        cin>>time;
        for(int abc=0;abc<time;abc++){
            cin>>siz;
            name=name.substr(siz)+name.substr(0,siz);
        }
        cout<<name<<endl;
    }
       
}


Measured memory_bytes: 3160
public partial class IntroductionToProgramming{
    public static void Main(){
        string[] line = System.Console.ReadLine().Split(' ');
 
        int h = int.Parse(line[0]);
        int w = int.Parse(line[1]);
 
        while (!(h == 0 && w == 0))
        {
            string f = new string('#', w);
            string s = new string('.', w - 2);
            System.Console.WriteLine(f);
            for (int i = 0; i < h - 2; i++ )
            {
                System.Console.WriteLine("#" + s + "#");
            }
            System.Console.WriteLine(f);
            System.Console.WriteLine(string.Empty);
 
            string[] line2 = System.Console.ReadLine().Split(' ');
 
            h = int.Parse(line2[0]);
            w = int.Parse(line2[1]);
        }
    }
}

Measured memory_bytes: 5360
# Partition
N = int(input())
A = list(map(int, input().split()))

i = -1
x = A[-1]
for j in range(N-1):
    if A[j] <= x:
        i += 1
        A[i], A[j] = A[j], A[i]

A[-1] = A[i+1]
A[i+1] = '[' + str(x) + ']'

print(*A)



Measured memory_bytes: 16384
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1153&lang=jp "Equal Total Scores" ????§£??????

while True:
    n, m = map(int, input().split())
    if not n:
        break
    taro = [int(input()) for i in range(n)]
    hanako = [int(input()) for i in range(m)]
    dif = sum(taro) - sum(hanako)
    ans = [-1]
    for i in taro:
        for j in hanako:
            if (i - j) * 2 == dif:
                if sum(ans) < 0 or i + j < sum(ans):
                    ans = [i, j]
    print(*ans)

Measured memory_bytes: 7680
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> HitPoint;
	for (int i = 0; i < N; i++) {
		int hp;
		cin >> hp;
		HitPoint.push_back(hp);
	}
	sort(HitPoint.begin(), HitPoint.end());
	long long int ans = 0;
	if (N <= K) {
		cout << 0 << endl;
	}
	else {
		for (int i = 0; i < (N - K); i++) {
			ans += HitPoint[i];
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1400
import bisect


N = int(input())
SL = [int(i) for i in input().split()]
SL.sort()
ans = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        ab = SL[i] + SL[j]
        r = bisect.bisect_left(SL, ab)
        l = j + 1
        ans += max(0, r - l)
print(ans)


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

using namespace std;
using int64 = long long;
using IntPair = pair<int, int>;

constexpr int DEBUG = 0;

struct Edge {
  int from;
  int to;
  bool w;
  Edge(int from, int to, bool w) : from(from), to(to), w(w) {}
};

struct PairHash {
  std::size_t operator()(const pair<int, int>& k) const {
    return hash<int>()(k.first) * 1000000007 ^ hash<int>()(k.second);
  }
};

template<class T> inline bool UpdateMin(T& a, T b) {
  if (a > b) { a = b; return 1; } return 0;
}

template<class T> inline bool UpdateMax(T& a, T b) {
  if (a < b) { a = b; return 1; } return 0;
}

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

  int n, m;
  cin >> n >> m;

  vector<int> v1s(m);
  vector<int> v2s(m);
  vector<int> cs(m);
  for (int i = 0; i < m; i++) {
    cin >> v1s[i] >> v2s[i] >> cs[i];
    v1s[i]--;
    v2s[i]--;
  }

  unordered_map<IntPair, int, PairHash> id_map;
  auto build_map = [&]() {
    int id = 0;
    for (int i = 0; i < n; i++) {
      id_map[IntPair(i, 0)] = id++;
    }
    for (int i = 0; i < m; i++) {
      IntPair p1 = IntPair(v1s[i], cs[i]);
      if (id_map.find(p1) == id_map.end()) {
        id_map[p1] = id++;
      }
      IntPair p2 = IntPair(v2s[i], cs[i]);
      if (id_map.find(p2) == id_map.end()) {
        id_map[p2] = id++;
      }
    }
  };
  build_map();
  int s = id_map.size();

  vector<vector<Edge>> graph(s);
  for (int i = 0; i < m; i++) {
    int v1 = v1s[i];
    int v2 = v2s[i];
    int c = cs[i];
    int a1 = id_map[IntPair(v1, 0)];
    int b1 = id_map[IntPair(v1, c)];
    int a2 = id_map[IntPair(v2, 0)];
    int b2 = id_map[IntPair(v2, c)];
    graph[a1].push_back(Edge(a1, b1, true));
    graph[b1].push_back(Edge(b1, a1, false));
    graph[a2].push_back(Edge(a2, b2, true));
    graph[b2].push_back(Edge(b2, a2, false));
    graph[b1].push_back(Edge(b1, b2, false));
    graph[b2].push_back(Edge(b2, b1, false));
  }

  vector<int> ds(s, INT_MAX);
  vector<int> visited(s);
  deque<int> q;
  ds[id_map[IntPair(0, 0)]] = 0;
  q.push_back(id_map[IntPair(0, 0)]);

  while (!q.empty()) {
    int v = q.front();
    q.pop_front();

    if (visited[v]) continue;
    visited[v] = true;
    
    for (const auto& e : graph[v]) {
      int nv = e.to;
      int nd = ds[v] + (e.w ? 1 : 0);
      if (nd < ds[nv]) {
        ds[nv] = nd;
        if (e.w) {
          q.push_back(nv);
        } else {
          q.push_front(nv);
        }
      }
    }
  }

  int ans = INT_MAX;
  for (const auto& kv : id_map) {
    const auto& k = kv.first;
    if (k.first == n - 1) {
      UpdateMin(ans, ds[kv.second]);
    }
  }

  if (ans == INT_MAX) ans = -1;

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

Measured memory_bytes: 66164
import Data.Char

ary = ["abcde","fghij","klmno","pqrst","uvwxy","z.?! "]

ans [] = Just []
ans (a:[])  = Nothing
ans (a:b:s) =
  let c = if (a <= 0 || a > 6) || (b <= 0 || b > 5)
          then Nothing
          else Just ((ary!!(a-1))!!(b-1))
      r = ans s
  in
    if c == Nothing || r == Nothing
    then Nothing
    else
      let Just c' = c
          Just r' = r
      in
        Just (c':r')

ans' x =
  let r = ans x
  in
    if r == Nothing
    then "NA"
    else
      let Just v = r
      in
        v

main = do
  c <- getContents
  let i = map (map digitToInt) $ lines c :: [[Int]]
      o = map ans' i
  mapM_ putStrLn o

Measured memory_bytes: 4084
def inpl(): return [int(i) for i in input().split()]

def dfs(i):
    for j in range(1,N+1):
        if visit[j]:
            continue
        if not path[i][j]:
            continue
        visit[j] = True
        X = dfs(j)
    return visit

N, M = inpl()
path = [[False for _ in range(N+1)] for i in range(N+1)]
visit = [False for _ in range(N+1)]
visit[0] = visit[1] = True
H = []
for i in range(M):
    a,b = inpl()
    path[a][b] = path[b][a] = True
    H.append((a,b))
    
ans = 0    
for st,en in H:
    path[st][en] = path[en][st] = False
    if False in dfs(1):
        ans += 1
    path[st][en] = path[en][st] = True
    for i in range(2,N+1):
        visit[i] = False
print(ans)

Measured memory_bytes: 3064
import sys
from heapq import heappop, heappush

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
works = [[] for _ in range(M+1)]
# M-1日後から選んでいく,
for _ in range(N):
    a, b = lr()
    if a <= M:
        works[a].append(-b)

heap = []
answer = 0
for work in works:
    for x in work:
        heappush(heap, x)
    if heap:
        answer -= heappop(heap) # heap構造なので

print(answer)
# 08


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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef array<int, 2> duo;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



void _main() {
        int n; cin >> n;
        vector<pair<int,int>> a(n);
        for (int i = 0; i < n; i++) {
                cin >> a[i].first;
                a[i].second = i + 1;
        }
        sort(all(a));
        for (int i = 0; i < n; i++) cout << a[i].second << ' ';
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 3960
#include "bits/stdc++.h"
using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 1e18 * 2;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	int h, w, i, j;
	cin >> h >> w;
	vs c(h);
	for (i = 0; i < h; i++) {
		cin >> c[i];
	}
	for (i = 0; i < h; i++) {
		cout << c[i] << endl << c[i] << endl;
	}
}

Measured memory_bytes: 764
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
 
struct edge_t {
    int from;
    int to;
    int cost;
};
typedef struct edge_t Edge;
 
int main(void) {
    int num, i, k, from, to, cost, update, nedge = 0;
    int dis[10000];
    Edge *edges, *p;
 
    edges = malloc(sizeof(Edge)*500000);
 
    scanf("%d", &num);
 
    for (i = 0; i < num; i++) {
        scanf("%d %d", &from, &k);
 
        while (k--) {
            scanf("%d %d", &to, &cost);
 
            p = &edges[nedge++];
            p->from = from;
            p->to = to;
            p->cost = cost;
        }
 
        dis[i] = INT_MAX;
    }
    dis[0] = 0;
 
    update = 1;
    while (update) {
        update = 0;
        for (i = 0; i < nedge; i++) {
            from = edges[i].from;
            to = edges[i].to;
            cost = edges[i].cost;
            if (dis[from] < INT_MAX && dis[to] > cost + dis[from]) {
                dis[to] = cost + dis[from];
                update = 1;
            }
        }
    }
 
    for (i = 0; i < num; i++) {
        printf("%d %d\n", i, dis[i]);
    }
    return 0;
}


Measured memory_bytes: 7588
import java.util.*;
 
public class Main {
 	public static void main(String[] args){
    	
    	Scanner sc = new Scanner(System.in);
    	int a = sc.nextInt();
		String s = sc.next();
		
		if(a>=3200){
		    System.out.println(s);
		}
		
		else{
		    System.out.println("red");
		}
		
 	}
}

Measured memory_bytes: 20692
#include <bits/stdc++.h>
#define rep(i, x, y) for (long long i = x; i <= y; i++)
#define fi first
#define se second
using namespace std;

const int N = 505;
typedef long long ll;
typedef pair<ll, ll> pll;
ll n, mod, dp[N][N];
pll a[N];

ll calc(ll x, ll y) {
    ll ret = 0;
    while (ret < 2 * n - 1 && (ret + 1) * (ret + 1) + x <= y)
        ++ret;
    return ret;
}

void add(ll &x, ll y) {
    x = (x + y) % mod;
}

ll solve(ll k) {
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    int A = 0, C = 0;
    rep(i, 0, 2 * n - 1) {
        if (~a[i].se) {
            rep(j, 0, A) {
                add(dp[i + 1][j + 1], dp[i][j] * (a[i].fi - j - C) % mod);
            }
            rep(j, 0, A) {
                add(dp[i + 1][j], dp[i][j] * (a[i].se - k - n - (A - j)) % mod);
            }
            ++A;  // 这里的 A 其实最终是 A 和 B 的总个数
        } else {
            rep(j, 0, A) {
                add(dp[i + 1][j], dp[i][j] * (a[i].fi - j - C) % mod);
            }
            ++C;
        }
    }
    return dp[n * 2][k];
}

int main() {
    cin >> n >> mod;
    rep(i, 0, n - 1) {
        a[i] = make_pair(calc(i * i, n * n - 1) + 1, calc(i * i, 4 * n * n) + 1);  // 一个范围
    }
    rep(i, n, 2 * n - 1) {
        a[i] = make_pair(calc(i * i, 4 * n * n) + 1, -1);
    }
    sort(a, a + 2 * n);
    ll ans = 0;
    rep(i, 0, n) {
        (ans += 1ll * (i & 1 ? mod - 1 : 1) * solve(i) % mod) %= mod;
    }
    printf("%lld\n", ans);
    return 0;
}

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

int main() {
  int K;
  string S;
  cin>>K>>S;
  if(K>=S.size()){
    cout<<S<<endl;
  }
  else{
    cout<<S.substr(0,K)<<"..."<<endl;
  }    
}

Measured memory_bytes: 3636
use proconio::*;

#[fastout]
fn main() {
    input! {
        n : usize,
    }
    let mut sum = 0;
    for i in 1..=n {
        if i % 3 > 0 && i % 5 > 0 {
            sum += i;
        }
    }
    println!("{}", sum);
}


Measured memory_bytes: 2176
import java.io.PrintWriter;
import java.util.*;

public class Main {
    PrintWriter out = new PrintWriter(System.out);
    final long max = Long.MAX_VALUE/10;
    int n=1;
    long[] dat;
    public static void main(String[] args) {
        Main main = new Main();
        System.out.println(main.solve());
    }
    // segment tree to record minimum value
    // Each point has a infinite distance from 0 (except itself)
    long solve() {
        Scanner sc = new Scanner(System.in);
        int n0 = sc.nextInt(), m = sc.nextInt();
        while(n<n0) n*=2; // let n be 1<<x
        dat = new long[2*n]; // this is why something like 4*n0+10 is safe
        for(int i=0;i<2*n-1;i++) dat[i] = max;
        update(0,0);
        Edge[] edges = new Edge[m];
        for(int i=0;i<m;i++){
            edges[i] = new Edge(sc.nextInt()-1, sc.nextInt()-1, sc.nextInt());
        }
        Arrays.sort(edges);
        if(edges[0].from!=0) return -1;
        for(Edge e:edges){
            int end = e.to;
            long curVal = find(end,end), prev = find(e.from,end-1);
            if(prev+e.cost<curVal){
                update(end,prev+e.cost);
            }
        }
        long ans = find(n0-1,n0-1);
        if(ans<max) return ans;
        return -1;
    }
    // find the minimum value in [left, right]
    long find(int left, int right){
        return query(left, right+1, 0, 0, n);
    }
    void update(int idx, long val){
        idx += n-1;
        dat[idx] = val;
        // update in an upward direction
        while(idx>0){
            idx = (idx-1)/2;
            dat[idx] = Math.min(dat[idx*2+1], dat[idx*2+2]);
        }
    }
    // find the minimum value in [a,b)
    // when invoking, query(a,b,0,0,n), n is the adjusted value ( n = 1<<x)
    long query(int a, int b, int idx, int left, int right){
        if(right<=a||left>=b) return max;
        if(a<=left&&right<=b) return dat[idx];
        int mid = (left+right)/2;
        long vl = query(a,b,2*idx+1, left, mid);
        long vr = query(a,b,2*idx+2, mid, right);
        return Math.min(vl,vr);
    }
    class Edge implements Comparable<Edge>{
        int from,to, cost;
        public Edge(int f, int t, int c){
            from = f; to = t; cost = c;
        }
        public int compareTo(Edge e){
            if(this.from!=e.from) return Integer.compare(from, e.from);
            if(this.to!=e.to) return Integer.compare(to, e.to);
            return cost-e.cost;
        }
    }
}


Measured memory_bytes: 104384
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,k;
ll a[200005];

bool C(ll v){
	ll cnt=0;
	for(int i=0;i<n;i++){
		cnt+=(a[i]+v-1LL)/v-1LL;
		if(cnt>k){
			return true;
		}
	}
	return false;
}

int main(void){
	scanf("%d%d",&n,&k);
	ll r=0;
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
		r=max(a[i]+1,r);
	}
	ll l=0;
	while(l+1LL<r){
		ll mid=(l+r)/2LL;
		if(C(mid))l=mid;
		else{
			r=mid;
		}
	}
	printf("%lld\n",r);
	return 0;
}


Measured memory_bytes: 5280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  repi(i, 1, 50001) {
    if (floor(i * 1.08) == n) {
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
  return 0;
}

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

int main() {
	int n;
	std::cin >> n;
	std::multiset<int> set;
	for (auto i = 0; i < n; ++i) {
		int o, x, r;
		std::cin >> o >> x;
		switch (o) {
		case 0: set.insert(x); std::cout << set.size() << std::endl; break;
		case 1: std::cout << set.count(x) << std::endl; break;
		case 2: set.erase(x); break;
		default:
			std::cin >> r;
			auto end = set.upper_bound(r);
			for (auto begin = set.lower_bound(x); begin != end; ++begin) {
				std::cout << *begin << std::endl;
			}
		}
	}
}


Measured memory_bytes: 12352
#include<iostream>
#include<algorithm>
#include<set>
#include<vector>
#include<queue>
#include<map>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include <climits>
using namespace std;

#define REP(i,a,n) for(int i = a ; i < n ; i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;

int dpAll[1000010];
int dpOdd[1000010];
vector<int> v;

int dfsAll(int rem){
  if(rem == 0) return 0;
  if(dpAll[rem] != INT_MAX) return dpAll[rem];

  int res = INT_MAX;
  for(int i=0;i<v.size() && v[i]<=rem;i++){
    int tmp = dfsAll(rem-v[i]);
    if(tmp != INT_MAX && res > tmp + 1) res = tmp + 1;
  }
  return dpAll[rem]=res;
}

int dfsOdd(int rem){
  if(rem == 0) return 0;
  if(dpOdd[rem] != INT_MAX) return dpOdd[rem];

  int res = INT_MAX;
  for(int i=0;i<v.size() && v[i]<=rem;i++){
    if(v[i] % 2 == 1){
      int tmp = dfsOdd(rem-v[i]);
      if(tmp != INT_MAX && res > tmp + 1) res = tmp + 1;
    }
  }
  return dpOdd[rem]=res;
}

int main(){
  int n;

  for(int i=1;i*(i+1)*(i+2)/6<=1000100;i++){
    v.push_back(i*(i+1)*(i+2)/6);
  }

  rep(i,1000010) dpAll[i] = INT_MAX;
  rep(i,1000010) dpOdd[i] = INT_MAX;
  for(int i=1;i<=1000002;i+=10000) dfsAll(i);
  for(int i=1;i<=1000002;i+=10000) dfsOdd(i);

  while(cin>>n,n){
    cout<<dpAll[n]<<" "<<dpOdd[n]<<endl;
  }
}

Measured memory_bytes: 8888
#include<iostream>
using namespace  std;
#define size 100
int main()
{
	int n,m,x,toll,squares[size],i,tolls_1=0;
	cin>>n>>m>>x;
	for(i=0;i<n+1;i++)
	{
		squares[i]=0;
	}
	for(i=0;i<m;i++)
	{
		cin>>toll;
		squares[toll] = 1;
	}
	for(i=0;i<x;i++)
	{
      tolls_1+=squares[i];
	}
      
    cout<<min(tolls_1,m-tolls_1);


}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i )
typedef std::pair<int,int> pint;

using namespace std;
typedef long long ll;

int main(){
    string str; cin >> str;
    int count = 0;
    int max = 0;
    rep (i,str.length()){
        if (str[i] == 'R'){
            count++;
            max = count;
        }
        else {
            count = 0;
        }
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define ff first 
#define ss second
#define mod 1000000007
#define lim 100005
#define nfs_mw ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

double dp[301][301][301] = {};
double get_dp(int c1, int c2, int c3, int n){
	double nn = n;
	if((!c1 && !c2 && !c3) || (c1<0) || (c2<0) || (c3<0)) return 0;
	if(dp[c1][c2][c3] != 0) return dp[c1][c2][c3];
	return dp[c1][c2][c3] = (1 + (c1/nn)*get_dp(c1-1,c2,c3,n) + (c2/nn)*get_dp(c1+1,c2-1,c3,n) + (c3/nn)*get_dp(c1,c2+1,c3-1,n))/((c1+c2+c3)/nn);
}



int main()
{
	int i,j,k,n,cnt[4] = {};
	cin>>n;
	for(i=1; i<=n; i++) {
		cin>>j;
		cnt[j]++;
	}
	printf("%.10lf",get_dp(cnt[1], cnt[2], cnt[3], n));
}

Measured memory_bytes: 213248
X,Y,A,B,C = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
Z = X+Y
P = p[:X]
Q = q[:Y]
R = r[:Z]
ans = 0
if X <= Y:
  S = P + R
  S.sort(reverse=True)
  a = S[:X]
  b = S[X:]
  ans += sum(a)
  T = Q + b
  T.sort(reverse=True)
  c = T[:Y]
  ans += sum(c)
else:
  S = Q + R
  S.sort(reverse=True)
  a = S[:Y]
  b = S[Y:]
  ans += sum(a)
  T = P + b
  T.sort(reverse=True)
  c = T[:X]
  ans += sum(c)
print(ans)

Measured memory_bytes: 23596
object Main {
  def main(args:Array[String]) = {
    val in = readLine.split(" ").map(_.toInt) 
	if (in(0) == 7 || in(0) == 5 || in(0) == 3){
      println("YES")
    }
    else{
    	println("NO")
    }
  }
}

Measured memory_bytes: 25520
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef pair<int, int> P;
#define REP(i, N) for (int i = 0; i < N; ++i)
#define ALL(a) a.begin(), a.end()
int main()
{
  int N;
  cin >> N;
  vector<int> A(N), B(N);
  REP(i, N)
  cin >> A[i] >> B[i];
  vector<P> vc;
  REP(i, N)
  vc.push_back(P(A[i] + B[i], i));
  sort(ALL(vc));
  reverse(ALL(vc));
  long ans = 0;
  REP(i, N)
  {
    if (i % 2 == 0)
      ans += A[vc.at(i).second];
    else
      ans -= B[vc.at(i).second];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2168
#include<iostream>
#include<utility>
#include<vector>
#include<stack>
#include<map>
using namespace std;
using Graph = vector<vector<int>>;

int main() {
	int n, root = 0, c = 1; cin >> n;
	Graph graph(n);
	vector<bool>seen(n, false);
	stack<int>todo;
	vector<int>parent(n, 0);
	map<pair<int, int>, int>ans;
	int input[n][2];
	for (int i = 0; i < n - 1; i++) {
		int a, b; cin >> a >> b; a--; b--;
		graph[a].emplace_back(b);
		graph[b].emplace_back(a);
		input[i][0] = a; input[i][1] = b;
	}
	for (int i = 1; i < n; i++) {
		if (graph[root].size() < graph[i].size()) {
			root = i;
		}
	}
	seen[root] = true;
	for (auto to : graph[root]) {
		parent[to] = root;
		ans[make_pair(root, to)] = c;
		ans[make_pair(to, root)] = c;
		todo.push(to);
		c++;
	}
	while (!todo.empty()) {
		int from = todo.top(), c = 1;
		todo.pop();
		seen[from] = true;
		for (auto to : graph[from]) {
			if (!seen[to]) {
				todo.push(to);
				parent[to] = from;
				if (c == ans[make_pair(parent[from], from)])c++;
				ans[make_pair(from, to)] = c;
				ans[make_pair(to, from)] = c;
				c++;
			}
		}
	}
	cout << graph[root].size() << endl;
	for (int i = 0; i < n - 1; i++) {
		cout << ans[make_pair(input[i][0], input[i][1])] << endl;
	}
}

Measured memory_bytes: 19712
#include <bits/stdc++.h>
#define ll long long
#define ar array
#define nl '\n'
#define AC ios_base::sync_with_stdio(0); cin.tie(NULL);
using namespace std;
const int M = 1e9+7;
const int N = 2*1e5;

int arr[N];

int main(){
    AC
    int n;
    cin>>n;
    int sum = 0;
    for(int i=1; i<=n; i++){
        cin>>arr[i];
        if(i%2==0)
            sum^=(arr[i]^arr[i-1]);
    }

    for(int i=1; i<=n; i++){
        cout<<(sum^arr[i])<<nl;
    }
}


Measured memory_bytes: 4420
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> Pa;
typedef pair<int, pair<int, int> > PP;
const int MAX=2e5+10;

template <typename T>
struct SegmentTree{
  using F = function<T(T,T)>;
  int n;
  F f;
  T ti;
  vector<T> dat;
  SegmentTree(){};
  SegmentTree(F f,T ti):f(f),ti(ti){}
  void init(int n_){    
    n=1;
    while(n<n_) n<<=1;
    dat.assign(n<<1,ti);
  }
  void build(const vector<T> &v){
    int n_=v.size();
    init(n_);
    for(int i=0;i<n_;i++) dat[n+i]=v[i];
    for(int i=n-1;i;i--)
      dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);
  }
  void set_val(int k,T x){
    dat[k+=n]=x;
    while(k>>=1)
      dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]);    
  }
  T query(int a,int b){
    T vl=ti,vr=ti;
    for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
      if(l&1) vl=f(vl,dat[l++]);
      if(r&1) vr=f(dat[--r],vr);
    }
    return f(vl,vr);
  }
  template<typename C>
  int find(int a,int b,C &check,int k,int l,int r){
    if(!check(dat[k])||r<=a||b<=l) return -1;
    if(k>=n) return k-n;
    int m=(l+r)>>1;
    int vl=find(a,b,check,(k<<1)|0,l,m);
    if(~vl) return vl;
    return find(a,b,check,(k<<1)|1,m,r);
  }
  template<typename C>
  int find(int a,int b,C &check){
    return find(a,b,check,1,0,n);
  }
};

int N,K;
vi P;
void input(){
	cin>>N>>K;
	rep(i,N){
		int x;
		cin>>x;
		P.pb(x);
	}
}

bool sam[MAX];
void solve(){
	int ac=0;
	rep(i,K-1)if(P[i]<P[i+1])ac++;
	if(ac==K-1)sam[0]=true;
	rep1(i,N-K){
		if(P[i-1]<P[i])ac--;
		if(P[K+i-2]<P[K+i-1])ac++;
		if(ac==K-1)sam[i]=true;
	}
	//rep(i,N-K+1)cout<<sam[i]<<" ";
  

	auto f=[](int a,int b){
		return min(a,b);
	};
	auto g=[](int a,int b){
		return max(a,b);
	};
	int ti=100000007;
	int ui=0;

	SegmentTree<int> segmin(f,ti);
	SegmentTree<int> segmax(g,ui);
	segmin.build(P);
	segmax.build(P);
	int ans=N-K+1;
  	bool allsam=false;
	rep(i,N-K){
      	//cout<<segmin.query(i,i+K)<<" ";
		int xmin=segmin.query(i,i+K);
		int xmax=segmax.query(i+1,i+K+1);
      	//cout<<xmin<<" "<<xmax<<endl;

		if(sam[i]){ans--;allsam=true;}
		else if(xmin==P[i] && xmax==P[i+K])ans--;
	}
  	if(sam[N-K]){ans--;allsam=true;}
  	if(allsam)ans++;
	cout<<ans<<endl;
}

void output(){
  
}

int main(){
  input();
  solve();
  output();
}

Measured memory_bytes: 5504
#include<bits/stdc++.h>
using ll = int_fast64_t;
#define REP(i,b,e) for(ll i=b; i<e; i++)

int main(){
        int n, m, k;
        scanf("%d %d %d", &n, &m, &k);
        bool ok = false;
        REP(i, 0, n+1) REP(j, 0, m+1) {
            if((n-i)*(m-j)+i*j==k) ok = true;
        }
        if(ok) puts("Yes");
        else puts("No");
        return 0;
}

Measured memory_bytes: 3744