akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main()
{
  int	n, flag = 0;
  
  cin >> n;
  vector<int>	d1(n), d2(n);
  
  for(int i = 0; i < n; i++)
    cin >> d1.at(i) >> d2.at(i);
  for(int i = 0; i < n; i++)
  {
    if (d1.at(i) == d2.at(i))
      flag++;
    else
      flag = 0;
    if (flag == 3)
      break;
  }
  if (flag == 3)
    cout << "Yes\n";
  else
    cout << "No\n";
  return (0);
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <set>
#include <iomanip>
#include <vector>
#include <queue>
#include <numeric>
//#include <bits/stdc++.h>

using namespace std;
const int INF = 1 << 30;

int main()
{
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i = 0 ;i<n;++i)
        cin>>a[i];
    int ans = INF;
    for(int i = 0 ; i+k<=n;++i)
    {
        int r = i+k-1;
        ans= min(ans,a[r]-a[i]+min(abs(a[i]),abs(a[r])));
    }
    cout<<ans<<endl;
    return 0;
}

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

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int main(){
  int N;
  int P[200000];
  cin >> N;
  rep(i, N){
    cin >> P[i];
  }
  int min = 200001, ans = 0;
  rep(i, N){
    if(P[i] <= min){
      ans++;
      min = P[i];
    }
  }
  cout << ans <<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int a, b, c; cin >> a >> b >> c;
  cout << max(0, c - (a - b)) << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <utility>

int main() {
  intmax_t h, w;
  scanf("%jd %jd", &h, &w);
  if (!(h <= w)) std::swap(h, w);
  if (h == 1) return puts("1"), 0;
  printf("%jd\n", (h*w+1)/2);
}


Measured memory_bytes: 128
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String a=sc.next();
		
		if(a.equals("Sunny")){
			System.out.print("Cloudy");
		}
		else if(a.equals("Cloudy")){
			System.out.print("Rainy");
		}
		else if(a.equals("Rainy")){
			System.out.print("Sunny");
		}
	}
}


Measured memory_bytes: 21716
#include<iostream>
using namespace std;
int main()
{
    int i;
    char a[19];
    cin>>a;
    for(i=0;i<5;i++)
        cout<<a[i];
    cout<<" ";
     for(i=6;i<13;i++)
        cout<<a[i];
    cout<<" ";
     for(i=14;i<19;i++)
        cout<<a[i];
   return 0;
}


Measured memory_bytes: 256
n=int(input())
a=[int(i) for i in input().split()]
ans=[]
l=[a[0]*2]
for i in range(1,n):
    l.append(a[i]*2-l[-1])

x=a[-1]-(l[-2]//2)

print(x,end=" ")
for i in range(1,n):
    if i%2==0:
        print(l[i-1]+x,end=" ")
    else:
        print(l[i-1]-x,end=" ")
print("")

Measured memory_bytes: 14616
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
typedef long long int lli;
using namespace std;

int osenbei[10][10000];
int flag[10];
int C,R,ans;

int count(){
	int cnt=0;
	for(int i=0; i<C; ++i){
		int b=0;
		for(int j=0; j<R; ++j){
			if(flag[j]==1&&osenbei[j][i]==0) ++b;
			else if(flag[j]==0&&osenbei[j][i]==1) ++b;
		}
		if(b>R-b) cnt+=b;
		else cnt+=(R-b);
	}
	return cnt;
}

void solve(int k){
	if(k==R){
		ans=max(ans,count());
		return;
	}
	flag[k]=0;
	solve(k+1);
	flag[k]=1;
	solve(k+1);
	return;
}

int main(){
	//cin.tie(false);
    //ios::sync_with_stdio(false);
	while(cin >> R >> C&&C!=0&&R!=0){
		ans=0;
		for(int i=0; i<R; ++i){
			flag[i]=0;
			for(int j=0; j<C; ++j){
				cin >> osenbei[i][j];
			}
		}
		solve(0);
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 1548
// g++ -std=c++14 -O2 -Wall qa.cpp
#include <bits/stdc++.h>
using namespace std;

typedef long long 		ll;
typedef vector<int>		VI;
typedef vector<bool>  	VB;
typedef vector<ll>  	VLL;
typedef pair<int, int>  PII;
typedef pair <ll, ll>  	PLL;
typedef vector<PII>  	VPII;
typedef tuple<int,int,int>  TI;

typedef unordered_set<int> USI;
typedef set<int> SI;

typedef unordered_map<int, int> UMP;
typedef map<int, int> MP;

typedef queue<int> QI;
typedef queue<PII> QP;

typedef priority_queue<int> PQI;
typedef priority_queue<PII> PQP;

#define sc(n)		scanf("%d",&n)
#define sc2(i,j)	scanf("%d%d",&i,&j)
#define sc3(i,j,k)	scanf("%d%d%d",&i,&j,&k)
#define scl(n) 		scanf("%lld",&n)
#define scf(n) 		scanf("%lf",&n)
#define scs(n)  	scanf("%s",n)

#define FOR(i,x,y) 	for(int i=(x); i<=(y); i++)
#define REV(i,x,y) 	for(int i=(x); i>=(y); i--)
#define ALL(v) 		(v).begin(),(v).end()
#define SZ(v) 		(int)v.size()

#define PR(i)		printf("%d\n", (i))
#define PRL(i)		printf("%lld\n", (i))
#define PRA(arr)	FOR(i,0,(arr.size()-1)){ cout << arr[i] << " ";} cout << "\n"
#define PRV(v)		for(auto i : v) { cout << i << " ";} cout << "\n"

#define DBG2(i,j)	cout <<"DBG: "<< i << " " << j << endl
#define DBG3(i,j,k)	cout <<"DBG: "<< i << " " << j << " " << k << endl

#define bit(x,i) (x&(1<<i)) //ith bit of x;
#define ceilint(a,k) ((a-1)/k + 1) // round up a/k
#define min3(x,y,z) min(x,min(y,z))
#define max3(x,y,z) max(x,max(y,z))

#define mt make_tuple
#define pb push_back
#define fi first
#define se second
#define mod 1000000007

int main() {
    int n;
	sc(n);
    int m = n%1000;
    if(m == 0) PR(0);
    else PR(1000 - m);

	return 0;
}


Measured memory_bytes: 3820
n = int(input())
a = [0]+list(map(int, input().split()))

'''
ans = 1000
for i in range(n - 1):
    x = a[i]
    y = a[i + 1]
    if x < y:
        k = ans // x
        ans %= x
        ans += k * y

print(ans)
'''

dp = [0] * (n + 10)
dp[1] = 1000
for i in range(2, n + 1):
    dp[i] = dp[i - 1]
    for j in range(1, i):
        x = dp[j] // a[j]
        y = dp[j] + (a[i] - a[j]) * x
        dp[i] = max(dp[i], y)

ans = dp[n]
print(ans)


Measured memory_bytes: 9172
main :: IO()
main = do
    let n = 0
    [_,str] <- lines <$>getContents
    print $countABC n str
    
countABC :: Int -> String -> Int
countABC x s
    |s=="" = x
    |take 3 s =="ABC" = countABC (x+1) $drop 3 s
    |otherwise = countABC x $drop 1 s

Measured memory_bytes: 3732
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>

using namespace std;

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

    double x[100];
    double y[100];

    for (int i = 0; i < n; i++)
        cin >> x[i];
    for (int i = 0; i < n; i++)
        cin >> y[i];

    double distance1 = 0;
    for (int i = 0; i < n; i++)
        distance1 += abs(x[i] - y[i]);
    printf("%.6lf\n", distance1);
    
    double distance2 = 0;
    for (int i = 0; i < n; i++)
        distance2 += pow(x[i] - y[i], 2);
    distance2 = sqrt(distance2);
    printf("%.6lf\n", distance2);

    double distance3 = 0;
    for (int i = 0; i < n; i++)
        distance3 += abs(pow(x[i] - y[i], 3));
    distance3 = cbrt(distance3);
    printf("%.6lf\n", distance3);

    double maxDistance = 0;
    for (int i = 0; i < n; i++) {
        double distance = abs(x[i] - y[i]);
        if (distance > maxDistance)
            maxDistance = distance;
    }
    printf("%.6lf\n", maxDistance);

    return 0;
}



Measured memory_bytes: 3412
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    ll c[n];
    for(ll i=0;i<n;i++)cin>>c[i];
    ll ans=0;
    for(ll i=0;i<n-1;i++){
        ll diff=c[i+1]-c[i];
        if(diff*a>b)ans+=b;
        else ans+=diff*a;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>
int isprime(int);
main(){
  int n, i, p=0, N[10000];
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &N[i]);
    p += isprime(N[i]);
  }
 printf("%d\n", p);
  return 0;
}

int isprime(int x){
  int j;
    if(x == 2){
      return 1;
    }
    if(x < 2 || x % 2 == 0){
      return 0;
    }
    j = 3;
    while(j <= sqrt(x)){
      if(x % j == 0){
	return 0;
      }
      j += 2;
    }
    return 1;
}

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

int main()
{
	int i, j;
	string s, st;
	map<char, string> toCode;
	map<string, char> toA;

	toCode['A'] = "00000";
	toCode['B'] = "00001";
	toCode['C'] = "00010";
	toCode['D'] = "00011";
	toCode['E'] = "00100";
	toCode['F'] = "00101";
	toCode['G'] = "00110";
	toCode['H'] = "00111";
	toCode['I'] = "01000";
	toCode['J'] = "01001";
	toCode['K'] = "01010";
	toCode['L'] = "01011";
	toCode['M'] = "01100";
	toCode['N'] = "01101";
	toCode['O'] = "01110";
	toCode['P'] = "01111";
	toCode['Q'] = "10000";
	toCode['R'] = "10001";
	toCode['S'] = "10010";
	toCode['T'] = "10011";
	toCode['U'] = "10100";
	toCode['V'] = "10101";
	toCode['W'] = "10110";
	toCode['X'] = "10111";
	toCode['Y'] = "11000";
	toCode['Z'] = "11001";
	toCode[' '] = "11010";
	toCode['.'] = "11011";
	toCode[','] = "11100";
	toCode['-'] = "11101";
	toCode['\''] = "11110";
	toCode['?'] = "11111";
	toA["101"] = ' ';
	toA["000000"] = '\'';
	toA["000011"] = ',';
	toA["10010001"] = '-';
	toA["010001"] = '.';
	toA["000001"] = '?';
	toA["100101"] = 'A';
	toA["10011010"] = 'B';
	toA["0101"] = 'C';
	toA["0001"] = 'D';
	toA["110"] = 'E';
	toA["01001"] = 'F';
	toA["10011011"] = 'G';
	toA["010000"] = 'H';
	toA["0111"] = 'I';
	toA["10011000"] = 'J';
	toA["0110"] = 'K';
	toA["00100"] = 'L';
	toA["10011001"] = 'M';
	toA["10011110"] = 'N';
	toA["00101"] = 'O';
	toA["111"] = 'P';
	toA["10011111"] = 'Q';
	toA["1000"] = 'R';
	toA["00110"] = 'S';
	toA["00111"] = 'T';
	toA["10011100"] = 'U';
	toA["10011101"] = 'V';
	toA["000010"] = 'W';
	toA["10010010"] = 'X';
	toA["10010011"] = 'Y';
	toA["10010000"] = 'Z';

	while (getline(cin, s)) {
		st = "";
		for (i = 0; i < s.size(); i++) st += toCode[s[i]];

		s = "";
		for (i = 0; i < st.size(); i++) {
			s += st.substr(i, 1);
			if (toA.count(s)) {
				cout<<toA[s];
				s = "";
			}
		}
		cout<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <climits>
using namespace std;
// rep macro
#define rep(i, n)        for (int i = 0; i < (int)(n); i++)
#define rev(i, n)        for (int i = (int)(n - 1); i >= 0; i--)
#define rep2(i, s, n)    for (int i = (s); i < (int)(n); i++)
#define rev2(i, s, n)    for (int i = (int)(n) - 1; i >= (int)(s); i--)
#define bitrep(i, n)     for (int i = 0; i < (1 << (int)(n)); i++)
#define bitrep2(i, s, n) for (int i = (s); i < (1 << (int)(n)); i++)
// vector macro
#define all(v) v.begin(), v.end()
using vi  = vector<int>;
using vvi = vector<vector<int>>;
using vl  = vector<long>;
using vvl = vector<vector<long>>;
using vb  = vector<bool>;
using vvb = vector<vector<bool>>;
// math macro
#define lcm(a, b) a / __gcd(a, b) * b
// print macro
#define println(x) cout << x << endl
#define Yes println("Yes")
#define No println("No")
#define YES println("YES")
#define NO println("NO")
// pair macro
#define x first
#define y second
using pii = pair<int, int>;
using pdd = pair<double, double>;
// memo
// desc sort: sort(vec.begin(), vec.end(), greater<int>());

double dist(pii a, pii b)
{
    return sqrt(pow(a.x - b.x, 2) + pow(a.y - b.y, 2));
}

int main()
{
    int n; cin >> n;
    vi I(n); iota(all(I), 0);
    vi a(n), b(n); rep(i, n) cin >> a[i] >> b[i];
    double sum = 0;
    int cnt = 0;
    do {
        rep(i, n - 1) sum += dist(pii(a[I[i]], b[I[i]]), pii(a[I[i+1]], b[I[i+1]]));
        cnt++;
    } while (next_permutation(all(I)));
    cout << fixed << setprecision(10) << sum / cnt << endl;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9+10;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    ll x, y; cin >> x >> y;
    if (abs(x-y) <= 1) cout << "Brown" << endl;
    else cout << "Alice" << endl;
}

Measured memory_bytes: 3544
import java.util.Scanner;
import java.util.ArrayList;
 
public class Main {
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int N = Integer.parseInt(scanner.next());
    int M = Integer.parseInt(scanner.next());
    
    ArrayList<Integer> answer = new ArrayList<Integer>();
    for(int i=0;i<=M;i++){
      answer.add(0);
    }
    
    for(int i=0;i<N;i++){
      int A = Integer.parseInt(scanner.next());
      for(int j=0;j<A;j++){
      	int input = Integer.parseInt(scanner.next());
      	int pre = answer.get(input);
       	answer.set(input, pre + 1);
      }
    }
    int ans = 0;
    for(int i=1;i<=M;i++){
      if(answer.get(i) == N)
        ans++;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 21972
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        int N;
        int[] p;

        boolean asc(int[] a) {
            boolean ret = true;

            for (int i = 0; i < N - 1; ++i) {
                ret &= a[i] <= a[i + 1];
            }

            return ret;
        }

        void solve(InputReader in, PrintWriter out) {
            N = in.nextInt();
            p = in.nextIntArray(N);

            for (int i = 0; i < N; ++i) {
                for (int j = i; j < N; ++j) {
                    int[] cp = p.clone();
                    int tmp = cp[i];
                    cp[i] = cp[j];
                    cp[j] = tmp;
                    if (asc(cp)) {
                        out.println("YES");
                        return;
                    }
                }
            }

            out.println("NO");
        }

    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int size) {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        long[] nextLongArray(int size) {
            long[] arr = new long[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }
    }
}

Measured memory_bytes: 21332
#include <iostream>
#include <cstdio>

using namespace std;

int is_prime(int n) {
  if (n == 1)
    return 0;
  if (n == 2)
    return 1;
  for (int i = 2; i < n; i++) {
    if (n % i == 0)
      return 0;
  }
  return 1;
}

int main() {
  int s[1001] = { 0 };
  int n;
  cin >> n;

  for (int i = 2; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      if (is_prime(i)) {
        int k = j;
        while (k % i == 0) {
          s[i]++;
          k /= i;
        }
      }
    }
  }

  long long num = 1;

  for (int i = 2; i <= n; i++) {
    if (s[i]) {
      num *= s[i] + 1;
      while (num > 1000000007)
        num -= 1000000007;
    }
  }

  cout << num % 1000000007 << "\n";

  return 0;
}



Measured memory_bytes: 256
#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 main(){
    int n;
    cin>>n;
    deque<int>q;
    rep(i,n){
        int a; cin>>a;
        int x=lower_bound(q.begin(),q.end(), a)-q.begin();
        if(x==0)q.push_front(a);
        else q[x-1]=a;
    }
    cout<<q.size()<<endl;
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  vi A(N);
  rep(i,N) {
    cin >> A[i];
  }
  rep(i,N) {
    if(A[i] % 2 != 0) {
      cout << "first" << endl;
      return 0;
    }
  }
  cout << "second" << endl;
  return 0;
}

Measured memory_bytes: 640
int main(void) {
	int  i, n, x[101], p;
	long t = 0;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &x[i]);
		t += x[i];
	}
	
	int min=1000000,j;
	for (i = 1; i <= 100; i++) {
		t = 0;
		for (j = 0; j < n; j++)
			t += pow(x[j] - i, 2);
		if (t < min) 
			min = t;

	}
	//p = (t%n t/2)?t/n-1:t/n;

//	t = 0;
//	for (i = 0; i < n; i++) 
//		t += pow(x[i] - p, 2);
	printf("%ld", min);
	return 0;
}

Measured memory_bytes: 128
import Data.List
import Data.Maybe
import Data.Bits
import Data.Char
import qualified Data.ByteString.Char8 as BS
import Control.Monad

main = do
	s <- BS.getLine
	print $ solve $ map digitToInt $ BS.unpack $ s

solve :: [Int] -> Int
solve [] = 0
solve [a] = a
solve (a:b:xs) = a `shiftL` (length xs) + solve (a*10+b:xs) + solve (b:xs)

-- IO --
readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt

readIntList :: BS.ByteString -> [Int]
readIntList = map readInt . BS.words

getInt :: IO Int
getInt = readInt <$> BS.getLine

getIntList :: IO [Int]
getIntList = readIntList <$> BS.getLine

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for(ll i = 0;i < n;i++)
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

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

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

  ll ans = 0;
  if (n == 1) {
    cout << a[0]/2 << endl;
    return 0;
  }
  rep(i, n-1) {
    ll tmp = (a[i]+a[i+1]) / 2;
    if (tmp > 0) {
      ans += tmp;
      a[i+1] = (a[i]+a[i+1]) % 2;
    }
    cerr << ans << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
const int N=100010;
int n;
long long a[N],b[N];
int main(){
	while(~scanf("%d",&n)){
	    for(int i=1;i<=n;i++)scanf("%lld%lld",a+i,b+i);
		long long s=0;
		for(int i=n;i;i--){
		    long long t=(s+a[i])%b[i];
		    if(t)s+=b[i]-t;
		}printf("%lld\n",s);	
	}return 0;
} 

Measured memory_bytes: 1664
N = int(input())
cnt = 0
flg = False
for _ in range(N):
    a, b = map(int, input().split())
    if a != b:
        cnt = 0
    else:
        cnt += 1
    if cnt >= 3:
        flg = True

if flg:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 62464
#![allow(unused_imports)]
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{fastout, input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize, k: usize,
        mut a: [i64; n],
    }
    let m = 1000000007i64;
    let mod_product = |acc: i64, &value: &i64| {
        (acc * value).rem_euclid(m)
    };

    if k == n || k % 2 == 1 && a.iter().all(|v| *v <= 0) {
        a.sort_by_key(|v| -*v);
        let ans = a.iter().take(k).fold(1, mod_product);
        println!("{}", ans);
        return;
    }

    a.sort_by_key(|v| Reverse(v.abs()));
    let mut plus = Vec::new();
    let mut minus = Vec::new();
    for i in 0..n {
        if a[i] >= 0 {
            plus.push(a[i]);
        } else {
            minus.push(a[i]);
        }
    }

    let mut ppos = 0;
    let mut mpos = 0;
    let mut vals = Vec::new();
    let mut retry = false;
    while vals.len() < k {
        if vals.len() < k - 1 && ppos + 1< plus.len() && mpos + 1 < minus.len() {
            if plus[ppos] * plus[ppos+1] < minus[mpos] * minus[mpos+1] {
                vals.push(minus[mpos]);
                vals.push(minus[mpos+1]);
                mpos += 2;
            } else {
                vals.push(plus[ppos]);
                vals.push(plus[ppos+1]);
                ppos += 2;
            }
        } else if vals.len() < k - 1 && mpos + 1 < minus.len() {
            vals.push(minus[mpos]);
            vals.push(minus[mpos+1]);
            mpos += 2;
        } else if ppos < plus.len() {
            vals.push(plus[ppos]);
            ppos += 1;
        } else {
            retry = true;
            break;
        }
    }
    let ans = if !retry {
        vals.iter().fold(1, mod_product)
    } else {
        a.sort_by_key(|v| v.abs());
        assert!(a.iter().take(k).any(|v| *v > 0));
        a.iter().take(k).fold(1, mod_product)
    };
    println!("{}", ans);
}


Measured memory_bytes: 9788
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pll, int> plp;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const bool debug = 0;
//--------------------------------//

int N;
int t[101], v[101];
double dp[40001][201];
int ma[40001];

int main() {
	cin >> N;
	REP(i, N) scanf("%d", t + i), t[i] *= 2;
	REP(i, N) scanf("%d", v + i), v[i] *= 2;
	
	int now = 0;
	REP(i, N) REP(j, t[i]) ma[now++] = v[i];
	
	fill(dp[0], dp[now + 1], -1.0);
	dp[0][0] = 0.0;
	REP(i, now) REP(j, ma[i] + 1) {
		if (dp[i][j] < 0) continue;
		
		//printf("%d %d, %lf\n", i, j, dp[i][j]);
		if (j <= ma[i + 1]) chmax(dp[i + 1][j], dp[i][j] + j * 0.25);
		if (j < ma[i] && j + 1 <= ma[i + 1]) chmax(dp[i + 1][j + 1], dp[i][j] + j * 0.25 + 0.25);
		if (j > 0 && j - 1 <= ma[i + 1]) chmax(dp[i + 1][j - 1], dp[i][j] + j * 0.25 - 0.25);
	}
	
	printf("%.15lf\n", dp[now][0]);
	
	return 0;
}
/*
1
9
10
*/

Measured memory_bytes: 63232
#include<stdio.h>

#define N 10000
#define M 500

int n,s[N],t[M];

int linearSearch(int);

int main(){

  int q,i,count=0;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&s[i]);

  }
  scanf("%d",&q);

    for(i=0;i<q;i++){

      scanf("%d",&t[i]);

      if(linerSearch(t[i])==1) {count++;}

    }

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

  return 0;
}

int linerSearch(int key){

  

  int i;

  for(i=0;i<n;i++){

    if (s[i]==key) return 1;
  }

  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
struct edge{ll to,cost;};
const int inf = 1<<28;
const ll INF = 1LL<<53;
const int COMBMAX = 500005;
const ll MOD = 1e9+7;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;++i)
#define repf(i,n) for(int i=0;i<=n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define eachdo(v, e) for(const auto& e : v)
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (ll)distance(v.begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (ll)distance(v.begin(), upper_bound((v).begin(), (v).end(), e))
ll mpow(ll a, ll n,ll mod=MOD){ll res=1;while(n>0){if(n&1)res=res*a%mod;a=a*a%mod;n>>=1;}return res;}
template<class T1, class T2> ll bcount(T1 v, T2 a){return upper_index(v,a)-lower_index(v,a);} 
template<class T> bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
template<class T> void debug2(T v){rep(i,v.size()){rep(j,v[i].size())cout<<v[i][j]<<" ";cout<<endl;}}
template<class T> void rdv(T &v){rep(i,v.size())cin>>v[i];}
template<class T> void rdvv(T &v){rep(i,v.size()){rep(j,v[i].size())cin>>v[i][j];}}
// multimap
// mmap.emplace(key,value);
// auto ngw = list.equal_range("");
// for(auto e = ngw.first; it != ngw.second ; ++e)


int main(){
    ll N, M; cin >> N >> M;
    vector<ll> from(M), to(M);
    vector<vector<ll>> g(N, vector<ll>()), gRev(N, vector<ll>());
    rep(i, M){
        cin >> from[i] >> to[i];
        g[--from[i]].emplace_back(--to[i]);
        gRev[to[i]].emplace_back(from[i]);
    }
    vector<ll> enterEdge(N);
    queue<ll> noEdge;
    rep(i, N) {
        enterEdge[i] = gRev[i].size();
        if (!enterEdge[i]) noEdge.push(i);
    }
    vector<ll> tsort;
    while(!noEdge.empty()){
        ll v = noEdge.front(); noEdge.pop();
        tsort.emplace_back(v);
        eachdo(g[v], e){
            enterEdge[e]--;
            if (!enterEdge[e]) noEdge.push(e);
        }
    }
    vector<ll> dp(N, 0);
    eachdo(tsort, v){
        eachdo(g[v], e){
            chmax(dp[e], dp[v] + 1);
        }
    }
    cout << *max_element(all(dp)) << endl;
    return 0;
}

Measured memory_bytes: 15224
import java.util.*;

public class Main {
    public  static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int sheep = Integer.parseInt(sc.next());
        int wolves = Integer.parseInt(sc.next());

        if(sheep <= wolves) {
            System.out.println("unsafe");
        } else {
            System.out.println("safe");
        }
    }
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.txt", "r", stdin);
		//freopen("out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(0), cin.tie(0);

	ll k, a, b;
	cin >> k >> a >> b;

	ll bi = 1, g = 0;
	if (a > 1)
	{
		bi += min(k, a-1);
		k -= min(k, a-1);
	}

	if (k > 0)
	{
		if (k == 1)
			++bi;
		else
		{
			if (b-a > 2)
			{
				bi += (b-a)*(k>>1);
				if (k&1) ++bi;
			}
			else
			{
				bi += k;
			}
		}
	}

	cout << bi << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
const long long mod = (1e9) + 7;

int main(){
  string S;
  cin >> S;
  long long c = 0, q = 0, a = 0, lq = 0;
  for(size_t i = 0; i < S.length(); ++i){
    c += (int)(S[i] == 'C');
    q += (int)(S[i] == '?');
  }
  long long ans = 0;
  vector<long long> T(q+1,1);
  for(int i = 0; i < q; ++i){
    T[i+1] = (T[i]*3)%mod;
  }
  for(size_t i = 0; i < S.length(); ++i){
    if(S[i] == 'B'){
      ans += (((a*c)%mod)*T[q])%mod;
      ans %= mod;
      ans += (((lq*c)%mod)*T[q-1])%mod;
      ans %= mod;
      ans += (((a*(q-lq))%mod)*T[q-1])%mod;
      ans %= mod;
      ans += (((lq*(q-lq))%mod)*T[q-2])%mod;
      ans %= mod;
    }else if(S[i] == '?'){
      ans += (((a*c)%mod)*T[q-1])%mod;
      ans %= mod;
      ans += (((lq*c)%mod)*T[q-2])%mod;
      ans %= mod;
      ans += (((a*(q-lq-1))%mod)*T[q-2])%mod;
      ans %= mod;
      ans += (((lq*(q-lq-1))%mod)*T[q-3])%mod;
      ans %= mod;
      ++lq;
    }
    if(S[i] == 'A') ++a;
    if(S[i] == 'C') --c;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
const int inf = 1e9;

string str;
int ans[4];
int main(){
	int n;
	scanf("%d", &n);
	rep(i,n){
		cin >> str;
		if(str[0] == 'P')ans[0]++;
		if(str[0] == 'W')ans[1]++;
		if(str[0] == 'G')ans[2]++;
		if(str[0] == 'Y')ans[3]++;
	}
	int f = 0;
	rep(i,4)if(ans[i] == 0)f = 1;
	if(f == 1)printf("Three\n");
	else printf("Four\n");
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
N = int(input())
A = list(map(int, input().split()))
S = sum(A)
X = [0] * N

A_e = 0
for i, a in enumerate(A):
    if i % 2 == 1:
        A_e += a

X[0] = S - 2 * A_e
for i in range(1, N):
    X[i] = 2 * A[i-1] - X[i-1]

print(' '.join(map(str, X)))

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

COST = [INT() for _ in range(4)]
print(min(COST[0], COST[1]) + min(COST[2], COST[3]))

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


void input(); template<typename First,typename... Rest> void input(First&,Rest&...);
void inputVector(); template<typename First,typename... Rest>  void inputVector(std::vector<First>&,Rest&...);
#define loop(n) for(int i = 0;i < (int)(n);++i)
#define rep(i,n) for(int i = 0;i < (int)(n);++i)
#define all(vec) (vec).begin(),(vec).end()
#define sort(vec) std::sort(all(vec))
#define rev(vec) std::reverse(all(vec))

void calculate(){

}

int main(int,char**){
    int N;
    input(N);
    std::vector<long long> A(N);
    inputVector(A);
    long long res = 1L << 60;
    for(auto i : A)
    {
        long long count = 0;
        while(i % 2 == 0)
        {
            i /= 2;
            count++;
        }
        res = std::min(res,count);
    }
    std::cout << res << '\n';
}


void input(){return;}
template<typename First,typename... Rest>
void input(First &first,Rest&... rest){
    std::cin >> first;
    input(rest...);
}

void inputVector(){return;}
template<typename First,typename... Rest> 
void inputVector(std::vector<First> &first,Rest&... rest){
    int N = first.size();
    for(int i = 0;i < N;i++){
        std::cin >> first[i];
    }
    inputVector(rest...);
}

Measured memory_bytes: 256
#include<iostream>
#include<cctype>
#include<string>
using namespace std;
int main(){


	string s;
	string p;

	cin>>s;
	cin>>p;

	s=s+s;
	std::string::size_type a = s.find(p);
     
    if(a == string::npos)
    	cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;

}

Measured memory_bytes: 1192
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define max(a, b) ((a)<(b) ? (b) : (a))

int main(){
  int n;  scanf("%d", &n);
  char s[200001][11];
  for(int i=0; i<n; i++) scanf("%s", s[i]);

  qsort(s, n, 11, strcmp);

  //  for(int i=0; i<n; i++) printf("%s\n", s[i]);


  int count = 0, ans = 0;
  for(int i=1; i<n; i++){
    if(strcmp(s[i-1], s[i])==0){
      count++;
    }else{
      ans = max(ans, count);
      count = 0;
    }
  }
  ans = max(ans, count);
  count = 0;
  for(int i=1; i<n; i++){
    if(strcmp(s[i-1], s[i])==0){
      count++;
    }else if(count==ans){
      printf("%s\n", s[i-1]);
      count = 0;
    }else{
      count = 0;
    }
  }
  if(count == ans)
    printf("%s\n", s[n-1]);
  
      

  return 0;
}


Measured memory_bytes: 4476
#include<iostream>
using namespace std;
int check(char c){
	if(c=='A'||c=='C'||c=='G'||c=='T')
		return 1;
	return 0;
}
int main(){
	string s;
	cin>>s;
	int a[s.length()];
	a[0]=check(s[0]);
	for(int i=1;i<s.length();++i)
		a[i]=check(s[i])?check(s[i])+a[i-1]:0;
	int maxv=-1;
	for(int i=0;i<s.length();++i)
		maxv=max(a[i],maxv);
	cout<<maxv<<endl;
	return 0;
}

Measured memory_bytes: 256
//073 A - September 9 2017/09/09
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main(){
    int n; cin >> n;
    cout << ((n%10==9 || (n/10)%10==9 ) ? "Yes" : "No" ) << endl; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  Int ans=0;
  vector<Int> c(n),v(n);
  for(Int i=0;i<n;i++) cin>>v[i];
  for(Int i=0;i<n;i++) cin>>c[i];
  for(Int i=0;i<n;i++){
    if(v[i]>c[i]) ans+=v[i]-c[i];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

class StarrySkyTree {
  static const ll INF = 1e18;
  int N;
  std::vector<ll> segmentTreeMin, segmentTreeAdd;
public:
  StarrySkyTree(int n_){
    N = 1;
    while(N<n_) N *= 2;
    segmentTreeMin.resize(2*N);
    segmentTreeAdd.resize(2*N);
    for(int i=0; i<2*N; i++){
      segmentTreeMin[i] = 0;
      segmentTreeAdd[i] = 0;
    }
  }

  void add(int a, int b, ll x){
    return add(a, b, x, 0, 0, N);
  }
  void add(int a, int b, ll x, int k, int l, int r){
    if(r<=a || b<=l) return;
    if(a<=l && r<=b){
      segmentTreeAdd[k] += x;
      return;
    }
    add(a, b, x, k*2+1, l, (l+r)/2);
    add(a, b, x, k*2+2, (l+r)/2, r);
    segmentTreeMin[k] = std::min(segmentTreeMin[k*2+1]+segmentTreeAdd[k*2+1],
                                 segmentTreeMin[k*2+2]+segmentTreeAdd[k*2+2]);
  }

  ll getMin(int a, int b){
    return getMin(a, b, 0, 0, N);
  }
  ll getMin(int a, int b, int k, int l, int r){
    if(r<=a || b<=l) return INF;
    if(a<=l && r<=b) return segmentTreeMin[k] + segmentTreeAdd[k];
    ll lmin = getMin(a, b, k*2+1, l, (l+r)/2);
    ll rmin = getMin(a, b, k*2+2, (l+r)/2, r);
    return std::min(lmin, rmin) + segmentTreeAdd[k];
  }
};


int main(){
  int N, D, A;
  cin >> N >> D >> A;
  vector<pair<ll,ll>> v;
  rep(i,N){
    ll x, h;
    cin >> x >> h;
    v.emplace_back(x,h);
  }

  sort(ALLOF(v));

  vector<int> range;
  int idx = 0;
  rep(i,N){
    while(idx+1 < N && v[idx+1].first <= v[i].first + 2*D) idx++;
    range.push_back(idx+1);
  }

  StarrySkyTree sst(N);
  
  rep(i,N){
    sst.add(i, i+1, v[i].second);
  }
  ll ret = 0;
  rep(i,N){
    ll val = sst.getMin(i,i+1);
    if(val <= 0) continue;
    ll damage = (val + A - 1) / A;
    sst.add(i, range[i], -damage * A);
    ret += damage;
  }

  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 14316
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;


bool check(vector< vector<int> > board){
    for(int i=0;i<4;i++){
	for(int j=0;j<4;j++){
	    if(board[i][j] == 0) return false;
	}
    }
    return true;
}

int saiki(vector<int> x,vector<int> y,vector< vector<int> > board,int nx,int ny){

    int res = 0;
    bool flag = true;
    while(flag){
	if (check(board)) return 1;
	if (nx == 4){
	    nx = 0;
	    ny++;
	}
	if (board[ny][nx] == 0){
            flag = false;
	    board[ny][nx]++;
	    for(int i=0;i<x.size();i++){
		int nexty = ny + y[i],nextx = nx + x[i];
		if(nexty > -1 && nexty < 4 && nextx > -1 && nextx < 4 && board[nexty][nextx] == 0){
		    board[nexty][nextx]++;
		    res += saiki(x,y,board,nx+1,ny);
		    board[nexty][nextx]--;
		}
	    }
	}else{
	    nx++;
	}
    }
    return res;
}

   
int main(){

    vector< vector<int> > board(4,vector<int>(4));


    int temp,c1=0,c=0;
    vector< vector<int> > x,y;
    vector<int> dx,dy;
    while(true)
    {
	cin >> temp;
	if (temp > 3) break;
	dx.push_back(temp);
	cin >> temp;
	dy.push_back(temp);

	c1++;
	if(c1 == 4)
	{
	    c1 = 0;
	    c++;
	    x.push_back(dx);
	    y.push_back(dy);
	    dx.clear();
	    dy.clear();
	}
    }

    vector<int> t(4);
    
    for(int i=0;i<c;i++){
	fill(board.begin(),board.end(),t);
        cout << saiki(x[i],y[i],board,0,0) << endl;
    }

    return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i;
	long long min=1000000001,max=0,tmp;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%lld",&tmp);
		if(min>tmp)
			min=tmp;
		if(max<tmp)
			max=tmp;
	}
	printf("%lld",max-min);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define boost ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define M 1000000007
#define eb emplace_back
#define watch(x) cout << (#x) <<" is "<< x <<"\n";


using namespace std;
//const int N = 1e6;

int32_t main(){
  boost;
  int tc = 1; //cin >> tc;
  while(tc--)
  {
    int n; cin >> n;
    int arr[n];
    int xorr = 0;
    for(int i=0; i<n; i++)
    {
      cin >> arr[i];
      xorr ^= arr[i];
    }
    for(int i=0; i<n; i++)
    {
      cout << (xorr^arr[i]) << " ";
    }

  }
}



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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    string s; cin >> s;
    if(s == "RRR") cout << 3 << endl;
    else if((s[0] == 'R' && s[1] == 'R') || s[1] == 'R' && s[2] == 'R') cout << 2 << endl;
    else if(count(all(s), 'R')) cout << 1 << endl;
    else cout << 0 << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<set<int>> st(26);
  for (int i = 0; i < n; i++) st[s[i] - 'a'].insert(i);
  int q;
  cin >> q;

  while (q--) {
    int f;
    cin >> f;
    f--;
    if (f) {
      int l, r;
      cin >> l >> r;
      l--;
      r--;
      int res = 0;
      for (int i = 0; i < 26; i++) {
        auto itr = st[i].lower_bound(l);
        if (itr == st[i].end()) continue;
        if (*itr <= r) res++;
      }
      cout << res << "\n";
    } else {
      int i;
      char c;
      cin >> i >> c;
      i--;
      st[s[i] - 'a'].erase(i);
      st[c - 'a'].insert(i);
      s[i] = c;
    }
  }
  return 0;
} 

Measured memory_bytes: 27236
num_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input()) - 1
print(num_list[K])

Measured memory_bytes: 38256
import java.util.*;
public class Main{
	public static String clockwise(Vector v1, Vector v2){
		long cross = v1.x * v2.y - v1.y * v2.x;
		long value = v1.x * v2.x + v1.y * v2.y;
		long len1 = v1.x * v1.x + v1.y * v1.y;
		long len2 = v2.x * v2.x + v2.y * v2.y;
		if(cross == 0L){
			if(value < 0L)
				return "ONLINE_BACK";
			else if(len1 < len2)
				return "ONLINE_FRONT";
			else
				return "ON_SEGMENT";
		}
		else if(cross > 0L){
			return "COUNTER_CLOCKWISE";
		}
		else{
			return "CLOCKWISE";
		}
	}
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Point p0 = new Point(sc.nextLong(),sc.nextLong());
		Point p1 = new Point(sc.nextLong(),sc.nextLong());
		Vector v1 = new Vector(p0,p1);
		int q = sc.nextInt();
		for(int i = 0 ; i < q ; i++){
			Point p2 = new Point(sc.nextLong(),sc.nextLong());
			Vector v2 = new Vector(p0,p2);
			System.out.println(clockwise(v1,v2));
		}
	}
}
class Point{
    long x;
    long y;
    Point(long x, long y){
        this.x = x;
        this.y = y;
    }
}
class Vector{
        long x;
	long y;
	Vector(Point ps, Point pg){
		x = pg.x - ps.x;
		y = pg.y - ps.y;
	}
}


Measured memory_bytes: 34036
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <unordered_set>
#include <bitset>
#include <cmath>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
static const int INF = 1000010000;
static const int NIL = -1;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue
 
int gcd(int a, int b) { int c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
int lcm(int a, int b) { int c = gcd(a, b); a /= c; return a*b; }
int nCr(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
int pow(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llpow(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llgcd(long long a, long long b) { long long c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
long long lllcm(long long a, long long b) { long long c = llgcd(a, b); a /= c; return a*b; }
long long llnCr(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
 
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

int main(){
    vector<int> a;
    REP(i, 3){
        int t; cin >> t; a.pb(t);
    }
    SORT(a);
    if(a[0] == a[1] && a[0] == 5 && a[2] == 7){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from math import pi, cos

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

def main():
    A, B, H, M = MII()
    
    theta = abs(H*30-6*M+M/2)*pi/180
    print((A**2+B**2-2*A*B*cos(theta))**(1/2))


if __name__ == '__main__':
    main()


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

#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795
#define INF 9223372036854775807LL


int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int a,b,c,d;
	string s;
	cin >> s;
	a = s.at(0)-'0';
	b = s.at(1)-'0';
	c = s.at(2)-'0';
	d = s.at(3)-'0';
	for(int op1 = 0; op1 < 2; op1++) {
		for(int op2 = 0; op2 < 2; op2++) {
			for(int op3 = 0; op3 < 2; op3++) {
				int num = a+(op1 ? -b : b)+(op2 ? -c : c)+(op3 ? -d : d);
				if(num == 7) {
					cout << a << (op1 ? "-" : "+") << b << (op2 ? "-" : "+") << c << (op3 ? "-" : "+") << d << "=7";
					return 0;
				}
			}
		}
	}
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include<map>	
#include<cstring>
#include<iomanip>
#include <string>
#include <vector>	
#include<unordered_map>
#include<unordered_set>
using namespace std;


typedef long long unsigned llu;
typedef long double ld;
#define ll long long
#define PI 3.14159265358979323846
#define For(i, a, b) for (int i = a, sz = (int)b; i < sz; i++)
#define rFor(i, a, b, c) for (int i = (a); i >= (b); i -= (c))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fill(a, b) memset(a, b, sizeof(a))
#define IO ios_base::sync_with_stdio(false), cin.tie(0),cout.tie(0)
const int mod = 1000000007;
const ll inf = 1000000000009;
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);}

//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdoutn

int main()
{
	IO;
	int n{},x{},ans{};
	cin>>n>>x;
	vector<int>v(n);
	For(i,0,n)cin>>v[i];
	sort(all(v));
	For(i,0,n){
		if(x>=v[i])ans++,x-=v[i];
		else break;
	}
	if(ans==n){
		if(x>0)cout<<ans-1<<'\n';
		else cout<<ans<<'\n';
	}else cout<<ans<<'\n';
	//system("pause");
	return 0;

}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int S = Integer.parseInt(sc.next());
		int W = Integer.parseInt(sc.next());
		if (W >= S) {
			System.out.println("unsafe");
		} else {
			System.out.println("safe");
		}
	}
}


Measured memory_bytes: 27008