akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <string>
 
#ifndef ONLINE_JUDGE
	#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#else
	#define DEBUG(x) do {} while(0);
#endif
 
#define pb push_back
#define mp make_pair
#define ALL(x) (x).begin(), (x).end()
#define PER(i, N) for(int (i) = (N)-1; (i) >= 0; (i)--)
#define REP(i, N) for(int (i) = 0; (i) < (int)(N); (i)++)
 
using namespace std;
typedef long long ll;
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.x >> p.y; return i;}
template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.x << ' ' << p.y; return o;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}
template<typename T> using minheap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using maxheap = priority_queue<T, vector<T>, less<T>>;
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }

int n,m;

void solve(istream& cin, ostream& cout) {
	cin >> n;
	ll ans = 0;
	REP(i, n) {
		if((i+1) % 3 != 0 && (i+1) % 5 != 0) {
			ans += i+1;
		}
	}
	cout << ans <<endl;
}


int main() {
    ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	solve(cin, cout);
	/*
	{
		istringstream instr("2\n2\n14");
		solve(instr, cout);
	}
 */
	return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
int main()
{
  int n;
  cin >> n;
  vi a(n);
  re(i, n) cin >> a[i];

  sort(a.begin(), a.end());

  cout << a[n-1] - a[0] << endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
using namespace std;
int main(void){
	char a[100][101];
	int k,s;
	int n, m;
	int x, y, z;
	int ans;
	for (int i = 0; i < 101; i++){
		for (int j = 0; j < 100; j++)a[j][i] = 0;
	}

	scanf("%d %d",&n,&m);
	for (int i = 0; i < n; i++){
		scanf("%s", a[i]);
	}
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			if (a[i][j] == '.'){
				k = 0;
				for (int p = -1; p < 2; p++){
					for (int q = -1; q < 2; q++){
						x = i + p;
						y = j + q;
						if (x >= 0 && x < n&&y >= 0 && y < m){
							if (a[x][y] == '#')k++;
						}
					}
				}
				a[i][j] = k + 48;
			}
		}
	}


	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++)printf("%c", a[i][j]);
		printf("\n");
	}

	return 0;
}



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

public class Main{

	public static void main(String[] args) throws IOException {
		int N = readInt();
		int arr[] = new int[N+1];
		arr[0] = readInt();
		for(int i = 1; i<=N; i++) arr[i]= readInt();
		Arrays.sort(arr);
		long gcd = arr[1]-arr[0];
		for(int i = 2; i<=N; i++) gcd = gcd(gcd, arr[i]-arr[i-1]);
		println(gcd);
		exit();
	}
	
	static long gcd(long a, long b) {
		return a*b == 0 ? a+b : gcd(b, a%b);
	}

	final private static int BUFFER_SIZE = 1 << 16;
	private static DataInputStream din = new DataInputStream(System.in);
	private static byte[] buffer = new byte[BUFFER_SIZE];
	private static int bufferPointer = 0, bytesRead = 0;
	static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	public static String readLine() throws IOException {
		byte[] buf = new byte[64]; // line length
		int cnt = 0, c;
		while ((c = Read()) != -1) {
			if (c == '\n')
				break;
			buf[cnt++] = (byte) c;
		}
		return new String(buf, 0, cnt);
	}

	public static String read() throws IOException {
		byte[] ret = new byte[1024];
		int idx = 0;
		byte c = Read();
		while (c <= ' ') {
			c = Read();
		}
		do {
			ret[idx++] = c;
			c = Read();
		} while (c != -1 && c != ' ' && c != '\n' && c != '\r');
		return new String(ret, 0, idx);
	}

	public static int readInt() throws IOException {
		int ret = 0;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');

		if (neg)
			return -ret;
		return ret;
	}

	public static long readLong() throws IOException {
		long ret = 0;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');
		if (neg)
			return -ret;
		return ret;
	}

	public static double readDouble() throws IOException {
		double ret = 0, div = 1;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();

		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');

		if (c == '.') {
			while ((c = Read()) >= '0' && c <= '9') {
				ret += (c - '0') / (div *= 10);
			}
		}

		if (neg)
			return -ret;
		return ret;
	}

	private static void fillBuffer() throws IOException {
		bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
		if (bytesRead == -1)
			buffer[0] = -1;
	}

	private static byte Read() throws IOException {
		if (bufferPointer == bytesRead)
			fillBuffer();
		return buffer[bufferPointer++];
	}

	static void print(Object o) {
		pr.print(o);
	}

	static void println(Object o) {
		pr.println(o);
	}

	static void flush() {
		pr.flush();
	}

	static void println() {
		pr.println();
	}

	static void exit() throws IOException {
		din.close();
		pr.close();
		System.exit(0);
	}
}


Measured memory_bytes: 24384
import qualified Data.Vector.Unboxed as V
import Control.Monad
import Data.Maybe
import Data.List
import qualified Data.ByteString.Char8 as BS
readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getIntList = readIntList <$> BS.getLine

main = do
  [n,k] <- getIntList
  p <- V.fromList . map (+(-1)) <$> getIntList
  c <- V.fromList <$> getIntList
  let acc i = tail $ scanl' (+) 0 $ map ((c V.!).(p V.!)) $ takeWhile (/=i) (iterate (p V.!) (p V.! i)) ++ [i] -- O(n)
      ans i = -- O(n)
        if val > 0
          then
            if rem /= 0
              then num * val + maximum (take (fromIntegral rem) list)
              else (num-1) * val + maximum list
          else maximum list
        where list = acc i
              val = last list
              len = fromIntegral $ length list
              num = k `div` len
              rem = k `mod` len
  print $ maximum $ map ans [0..n-1] -- n * O(n) = O(n^2)


Measured memory_bytes: 6048
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

const long long  mod = 1e9 + 7;

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

	vector<int>da(n + 1, true);
	for (int i = 0; i < m; ++i) {
		int a; cin >> a;
		da[a] = false;
	}

	vector<long long int>dp(n + 1);
	dp[0] = 1;
	for (int now = 0; now < n; ++now) {
		for (int next = now + 1; next <= min(n, now + 2); ++next) {
			if (da[next]) {
				dp[next] += dp[now];
				dp[next] %= mod;
			}
		}
	}

	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {

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

    int n = scan.nextInt();

    int[] array = new int[n];

    for (int i = 0; i < n; i++) {
      array[i] = scan.nextInt();
    }

    for (int i = n-1; i > 0; i--) {
      System.out.print(array[i] + " ");    
    }
    
    System.out.println(array[0]);
  }
  
}


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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    string s;
    cin >> s;
    int n = stoi(s);
    int sum = 0;
    for(int i = 0; i < s.size(); ++i)
        sum += s[i] - '0';
    cout << (n % sum == 0 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

static const int N = 100;

int min(int a, int b){

  if(a < b){
    return a;
  }

  else if(a > b){
    return b;
  }

}


int main(){

  int i,j,k,l,v,n,X[N+1],Y[N+1][N+1];
  
  scanf("%d",&n);
  
  for(i=1;i<=n;i++){
    scanf("%d%d",&X[i-1],&X[i]);
  }

  for(i=1;i<=n;i++){
    Y[i][i] = 0;
  }
  
  for(l=2;l<=n;l++){
    for(i=0;i<=n-l+1;i++){
      j = i + l -1;

      Y[i][j] = (1<<21);
      
      for(k=i;k<=j-1;k++){
        Y[i][j] = min(Y[i][j],Y[i][k] + Y[k+1][j] + X[i-1]*X[k]*X[j]);
        v = Y[i][k] + Y[k+1][j] + X[i-1]*X[k]*X[j];
      }
    }
  }

printf("%d\n",Y[1][n]);

  return 0;

}


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

typedef long long ll;

const ll MOD = 1e9 + 7;
const int N = 100 + 5;
const int M = 63244 + 5;

ll dp[N][M];

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a;
  for (int i = 1; i <= n; ) {
    a.emplace_back(n / i);
    i = n / (n / i) + 1;
  }
  int m = a.size();
  sort(a.begin(), a.end());
  for (int i = 0; i < m; ++ i) {
    dp[1][i] = a[i];
  }
  ll ans = 0;
  for (int i = 2; i <= k; ++ i) {
    for (int j = 0; j < m; ++ j) {
      int oj = m - j - 1;
      int t = a[j] - (j == 0 ? 0 : a[j - 1]);
      dp[i][j] = 1ll * t * dp[i - 1][oj] % MOD;
      if (i == k) {
        ans = (ans + dp[i][j]) % MOD;
      }
    }
    for (int j = 1; j < m; ++ j) {
      dp[i][j] = (dp[i][j] + dp[i][j - 1]) % MOD;
    }
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 51324
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
LL N, M, S;
vector<LL> A;
inline LL ceil(LL d, LL n) {return (d+n-1)/n;}
inline bool ok(LL x) {
  if(M < S-x) return false;
  LL s = 0;
  for(auto a: A) s += max(0ll, ceil(a+x+1-N, N+1));
  return s <= x;
}
int main() {
  scanf("%lld", &N);
  M=N*(N-1);
  A.resize(N);
  for(auto& a: A) scanf("%lld", &a), S+=a;
  LL l = -1, h = 1e18;
  while(l+1 < h) {
    LL m = (l+h)>>1;
    if(ok(m)) h = m;
    else      l = m;
  }
  for(auto x=max(0ll,h-N*N); x<=h; ++x) if(ok(x)) {
    printf("%lld\n",x);
    break;
  }
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    ll A[N];
    REP(i, N)
    {
        cin >> A[i];
    }
    
    ll sumAll = 0;
    REP(i, N)
    {
        if (i == 0)
        {
            sumAll += abs(A[i]);
        }
        else
        {
            sumAll += abs(A[i] - A[i - 1]);
        }
    }
    sumAll += abs(A[N - 1]);

    REP(i, N)
    {
        ll sumExceptForI = 0;
        if (i == 0)
        {
            sumExceptForI = sumAll - abs(A[i]) - abs(A[i + 1] - A[i]) + abs(A[i + 1]);
        }
        else if (i == N - 1)
        {
            sumExceptForI = sumAll - abs(A[i] - A[i - 1]) - abs(A[i]) + abs(A[N - 2]);
        }
        else 
        {
            sumExceptForI = sumAll - abs(A[i] - A[i - 1]) - abs(A[i + 1] - A[i]) + abs(A[i + 1] - A[i - 1]);
        }
        cout << sumExceptForI << endl;
    }
}


Measured memory_bytes: 2048
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
ll dp[100100][4] = {0};
int main(void){
    string s;
    cin >> s;
    dp[0][0] = 1;
    for(int i = 0; i < s.size(); i++){
        for(int j = 0; j < 4; j++){
            if(s[i] == '?'){
                if(j != 3){
                    dp[i + 1][j + 1] += dp[i][j];
                }
                dp[i + 1][j] += dp[i][j] * 3;
            } else {
                if(s[i] == 'A' && j == 0){
                    dp[i + 1][j + 1] += dp[i][j];
                } else if(s[i] == 'B' && j == 1){
                    dp[i + 1][j + 1] += dp[i][j];
                } else if(s[i] == 'C' && j == 2){
                    dp[i + 1][j + 1] += dp[i][j];
                }
                dp[i + 1][j] += dp[i][j];
            }
            dp[i + 1][j] %= MOD;
            
        }
    }

    // for(int i = 0; i <= s.size(); i++){
    //     for(int j = 0; j < 4; j++){
    //         cout << i << " " << j << " " << dp[i][j] << endl;
    //     }
    // }
    cout << dp[s.size()][3] << endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define vite ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define tst ll T; cin>>T; while(T--)
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define ll long long int
#define vt vector
#define pb push_back
int main()
{
    clock_t start, end;
    start = clock();
    vite;
    ll n,k;
    cin >> n >> k;
    ll a[n];
    for (ll i = 0; i < n;i++)
        cin >> a[i];
    sort(a, a + n);
    ll t = 0;
    for (ll i = 0; i < k;i++)
        t += a[i];
    cout << t;
    end = clock();
    // double time_taken = double(end - start) / double(CLOCKS_PER_SEC);
    // cout<<fixed << time_taken << setprecision(5);
    return 0;
}

Measured memory_bytes: 3620
n, k = map(int,input().split())
r, s, p = map(int,input().split())
r_s_p_points = [r, s, p]
t = input()
my_hands = []
points = 0
r_s_p = [0, 1, 2]
t_num_list = []
for i in range(n):
    if t[i] == "r":
        t_num_list.append(0)
    elif t[i] == "s":
        t_num_list.append(1)
    else:
        t_num_list.append(2)

for i in range(k):
    if t_num_list[i] == 0:
        my_hands.append(2)
        points += p
    elif t_num_list[i] == 1:
        my_hands.append(0)
        points += r
    else:
        my_hands.append(1)
        points += s

for i in range(k, n):
    if r_s_p[(t_num_list[i] - 1) % 3] != my_hands[i - k]:
        my_hands.append(r_s_p[(t_num_list[i] - 1) % 3])
        points += r_s_p_points[r_s_p[(t_num_list[i] - 1) % 3]]
    else:
        if i + k <= n-1:
            for j in range(3):
                if j == r_s_p[(t_num_list[i] - 1) % 3]:
                    continue
                elif j == r_s_p[(t_num_list[i + k] - 1) % 3]:
                    continue
                else:
                    my_hands.append(j)
                    break
        else:
            my_hands.append(0)

print(points)


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}

const ll MOD = 1e9 + 7;

int main2() {
  int N = nextInt();
  string s; cin >> s;
  N = s.size();
  vector<int> B(N);
  REP(i, N) B[i] = s[i] == 'W' ? 1 : 0;
  string t;
  ll ans = 1;
  ll open = 0;
  for (int i = 0; i < N; i++) {
    if ((B[i] + open) % 2 == 0) {
      t += "(";
      open++;
    } else {
      t += ")";
      if (open <= 0) ans = 0;
      ans = (ans * open) % MOD;
      open--;
    }
  }
  // cout << t << endl;
  if (open != 0) ans = 0;

  REP(i, N/2) ans = (ans * (1+i)) % MOD;
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 1544
import collections
MOD = 10 ** 9 + 7
def main():
    N = int(input())
    S = input()

    cc = collections.Counter(S)
    output = 1
    for k in cc.keys():
        output *= (cc[k] + 1)
        output %= MOD
    print(output-1)
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <cmath>
#include <limits.h>
#include <utility>
#include <map>
#include <algorithm>
#include <set>
using namespace std;
using P = pair<int,int>;
using ll = long long;
constexpr int MOD=1000000007;
constexpr int MAX=510000;
//2数の最大公約数,O(log max(a,b))
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
//2数の最小公倍数,O(log max(a,b))
long long lcm(long long i, long long j) { return i * (j / gcd(i, j)); }

int main(){
    int x;
    cin>>x;
    cout<<lcm(x,360)/x<<endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    IOS
    int n,q; cin >> n >> q;

    vector<int> v(n+1);
    vector<vector<int>> r(n+1,vector<int>());

    REP(i,n-1) {
        int a,b; cin >> a >>b;
        r[a].emplace_back(b);
        r[b].emplace_back(a);
    }
    REP(i,q) {
        int p,x; cin >> p >> x;
        v[p] += x; 
    }

    vector<int> vb = {1};
    vector<bool> visit(n+1,false);

    while(vb.size() != 0) {
        vector<int> tmp;
        for(auto i : vb) {
            for(auto y : r[i]) {
                if (!visit[y]) {
                    tmp.emplace_back(y);
                    v[y] += v[i];
                }
            }
            visit[i] = true;
        }
        vb = tmp;
    }

    FOR(i,1,n+1) cout << v[i] << " ";

    
    return 0;
}

Measured memory_bytes: 15716
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int M = scanner.nextInt();
		int[] Hs = new int[N];
		for(int i = 0; i < N; i++) Hs[i] = scanner.nextInt();
		boolean[] Gs = new boolean[N];
		for(int i = 0; i < N; i++) Gs[i] = true;
		for(int i = 0; i < M; i++) {
			int A = scanner.nextInt() - 1;
			int B = scanner.nextInt() - 1;
			if(Hs[A] == Hs[B]) {
				Gs[B] = Gs[A] = false;
			}
			else if(Hs[A] > Hs[B]) {
				Gs[B] = false;
			} else {
				Gs[A] = false;
			}
		}
		int count = 0;
		for(int i= 0; i < N; i++) {
			if(Gs[i]) count++;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 51508
fun main(args: Array<String>) {

    val n = readLine()!!.toInt()

    val a = readLine()!!.split(" ").map { it.toInt() }

    val aPair = a.mapIndexed { index, i -> Pair(index+1, i) }.sortedBy { it.second }

    aPair.forEach{
        print(it.first)
        print(" ")
    }
}

Measured memory_bytes: 85128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<bitset>
#include<set>
#define N (110)
#define P (1000000007)
#define M ()
#define inf (0x7f7f7f7f)
#define rg register int
#define Label puts("NAIVE")
#define spa print(' ')
#define ent print('\n')
#define rand() (((rand())<<(15))^(rand()))
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
typedef long double ld;
typedef long long LL;
typedef unsigned long long ull;
using namespace std;
namespace fastIO1{
	inline char read(){
		static const int IN_LEN=1000000;
		static char buf[IN_LEN],*s,*t;
		return (s==t?t=(s=buf)+fread(buf,1,IN_LEN,stdin),(s==t?-1:*s++):*s++);
	}
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=read();!isdigit(c);c=read()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=read())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
	inline char readc(char &c){
		for(c=read();!isalpha(c)&&!isdigit(c);c=read())
		if(c==-1)return 0;
	}
	const int OUT_LEN = 10000000;
	char obuf[OUT_LEN],*ooh=obuf;
	inline void print(char c){
		if(ooh==obuf+OUT_LEN)fwrite(obuf,1,OUT_LEN,stdout),ooh=obuf;
		*ooh++=c;
	}
	template<class T>
	inline void print(T x){
		static int buf[30],cnt;
		if(x==0)print('0');
		else{
			if(x<0)print('-'),x=-x;
			for(cnt=0;x;x/=10)buf[++cnt]=x%10+48;
			while(cnt)print((char)buf[cnt--]);
		}
	}
	inline void flush(){fwrite(obuf,1,ooh-obuf,stdout);}
}
namespace fastIO2{
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=getchar();!isdigit(c);c=getchar()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=getchar())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
}
using namespace fastIO1;
int n,m,h[N],oth=1;
typedef pair<int,int> PII;
int ksm(int a,int p){
	int res=1;
	while(p){
		if(p&1)res=1ll*res*a%P;
		a=1ll*a*a%P,p>>=1; 
	}
	return res;
}
PII solve(int L,int R,int lim){
	//if(L>R)return;
	//cout<<L<<" "<<R<<endl;
	int mn=inf,cnt=0; PII cur;
	for(int i=L;i<=R;i++)if(h[i]<mn)mn=h[i],cnt=1;else if(h[i]==mn)cnt++;
	if(cnt==R-L+1){
		cur.first=(1ll*ksm(2,R-L+1)+P-2)%P;
		cur.second=ksm(2,mn-lim-1);
		return cur;
	}
	int l=R-L+1,s0=1,s1=1,lst=0;
	for(int i=L;i<=R+1;i++)
	if(!lst&&h[i]>mn)lst=i;
	else if(lst&&(h[i]<=mn||i>R)){
		l-=i-lst;
		PII ans=solve(lst,i-1,mn);
		s0=1ll*s0*(ans.first+4ll*ans.second%P)%P;
		s1=2ll*s1*ans.second%P; lst=0;
	}
	cur.first=1ll*(s0-s1+P)*ksm(2,l)%P;
	cur.first=(cur.first+1ll*s1*(ksm(2,l)+P-2)%P)%P;
	cur.second=1ll*s1*ksm(2,mn-lim-1)%P;
	return cur;
}
int main(){
	read(n);
	for(int i=1;i<=n;i++)read(h[i]);
	if(n==1)printf("%d\n",ksm(2,h[1])),exit(0);
	for(int i=1;i<=n;i++)
	if(h[i]>h[i+1]&&h[i]>h[i-1]){
		oth=1ll*oth*ksm(2,h[i]-max(h[i+1],h[i-1]))%P;
		h[i]=max(h[i-1],h[i+1]);
	}
	PII ans=solve(1,n,0);
	printf("%lld\n",1ll*oth*(0ll+ans.first+ans.second+ans.second)%P);
}

Measured memory_bytes: 2304
inputs = open(0).readlines()
n = int(inputs[0])
uvw = [list(map(int, uvw.split())) for uvw in inputs[1:]]

def dfs(root, option):
    nodes, stack = {}, [(root, 0)]
    while stack:
        current_node, color = stack.pop()
        if current_node in nodes:
            continue
        nodes[current_node] = color
        for n, w in get_next_nodes(current_node):
            if n not in nodes:
                stack.append((n, (color + w) % 2))
    return nodes

def get_next_nodes(node):
    return lst[node].items()

lst = [{} for _ in range(n)]
for u, v, w in uvw:
    lst[u-1][v-1] = lst[v-1][u-1] = w

dct = dfs(0, get_next_nodes)
for i in range(max(dct)+1):
    print(dct[i])

Measured memory_bytes: 85108
def convert(st):
    d = {}
    lst = []
    for ch in st:
        if ch not in d:
            d[ch] = len(d)
        lst.append(d[ch])
    return lst


S = input()
T = input()
Sl = convert(S)
Tl = convert(T)
print('Yes' if Sl == Tl else 'No')

Measured memory_bytes: 6832
#include <cstdio>
#include <cmath>
#include <cstring>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <set>
#include <functional>
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;
int main() {
	int N;
	scanf("%d",&N);
	for(int i=0;i<N;i++) {
		int K,P;
		scanf("%d %d",&K,&P);
		printf("%d\n",K%P==0?P:(K%P));
	}
}

Measured memory_bytes: 1192
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

ll MOD = 1000000007;

int N, A[15], X[15][15], Y[15][15];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        for (int j = 0; j < A[i]; ++j)
            cin >> X[i][j] >> Y[i][j];
    }

    int ans = 0;
    for (int b = 0; b < (1 << N); ++b) {
        int h[15];
        for (int i = 0; i < N; ++i) h[i] = ((b >> i) & 1);

        bool ok = true;
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < A[i]; ++j) {
                if (h[i] == 1) {
                    if (Y[i][j] != h[X[i][j]-1]) ok = false;
                }
            }
        }

        if (ok) {
            int num = 0;
            for (int i = 0; i < N; ++i) num += h[i];
            ans = max(ans, num);
        }
    }
    cout << ans << endl;

    return 0;
}



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

int main() {
	int n,k;
	cin >> n >> k;
	vector<int> p(n);
	for(int i=0;i<n;i++)
	{
		cin >> p.at(i);
	}
	sort(p.begin(),p.end());
	int a=0;
	for(int i=0;i<k;i++)
	{
		a+=p.at(i);
	}
	cout << a << endl;
	return 0;
}


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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}

char s;

int main(){
  REP(i,5){
    scanf("%c",&s);
    printf("%c",s);
  }
  scanf("%c",&s);
  cout << ' ';
  REP(i,7){
    scanf("%c",&s);
    printf("%c",s);
  }
  scanf("%c",&s);
  cout << ' ';
  REP(i,5){
    scanf("%c",&s);
    printf("%c",s);
  }
  cout << endl;
}


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

int main(){
  int D;
  cin >> D;
  if(D == 22){
    cout << "Christmas Eve Eve Eve" << endl;
  }else if(D == 23){
    cout << "Christmas Eve Eve" << endl;
  }else if(D == 24){
    cout << "Christmas Eve" << endl;
  }else if(D == 25){
    cout << "Christmas" << endl;
  }
}

Measured memory_bytes: 256
S=input()
if S=="SUN":
    print("7")
elif S=="MON":
    print("6")
elif S=="TUE":
    print("5")
elif S=="WED":
    print("4")
elif S=="THU":
    print("3")
elif S=="FRI":
    print("2")
elif S=="SAT":
    print("1")


Measured memory_bytes: 2940
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int inf = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % inf;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), inf - 2, inf) % inf * mod_pow(kai(y), inf - 2, inf) % inf;
}

signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << (c / a) * b << endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;

ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

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




int main() 
{
  ll N; cin>>N;
  vector<ll> x(N+1);
  rep(i,N+1)
  {
    cin>>x.at(i);
  }
  sort(x.begin(),x.end());
  vector<ll> sa(N);
  rep(i,N)
  {
    sa.at(i)=x.at(i+1)-x.at(i);
  }
  ll ans;
  rep(i,N)
  {
    if(i==0) {ans=sa.at(0); continue;}
    ans=gcd(ans,sa.at(i));
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template <class T>
bool chmax(T &a, const T &b) {if (a < b){ a = b; return 1;} return 0;}
template <class T>
bool chmin(T &a, const T &b) {if (a > b){ a = b; return 1;}return 0;}
template <class T>
void printv(vector<T> v) {for (T t : v) {cout << t << " ";}cout << '\n';}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#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 ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" <<endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    cout << pow(n,3) << endl;

    return 0;
}


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    string s;
    cin >> s;
    ll n = s.size();

    ll cnt = 0, ret = 0;
    REP(i, n) {
        if(s[i]=='A') cnt++;
        else if(s[i]=='B' && i+1<n && s[i+1]=='C') {
            ret += cnt;
            ++i;
        } else {
            cnt = 0;
        }
    }
    cout << ret << endl;

    return 0;
}


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

int main() {
  int n, a;
  string s = "No";
  cin >> n >> a;
  n = n - 500 * (n / 500);
  if (n - a <= 0) {
    s = "Yes";
  }
  cout << s << endl;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
  var N int
  fmt.Scanf("%d\n", &N)
  A := make([]int, N)
  for i := 0; i < N; i++ {
    fmt.Scanf("%d", &A[i])
  }
  
  B := make([]int, N)
  B[N-1] = 0
  for i := N-2; i >= 0; i-- {
    B[i] = (B[i+1] + A[i+1]) % (1e9+7)
  }
  
  var ret int = 0
  for i := 0; i < N; i++ {
    ret = (ret + A[i] * B[i]) % (1e9+7)
  }
  fmt.Println(ret)
}

Measured memory_bytes: 8112
void main()
{
    long n, c;
    rdVals(n, c);

    long lim = 2 * 10L^^5 + 1;
    long[][] list = new long[][](c, lim);
    foreach (i; 0 .. n)
    {
        long s, t, d;
        rdVals(s, t, d);
        --d;
        ++list[d][(s<<1)-1], --list[d][t<<1];
    }

    long[] cnt = new long[lim];
    foreach (i; 0 .. c)
    {
        foreach (j; 1 .. lim)
        {
            list[i][j] += list[i][j-1];
            if (list[i][j]) ++cnt[j];
        }
    }

    cnt.reduce!max.writeln;
}

enum long mod = 10L^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 53756
using CompLib.Util;
using System;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int r = sc.NextInt();
        int g = sc.NextInt();

        Console.WriteLine(g * 2 - r);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;
    class Scanner
    {
        private int _index;
        private string[] _line;
        const char separator = ' ';

        public Scanner()
        {
            _index = 0;
            _line = new string[0];
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(separator);
                _index = 0;
            }
            return _line[_index++];
        }
        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(separator);
            _index = _line.Length;
            return _line;
        }
        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
    }
}

Measured memory_bytes: 11092
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#include <cmath>
#define WMAX 10000
#define HMAX 10000

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef long long ll;
typedef pair<int ,int > P;

struct edge{
  int to,cost;
};

int A,B,C,N,W,H,ans,dp[HMAX][WMAX];
string S;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};

void solve(){
	N = B*10 + C;
	if(N % 4)
		cout << "NO\n";
	else
		cout << "YES\n";
}

void debug(){

}

void answer(){
	cout << ans << "\n";
}

int main(){
	cin >> A >> B >> C;
	solve();
	#ifdef DEBUG
	debug();
	#endif
	// answer();

	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(_) for _ in input().split()]

class BIT:
    # index 1~
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

def sub_problem(x):
    S = [0] * (N + 1)
    for i in range(N):
        S[i + 1] = S[i] + 1 if A[i] >= x else S[i] - 1

    geta = abs(min(S)) + 1
    for i in range(N + 1):
        S[i] += geta

    forward = 0
    bit = BIT(max(S))
    for s in S:
        forward += bit.sum(s)
        bit.add(s, 1)

    return forward >= (M + 1) // 2

M = N * (N + 1) // 2  # (N+1)C2
sorted_A = sorted(A)

inf = 0
sup = N
while sup - inf > 1:
    mid = (sup + inf) // 2
    x = sorted_A[mid]

    if sub_problem(x):
        inf = mid
    else:
        sup = mid

print(sorted_A[inf])


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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[],int n){
    for(int i=0;i<n;i++){
    cout<<a[i]<<" ";
    }
    cout<<endl;
}

int main() {
    int i,n,m,k,c=0,sum=0;
    c_p_c();
    // cout<<c<<endl;
    string s;
    c=0;
    m=INT_MIN;
    cin>>s;
    for (int i = 0; i <=s.size(); ++i)
    {
    	if(s[i]=='R')
    		c++;
    	else{
    		// watch(c);
    		m=max(m,c);
    		c=0;
    	}
    }
    cout<<m<<endl;
    return 0;
}



Measured memory_bytes: 3476
use std::io::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
 
fn read_spc<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    multiple_gift();
}

fn multiple_gift() {
    let xy: Vec<usize> = read_spc();
    let mut x = xy[0];
    let y = xy[1];
    let mut m = 0;
    while x <= y {
        x = x * 2;
        m += 1;
    }
    println!("{}", m);
}

Measured memory_bytes: 4352
import java.util.*;

public class Main{
	public static void main(String[] args) {

		Scanner keyboard = new Scanner(System.in);

		int N = keyboard.nextInt();
		
		if(N%10 == 3) {
			System.out.println("bon");
		}else if(N%10 == 0 ||N%10 == 1 ||N%10 == 6 ||N%10 == 8) {
			System.out.println("pon");
		}else {
			System.out.println("hon");
		}
		
		keyboard.close();
	}
}

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

int main() {
  ll H, W, M;
  cin >> H >> W >> M;

  vector<ll> h(M), w(M);
  vector<ll> y(H + 10), x(W + 10);
  for(ll i = 0; i < M; i++) {
    cin >> h[i] >> w[i];
    h[i]--; w[i]--;
    y[h[i]]++;
    x[w[i]]++;
  }

  vector<pair<ll, int>> bom;
  map<pair<ll, int>, int> mp;
  for(int i = 0; i < M; i++) {
    bom.push_back(make_pair(h[i], w[i]));
    mp[make_pair(h[i], w[i])] = 1;
    
  }
  ll y_max, x_max;
  y_max = 0;
  x_max = 0;

  for(int i = 0; i < H; i++) {
    if(y_max < y[i]) y_max = y[i];
  }
  vector<ll> y_a, x_a;
  for(int i = 0; i < H; i++) {
    if(y_max == y[i]) y_a.push_back(i);
  }

  for(int i = 0; i < W; i++) {
    if(x_max < x[i]) x_max = x[i];
  }
  for(int i = 0; i < W; i++) {
    if(x_max == x[i]) x_a.push_back(i);
  }

  for(ll i = 0; i < y_a.size(); i++) {
    for(ll j = 0; j < x_a.size(); j++) {
      if(mp.count(make_pair(y_a[i],x_a[j])) == 0) { cout << x_max + y_max; return 0; }
      //if(j == x_a.size() - 1) { cout << x_max + y_max - 1; return 0; }  
    }
  }

  cout << x_max + y_max - 1;
  
  return 0;
}

Measured memory_bytes: 44880
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

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

#define MP make_pair
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N, M;
	cin >> N >> M;

	vector<int> H(N);
	REP(i, N) cin >> H[i];

	vector<int> good(N, 1);
	REP(i, M){
		int a, b;
		cin >> a >> b;
		a--; b--;
		if(H[a] < H[b]) good[a] = 0;
		if(H[b] < H[a]) good[b] = 0;
		if(H[a] == H[b]){
			good[a] = 0;
			good[b] = 0;
		}
	}

	int ret = 0;
	REP(i, N) ret += good[i];

	cout << ret << endl;


	return 0;
}


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

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  int n;
  cin>>n;
  ll a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  ll money=1000,stock=0;
  ll sa[n-1];
  for(int i=0;i<n-1;i++){
    sa[i]=a[i+1]-a[i];
  }
  for(int i=0;i<n-1;i++){
    if(sa[i]==0) continue;
    if(sa[i]<0) {
      money+=stock*a[i];
      stock=0;
    }
    if(sa[i]>0){
      ll temp=money;
      money=temp%a[i];
      stock+=temp/a[i];
    }
  }
  money+=stock*a[n-1];
  cout<<money<<endl;
  return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>

int main(){
  int W,H,N;
  scanf("%d %d %d",&W,&H,&N);

  int x[N],y[N],a[N];
  for(int i=0; i<N; i++){
    scanf("%d %d %d",&x[i],&y[i],&a[i]);
  }

  int color[W][H];
  for(int i=0; i<W; i++){
    for(int j=0; j<H; j++){
      color[i][j] = 0;
    }
  }

  for(int i=0; i<N; i++){
    switch(a[i]){
    case 1:
      for(int j=0; j<x[i]; j++){
	for(int k=0; k<H; k++){
	  color[j][k] = 1;
	}
      }
      break;
      
    case 2:
      for(int j=x[i]; j<W; j++){
	for(int k=0; k<H; k++){
          color[j][k] = 1;
	}
      }
      break;

    case 3:
      for(int j=0; j<W; j++){
	for(int k=0; k<y[i]; k++){
          color[j][k] = 1;
	}
      }
      break;

    default:
      for(int j=0; j<W; j++){
	for(int k=y[i]; k<H; k++){
          color[j][k] = 1;
	}
      }
      break;
    }

    /*for(int j=0; j<H; j++){
      for(int i=0; i<W; i++){
	printf("%d ",color[i][j]);
      }
      printf("\n");
    }
    printf("\n");*/

  }

  int count = 0;
  for(int i=0; i<W; i++){
    for(int j=0; j<H; j++){
      if(!color[i][j]){count++;}
    }
  }
  printf("%d\n",count);

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int a[50];

int main(){
  int n,i;
  scanf("%d",&n);
  a[0]=a[1]=1;
  for(i=2;i<=n;i++)a[i]=a[i-1]+a[i-2];
  printf("%d\n",a[n]);

  return 0;
}



Measured memory_bytes: 2056