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

int main() {
  string a, b, c; cin >> a >> b >> c;
  transform(a.begin(), a.end(), a.begin(), ::toupper);
  transform(b.begin(), b.end(), b.begin(), ::toupper);
  transform(c.begin(), c.end(), c.begin(), ::toupper);
  cout << a[0] << b[0] << c[0];
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn parse_time(s: &str) -> usize {
    let mut ret = 0;
    for t in s.split(":") {
        let n: usize = t.parse().unwrap();
        ret = ret * 60 + n;
    }
    ret
}

const MAX: usize = 24 * 60 * 60;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    loop {
        let n: usize = sc.get();
        if n == 0 {
            break;
        }
        let mut cum = vec![0i64; MAX+2];
        for _ in 0..n {
            let s: String = sc.get();
            let e: String = sc.get();
            let s = parse_time(&s);
            let e = parse_time(&e);
            cum[s] += 1;
            cum[e] -= 1;
        }
        for i in 0..MAX {
            cum[i+1] += cum[i];
        }
        if let Some(ans) = cum.into_iter().max() {
            println!("{}", ans);
        }
    }
}



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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

// clang-format off
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int a;
    cin >> a;
    string s;
    cin >> s;
    print(a >= 3200 ? s : "red");

    return 0;
}


Measured memory_bytes: 256
n = int(input())
arm = []
for i in range(n):
    x , l = map(int,input().split())
    arm.append([x,l])
arm.sort()
dp = [[0,0] for i in range(n)]
dp[0][1] = arm[0][0] + arm[0][1]
for i in range(1,n):
    if dp[i-1][1] <= arm[i][0] -arm[i][1]:
        dp[i][0] = dp[i-1][0]
        dp[i][1] = arm[i][0] + arm[i][1]
    else:
        dp[i][0] = dp[i-1][0] + 1
        dp[i][1] = min(arm[i][0] + arm[i][1],dp[i-1][1])
        
print(n-dp[n-1][0])

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

using namespace std;

typedef long long ll;

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

	int n;
	cin >> n;

	vector<string> s(n);
	vector<int> t(n);
	rep(i, n) cin >> s[i] >> t[i];

	string x;
	cin >> x;

	bool slept = false;
	int ans = 0;
	rep(i, n){
		if(slept) ans += t[i];
		if(s[i] == x) slept = true;
	}
	
	cout << ans << endl;
}


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

int main(){
	int n,r;
	cin>>n;
	cin>>r;
	int min=r,rx=0x1<<31;
	for(int i=1;i<n;i++){
		cin>>r;
		if(rx<r-min){
			rx=r-min;
		}
		if(min>r){
			min=r;
		}
	}
	cout<<rx<<endl;
	return 0;
}


Measured memory_bytes: 3116
N=int(input())
h=list(map(int,input().split()))
H=[0]*N#花の高さ
c=0#水やり回数
while H!=h:
    l=0
    r=N
    for i in range(N):
        if H[i]!=h[i]:
            l=i
            break
    for i in range(N):
        if H[i]==h[i]:
            r=i
            if r>l:
                break
            else:
                r=N
    for i in range(l,r):
        H[i]+=1
    c+=1
print(c)

Measured memory_bytes: 3064
from functools import reduce
import math

#def gcd(*numbers):
#    return reduce(math.gcd, numbers)

a = int(input())
result = 0

for i in range(1, a+1):
  for j in range(1, a+1):
    for k in range(1, a+1):
      result += math.gcd(math.gcd(i, j),k)
      
print(result)


Measured memory_bytes: 74360
n = int(input())
a,b = map(int,input().split())
p = list(map(int,input().split()))
ans = [0]*3

for i in range(n):
    if p[i] <= a:
        ans[0] += 1
    elif p[i] <= b:
        ans[1] += 1
    else:
        ans[2] += 1

print(min(ans[0],ans[1],ans[2]))

Measured memory_bytes: 9056
#include<iostream>
#include<algorithm>
using namespace std;
int map[2000][2000],dp[2000][2000];
int isprime[200];
bool prime[1000001];
bool square;
void issquare(int n){
	square=false;
	for(int i=2;i*i<=n;i++)if(n==i*i)square=true;
	return;
}
int main(){
	for(int i=0;i<=1000000;i++)prime[i]=true;
	prime[1]=false;
	int pcnt=0;
	for(int i=2;i<1000;i++){
		bool ok=true;
		for(int j=0;j<pcnt;j++)if(i%isprime[j]==0)ok=false;
		if(ok){
			for(int j=i*i;j<=1000000;j+=i)prime[j]=false;
			isprime[pcnt]=i,pcnt++;
		}
	}
	for(int i=0;i<2000;i++)for(int j=0;j<2000;j++){map[i][j]=-1,dp[i][j]=-10000;}
	int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
	int x=1000,y=1000,s=0,t=1,r=1;
	map[999][999]=1;
	for(int k=1;k<=1000000;k++){
		map[y][x]=k;
		y+=dy[r],x+=dx[r];
		issquare(k+1);
		if(square)t++;
		if(s==t){r=(r+1)%4;s=0;}
		s++;
	}//prepara
	int n,m;
	while(true){
		cin>>m>>n;
		if(n==0&&m==0)break;
		for(int i=0;i<2000;i++)for(int j=0;j<2000;j++)dp[i][j]=-10000;
		int x=0,y=0;
		bool end=false;
		while(true){
			while(true){
				if(map[y][x]==n){end=true;break;}
				x++;if(x==2000)break;
			}if(end)break;y++;
		}
		int ans=0,set=0;
		dp[y][x]=0;
		for(int i=1;i<2000;i++){
			for(int j=1;j<1999;j++){
				if(map[i][j]>0&&map[i][j]<=m){
					for(int k=j-1;k<=j+1;k++)if(map[i-1][k]<=m)dp[i][j]=max(dp[i][j],dp[i-1][k]);
					dp[i][j]+=prime[map[i][j]];
					if(ans<dp[i][j])ans=dp[i][j],set=map[i][j];
					if(ans==dp[i][j]&&prime[map[i][j]]==true&&set<map[i][j])set=map[i][j];
				}
			}
		}
		cout<<ans<<" "<<set<<endl;
	}
	return 0;
}

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

const int MAXN = 1e5 + 7;
const int MAXM = 1e2 + 7;
int B[MAXM];
int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n - 1; i++) scanf("%d", &B[i]);
    B[n - 1] = MAXN;
    LL ans = 0;
    ans += B[0];

    // B_i >= max(A_i, A_{i+1})
    // 0 0 10
    // B_1(1) >= max(A_1, A_2)
    // B_2(153) >= max(A_2, A_3)
    // B_3(10) >= max(A_3, A_4)
    // A_i = min(B_{i-1}, B_i)

    for (int i = 1; i < n; i++) {
        ans += min(B[i - 1], B[i]);
    }
    printf("%lld\n", ans);
}

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

using namespace std;

int main() {
    int N,D; cin>>N>>D;
    int Xij[N][D];
    for (int i=0;i<N;i++) {
        for (int j=0;j<D;j++) {
            int x; cin>>x;
            Xij[i][j] = x;
        }
    }

    int cnt=0;
    for (int i=0;i<N;i++) {
        for (int ii=i+1;ii<N;ii++) {
            double d=0.0;
            for (int j=0;j<D;j++) {
                d += pow(Xij[i][j] - Xij[ii][j],2);
            }
            d = sqrt(d);
            //cout << d << endl;
            if (d-(int)d==0.0) {
                cnt++;
            }
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;

ll pwr(ll base, ll p, ll mod = MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}


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



char str1[100005], str2[100005];
int n1, n2, sparse1[20][100005], sparse2[20][100005];


int combine(int a, int b){
    if(a == -1) return b;
    if(b == -1) return a;
    if(a == b)  return 1-a;
    return -1;
}


int query1(int l, int r){
    int ans = -1;
    for(int i=19;i>=0;i--)
        if(l+(1<<i)-1 <= r){
            ans = combine(ans, sparse1[i][l]);
            l += (1<<i);
        }
    return ans;
}

int query2(int l, int r){
    int ans = -1;
    for(int i=19;i>=0;i--)
        if(l+(1<<i)-1 <= r){
            ans = combine(ans, sparse2[i][l]);
            l += (1<<i);
        }
    return ans;
}


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

    cin>>(str1+1)>>(str2+1);
    n1 = strlen(str1+1);
    n2 = strlen(str2+1);

    memset(sparse1, -1, sizeof(sparse1));
    memset(sparse2, -1, sizeof(sparse2));
    for(int i=1;i<=n1;i++)
        sparse1[0][i] = str1[i]-'A';
    for(int j=1;j<20;j++)
        for(int i=1;i+(1<<j)-1<=n1;i++)
            sparse1[j][i] = combine(sparse1[j-1][i], sparse1[j-1][i+(1<<(j-1))]);

    for(int i=1;i<=n2;i++)
        sparse2[0][i] = str2[i]-'A';
    for(int j=1;j<20;j++)
        for(int i=1;i+(1<<j)-1<=n2;i++){
// if(i == 3 && j == 1)    cout<<"fuck this "<<sparse2[j-1][i]<<" "<<sparse2[j-1][i+(1<<(j-1))]<<endl;
            sparse2[j][i] = combine(sparse2[j-1][i], sparse2[j-1][i+(1<<(j-1))]);
        }

// cout<<"sparse1:\n";
// for(int i=1;i<=n1;i++){
//     cout<<i<<": ";for(int j=0;i+(1<<j)-1<=n1;j++)   cout<<sparse1[j][i]<<" ";cout<<endl;
// }cout<<endl;
// cout<<"sparse2:\n";
// for(int i=1;i<=n2;i++){
//     cout<<i<<": ";for(int j=0;i+(1<<j)-1<=n2;j++)   cout<<sparse2[j][i]<<" ";cout<<endl;
// }cout<<endl;

    int q;
    cin>>q;
// q=1;
    while(q--){

        int l1, r1, l2, r2;
        cin>>l1>>r1>>l2>>r2;

// cout<<query1(l1, r1)<<" "<<query2(l2, r2)<<endl;

        if(query1(l1, r1) == query2(l2, r2))    cout<<"YES"<<endl;
        else    cout<<"NO"<<endl;
    }
    return 0;
}
 









Measured memory_bytes: 16384
//Abhinav ---IIIT_A
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define f(i,x,n) for(int i=x;i<(int)n;++i)
#define vpii vector<pair<int,int>>
#define vi vector<int>
#define mpii map<pair<int,int>,int>
#define mpivpii map<int,vector<pair<int,int>>>
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define mpi map<int,int>
#define vvi vector<vector<int>>
#define vvvi vector<vvi>
#define my vector<pii>
ld pie=3.141592653589;
int mod=1e9+7;


bool Compare(pii a, pii b)
{
	return a.ff > b.ff;
}
priority_queue<pii, vector<pii>, function<bool(pii, pii)>> pq(Compare);

void solve(){
	int n; cin>>n;
	int a[n]; f(i,0,n) cin>>a[i];
	int sum=a[n-1];
	int ret=0;
	for(int i=n-2;i>=0;--i){
		ret+=a[i]*sum;
		ret%=mod;
		sum+=a[i]; sum%=mod;
	}
	cout<<ret;
}

int32_t main(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  int t=1; //cin>>t;
  while(t--) solve();
  return 0;
}
// check for overflows dummy !!!

Measured memory_bytes: 5124
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    }    

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
  int main(){
      lint n,l;
      cin>>n>>l;
      lint a[n];
      rep(i,n)cin>>a[i];
      lint max=a[0];
      bool isp=false;
      lint last;
      rep(i,n-1){
          max+=a[i+1];
          if(max>=l){
              last=i+1;
              isp=true;
          }
          max-=a[i];
      }
      if(!isp){
          cout<<"Impossible"<<endl;
      }else{
          cout<<"Possible"<<endl;
      repp(i,1,last){
         cout<<i<<endl;
      }
     for(int i=n-1;i>last;i--)cout<<i<<endl;
     cout<<last<<endl;
      }
  }
  
  
     
  

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
int min(int a, int b){
  return a<b?a:b;
}
int main(){
  int n;
  cin >> n;
  int dp[n],val[n];
  for(int i=0;i<n;i++){
  	cin >> val[i];
  }
  for (int i = 0; i < n; ++i)
  {
  	if(i == 0){
  		dp[0] = 0;
  		//printf("%d ",dp[i] );
  	}
  	else if(i == 1){
  		dp[1] = abs(val[1] - val[0]);
  		//printf("%d ",dp[i] );
  	}
  	else{
	  	dp[i] = min((dp[i-2]+abs(val[i]-val[i-2])), (dp[i-1]+abs(val[i]-val[i-1])));
	  	//printf("%d ",dp[i] );
  	}
  }
  printf("%d\n",dp[n-1] );
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

int main(){
    int n, m, q, ans = 0;
    cin >> n >> m >> q;
    vector<vector<int>> t(n + 1, vector<int>(n + 1, 0));
    for(int i = 0; i < m; i++){
        int l, r;
        cin >> l >> r;
        t[l][r]++;
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            t[i][j] += t[i - 1][j]; 
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            t[i][j] += t[i][j - 1]; 
        }
    }
    for(int i = 0; i < q; i++){
        int l, r;
        cin >> l >> r;
        ans = t[r][r] - t[l - 1][r] - t[r][l - 1] + t[l - 1][l - 1];
        cout << ans << endl;
    }
    return 0;
}

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

int main(){
	int n;
	cin>>n;
	int x;
	deque<int> d;
	for(int i=0;i<n;i++){
	    cin>>x;
	    if(i%2==1) d.push_front(x);
	    else d.push_back(x);
	}
	if(n%2==0){
	    while(!d.empty()){
	        cout<<d.front()<<" ";
	        d.pop_front();
	    }
	}
	else{
	    while(!d.empty()){
	        cout<<d.back()<<" ";
	        d.pop_back();
	    }
	}
}

Measured memory_bytes: 2944
/*
Author : N_o_o_B
Created : May 30 2020 17:30:42 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    int h1,m1,h2,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int t1 = h1*60 + m1,t2 = h2*60 + m2;
    cout << max(t2-k-t1,0) << endl;



    time_taken();
    return 0;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
#define forx(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;


int main(){
    string s,t;
    cin>>s;
    int k;
    cin>>k;
    int n=s.size();
    
    vector<string>v;
    rep(i,n){
        t={s[i]};
        v.push_back(t);
    }
    if(n>=2)rep(i,n-1){
        t={s[i],s[i+1]};
        v.push_back(t);
    }
    if(n>=3)rep(i,n-2){
        t={s[i],s[i+1],s[i+2]};
        v.push_back(t);
    }
    if(n>=4)rep(i,n-3){
        t={s[i],s[i+1],s[i+2],s[i+3]};
        v.push_back(t);
    }
    if(n>=5)rep(i,n-4){
        t={s[i],s[i+1],s[i+2],s[i+3],s[i+4]};
        v.push_back(t);
    }
    sort(begin(v),end(v));
    unique(begin(v),end(v));
    cout<<v[k-1]<<endl;
    return 0;
}


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

int main()
{
string s1, s2; cin >> s1 >> s2;
int size = s2.size();
for (int i = 0; i < size; i++) {
    if(s1[i] != s2[size-1-i]){
        cout << "NO" << endl;
        return 0;
    }
}
cout << "YES" << endl;
return 0;
}

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

using namespace std;

int main()
{
    #ifdef LOCAL_EXEC
    #else
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #endif // LOCAL_EXEC
    long long int i,j;
    string s,result;
    cin>>s;
    if(s=="ABC")
        cout<<"ARC";
    else
        cout<<"ABC";
    return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
//#define Fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef vector<ll>Vl;
typedef pair<ll,ll>PII;
typedef vector<PII>Vll;
typedef vector<pair<ll,pair<ll,ll> > >Vlll;
typedef priority_queue<ll>PQL;
typedef map<ll,ll>MP;
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) scanf("%lld",&n)
#define pl(n) printf("%lld",n)
const ll mod=1e9+7;
ll N;
int main(){
	sl(N);
	ll ans=0;
	if(N%2)cout<<"0"<<endl;
	else{
	N=N/2;
	for(ll i=5;N/i>=1;i*=5)ans+=N/i;
	cout<<ans<<endl;
}
  return 0;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
typedef pair<int,int> P;
int w,h;

int calc(int x,int y){
  if(x==0) return y;
  if(y==h) return h+x;
  if(x==w) return h+w+h-y;
  return h+w+h+w-x;
}

int LU(int x,int y){
  int d=min(x,h-y);
  return calc(x-d,y+d);
}

int RU(int x,int y){
  int d=min(w-x,h-y);
  return calc(x+d,y+d);
}

int RD(int x,int y){
  int d=min(w-x,y);
  return calc(x+d,y-d);
}

int LD(int x,int y){
  int d=min(x,y);
  return calc(x-d,y-d);
}

bool check(P a,int b){
  if(a.f<a.s&&(a.f<=b&&b<=a.s))return 1;
  if(a.f>a.s&&!(a.s<b&&b<a.f)) return 1;
  return 0;
}

int main(){
  int n;
  cin>>n>>w>>h;
  
  vector <P> lr;
  for(int i=0;i<n;i++){
    int x,y;
    char ch;
    cin>>x>>y>>ch;
    if(ch=='N')lr.push_back(P(LU(x,y),RU(x,y)));
    if(ch=='E')lr.push_back(P(RU(x,y),RD(x,y)));
    if(ch=='S')lr.push_back(P(RD(x,y),LD(x,y)));
    if(ch=='W')lr.push_back(P(LD(x,y),LU(x,y)));
  }

  for(int i=0;i<n;i++)swap(lr[i].f,lr[i].s);
  sort(lr.begin(),lr.end());
  for(int i=0;i<n;i++)swap(lr[i].f,lr[i].s);
  
  
  int ans=n;
  for(int i=0;i<n;i++){
    int cnt=1,pos=lr[i].s;
    for(int j=0;j<n;j++){
      int idx=(i+j)%n;
      if(check(lr[idx],pos))continue;
      cnt++;
      pos=lr[idx].s;
    }
    ans=min(ans,cnt);
  }
  cout <<ans<<endl;  
  

  return 0;
}

Measured memory_bytes: 3108
def isEven(num):
    if num % 2 == 0:
        return 0
    else:
        return 1

def isAllEven(l):
    allEven = 0
    for i in l:
        allEven += isEven(i)
    
    if allEven == 0:
        return True
    else:
        return False

def countDivide(n, l):
    if isAllEven(l):
        newl = list(map(lambda x: int(x/2), l))
        n += 1
        return countDivide(n, newl)
    else:
        return n

N = int(input())
A = list(map(int, input().split()))

print(countDivide(0, A))


Measured memory_bytes: 3188
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

//?????¢???????????????????????????????????????2???????????§????????????????????????????????????

int main(void){
	int H,W;
	cin>>H>>W;
	int c[1400][1400],DP[1400][1400],ans=0;
	rep(i,H){
		rep(j,W)cin>>c[i][j];//y,x
	}
	rep(i,H){
		rep(j,W){
			if(i==0 || j==0){
				if(c[i][j]==0){
					DP[i][j]=1;
				}else{
					DP[i][j]=0;
				}
			}else if(c[i][j]==0){
				DP[i][j]=min(min(DP[i-1][j],DP[i][j-1]),DP[i-1][j-1])+1;
			}else{
				DP[i][j]=0;
			}
			if(ans<DP[i][j])ans=DP[i][j];
		}
	}
	ans=ans*ans;
	cout<<ans<<endl;
	// rep(i,H){
	// 	rep(j,W)cout<<DP[i][j]<<" ";
	// 	cout<<endl;
	// }
	return 0;
}

Measured memory_bytes: 18396
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            //var NKMR = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            //var S = Console.ReadLine();

            var robot = new Tuple<long, long>[N];
            for (int i = 0; i < N; i++)
            {
                var XL = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
                robot[i] = new Tuple<long, long>(XL[0], XL[1]);
            }

            Sort(robot);
            var now = 0L;
            var ext = 0L;
            for (int i = 1; i < N; i++)
            {
                if(robot[now].Item1+ robot[now].Item2 > robot[i].Item1 - robot[i].Item2)
                {
                    ext++;
                    if(robot[now].Item1 + robot[now].Item2 > robot[i].Item1 + robot[i].Item2)
                    {
                        now = i;
                    }
                }
                else
                {
                    now = i;
                }
            }
            Console.WriteLine(N - ext);
            
        }
    }


}


Measured memory_bytes: 51424
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long llint;
typedef long double ldouble;
// 小大
int compare(const void *a, const void *b){return *(llint *)a - *(llint *)b;}
typedef struct{
    llint aa;
    llint bb;
}frequent;
// 小大
int cmp( const void *p, const void *q ) {
    return ((frequent*)p)->bb - ((frequent*)q)->bb;
}
llint memoplace[50];
llint route(llint n, llint gra[n][n], llint bra[], llint a1, llint a, llint b){
    // printf("?%lld %lld? ",a,b);
    if(memoplace[a-1] == 1){
        // printf(" c ");
        return 0;
    }
    llint ans=0;
    memoplace[a-1] = 1;
    // printf(" /%lld/ ",bra[a-1]);
    for(llint i=0;i<bra[a-1];i++){
        // printf("|%lld,%lld,%lld|",gra[a-1][i],a-1,i);
        if(gra[a-1][i] == b && a1==a){
            // printf(" q ");
            continue;
        }
        if(gra[a-1][i] == b) return 1;
        ans = route(n,gra,bra,a1,gra[a-1][i],b);
        if(ans!=0) return 1;
    }
    // printf(" r ");
    return 0;
}


int main(void){
    llint n,m,i,ans=0;
    scanf("%lld%lld",&n,&m);
    llint a[m],b[m],graph[n][n],branch[n];
    for(i=0;i<n;i++){
        branch[i]=0;
        for(llint j=0;j<n;j++){
            graph[i][j]=0;
        }    
    }
    for(i=0;i<m;i++){
        scanf("%lld%lld",&a[i],&b[i]);
        branch[a[i]-1]++;
        branch[b[i]-1]++;
        graph[a[i]-1][branch[a[i]-1]-1] = b[i];
        graph[b[i]-1][branch[b[i]-1]-1] = a[i];
    }

    // for(i=0;i<n;i++){
    //     for(llint j=0;j<n;j++){
    //         printf("%lld ",graph[i][j]);
    //     }
    //     printf("\n");
    // }

    // ans = route(n,graph,branch,a[3],a[3],b[3]);

    for(i=0;i<m;i++){
        for(llint j=0;j<n;j++){
            memoplace[j] = 0;
        }
        // printf("%lld\n",route(n,graph,branch,a[i],a[i],b[i]));
        // for(llint j=0;j<n;j++){
        //     printf("%lld ",memoplace[j]);
        // }
        // printf("\n");
        if( route(n,graph,branch,a[i],a[i],b[i]) == 0) ans++;
        
    }

    // printf("\n");
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{	
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;

	if (x - r >= 0 && W - x >= r && y - r >= 0 && H - y >= r)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}



Measured memory_bytes: 3108
#include<iostream>
#include<iomanip>
#include<cmath>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
void fillc(vector<vector<int>> &adj, vector<int> &par, vector<vector<int>> &cld, int root){
  for(int &n: adj[root]){
    if(n!=par[root]){
      cld[root].push_back(n);
      par[n]=root;
      fillc(adj, par, cld, n);
    }
  }
}

void acc(vector<vector<int>> &cld, vector<long> &s, int root){
  for(int &n: cld[root]){
    s[n] += s[root];
    acc(cld, s, n);
  }
}

int main(){
  cout << setprecision(10);
  int N, Q;
  cin >> N >> Q;
  vector<vector<int>> adj(N+1);
  for(int i=1; i<=N-1; i++){
    int ai, bi;
    cin >> ai >> bi;
    adj[ai].push_back(bi);
    adj[bi].push_back(ai);
  }
  vector<int> par(N+1, -1);
  vector<vector<int>> cld(N+1);
  fillc(adj, par, cld, 1);
  vector<long> s(N+1, 0);
  for(int j=0; j<Q; j++){
    int pj, xj;
    cin >> pj >> xj;
    s[pj] += xj;
  }
  acc(cld, s, 1);
  cout << s[1];
  for(int i=2; i<=N; i++) cout << " " << s[i];
  cout << endl;
  return 0;
}

Measured memory_bytes: 42240
function Main(input) {
  input = input.split(" ");
  var S = input[0].replace("\n","");

  var Words = function(){
    this.Can = {"dream":5, "dreamer":7, "erase":5, "eraser":6};
    this.S = S;
    this.dp = Array(this.S.length);
    this.flag = true;
  }

  Words.prototype = {
    procedure: function(){
      this.dp[0]=1;
      for(var i = 1; i <= this.S.length; i++){
        this.flag = true;
        if(i >= 5){
          if(this.dp[i-5] == 1 && this.S.substr(i-5, 5) == "dream"){
            this.dp[i]=1;
            continue;
          }else if(this.dp[i-5] == 1 && this.S.substr(i-5, 5) == "erase"){
            this.dp[i]=1;
            continue;
          }else{
            this.flag = false;
          }
        }
        if(i >= 6){
          if(this.dp[i-6] == 1 && this.S.substr(i-6, 6) == "eraser"){
            this.dp[i]=1;
            continue;
          }else{
            this.flag = false;
          }
        }
        if(i >= 7){
          if(this.dp[i-7] == 1 && this.S.substr(i-7, 7) == "dreamer"){
            this.dp[i]=1;
            continue;
          }else{
            this.flag = false;
          }
        }
        if(i < 5){
          this.dp[i]=0;
        }
        if(this.flag == false) this.dp[i] =0;
      }
      if(this.dp[this.S.length] == 1){
        return "YES"
      }else{
        return "NO"
      }
    }
  }

var words = new Words();
console.log(words.procedure(""));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 5010

#define CHECK

ll N;
string S;

int LCSuff[MAX_N+1][MAX_N+1]; 

int LCSubStr(const char *X, const char *Y, int m, int n) 
{ 
    // Create a table to store lengths of longest 
    // common suffixes of substrings.   Note that 
    // LCSuff[i][j] contains length of longest 
    // common suffix of X[0..i-1] and Y[0..j-1].  

    int result = 0;  // To store length of the  
    // longest common substring 

    /* Following steps build LCSuff[m+1][n+1] in 
       bottom up fashion. */
    for (int i=0; i<=m; i++) 
    { 
        for (int j=0; j<=n; j++) 
        { 

            // The first row and first column  
            // entries have no logical meaning,  
            // they are used only for simplicity  
            // of program 
            if (i == 0 || j == 0) 
                LCSuff[i][j] = 0; 

            else if (X[i-1] == Y[j-1]) 
            { 
                LCSuff[i][j] = LCSuff[i-1][j-1] + 1; 
                result = max(result, LCSuff[i][j]); 
            } 
            else LCSuff[i][j] = 0; 
        } 
    } 
    return result; 
} 

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

    cin >> N >> S;

    const char* S_c = S.c_str();

    ll ans = 0;
    ll lb = 1, ub = N - 1;

#ifdef CHECK
    while(ub - lb > 100) {
#else
    while(ub - lb > 2) {
#endif
        ll t1 = (2 * lb + ub) / 3;
        ll t2 = (lb + 2 * ub) / 3;

        ll cand1 = LCSubStr(S_c, S_c + t1, t1, N - t1);
        ll cand2 = LCSubStr(S_c, S_c + t2, t2, N - t2);
        ans = max({ans, cand1, cand2});

        //DBG("t1: %lld t2: %lld cand1: %lld cand2: %lld\n", t1, t2, cand1, cand2);

        if(cand1 <= cand2) {
            lb = t1 - 2;
            lb = max(lb, (ll)1);
        }
        else {
            ub = t2 + 2;
            ub = min(ub, N - 1);
        }
    }

    for(int i = lb; i <= ub; ++i) {
        ll cand = LCSubStr(S_c, S_c + i, i, N - i);
        ans = max(ans, cand);
    }
#ifdef CHECK
    for(int i = 0; i < (int)(min((int)150, N)); ++i) {
        ll cand = LCSubStr(S_c, S_c + i, i, N - i);
        ans = max(ans, cand);
    }
    for(int i = (int)(max((int)0, N - 150)); i < N; ++i) {
        ll cand = LCSubStr(S_c, S_c + i, i, N - i);
        ans = max(ans, cand);
    }
#endif

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 194944
#include<stdio.h>
#include<iostream>
#include<algorithm>
typedef long long ll;
using namespace std;
ll a[200005];
int main(){
    int i,n;ll k;
    scanf("%d %lld",&n,&k);
    for(i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
    }
    sort(a,a+n);
    ll L=-1e18,R=1e18;
    while(L+1!=R){
        ll Mid=(L+R)/2;
        ll cnt=0;//每次L,R改变后都要重新统计cnt的个数
        for(i=0;i<n;i++){
            if(a[i]<0){
                int l=i,r=n;
                while(l+1!=r){
                    int mid=(l+r)/2;
                    if(a[i]*a[mid]<=Mid) r=mid;//负数时数越前越小，乘积越大
                    else l=mid;//越后越大，乘积越小
                }
                cnt+=n-r;//数组中有多少数和a[i]乘积小于mid
            }
            else {
                int l=i,r=n;
                while(l+1!=r){
                    int mid=(l+r)/2;
                    if(a[i]*a[mid]<=Mid) l=mid;//正数时越后越大，乘积越大
                    else r=mid;
                }
                cnt+=l-i;//i到l有多少数和a[i]乘积小于mid
            }
        }
        if(cnt<k) L=Mid;//还没到第k大的乘积数，继续往大的方向二分
        else R=Mid;//cnk到达k以后，R会一直往第K大乘积数挪
    }
    printf("%lld",R);
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int result = 0;
        for(int i=1; i<=5; i++) {
            int x = sc.nextInt();
            if(i!=x) {
                result = i;
            }
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 35644
using System;
using System.Linq;

namespace Volume0
{
    class Program
    {
        static void Main(string[] args)
        {
            string s;
            while((s = Console.ReadLine()) != null)
            {
                double[] i = s.Split(' ')
                              .Select(e => double.Parse(e))
                              .ToArray();
                var x = (i[2] * i[4] - i[1] * i[5]) 
                              / (i[0] * i[4] - i[1] * i[3]);
                var y = (i[5] * i[0] - i[2] * i[3])
                              / (i[0] * i[4] - i[3] * i[1]);
                Console.WriteLine("{0:F3} {1:F3}", x, y);
            }
        }
    }
}

Measured memory_bytes: 9684
import java.util.Scanner;

class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		
		String w=scan.next();
		int cnt=0;
		
		while(scan.hasNext()){
			String s=scan.next();
			if(s.equals("END_OF_TEXT"))
				break;
			
			s=s.toLowerCase();
			if(s.equals(w))
				cnt++;
			
		}
		
		System.out.println(cnt);
		
	}
}


Measured memory_bytes: 25896
#include <bits/stdc++.h>
using namespace std;
int n,m,i;
char s[200200],t[200200];
int main() {
  scanf("%s",s);
  n=strlen(s);
  for (i=0; i<n; i++) if (m>0 && t[m]=='S' && s[i]=='T') m--; else t[++m]=s[i];
  printf("%d\n",m);
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>

int n;

char s[305][305];
int ans=0;

void check()
{
    /*for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            printf("%d %d = %c\n",i,j,s[i][j]);
        }
    }*/
    for (int i=0; i<n; i++) {
        for (int j=i+1; j<n; j++) {
            if (s[i][j]!=s[j][i]) {
                //printf("bad %d %d\n",i,j);
                return;
            }
        }
    }
    //printf("added %d %d\n",ans,n);
    ans+=n;
}

char t[305];
void shift()
{
    for (int j=0; j<n; j++) t[j]=s[0][j];
    for (int i=1; i<n; i++) {
        for (int j=0; j<n; j++) s[i-1][j]=s[i][j];
    }
    for (int j=0; j<n; j++) s[n-1][j]=t[j];
}

int main()
{
    #ifdef NOT_DMOJ
    freopen("data.txt","r",stdin);
    #endif // NOT_DMOJ
    scanf("%d",&n);
    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            scanf(" %c",&s[i][j]);
        }
    }
    // if (i,j) is good, then (i+1,j+1) is good
    for (int i=0; i<n; i++) {
        check();
        shift();
    }
    printf("%d\n",ans);
}


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

int main() {
  string s; cin >> s;
  if (s == "ABC") cout << "ARC" << endl;
  if (s == "ARC") cout << "ABC" << endl;
  return 0;
}

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

struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) (1 + (int)((a) - 1)/(int)(b))
#define int long long

signed main(){
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int ans = 0;
    reps(i,0,a)reps(j,0,b)reps(k,0,c){
        if(500*i + 100*j + 50*k == x) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

struct SegTree(alias fun, alias E, T)
if (is(typeof(E) : T))
{
    import std.functional : binaryFun;
    alias OP = binaryFun!fun;

    ///
    this(size_t n, T[] ts) {
        this.n = 1;
        while (this.n < n) this.n *= 2;
        this.tree.length = this.n * 2 - 1;
        foreach (ref e; this.tree) e = E;
        foreach (i, e; ts) this.update(i, e);
    }

    ///
    void replace(size_t i, T e) {
        i += this.n - 1;
        this.tree[i] = e;
        while (i > 0) {
            i = (i-1) / 2;
            this.tree[i] = OP(this.tree[i*2+1], this.tree[i*2+2]);
        }
    }

    ///
    void update(size_t i, T e) {
        replace(i, OP(e, tree[i + this.n - 1]));
    }

    ///
    T query(size_t a, size_t b) {
        T impl(size_t i, size_t l, size_t r) {
            if (r <= a || b <= l) return E;
            if (a <= l && r <= b) return this.tree[i];
            return OP(
                impl(i*2+1, l, (l+r)/2),
                impl(i*2+2, (l+r)/2, r)
            );
        }
        return impl(0, 0, this.n);
    }

private:
    size_t n;
    T[] tree;
}

///
auto seg_tree(alias f, alias E, T)(size_t n, T[] arr = [])
{
    return SegTree!(f, E, T)(n, arr);
}

///
auto seg_tree(alias f, alias E, T)(T[] arr)
{
    return SegTree!(f, E, T)(arr.length, arr);
}

auto max_seg_tree(T)(size_t n, T[] arr = [])
{
    return seg_tree!("a > b ? a : b", 0, T)(n, arr);
}

auto max_seg_tree(T)(T[] arr)
{
    return max_seg_tree!T(arr.length, arr);
}

alias P = Tuple!(int, "i", int, "d");

void main()
{
    auto nq = readln.split.to!(int[]);
    auto N = nq[0];
    auto Q = nq[1];

    alias SEGT = typeof(max_seg_tree!int(N));
    long r = (N.to!long-2)^^2;
    void put(int p, ref int min_line, int min_line_opposite, ref int[] lines, SEGT segt) {
        segt.update(p, p+1);
        auto above = segt.query(0, p);
        if (above) {
            lines[p] = lines[above-1];
        } else {
            min_line = p;
            lines[p] = min_line_opposite - 1;
        }
        r -= lines[p];
    }

    auto lms = new int[](N);
    int min_w = N-1;
    auto bms = new int[](N);
    int min_v = N-1;
    auto wsegt = max_seg_tree!int(N);
    auto vsegt = max_seg_tree!int(N);
    foreach (_; 0..Q) {
        auto q = readln.split.to!(int[]);
        auto x = q[1]-1;
        if (q[0] == 1) {
            put(x, min_v, min_w, lms, wsegt);
        } else {
            put(x, min_w, min_v, bms, vsegt);
        }
    }
    writeln(r);
}

Measured memory_bytes: 9464
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define ff first
#define ss second
const ll mod =   1e9+7 ;
ll multiply(ll a, ll b ){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
////////////////////////////////////////////////////////////////
ll power ( ll x , ll n){
    if(n==0) return 1  ;
    if(n==1) return x ;
    ll y = power(x,n/2);
    if(n%2==0) return multiply(y,y);
    return multiply(y,multiply(x,y));
}
ll cal(int n , int r){
    ll x = 1 ;
    for( int i = n ; i > n-r; i--){
        x = multiply(x,i);
    }
    ll fact = 1 ;
    for( int i = 1 ; i <= r ; i++) fact = multiply(fact,i);
    ll y = power(fact,mod-2);

    return multiply(x,y);
    // n * (n-1) * (n-2) ....... (n-r-1)  / (n-r)! * r!
}
///////////////////////////////////////////////////////////////
void solve(){
    int n , a , b ;
    cin >> n >> a >> b ;
    //cout << power(2,n) ;
    cout << sub(sub(power(2,n),1),add(cal(n,a),cal(n,b))) ;

}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t ;
    t = 1 ;
   // cin >> t ;
    while(t--){
        solve( );
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
const int INF = 1 << 30;
int main(){
  int n, m, a[50], b[50], c[50], dp[51][51][51];
  cin >> n >> m;
  for(int i = 0; i < n; i++){
    cin >> a[i] >> b[i] >> c[i];
  }
  fill_n( **dp, 51 * 51 * 51, -INF);
  dp[0][m][0] = 0;
  for(int i = 0; i < n; i++){ // O(nm^3*64) = O(4*10^8)
    for(int j = 0; j <= m; j++){
      for(int k = 0; k <= m - j; k++){ // レベル1のサイリウムの数
        if(dp[i][j][k] == -INF) continue;
        for(int l = j; l >= 0; l--){ // レベル2のサイリウムの数

          //はやくするならここだな
          for(int o = 0; o <= k && o <= 8; o++){ // 実際にふる数 レベル1
            for(int p = 0; p <= l && o + p <= 8; p++){ // 実際にふる数 レベル2
              if(o + p == 0){
                dp[i + 1][j - l][l] = max( dp[i + 1][j - l][l], dp[i][j][k] + c[i]); 
              } else {
                dp[i + 1][j - l][l] = max( dp[i + 1][j - l][l], dp[i][j][k] + b[i] * o + a[i] * p);
              }
            }
          }
        }
      }
    }
  }
  int ret = -INF;
  for(int i = 0; i <= m; i++){
    for(int j = 0; j <= m; j++){
      ret = max( ret, dp[n][i][j]);
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 1680
#include<stdio.h>
int main(){

  int t[1000],juni[1000];
  int i=1,ju=1,k,j;
  int n,toi;
  

  while(1){
    scanf("%d,%d",&n,&t[i]);
    if(n==0)break;
    i++;
  }
  for(k=30;k>=0;k--){
    for(j=0;j<i;j++){
      if(k==t[j]){
	juni[j]=ju;
	n=1;
      }
    }
    if(n==1){
      n=0;
      ju++;
    }
  }
  while(scanf("%d",&toi)!=EOF){
    printf("%d\n",juni[toi]);
  }
  return 0;
}

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

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int n,H,W,count=0;	cin>>n>>H>>W;
	for(int i=0;i<n;i++){
		int h,w;	cin>>h>>w;
		if(h>=H && w>=W)	count++;
	}
	cout<<count<<'\n';
	
	return 0;
}


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

int main(){
  long n,k;
  cin >> n >> k;
  long a[n];
  long maxa = 0;
  rep(i,n){
    cin >> a[i];
    if(maxa<a[i])maxa = a[i];
  }
  long li = 0, ri = maxa;
  long mid = (li+ri)/2;
  while(li+1<ri){
    long tmp=0;
    mid = (li+ri)/2;
    rep(i,n){
      tmp += ceil((double)a[i]/(double)mid)-1;
      //tmp += (a[i]-1)/mid;
    }
    if(tmp<=k)ri = mid;
    else if(tmp>k)li = mid;
  }
  cout << ri << endl;
  return 0;
}

Measured memory_bytes: 5172