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

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	a[0] = toupper(a[0]);
	b[0] = toupper(b[0]);
	c[0] = toupper(c[0]);
	cout << a[0] << b[0] << c[0];
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <deque>
#include <map>
#include <set>
 
#define ll long long
#define inf 0x3f3f3f3f
#define il inline
 
namespace io {
 
    #define in(a) a=read()
    #define out(a) write(a)
    #define outn(a) out(a),putchar('\n')
 
    #define I_int ll
    inline I_int read() {
        I_int x = 0 , f = 1 ; char c = getchar() ;
        while( c < '0' || c > '9' ) { if( c == '-' ) f = -1 ; c = getchar() ; }
        while( c >= '0' && c <= '9' ) { x = x * 10 + c - '0' ; c = getchar() ; }
        return x * f ;
    }
    char F[ 200 ] ;
    inline void write( I_int x ) {
        if( x == 0 ) { putchar( '0' ) ; return ; }
        I_int tmp = x > 0 ? x : -x ;
        if( x < 0 ) putchar( '-' ) ;
        int cnt = 0 ;
        while( tmp > 0 ) {
            F[ cnt ++ ] = tmp % 10 + '0' ;
            tmp /= 10 ;
        }
        while( cnt > 0 ) putchar( F[ -- cnt ] ) ;
    }
    #undef I_int
 
}
using namespace io ;
 
using namespace std ;
 
#define N 100010
 
ll n = read(), K = read();
ll a[N], cnt[2];
 
bool cmp(int a, int b) {
    return a > b;
}
 
int main() {
    for(int i = 1; i <= n; ++i) a[i] = read();
    ll ans = 0;
    for(ll k = 42; k >= 0; --k) {
        cnt[0] = cnt[1] = 0; 
        for(int i = 1; i <= n; ++i) {
            cnt[(a[i]>>k)&1ll]++;
        }
        if(cnt[0] > cnt[1] && ans + (1ll << k) <= K) ans += (1ll << k);
    }
    ll sum = 0;
    for(int i = 1; i <= n; ++i) {
        sum += ans ^ a[i];
    }
    printf("%lld\n", sum);
    return 0;
}

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

using namespace std;

typedef long long int64;

struct UnionFind
{
  vector< int > data;

  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }

  void unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x != y) {
      if(data[x] > data[y]) swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
  }

  int find(int k)
  {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k)
  {
    return (-data[find(k)]);
  }
};

int main()
{
  int N, A[200000];

  cin >> N;
  for(int i = 0; i < N; ++i) {
    cin >> A[i];
  }

  vector< int > idx(N);
  iota(begin(idx), end(idx), 0);
  sort(begin(idx), end(idx), [&](int a, int b)
  {
    return (A[a] > A[b]);
  });

  int64 ret = 0;
  UnionFind tree(N);
  for(int& i : idx) {
    int Left = 1, Right = 1;
    if(i > 0 && A[i] < A[i - 1]) {
      Left += tree.size(i - 1);
      tree.unite(i - 1, i);
    }
    if(i + 1 < N && A[i] < A[i + 1]) {
      Right += tree.size(i + 1);
      tree.unite(i + 1, i);
    }
    ret += 1LL * A[i] * Left * Right;
  }
  cout << ret << endl;
}


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

const int MOD = 1000000007;
const int INF = 999999999;

int main(){
    int H, W;
    cin >> H >> W;
    vector<vector<char>> board(H, vector<char>(W));
    vector<bool> hb(H, false);
    vector<bool> wb(W, false);
    rep(i, H){
        rep(j, W){
            cin >> board[i][j];
            if(board[i][j] == '#'){
                hb[i] = true;
                wb[j] = true;
            }
        }
    }
    rep(i, H){
        if(hb[i] == true){
            rep(j, W){
                if(wb[j] == true){
                    cout << board[i][j];
                }
            }
            cout << endl;
        }
    }
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
	int H, W;
	cin >> H >> W;

	char a[H][W];
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++) cin >> a[i][j];
	}

	for(int i=0;i<W+2;i++){
		cout << '#';
	}
	cout <<endl;

	for(int i=0;i<H;i++){
		cout << '#';
		for(int j=0;j<W;j++){
			cout << a[i][j];
		}
		cout << '#' <<endl;
	}


	for(int i=0;i<W+2;i++){
		cout << '#';
	}
	cout <<endl;    
	return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::max;

fn main() {
    input!{
        n: usize,
        v: [isize; n]
    }
    let mut ans: isize = 0;
    for c in 1..n - 1 {
        let mut s: isize = 0;
        for i in 1..(n - 1) / c {
            s += v[i * c] + v[n - 1 - i * c];
            if (n - 1) % c == 0 && (n - 1) / c <= 2 * i {
                continue;
            }
            ans = max(ans, s);
        }
    }
    println!("{}", ans);
}


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

int main(){
  string O,E; cin >> O >> E;
  string emp = "";

  int indO = 0;
  int indE = 0;
  
  for(int i = 0;i < (O.size()+E.size());i++){
    if(i % 2 == 0){
      emp += O[indO];
      indO++;
    }
    else{
      emp += E[indE];
      indE++;
    }
  }

  cout << emp << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <unordered_map>
#include <iomanip>

#define DEBUG(x) cout << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<pair<T, T> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int l;
	cin >> l;

	double third = (double) l / 3;
	cout << setprecision(12) << third * third * third << "\n";

	return 0;

}

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

int main(){
    string S;
    cin >> S;
    int fir = 0, sec = 0;
    int size = (int)S.size();
    //cout << size << endl;
    for(int i = 0; i < size; i+=2) if(S[i] == '0') fir++;
    for(int i = 1; i < size; i+=2) if(S[i] == '1') fir++;
    for(int i = 0; i < size; i+=2) if(S[i] == '1') sec++;
    for(int i = 1; i < size; i+=2) if(S[i] == '0') sec++;

    if(fir > sec) cout << (size - fir) << endl;
    else cout << (size - sec) << endl;
}

Measured memory_bytes: 512
#include <stdio.h>
int main(void) {
  int i, sum = 0;
  int stu[5];
  for(i=0;i < 5;i++) {
    scanf("%d",&stu[i]);
    if (stu[i] < 40) {
      stu[i] = 40;
    }
    if (stu[i] > 100) {
      stu[i] = 100;
    }
    sum += stu[i];
  }
  printf("%d\n",sum / 5);
  return(0);
}

Measured memory_bytes: 600
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<utility>
using namespace std;
#define MS(m,z) memset(m,z,sizeof(m))
typedef unsigned U;typedef long long ll;typedef pair<int,int > P;
void inp();
int main(){
#ifdef XS
	//freopen(".in","r",stdin);
#endif
	//int ttt;scanf("%d",&ttt);for(int i=1;i<=ttt;i++)
	inp();
	return 0;
}
int G[600][600];
int dp[5][50];
int C[50][50];
int ans = 1e9;
int p[3];
int n,x,c;
void jd(){
	int cur = 0;
	for(int i = 0;i<3;i++){
		for(int j = 1;j<=c;j++){
			cur += dp[i][j] * C[ j ][ p[ i] ];
		}
	}
	ans = min(ans, cur);
}
void inp(){
	scanf("%d", &n); scanf("%d",&c);
	for(int i = 1;i<=c;i++){
		for(int j =1;j<=c;j++){
			scanf("%d", &C[i][j]); // from i to j
		}
	}
	for(int i =1;i<=n;i++){
		for(int j=1;j<=n;j++){
			scanf("%d",&G[i][j]);
			int r = (i+j)%3;
			dp[r][ G[i][j] ] ++;
		}
	}
	for(int i = 1;i<=c;i++){
		for(int j = 1;j<=c;j++){
			for(int k = 1;k<=c;k++){
				if( i == j || j == k || i == k)continue;
				p[0]=i;
				p[1]=j;
				p[2]=k;
				jd();
			}
		}
	}
	printf("%d", ans);
}
//d.cc by xsthunder at Fri Jul 27 23:58:32 2018


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

int main() {
  int N, S = 0;
  cin >> N;
  vector<int> A(N), B(N), C(N - 1);
  
  for(int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
   for(int i = 0; i < N; i++) {
    cin >> B.at(i);
  }
  
  for(int i = 0; i < (N - 1); i++) {
    cin >> C.at(i);
  }
  
  for(int i = 0; i < N; i++) {  
    S += B.at(A.at(i) - 1);
    
    if(i < N - 1){
      if(A.at(i) + 1 == A.at(i + 1)) {
        //次の料理がi+1なら満足度C(i)を足す
        S += C.at(A.at(i) - 1);
      }  
    }
    else {
      //最後の料理の場合終了
      break; 
    }
    
  }
  cout << S;
 
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
int main() {
  int n,a[50]={},ans=0;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  for(int i=0; i<n-1; i++) {
    for(int j=i+1; j<n; j++) {
      ans+=a[i]*a[j];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n,m=gets.split.map(&:to_i)
xy=[]
m.times{xy<<gets.split.map(&:to_i)}
exst=Array.new(n+1,false)
exst[1]=true
num=Array.new(n+1,1)
num[0]=0

xy.each{|arr|
  num[arr[1]]+=1
  exst[arr[1]]=true if exst[arr[0]]
  num[arr[0]]-=1
  exst[arr[0]]=false if num[arr[0]]==0
  }
puts exst.count{|x|x}

Measured memory_bytes: 11132
#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 pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
int a[3][3],n;
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}









int main() {
  int x[5];
  rep (i,5) cin >> x[i];
  rep (i,5){
    if (x[i]==0){
      cout << i+1 << endl;
      return 0;    }
  }
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int main(){
	int n,m;
	cin>>n>>m;
	map<int,int>mm;
	multiset<int>ss;
	for(int i=0;i<m;i++)mm[i]=i;
	for(int i=0;i<m;i++)ss.insert(0);
	for(int i=1,add=1;i<=n;i++){
		int a,b,c,d;
		cin>>a>>b;
		c=-1;
		for(auto j=mm.lower_bound(--a);j!=mm.end()&&j->F<=b;mm.erase(j++)){
			d=j->F;
			c=max(c,mm[d]);
			ss.erase(ss.find(d-mm[d]));
		}
		if(c+1&&b<m)mm[b]=c,ss.insert(b-c);
		if(ss.size())cout<<*ss.begin()+add<<endl,add++;
		else puts("-1");
	}
}

Measured memory_bytes: 22336
#include<stdio.h>
int main(void)
{ char cl[]={'A','T','G','C'};
  char b;
  int i;
  scanf("%c",&b);
 if(b=='T')i=0;
 if(b=='A')i=1;
 if(b=='G')i=3;
 if(b=='C')i=2;
 printf("%c",cl[i]);
 return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iomanip>
#include <algorithm>
#define ll long long
#include <unordered_map>
using namespace std;
 
int main() {
  ll X;
  cin >> X;
  if(X >= 30) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    int n,m;
    cin>>n>>m;
    int a[9]={2,5,5,4,5,6,3,7,6};
    vector<pair<int,int>> p;
    for(int i=0;i<m;i++){
        int k;
        cin>>k;
        p.emplace_back(a[k-1],k);
    }
    vector<bool> ok(20000,false);
    vector<vector<int>> v(20000);
    ok[0]=true;
    for(int i=1;i<n+1;i++){
        vector<int> vv;
        for(int j=0;j<m;j++){
            if((i-p[j].first>-1)&&ok[i-p[j].first]){
                ok[i]=true;
                vector<int> vs;
              vs=v[i-p[j].first];
                vs.push_back(p[j].second);
                if(vv.size()<vs.size()||(vv.size()==vs.size()&&vv<vs))vv=vs;
            }
        }
        if(ok[i]){
            v[i]=vv;
          //cout<<i<<endl;
          for(int t=0;t<v[i].size();t++){
        //cout<<v[i][t];
    }
          //cout<<endl;
        }
    }
    for(int i=0;i<v[n].size();i++){
        cout<<v[n][i];
    }
}



Measured memory_bytes: 110720
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,t;
	cin >> n >> t;
	vector<int> a(n),cnt(n);
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
	}
	int cur=a[n-1];
	for(int i=n-1;i>=0;i--)
	{
		cnt[i]=cur-a[i];
		cur=max(cur,a[i]);
	}
	sort(cnt.rbegin(),cnt.rend());
	int ans=1;
	for(int i=1;i<n;i++)
	{
		if(cnt[0]==cnt[i]) ans++;
		else
		break;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;

class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		
		while (true) {
			int h = sc.nextInt(); int w = sc.nextInt();
			if (h==0 && w==0) return;
			
			for (int i=0; i<h; i++) {
				StringBuilder sb = new StringBuilder();
				for (int j=0; j<w; j++) sb.append("#");
				System.out.println(sb);
			}
			
			System.out.println();
		}
		
	}
}


Measured memory_bytes: 28900
#include<stdio.h>

int main(void)
{
        int i,j;
        int n,m,a[50],b[50],c[50];

        scanf("%d%d",&n,&m);

        for(i=0;i<m;i++){
                scanf("%d%d",&a[i],&b[i]);
        }

        for(i=0;i<n;i++)
                c[i]=0;

        for(i=0;i<m;i++){
                for(j=1;j<=n;j++){
                        if(a[i]==j)
                                c[j-1]++;
                        if(b[i]==j)
                                c[j-1]++;
                }
        }

        for(i=0;i<n;i++)
                printf("%d\n",c[i]);

        return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<vector>
using namespace std;
static const int MAX_H = 500;
static const int MAX_W = 500;

int H, W;
int a[MAX_H][MAX_W];
vector<int> va, vb, vc, vd;

int main(){
	scanf("%d %d", &H, &W);
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			scanf("%d", &a[i][j]);
		}
	}
	int cnt = 0;
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W - 1; j++){
			if(a[i][j] % 2 == 1){
				a[i][j + 1] += 1;
				va.push_back(i + 1);
				vb.push_back(j + 1);
				vc.push_back(i + 1);
				vd.push_back(j + 2);
			}
		}
	}
	for(int i = 0; i < H - 1; i++){
		if(a[i][W - 1] % 2 == 1){
			a[i + 1][W - 1] += 1;
			va.push_back(i + 1);
			vb.push_back(W);
			vc.push_back(i + 2);
			vd.push_back(W);
		}
	}
	printf("%d\n", va.size());
	for(int i = 0; i < va.size(); i++){
		printf("%d %d %d %d\n", va[i], vb[i], vc[i], vd[i]);
	}
	return 0;
}


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

//#define debug
using namespace std;
int n, m, a[105];

int main() {
#ifdef debug
	freopen("1.in", "r", stdin);
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	while (cin >> n) {
		int sum = 0;
		for (int i = 0; i < n; i++) {
			cin >> a[i];
			sum += a[i];
		}
		int x = sum / n, res1 = 0, res2 = 0;
		for (int i = 0; i < n; i++) {
			res1 += (int)pow(abs(x - a[i]), 2);
			res2 += (int)pow(abs(x + 1 - a[i]), 2);
		}
		cout << min(res1, res2) << endl;
	}
	return 0;
}


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

typedef long long int lli;
typedef long double lld;
typedef long long ll;
//Datatype
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define vvlli vector<vector<long long int>>
#define ppi pair<int, int>
#define rppi pair<int, pair<int, int>>
#define lppi pair<pair<int, int>, int>
#define vppi vector<pair<int, int>>
#define sppi stack<pair<int int>>
#define qppi queue<pair<int, int>>
//function
#define f first
#define s second
#define pb(x) push_back(x)
#define mkp(i, j) make_pair(i, j)
#define lmkp(i,j,k) make_pair(make_pair(i,j),k)
#define rmkp(i,j,k) make_pair(i,make_pair(j,k))
//loop
#define loop(i,n) for (i = 0; i < n; ++i)
#define loops(i,k,n) for (i = k; i <= n; ++i)
#define looprev(i,k,n) for (i = k; i >= n; --i)
//Const
#define inf (int)1e9
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
//Print
#define prd(n) printf("%d", n)
#define prl(n) printf("%lld", n)
#define prdn(n) printf("%d\n", n)
#define prln(n) printf("%lld\n", n)
#define prf(n) printf("%f", n)
//Scan
#define scd(n) scanf("%d", &n)
#define scd2(a, b) scanf("%d %d", &a, &b)
#define scd3(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scl(n) scanf("%lld", &n)
#define scl2(a, b) scanf("%lld %lld", &a, &b)
#define scl3(a, b, c) scanf("%lld %lld %lld", &a, &b, &c)
#define scf(n) scanf("%f", &n)

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli i, j, N, K, t;
    cin>>N>>K;
    vector<lli> vec(N, 0);
    vector<bool> dp(K+1, false);
    loop(i, N){
        cin>>vec[i];
    }
    for(lli stones=0; stones <= K; stones++){
        for(auto a: vec){
            if(stones >= a && !dp[stones-a]){
                dp[stones] = true;
            }
        }
    }
    //for(auto a: dp) cout<<a<<endl;
    cout<<(dp[K] == true ? "First" : "Second")<<endl;
  return 0;
}

Measured memory_bytes: 3584
#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>;

ll mod = 1000000007;
ll modpow(ll a, ll n, ll mod){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll com(ll a, ll b, ll mod){
	ll res = 1;
	b = min(b, a-b);
	ll n = b;
	for(int i=0; i<n; i++){
    	res *= a;
    	if(res >= mod) res %= mod;
    	res *= modpow(b, mod-2, mod);
    	if(res >= mod) res %= mod;
    	a--;
    	b--;
    }
	return res;
}

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int ans = modpow(2, a, mod);
	ans--;
	if(ans < 0) ans += mod;
	ans -= com(a, b, mod);
	if(ans < 0) ans += mod;
	ans -= com(a, c, mod);
	if(ans < 0) ans += mod;
	cout << ans << endl;
}

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

int main() {
	string str;
	cin >> str;
	for(size_t i = str.size() - 1; i >= 0; --i){
		if(i == -1) break;
		cout << str[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1180
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    S = lines.pop(0)
    re = 0
    for i in S:
        if i == '+':
            re += 1
        else:
            re -= 1
    print(re)

#
# main
#

# 1. use list instead of stdin

# contents = '''\
# --++\
# '''
# lines = contents.split('\n')

# 2. use stdin

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Measured memory_bytes: 2940
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    string s; cin>>s;
    for(auto &ch:s){
        if(ch=='1') ch='9';
        else if(ch=='9') ch='1';
    }
    cout<<s<<endl;
}

Measured memory_bytes: 3576
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {


	
	public static void main(String[] args) throws NumberFormatException, IOException {
	        BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 1);
	        String str = "";
	        StringTokenizer st;
	        while ((str = br.readLine()) != null) {
	            st = new StringTokenizer(str, " ");
	            if(st.countTokens() > 2)
	            	System.out.println("Only 2 numbers per dataset allowed.");
	            int n1;
				int n2;
				try {
					n1 = Integer.parseInt(st.nextToken());
					n2 = Integer.parseInt(st.nextToken());
		            if(n1<0 || n2 < 0 || n1 > 1000000 || n2 > 1000000)
		            	System.out.println("Out of range. 0 ??? a, b ??? 1,000,000");
		            
		            str = String.valueOf(n1+n2);
		            System.out.println(str.length());
				} catch (NumberFormatException e) {
					System.out.println("Only number as follows allowed: 0 ??? a, b ??? 1,000,000");
				}
	        }
	}

}

Measured memory_bytes: 24388
def main():

    import sys, math
    #from bisect import bisect_left as bl, bisect_right as br, insort
    #from heapq import heapify, heappush, heappop
    from collections import defaultdict as dd, deque
    def data(): return sys.stdin.readline().strip()
    def mdata(): return list(map(int, data().split()))
    def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
    # sys.setrecursionlimit(100000)
    INF = int(1e9)
    mod = int(1e9)+7

    n,k=mdata()
    A=mdata()
    cnt=1
    d=dd(int)
    d1=dd(int)
    d[0]=1
    d1[1]=0
    t=0
    while True:
        if d[A[t]-1]==0:
            cnt+=1
            d[A[t]-1]=cnt
            d1[cnt]=A[t]-1
        else:
            ind1=d[A[t]-1]
            ind2=d[t]
            break
        t=A[t]-1
    if k+1<=ind1:
        print(d1[k+1]+1)
    else:
        k+=1
        k-=ind1
        k=k%(ind2-ind1+1)
        print(d1[(ind1+k)]+1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 151852
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <functional>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
int main(){
    ll n,a,b;
    cin >> n >> a >> b;

    cout << n / (a + b) * a + min(a,n % (a + b)) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <map>
#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 <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;
int mod = 1e9 + 7;

int main()
{
	int N;
	cin >> N;
	vector<int> a(N, 0);
	rep(i, N)
	{
		int tmp; cin >> tmp;
		a[tmp]++;
	}
	int p = 0;
	if (N % 2 == 0)
	{
		rep(i, N)
		{
			if ((i % 2 == 1 && a[i] != 2) || (i % 2 == 0 && a[i] != 0))
			{
				co(0); return 0;
			}
		}
		p = N / 2;
	}
	else
	{
		rep(i, N)
		{
			if ((i == 0 && a[i] != 1)||(i > 0 &&i % 2 == 0 && a[i] != 2) || (i % 2 == 1 && a[i] != 0))
			{
				co(0); return 0;
			}
		}
		p = (N - 1) / 2;
	}
	ll ans = 1;
	rep(i, p)
	{
		ans *= 2;
		ans %= mod;
	}
	co(ans);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  string s, t; cin >> s >> t;
  V<> a(26), b(26);
  int n = s.size();
  for (int i = 0; i < n; i++) a[s[i] - 'a']++;
  for (int i = 0; i < n; i++) b[t[i] - 'a']++;
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  bool same = true;
  for (int i = 0; i < 26; i++) if (a[i] != b[i]) same = false;
  cout << (same ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 916
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<=(b);++i)
#define ROF(i,a,b) for (int i=(a);i>=(b);--i)
typedef long long ll;
inline int read() {
	int x=0,s=1; char ch=getchar();
	while (ch<'0'||ch>'9') { if (ch=='-') s=-1; ch=getchar(); }
	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return s*x;
}

const int MAXN=1000005,MAXM=4000006,INF=2147483647;
int en,u[MAXN],cur[MAXN];//cur为当前弧优化
struct edge{ int v,nt,c; }e[MAXM];
inline void clear(){ en=0; memset(u,-1,sizeof(u)); }
inline void addEdge(int x,int y,int z){//反向边为i^1
	e[en]=(edge){y,u[x],z}; u[x]=en++;
	e[en]=(edge){x,u[y],0}; u[y]=en++;
}
int S,T,nn,rear,head,Q[MAXN],dis[MAXN];
int BFS(){
	FOR(i,1,nn) dis[i]=INF;
	rear=head=0; dis[Q[++rear]=S]=0;
	while (head<rear) {
		int x=Q[++head];
		for (int i=u[x];~i;i=e[i].nt) {
			int j=e[i].v;
			if (e[i].c>0&&dis[j]>dis[x]+1) dis[Q[++rear]=j]=dis[x]+1;
		}
	}
	return dis[T]!=INF;
}
int DFS(int now,int flow) {
	if (now==T) return flow;
	int ans=0;
	for (int& i=cur[now];~i;i=e[i].nt) {
		int j=e[i].v;
		if (e[i].c>0&&dis[j]==dis[now]+1) {
			int k=min(e[i].c,flow); k=DFS(j,k);
			e[i].c-=k; e[i^1].c+=k; ans+=k; flow-=k;
		}
		if (!flow) break;
	}
	return ans;
}
int Dinic() {
	int ans=0;
	while (BFS()) {
		FOR(i,1,nn) cur[i]=u[i];
		ans+=DFS(S,INF);
	}
	return ans;
}
int n,m,q,a[MAXN],b[MAXN];
int main(){
	n=read(); m=read(); clear();
	S=n+m+1,nn=T=S+1;
	FOR(i,1,n)
		FOR(j,1,m) {
			char ch=getchar();
			while (ch!='.'&&ch!='o'&&ch!='S'&&ch!='T') ch=getchar();
			if (ch=='o') addEdge(i,n+j,1),addEdge(n+j,i,1);
			if (ch=='S') addEdge(S,i,n*m+1),addEdge(S,n+j,n*m+1);
			if (ch=='T') addEdge(i,T,n*m+1),addEdge(n+j,T,n*m+1);
		}
	int ans=Dinic();
	if (ans>=n*m) puts("-1");
	else printf("%d\n",ans);
	
	return 0;
}

/*
*/


Measured memory_bytes: 13312
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <utility>
using namespace std;

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

typedef long long ll;

const int kMaxK = 100000;
const int kMaxA = 1000000000;

ll K;
int A[kMaxK];
ll ans1, ans2;

ll G(ll n) {
  REP(i, K) { n = (n/A[i])*A[i]; }
  return n;
}

ll BinSearch1(ll i, ll j) {
  while (i+1 != j) {
    ll k = (i+j)/2;
    if (G(k) >= 2) {
      j = k;
    } else {
      i = k;
    }
  }
  return j;
}

ll BinSearch2(ll i, ll j) {
  while (i+1 != j) {
    ll k = (i+j)/2;
    if (G(k) <= 2) {
      i = k;
    } else {
      j = k;
    }
  }
  return i;
}

int main() {
  cin >> K;
  REP(i, K) { cin >> A[i]; }

  ans1 = BinSearch1(0, 3+K*kMaxA);
  ans2 = BinSearch2(0, 3+K*kMaxA);

  if (ans1 > ans2) {
    cout << -1 << endl;
  } else {
    cout << ans1 << " " << ans2 << endl;
  }
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long double ldb;
typedef long long ll;
const double pi=acos(-1);
double a,b,s;
inline bool check(double x){
	double c=tan(x)*a;
	 if(c<=b){
		double b1=(b-tan(x)*a+b)*a/2.0;
		return b1>=s;
	 }
	 double x1=pi/2-x;
	 double a1=tan(x1)*b;
	 return a1*b/2>=s;
}
int main(){
	double l=0,r=90;
	cin>>a>>b>>s;
	s/=a;
 for(int i=0;i<10000;i++){
		double mid=(l+r)/2;
		if(check(mid*pi/180)) l=mid;
		else r=mid;
	}
	printf("%.12f\n",l);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int> left(vector<int> a,vector<int> l);
vector<int> right(vector<int> a,vector<int> r);
int gcd(int x, int y);
int n;

int main(){
    cin>>n;
    vector<int> a(n);
    vector<int> l(n+1);
    vector<int> r(n+1);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int ans=0;
    l=left(a,l);
    r=right(a,r);
    for(int i=1;i<n-1;i++){
        //cout<<l[i]<<" "<<r[i+1]<<endl;
        ans=max(ans,gcd(l[i-1],r[i+1]));
    }
    ans=max(ans,r[1]);
    ans=max(ans,l[n-2]);
    cout<<ans<<endl;
    return 0;
}
vector<int> left(vector<int> a,vector<int> l){
    l[0]=a[0];
    for(int j=1;j<n;j++){
        l[j]=gcd(l[j-1],a[j]);
    }
    return l;
}
vector<int> right(vector<int> a,vector<int> r){
    r[n]=a[n-1];
    for(int j=n-1;j>=0;j--){
        r[j]=gcd(r[j+1],a[j]);
        //cout<<r[j-1]<<endl;
    }
    return r;
}
int gcd(int x, int y){
    //if(x==0) return y;
    if(y==0) return x;
    else return gcd(y,x%y);
}


Measured memory_bytes: 2176
import Data.Char

main = do
        n <- readLn :: IO Int
        s <- getLine
        putStrLn $ ans n s

ans :: Int -> String -> String
ans n s = map (ans1 n) s
ans1 :: Int -> Char -> Char
ans1 n c
   | n+(ord c) > ord 'Z' = chr $ n+(ord c)-26
   | otherwise = chr $ n+(ord c)


Measured memory_bytes: 1404
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
int main(){
	ll a,b,k; cin>>a>>b>>k;
	ll x=min(a,k);a-=x,k-=x;
	b-=min(b,k);
	cout<<a<<" "<<b<<endl;
}


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

#define 	ll 						long long int
#define 	pb 						push_back
#define 	mp 						make_pair
#define 	fast 					ios_base::sync_with_stdio(false);cin.tie(NULL);
#define 	ff 						first
#define 	ss 						second
#define 	nil 					-10e+9
#define 	initial 				0
#define 	waiting 				1
#define 	visit 					2
#define 	inf  					10e+9
#define 	mx   					200005
#define 	mxx  					1000005
#define 	mod  					1000000007
#define 	pr   					pair<ll,ll>
#define 	pp_queue 			priority_queue<pr,vector<pr>, greater<pr> >
#define 	dp_queue 			priority_queue<int,vector<int>, greater<int> >
#define 	sp_queue 			priority_queue<int>
#define 	fr(i,p,q)			for(int i=p;i<q;++i)
#define 	frr(i,p,q) 		for(int i=p;i<=q;++i)
#define 	mem(a,b) 			memset(a,b,sizeof(a))
#define 	len(a)   			(int)a.size()
#define 	input  				freopen("input.txt", "r", stdin);
#define 	output 				freopen("output.txt", "w", stdout);
#define 	debug(arr,j,n) fr(i,j,n) cout<<arr[i]<<" ";

ll power(ll a,ll b){ll aa=1;while(b){if(b&1){aa=aa*a;aa%=mod;}a=a*a;a%=mod;b/=2;}return aa;}

using namespace std;

vector<int> tree[1000005];
vector<int> ans(1000005,0);
vector<int> temp(1000005,0);


void dfs(int node,int parent,int cnt){
	cnt+=temp[node];
	ans[node]=cnt;

	for(int to:tree[node]){
		if(to==parent) continue;
		dfs(to,node,cnt);
	}
}

int main()
{
  int n,q;
	cin>>n>>q;
	//int ans[n+1];
	//mem(ans,0);

	fr(i,0,n-1){
		int u,v;
		cin>>u>>v;
		tree[u].pb(v);
		tree[v].pb(u);
	}

	fr(i,0,q){
		int node,val;
		cin>>node>>val;
		temp[node]+=val;
		//cout<<temp[node]<<" ";
  }

	dfs(1,1,0);

	fr(i,1,n+1) cout<<ans[i]<<" ";
	cout<<"\n";
}


Measured memory_bytes: 49408
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<ll> a(n);
	REP(i,n) cin>>a[i];
	vector<ll> acm(n);
	acm[0]=a[0];
	FOR(i,1,n) acm[i]=acm[i-1]+a[i];
	ll ans=INF*INF;
	for(ll i=1;i<=n-3;i++) {
		ll b1=-1,b2=-1,c1=-1,c2=-1;
		auto ite=lower_bound(ALL(acm),(acm[i]+1)/2);
		if(ite-acm.begin()!=i) {
			b1=*ite;
			c1=(acm[i]-*ite);
		}
		if(ite!=acm.begin()) {
			ite--;
			b2=*ite;
			c2=(acm[i]-*ite);
		}
		ll tmp=acm[n-1]-acm[i];
		auto ite2=lower_bound(ALL(acm),acm[i]+(tmp+1)/2);
		if(ite2-acm.begin()!=n-1) {
			if(b1!=-1) ans=min(ans,max({b1,c1,(*ite2-acm[i]),(acm[n-1]-*ite2)})-min({b1,c1,(*ite2-acm[i]),(acm[n-1]-*ite2)}));
			if(b2!=-1) ans=min(ans,max({b2,c2,(*ite2-acm[i]),(acm[n-1]-*ite2)})-min({b2,c2,(*ite2-acm[i]),(acm[n-1]-*ite2)}));
		}
		if(ite2-acm.begin()!=i+1) {
			ite2--;
			if(b1!=-1) ans=min(ans,max({b1,c1,(*ite2-acm[i]),(acm[n-1]-*ite2)})-min({b1,c1,(*ite2-acm[i]),(acm[n-1]-*ite2)}));
			if(b2!=-1) ans=min(ans,max({b2,c2,(*ite2-acm[i]),(acm[n-1]-*ite2)})-min({b2,c2,(*ite2-acm[i]),(acm[n-1]-*ite2)}));
		}

	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
ll bpow(ll b, ll p, ll m = 1000000007LL) {
  ll rt = 1;
  for (; p; p >>= 1, b = b * b % m)
    if (p & 1)
      rt = rt * b % m;
  return rt;
}
int main() {
  IOS;
  int n;
  cin >> n;
  cout << (n / 1000 + (n % 1000 != 0)) * 1000 - n << endl;
}

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

#define all(x) (x).begin(),(x).end()

using namespace std;

int main(){
	string s;
	
	cin >> s;
	
	if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3])	cout << "Bad" << endl;
	else	cout << "Good" << endl;
	
	return 0;
}

Measured memory_bytes: 256
s = input().split()
s = map(int, s)
res = []
group1 = [1, 3, 5, 7, 8, 10, 12]
group2 = [4, 6, 9, 11]
group3 = [2]
for i in s:
    if i in group1:
        res.append('group1')
    elif i in group2:
        res.append('group2')
    else:
        res.append('group3')
if len(list(set(res))) == 1:
    print('Yes')
else:
    print('No')


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


int main () {
    string s ;
    cin >> s ;
    bool can = true ;
    rep(i, s.size()){
        if(i%2 == 0){
            if(s[i] != 'R'&& s[i] != 'U' && s[i] != 'D'){
                can = false ;
            }
        }
        else {
            if(s[i] != 'L'&& s[i] != 'U' && s[i] != 'D'){
                can = false ;
            }
        }
    }
    if(can){
        cout << "Yes" << endl; 
    }
    else {
        cout << "No" << endl ;
    }
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int n, d[3003][3003] = {};
string s;
int main() {
    cin >> n >> s;
    for (int i = 1; i <= n; i++) d[1][i] = 1;
    for (int i = 2; i <= n; i++) {
        if (s[i - 2] == '<')
            for (int j = 1; j <= n - i + 1; j++)
                d[i][j] = (d[i][j - 1] + d[i - 1][j]) % 1000000007;
        else
            for (int j = n - i + 1; j; j--)
                d[i][j] = (d[i][j + 1] + d[i - 1][j + 1]) % 1000000007;
    }
    cout << d[n][1] << '\n';
}


Measured memory_bytes: 35200
#include <bits/stdc++.h>
#define pii              pair <int,int>
#define pll              pair <long long,long long>
#define sc               scanf
#define pf               printf
#define Pi               2*acos(0.0)
#define ms(a,b)          memset(a, b, sizeof(a))
#define pb(a)            push_back(a)
#define MP               make_pair
#define db               double
#define ll               long long
#define ull              unsigned long long
#define f                first
#define s                second
#define sqr(x)           (x)*(x)
#define VI               vector <int>
#define DBG              pf("Hi\n")
#define MOD              1000000007
#define SZ(a)            (int)a.size()
#define sf(a)            scanf("%d",&a)
#define sfl(a)           scanf("%lld",&a)
#define sff(a,b)         scanf("%d %d",&a,&b)
#define sffl(a,b)        scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)      scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)     scanf("%lld %lld %lld",&a,&b,&c)
#define loop(i,n)        for(int i=0;i<n;i++)
#define loop1(i,n)       for(int i=1;i<=n;i++)
#define REP(i,a,b)       for(int i=a;i<b;i++)
#define RREP(i,a,b)      for(int i=a;i>=b;i--)
#define intlim           2147483648
#define ull              unsigned long long
#define gcd(a, b)        __gcd(a, b)
#define lcm(a, b)        ((a)*((b)/gcd(a,b)))
#define mk(x1,y1) make_pair(x1, y1)
#define maxl 100000
#define psz 20
using namespace std;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N | (1<<pos);}
//int reset(int N,int pos){return N= N & ~(1<<pos);}
//bool check(int N,int pos){return (bool)(N & (1<<pos));}
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdin);
//ios_base::sync_with_stdio(false);
 //cin.tie(NULL);

struct str{

    int a,b;

};

vector<str>v;

bool compare(str x, str y){

    return x.b < y.b;
}
int main(){

    int n;
    cin>>n;

    while(n--){

        int t1,t2;
        cin>>t1>>t2;

        v.push_back({t1,t2});
    }

    sort(v.begin(),v.end(),compare);

    ll time = 0;

    for(int i=0; i<v.size(); i++){

        time += v[i].a;

        if(time > v[i].b){ cout<<"No"<<endl; return 0; }
    }

    cout<<"Yes"<<endl;



    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main()
{
	IOS;
	int n;
	string s;
	cin >> n >> s;
	int cnt = 0;
	for(auto &it : s)
	{
		if(it == 'B')
			cnt--;
		else
			cnt++;
	}
	if(cnt > 0)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

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

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void setIO(string s = "") {
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9; 
const int N = 6e5+5;                                         
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
 
int rnd (int l, int r) {
	return uniform_int_distribution<int> (l, r)(gen);
}

int t[N*4];
int lim = (1<<19);
void upd (int p, int x) {
	p += lim;
	t[p] = x;
	while(p > 1) {
		t[p>>1] = max(t[p], t[p^1]);
		p >>= 1;
	}
}

int get (int l, int r) {
	l = max(1, l);
	r = min(r, 300001);
	l += lim;
	r += lim+1;
	int res = 0;
	while(l < r) {
		if(l&1) res = max(res, t[l++]);
		if(r&1) res = max(res, t[--r]);
		l /= 2, r /= 2;
	}
	return res;
}

int main () {
	SpeedForce;
	int n, ans = 1, k;
	cin >> n >> k;
	for (int i = 1, x; i <= n; ++i) {
		cin >> x;
		++x;
		int cur = get(x-k, x+k) + 1;
		upd (x, cur);
		ans = max(ans, cur);
	}
	
	cout << ans << '\n';
	
	return Accepted;
}

// B...a


Measured memory_bytes: 6040
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define cOut(i) cout<<i<<endl

int main(){
    int k,s;
    cin>>k>>s;

    int ans=0;
    k++;
    rep(x,0,k){
        rep(y,x,k){
            rep(z,y,k){
                if(x+y+z==s){
                    if(x==y && y==z) ans++;
                    else if(x==y || y==z || z==x) ans+=3;
                    else ans+=6;
                }
            }
        }
    }
    cOut(ans);
}

Measured memory_bytes: 256
/*
×¢Òâ·¶Î§£¡
short·¶Î§£º-32768~32767
unsigned short·¶Î§£º0~65535
int·¶Î§£º-2147483648~2147483647
uint·¶Î§£º0~4294967295
INT·¶Î§£º-9223372036854775808~9223372036854775807
UINT·¶Î§£º0~18446744073709551615
float·¶Î§£º-3.4e38~3.4e38£¬¾«¶È£º6~7Î»
double·¶Î§£º-1.7e308~1.7e308£¬¾«¶È£º15~16Î»
ldouble·¶Î§£º-1.2e4932~1.2e4932£¬¾«¶È£º18~19Î»
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define LL long long
#define pb push_back
#define pob pop_back
#define mp make_pair
#define FILL(a,v) memset((void*)a,v,sizeof(a))
#define FILL0(a) FILL(a,0)
#define FILL1(a) FILL(a,-1)
#define ALL(a) (a).begin(),(a).end()
#define Inf 1e9
#define Mod 1000000007
#define foreach(it,x) for(typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define FOR(i,x) for(int i=0;i<x;i++)
#define RFOR(i,x) for(int i=x-1;i>=0;i--)
#define FFOR(i,a,b) for(int i=a;i<b;i++)
#define FRFOR(i,a,b) for(int i=a-1;i>=b;i--)
#define SZ(a) ((int)(a).size())
#define FI first
#define SE second
#define OVER(a) return puts(a),0
#define fastio ios::sync_with_stdio(0)
#define filei(f) freopen(f,"r",stdin)
#define fileo(f) freopen(f,"w",stdout)
using namespace std;
void avoid(){}
typedef pair<int,int> pii;
typedef unsigned long long UINT;
typedef unsigned int Uint;
typedef long long INT;
typedef pair<INT,INT> PII;
typedef stringstream sst;
typedef istringstream iss;
typedef vector<int> vint;
typedef vector<INT> VINT;
typedef vector<pii> vpii;
typedef vector<PII> VPII;
typedef priority_queue<int> pqi;
typedef priority_queue<INT> PQI;
typedef priority_queue<pii> pqp;
typedef priority_queue<PII> PQP;
typedef priority_queue<int,vint,greater<int> > xqi;
typedef priority_queue<INT,VINT,greater<INT> > XQI;
typedef priority_queue<pii,vpii,greater<pii> > xqp;
typedef priority_queue<PII,VPII,greater<PII> > XQP;

int n,m,a,b;

//Can calculate a^(Mod-2) quickly(O(log a)).
inline INT mitsfun(int di,int zhi)
{
	if(zhi==0)return 1;
	INT num=mitsfun(di,zhi/2);
	num=num*num%Mod;
	if(zhi%2)num=num*di%Mod;
	return num;
}

INT c1[100007];

int main()
{
	scanf("%d%d%d%d",&n,&m,&a,&b);
	INT cdi=n-a-1,num=1;
	for(int i=1;i<m;i++)
	{
		num=num*(i+cdi)%Mod*mitsfun(i,Mod-2)%Mod;
		if(i>=b)c1[i]=num;
	}
	cdi=a-1;
	num=1;
	INT cnt=c1[m-1];
	for(int i=m-2,j=1;i>=b;i--,j++)
	{
		num=num*(j+cdi)%Mod*mitsfun(j,Mod-2)%Mod;
		cnt=(cnt+(num*c1[i]%Mod))%Mod;
	}
	printf("%I64d\n",cnt);
	return 0;
}

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

int main(){
  string w, t;
  int n = 0;

  cin >> w;

  for( int i = 0; i < w.size(); i++){
    w[i] = toupper(w[i]);
  }

  while(1){
    cin >> t;
    if( t == "END_OF_TEXT" ) break;
    for( int i = 0; i < t.size(); i++){
      t[i] = toupper(t[i]);
    }
    if( t == w ) n += 1;
  }

  cout << n << endl;

  return 0;
}

Measured memory_bytes: 3224
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FOR(i, a) for (auto &i : a)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define SUM(x) accumulate(ALL(x), 0LL)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
const int MOD   = (int)(1e9 + 7);
const int INF   = (int)(1e13 + 7);
const double EPS = 1e-14;
const double PI = acos(-1);

int CEIL(int a, int b) { return (a >= 0 ? (a + (b - 1)) / b : (a - (b - 1)) / b); } //ceil() for int
int mod(int a, int b) { return a >= 0 ? a % b : a - (b * CEIL(a, b)); }             //always return positive num
int bpm(int a, int b) {                                                             //return x^y in order(log(y))
  int res = 1;
  for (a %= MOD; b; a = a * a % MOD, b >>= 1)
    if (b & 1) res = res * a % MOD;
  return res;
}

class ARainySeason {
public:
  static void solve(istream &cin, ostream &cout) {
    string S;
    cin>>S;
    if ( S== "RRR"){
      cout<<3<<endl;
    }else if (S == "SSS"){
      cout<<0<<endl;
    }else if (S == "RSR"){
      cout<<1<<endl;
    }else{
      int ans = 0;
      FOR(i, S){
        if (i == 'R'){
          ans++;

        }
      }
      cout<<ans<<endl;
    }

  }
};


signed main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
  ARainySeason solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 3568
n = int(input())
ans_ac = 0
ans_wa = 0
ans_tle = 0
ans_re = 0

for i in range(n):
    s = input()
    if s == 'AC':
        ans_ac += 1
    elif s == 'WA':
        ans_wa += 1
    elif s == 'TLE':
        ans_tle += 1
    else:
        ans_re += 1
        
print('AC x '+str(ans_ac))
print('WA x '+str(ans_wa))
print('TLE x '+str(ans_tle))
print('RE x '+str(ans_re))


Measured memory_bytes: 9148
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    for (auto &&a: { 64, 32, 16, 8, 4, 2, 1 }) {
        if (n >= a) {
            cout << a << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256