akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=2e5+5,mod=1e9+7;
ll fct[N],inv[N],invfct[N];
inline void init(){
    fct[0]=fct[1]=1;
	inv[1]=1;
	invfct[0]=invfct[1]=1;
	for(ll i=2;i<N;i++){
		fct[i]=i*fct[i-1]%mod;
		inv[i]=ll(mod-inv[mod%i])*(mod/i)%mod;
		invfct[i]=ll(inv[i])*invfct[i-1]%mod;
	}
}
inline ll ncr(ll n,ll r){
    if(n<0 || r<0 || n-r<0)return 0;
    ll ans = fct[n]*invfct[r];
    ans%=mod;
    ans = ans * invfct[n-r];
    ans%=mod;
    return ans;
}
ll x,y,n,a[N],first[N],last[N];
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    init();
    cin>>n;
    for(ll i=1;i<=n+1;i++){
        cin>>a[i];
        if(!first[a[i]])first[a[i]]=i;
        last[a[i]]=i;
    }
    for(ll i=1;i<=n;i++)if(first[i]!=last[i])x=first[i]-1,y=n+1-last[i];
    cout<<n<<"\n";
    for(ll len=2;len<=n+1;len++)cout<<( ncr(n+1,len) - ncr(x+y,len-1) + mod )%mod<<"\n";
}

Measured memory_bytes: 9856
#include<iostream>
#include<string.h>
using namespace std;

int main(){

    char d[100];
    cin>>d;
    char a1[]="ABC";
    char b1[]="ARC";
  
    if(strcmp(d,a1)==0){
        cout<<b1;
    }
    else if(strcmp(d,b1)==0){
        cout<<a1;
    }
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
	int n,c; cin>>n>>c;
	int w[100005]; CLR(w);
	vector<vector<PII>> b(c);
	VVI input;
	rep(i,n){
		VI v(3); cin>>v[1]>>v[0]>>v[2]; v[2]--;
		input.PB(v);
	}
	sort(ALL(input));
	rep(i,n){
		int s=input[i][1],t=input[i][0],c=input[i][2];
		if(b[c].size()==0){
			b[c].PB(MP(s,t));
		}else{
			int idx=b[c].size()-1;
			if(b[c][idx].second==s) b[c][idx].second=t;
			else b[c].PB(MP(s,t));
		}
	}
	cerr<<endl;
	rep(i,c){
		rep(j,b[i].size()){
			int s=b[i][j].first, t=b[i][j].second+1;
			// cerr<<i+1 SP s SP t<<endl;
			w[s]++; w[t]--;
		}
	}
	int ans=0, cnt=0;
	rep(i,100002){
		cnt+=w[i]; chmax(ans,cnt);
	}
	cerr<<endl;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 7472
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;
 
int main(){
  using namespace std;
  string s;
  cin>>s;
  if(s == "AAA" || s == "BBB"){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 1e9+7;

signed main(){
    int N; cin >> N;
    vector<int> a(N), sum(N, 0);
    for(int i = 0; i < N; i++) cin >> a[i];
    int ans = 3;
    sum[0] = 1;
    if(a[0] != 0){
      cout << 0 << endl;
      return 0;
    }
    for(int i = 1; i < N; i++){
        if(a[i] != 0) ans *= (sum[a[i] - 1] - sum[a[i]]);
        if(a[i] == 0) ans *= (3 - sum[a[i]]);
        ans %= mod;
        sum[a[i]]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;

  if (a > 0 && a < 10 && b > 0 && b < 10) {
    cout << a * b << endl;
  } else {
    cout << -1 << endl;
  }
}


Measured memory_bytes: 256
import sys

l1 = sys.stdin.readline().strip().split()
l2 = sys.stdin.readline().strip().split()
l1 = [int(x.strip()) for x in l1]
l2 = [int(x.strip()) for x in l2]


N = l1[0]
k = l1[1]
A = l2

p = A.index(1)

nl = [0,0]
nr = [0,0]

def culc(q):
	m = 0
	l = 0
	if k >= q:
		m = 0
	else:
		m = (q-1) // (k-1)
	if m == 0:
		l = 0 #あとの計算の上で、これを端点としても問題ない
	else:
		l = (k-1)*(m-1) + k-1 #indexなので左端は0
	return [m, l]

nl = culc(p)
nr = culc(N-1-p)

#print(nr)
nr[1] = N-1-nr[1]
#print(nl)
#print(nr)

if nl[1] + (k-1) >= nr[1]:
	c = nl[0] + nr[0] + 1
else:
	c = nl[0] + nr[0] + 2

print(c)


Measured memory_bytes: 52204
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x, n;
  cin >> x >> n;
  vector<int>q(105); //0で初期化される
  for (int i=0; i<n; i++){
    int p;
    cin >> p;
    q[p] = 1;
  }
  int min = 1000000;
  int ans = 0;
  for (int i=105; i>-1; i--){
    if (q[i] == 1) continue;
    int dif = abs(x-i);
    if (dif <= min){
      ans = i;
      min = dif;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3624
@n = gets.to_i
@a = gets.split.map(&:to_i)
q = gets.to_i
m = gets.split.map(&:to_i)

def search(sum, v, i)
  return 1 if sum == v
  return 0 if i >= @n
  return search(sum, v, i+1) + search(sum+@a[i], v, i+1)
end

m.each do |v|
  puts search(0, v, 0) > 0 ? "yes" : "no"
end


Measured memory_bytes: 6868
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n;
  cin >> n;
  vector<int>a(n);
  rep(i,n) cin >> a[i];
  int cnt=0;
  rep(i,n){
    int b=a[i];
    if(a[b-1]==i+1)cnt++;
  }
  cout << cnt/2 << endl;
  return 0;     
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	static PrintWriter out = new PrintWriter(System.out);

	static int R,C;
	static int g[][];
	static int dp[][][];
	public static void main(String[] args) {
		FS in = new FS();
		R = in.nextInt();
		C = in.nextInt();
		g = new int[R][C];
		for(int i = 0; i < R; i++) {
			char cc[] = in.next().toCharArray();
			for(int j = 0; j < C; j++) {
				g[i][j] = cc[j] == '.' ? 0 : 1;
			}
		}
		dp = new int[2][R][C];
		for(int a[][] : dp)
			for(int b[] : a)
				Arrays.fill(b, -1);
		int res = -1;
		if(g[0][0] == 0) res = go(0,0,0);
		else res = 1 + go(1,0,0);
		out.println(res);
		out.close();
	}
	static int go(int st, int r, int c) {
		if(r == R-1 && c == C-1) return 0;
		if(dp[st][r][c] != -1) return dp[st][r][c];
		int res = 123123;
		// go right
		if(c < C-1) {
			int cur = 0;
			if(st == 0 && g[r][c+1] == 1) cur++;
			res = Math.min(res, cur + go(g[r][c+1], r, c+1));
		}
		if(r < R-1) {
			int cur = 0;
			if(st == 0 && g[r+1][c] == 1) cur++;
			res = Math.min(res, cur + go(g[r+1][c], r+1, c));
		}
		
		return dp[st][r][c] = res;
	}
	
	static class FS{
		BufferedReader br;
		StringTokenizer st;
		public FS() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String next() {
			while(st == null || !st.hasMoreElements()) {
				try {st = new StringTokenizer(br.readLine());}
				catch(Exception e) { throw null;}
			}
			return st.nextToken();
		}
		int nextInt() { return Integer.parseInt(next());}
		double nextDouble() { return Double.parseDouble(next());}
		long nextLong() { return Long.parseLong(next());}
		int[] NIA(int n) {
			int r[] = new int[n];
			for(int i = 0; i < n; i++) r[i] = nextInt();
			return r;
		}
		long[] NLA(int n) {
			long r[] = new long[n];
			for(int i = 0; i < n; i++) r[i] = nextLong();
			return r;
		}
		char[][] grid(int r, int c){
			char res[][] = new char[r][c];
			for(int i = 0; i < r; i++) {
				char l[] = next().toCharArray();
				for(int j = 0; j < c; j++) {
					res[i][j] = l[j];
				}
			}
			return res;
		}
	}
	
}


Measured memory_bytes: 21588
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iterator>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DT long long
#define forn(i,n)for(i=0;i<n;i++)
#define forc(i,c,n)for(i=c;i<=n;i++)

int main() {
	ifstream fin("Text.txt");
	int i=0, j, q;
	string st,st2;
	DT h,w,a, b, c, d, n, m, k, s = 0, t = 1, mod = 1000000007;
	cin >> n;
	cin >> st>>st2;
	while (i < n ) {
 		if (st[i] == st2[i]) {
			if (i == 0) {
				t *= 3;
				t %= mod;
			}
			else {
				if (st[i - 1] == st2[i - 1]) {
					t *= 2;
					t %= mod;
				}
			}
			i++;
		}
		else {
			if (i == 0) {
				t *= 6;
				t %= mod;
			}
			else {
				if (st[i - 1] == st2[i - 1]) {
					t *= 2;
					t %= mod;
				}
				else {
					t *= 3;
					t %= mod;
				}
			}
			i += 2;
		}
	}
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 256
N=str(input())
n=len(N)
K=int(input())
dp0=[[0]*(K+1) for _ in range(n+1)]
dp1=[[0]*(K+1) for _ in range(n+1)]
for l in range(1,n+1):
  dp0[l][0]=1
dp1[0][0]=1
for i in range(n):
  for j in range(K):
    if N[i]=='0':
      dp0[i+1][j+1]=9*dp0[i][j]+dp0[i][j+1]
      dp1[i+1][j+1]=dp1[i][j+1]
    else:
      dp0[i+1][j+1]=dp0[i][j]*9+dp0[i][j+1]+dp1[i][j]*(int(N[i])-1)+dp1[i][j+1]
      dp1[i+1][j+1]=dp1[i][j]
print(dp0[n][K]+dp1[n][K])

Measured memory_bytes: 3064
use std::fmt;
use std::io::stdin;
use std::io::BufRead;
use std::str;
use std::str::FromStr;
use std::vec::Vec;

fn main() {
    let stdin = stdin();
    let mut scan = InputScanner::new(stdin.lock(),256);

    let s = scan.next::<String>().chars().collect::<Vec<char>>();

    println!("{}",search(&s,0,0));
}
fn search(s:&[char],i:usize,n:usize) -> usize {
	let mut r = 0;

	if i >= s.len() {
		return n;
	}

    for j in i..s.len() {
		let n = n + to_int(s,i,j+1);
        r += search(s, j+1,n);
    }

    r
}
fn to_int(s:&[char],start:usize,end:usize) -> usize {
    let mut n = 0;

    for i in start..end {
        n = n * 10 + s[i] as usize - '0' as usize;
    }

    n
}
struct InputScanner<R: BufRead> {
	reader: R,
	buf: Vec<u8>, // Should never be empty
	pos: usize,   // Should never be out of bounds as long as the input ends with '\n'
}
impl<R: BufRead> InputScanner<R> {
	fn new(reader: R, capacity: usize) -> Self {
		InputScanner {
			reader: reader,
			buf: Vec::with_capacity(capacity),
			pos: 0,
		}
	}

	#[inline]
	fn next<T: FromStr>(&mut self) -> T
	where
		T::Err: fmt::Debug,
	{
		if self.buf.is_empty() {
			self._read_next_line();
		}
		let mut start = None;
		loop {
			match (self.buf[self.pos], start.is_some()) {
				(b' ', true) | (b'\n', true) | (b'\r', true) => break,
				(_, true) | (b' ', false) => self.pos += 1,
				(b'\n', false) | (b'\r', false) => self._read_next_line(),
				(_, false) => start = Some(self.pos),
			}
		}
		let target = &self.buf[start.unwrap()..self.pos];
		unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
	}

	#[inline]
	fn _read_next_line(&mut self) {
		self.pos = 0;
		self.buf.clear();
		if self.reader.read_until(b'\n', &mut self.buf).unwrap() == 0 {
			panic!("Reached EOF");
		}
	}
}



Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <stack>
#include <map>
#include <unordered_map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

int main() {
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;
    REP(i,a) {
        if (s[i] == '-') {
            cout << "No" << endl;
            return 0;
        }
    }
    if (s[a] != '-') {
        cout << "No" << endl;
        return 0;
    }
    REP(j,b) {
        if (s[a+1+j] == '-') {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
import sys
for n in sys.stdin:
	l=map(int,n.split())
	b=l[0]*l[1]
	u=[max(l),min(l)]
	while u[1]!=0:
		u=[u[1],u[0]%u[1]]
	print "%d %d"%(u[0],b/u[0])

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

int main(){
    int arr[5],i;
    for(i=0;i<5;i++)
    cin>>arr[i];
    for(i=0;i<5;i++){
        if(arr[i]==0)
        break;
    }
    cout<<i+1;
    return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  c *= 2;
  
  int n = max(x,y);
  int ans = 1 << 30;
  for(int i = 0; i <= n; i++){
    int tmp = 0;
    tmp += i * c;
    if(i<x) tmp += (x-i) * a;
    if(i<y) tmp += (y-i) * b;
    
    chmin(ans, tmp);
  }
  
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.000001
#define pi 3.141592653589793
#define pii pair<int , int>
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vii vector<int>
#define vpl vector<pll>
#define vll vector<ll>
#define sti stack <int>
#define stll stack <ll>
#define mseti set <ll>
#define msetd multiset <ll, greater <ll> >
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define stp setprecision(20)//use fixed before stp
#define endl '\n'
int main()
{  
    FAST
    ll n,w;
    cin>>n>>w;
    pll p[n];
    for(ll i=0;i<n;i++)
    {
        cin>>p[i].ff>>p[i].ss;
    }
    ll dp[w+1];
    for(ll i=1;i<=w;i++)
    {
        dp[i]=-1;
    }
    dp[0]=0;
    for(ll i=0;i<n;i++)
    {
        for(ll j=(w-p[i].ff);j>=0;j--)
        {
            if(dp[j]==-1)
                continue;
            if((dp[j]+p[i].ss)>dp[j+p[i].ff])
            {
                dp[j+p[i].ff]=(dp[j]+p[i].ss);
            }
        }
    }
    ll ans=0;
    for(ll i=1;i<=w;i++)
    {
        if(ans<dp[i])
            ans=dp[i];
    }
    cout<<ans;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <stack>
#include <unordered_map>
#include <utility>
#include <vector>

// Aliases
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;

using std::cout;
using std::cerr;
using std::cin;
using std::endl;
using std::string;
using std::vector;
using std::array;

int main()
{
    u32 a, b;
    cin >> a >> b;
    if (1 <= a && a <= 9 && 1 <= b && b <= 9)
    {
        cout << a * b << endl;
    }
    else
    {
        cout << -1 << endl;
    }
        

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define PI pair<int,int>
#define PL pair<long int,long int>
#define PLL pair<ll,ll>
#define Tcase int t;cin>>t;while(t--)   
int main(){
int n;cin>>n;int temp;set<string> a;
  while(n--){
  
    string s;
    cin>>s;
    a.insert(s);
    temp=a.size();
  }
  cout<<temp<<"\n";
return 0;
}

Measured memory_bytes: 19124
#include "bits/stdc++.h"
using namespace std;
#ifdef LOCAL
#define debug(x)   cerr<<#x<<" = "<<x<<endl
#else
#define debug(x) 
#endif
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define pii pair<int,int>
#define endl '\n'
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
const int inf = 1e18 + 5;
signed main()
{
    #ifdef LOCAL
        input_from_file;
        output_to_file;
    #endif 
    IOS
    int h,a; cin>>h>>a;
    int ans;
    if(h%a == 0) ans = h/a;
    else ans = h/a + 1;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,j) for (int (i)=0;(i)<(int)(j);++(i))
#define put(i) cout << (i) << endl
using namespace std;
typedef long long ll;
const int mod = 1e9+7;

int main() {
    int a,b,h; cin >> a >> b >> h;
    cout << (a+b)*h/2 << endl;
}


Measured memory_bytes: 256
// Problem: E - TrBBnsformBBtion
// Contest: AtCoder - AtCoder Regular Contest 071
// URL: https://atcoder.jp/contests/arc071/tasks/arc071_c
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll N = 1e6 + 5;

string s, t;
int ps[N], pt[N];

int32_t main() { cin.tie(0)->sync_with_stdio(0);
  cin >> s >> t;
  int n = s.size(), m = t.size();
  s = ' ' + s, t = ' ' + t;
  for (int i = 1; i <= n; i++) {
    if (s[i] == 'A') ps[i] = ps[i - 1] + 1;
    else ps[i] = ps[i - 1] + 2;
  }
  for (int i = 1; i <= m; i++) {
    if (t[i] == 'A') pt[i] = pt[i - 1] + 1;
    else pt[i] = pt[i - 1] + 2;
  }
  int q;
  cin >> q;
  while (q--) {
    int ls, rs, lt, rt;
    cin >> ls >> rs >> lt >> rt;
    int l = ps[rs] - ps[ls - 1];
    int r = pt[rt] - pt[lt - 1];
    if ((r - l) % 3 == 0) {
      cout << "YES\n";
    } else {
      cout << "NO\n";
    }
  }
}

Measured memory_bytes: 4552
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int Q;
vector<vi> ban;

signed main(){

    in(Q);
    ban.resize(9);
    rep(i,9) ban[i].assign(9,1);
    rep(i,9) {
        ban[i][0]=0;ban[0][i]=0;
    }
    for(int i=1;i<9;i+=2){
        for(int j=2;j<9;j+=2){
            ban[i][j]=0;
        }
    }
    // show(ban);
    rep(i,9){
        REP(j,1,9) ban[i][j]+=ban[i][j-1];
    }
    rep(i,9){
        REP(j,1,9) ban[j][i]+=ban[j-1][i];
    }/*
    rep(i,9){
        show(ban[i]);
    }*/
    int a,b,c,d;
    while(Q--){
        in(a,b,c,d);
        // show(ban[c][d],ban[a-1][d],ban[c][b-1],ban[a-1][b-1]);
        printf("%lld\n",ban[c][d]-ban[a-1][d]-ban[c][b-1]+ban[a-1][b-1]);
    }

    return 0;
}



Measured memory_bytes: 3236
import math
count = 0
a, b = map(int, input().split())
k = 10 * b
while 10 * b <= k < 10*b + 10:
  if math.floor(0.08 * k) == a:
    print(k)
    count += 1
    break
  else:
    k += 1

if count == 0:
  print(-1)

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

int main( void )
{
	vector <bool> isPrime( 51000 + 1 );
	isPrime[2] = true;
	for ( int i = 3; i < 51000; i += 2 )
	{
		isPrime[i] = true;
	}

	for ( int i = 3; i < 51000; i += 2 )
	{
		for ( int j = i + i; j < 51000; j += i )
		{
			isPrime[j] = false;
		}
	}

	vector <int> primes;
	primes.push_back( 2 );
	for ( int i = 3; i < 51000; i += 2 )
	{
		if ( isPrime[i] )
			primes.push_back( i );
	}

	int n;
	while ( cin >> n && n != 0 )
	{
		int kotae = 0;
		for ( int i = 0; i < primes.size(); i++ )
		{
			if ( primes[i] <= n / 2 )
			{
				if ( isPrime.at( n-primes[i] ) )
					kotae++;
			}
		}
		cout << kotae << endl;
	}

	return 0;
}

Measured memory_bytes: 964
#!/usr/bin/env python3
import numpy as np


def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

def seachPrimeNum(N):
    max = int(np.sqrt(N))
    seachList = [i for i in range(2, N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]


def prime3(n):
    counter = 0
    primes = [2, 3]

    for n in range(5, n, 2):
        isprime = True
        for i in range(1, len(primes)):
            counter += 1
            if primes[i] ** 2 > n:
                break
            counter += 1
            if n % primes[i] == 0:
                isprime = False
                break
        if isprime:
            primes.append(n)
    return primes

a,b=map(int,input().split())
# a=b=10**10
count=0
ad=set(make_divisors(a))
bd=set(make_divisors(b))
# print(ad)
common=ad & bd
# print(common)
l=[]
for s in common:
    if is_prime(s):
        count+=1
print(count+1)
# pr=set(seachPrimeNum(max(common)))
# ans=common & pr 
# print(ans)
# print(len(ans)+1)



Measured memory_bytes: 14184
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,i;
  int d;
  int sum=0;
  int amou=0;
  cin>>N;
    for(i=0;i<N;i++){
      cin>>d;
      sum+=d;
      amou+=d*d;
    }
  cout<<(sum*sum-amou)/2<<endl;
}

Measured memory_bytes: 256
#include <iostream>

int main (void) {
  int N, K;
  std::cin >> N >> K;
  int x[N];
  for (int i = 0; i < N; ++i) {
    std::cin >> x[i];
  }

  int len;
  int min_len = std::abs(x[0]) + std::abs(x[0] - x[0 + K - 1]);
  int min_l = x[0], min_r = x[0 + K - 1];
  for (int i = 0; i + K - 1< N; ++i) {
    len = std::abs(x[i]) + std::abs(x[i] - x[i + K - 1]);
    if (len < min_len) {
      min_len = len;
      min_l = x[i];
      min_r = x[i + K - 1];
    }
    len = std::abs(x[i + K - 1]) + std::abs(x[i] - x[i + K - 1]);
    if (len < min_len) {
      min_len = len;
      min_l = x[i + K - 1];
      min_r = x[i];
    }
  }
  std::cout << min_len << std::endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
typedef pair<lli,lli> P;
//const int MAX=1e5+5;


int H,W;
int c[400][400];
bool rh[400][400];

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

P dfs(int x,int y){
	P r;
	if(c[x][y]==0)r=make_pair(1,0);
	else r=make_pair(0,1);
	rh[x][y]=true;
	rep(k,4){
		int nx=x+dx[k], ny=y+dy[k];
		if(0<=nx && nx<H && 0<=ny && ny<W && !rh[nx][ny] && c[x][y]+c[nx][ny]==1){
			P s=dfs(nx,ny);
			lli white=r.first+s.first, black=r.second+s.second;
			r=make_pair(white, black);
		}
	}
	return r;
	
}

int main(){
	cin>>H>>W;
	rep(i,H)rep(j,W){
		char qqq;
		cin>>qqq;
		if(qqq=='.')c[i][j]=0;
		else c[i][j]=1;
	}
	lli ans=0;
	rep(i,H)rep(j,W)if(!rh[i][j]){
		P p=dfs(i,j);
		lli wh=p.first, bl=p.second;
		ans+=wh*bl;
	}
	cout<<ans;
}

Measured memory_bytes: 13568
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
const int INF = 1e6;
using namespace std;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int n,m,l;
    cin >> n >> m >> l;
    vector< vector< int > > matrix_A(n,vector<int>(m)),matrix_B(m,vector<int>(l));
    rep(i,n){
        rep(j,m){
            cin >> matrix_A[i][j];
        }
    }
    rep(i,m){
        rep(j,l){
            cin >> matrix_B[i][j];
        }
    }
    vector< vector<long> >matrix_ans(n,vector<long>(l));
    rep(i,n){
        rep(j,l){
            rep(k,m){
                matrix_ans[i][j] += matrix_A[i][k] * matrix_B[k][j];
            }
        }
    }
    rep(i,n){
        rep(j,l){
            cout << matrix_ans[i][j] << (j == l-1 ? '\n' : ' ');
        }
    }
}


Measured memory_bytes: 3252
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

class Program
{
    static void Main()
    {
        string S = Console.ReadLine();
        bool ans = false;

        if (S.StartsWith("A", StringComparison.Ordinal))
        {
            if (S.Substring(2, S.Length - 2 - 1).Count(ch => ch == 'C') == 1)
            {
                var tmp = S.Replace("C", "").Replace("A", "");
                if (tmp.ToLower() == tmp)
                {
                    ans = true;
                }
            }
        }

        Console.WriteLine(ans ? "AC" : "WA");
    }
    
}



static class MathUtil
{
    public static IEnumerable<IEnumerable<int>> GetPermutation(int n)
    {
        if (n == 0)
        {
            yield return Single(0);
            yield break;
        }

        for (int i = 0; i <= n; i++)
        {
            foreach (var x in GetPermutation(n - 1))
            {
                yield return Single(i).Concat(x.Select(itm => itm < i ? itm : itm + 1));
            }
        }
    }

    private static IEnumerable<int> Single(int x)
    {
        yield return x;
    }

    public static IEnumerable<int> EnumeratePrimeNumbers()
    {
        List<int> primes = new List<int>() { 2 };
        yield return 2;

        for (int i = 3; i < int.MaxValue; i++)
        {
            bool isPrime = true;
            int Sqrt = (int)Math.Sqrt(i) + 1;

            foreach (var prime in primes)
            {
                if (prime > Sqrt)
                {
                    break;
                }
                if (i % prime == 0)
                {
                    isPrime = false;
                    break;
                }
            }

            if (isPrime)
            {
                primes.Add(i);
                yield return i;
            }
        }
    }
}



Measured memory_bytes: 11220
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>
#include <map>
#include <numeric>
#include <functional>
#include <utility>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;

int main(void) {
  int k;
  cin >> k;
  int a, b;
  cin >> a >> b;
  bool ans = false;
  for (int i = a; i <= b; ++i) {
    if (i % k == 0) {
      ans = true;
    }
  }
  cout << (ans ? "OK" : "NG") << endl;

  return 0;
}


Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {

	//??????????????????????????°
	public static void main(String[] args) {

		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		try {
			String s = input.readLine();
			StringBuffer str = new StringBuffer(s);
			s = str.reverse().toString();
			System.out.println(s);
		} catch (IOException e) {
			// TODO ????????????????????? catch ????????????
			e.printStackTrace();
		}
		
		
		
	}

}

Measured memory_bytes: 23668
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n;
    cin >> n;
    vll vec(n);
    REP(i, n) cin >> vec.at(i);
    ll current = 0;
    ll counter = 0;
    vector<bool> visited(n, false);
    while (!visited.at(current)) {
        visited.at(current) = true;
        current = vec.at(current)-1;
        counter++;
        if (current == 1) {
            cout << counter << endl;
            return 0;
        }
    }
    cout << "-1" << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <sstream>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	int s;
	int max_n = 26;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	std::cin.rdbuf(ifs.rdbuf());
#endif

	while(std::cin >> s){
		if(s == 0){ break; }
		int min_val = 1000000000;

		for(int a = 0; a < max_n; a++){
			if(200 * a > s){ break; }
			for(int b = 0; b < max_n; b++){
				if(200 * a + 300 * b > s){ 
					break;
				}
				for(int c = 0; c < max_n; c++){
					if(200 * a + 300 * b + 500 * c > s){
						break;
					}
					if(200 * a + 300 * b + 500 * c == s){
						int val = 380 * 0.8 * (a - a % 5) + 380 * (a % 5) +
							550 * 0.85 * (b - b % 4) + 550 * (b % 4) +
							850 * 0.88 * (c - c % 3) + 850 * (c % 3);
						min_val = std::min(min_val, val);
					}
				}
			}
		}
		
		std::cout << min_val << std::endl;
	}


#if INPUT_FROM_FILE
		//fclose(fp);
#endif
	return 0;
}



Measured memory_bytes: 3000
import scala.io.StdIn

object Main extends App {
  val n  = StdIn.readLine().toInt
  val x  = StdIn.readLine().split(" ").map(_.toInt)
  val y  = StdIn.readLine().split(" ").map(_.toInt)  

  def solve(x: Array[Int], y: Array[Int]): Int = {
    val a = x zip y
    a.map{ v =>
      v._1 - v._2
    }.filter(_ > 0).sum
  }
  println(solve(x, y))

}
  




Measured memory_bytes: 27332
#include<iostream>
#include<cstdio>
#include<math.h>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<map>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
string s;
string t = "YAKI";

int main()
{
	cin >> s;
	int ope = 0;
	for (int i = 0; i < 4; i++) {
		if (s[i] != t[i])ope++;
	}
	if (ope != 0)cout << "No" << endl;
	else cout << "Yes" << endl;


	return 0;
}

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

int main()
{
	int r, c;
	int i, j;
	int a;
	int sum[100] = {};
	int sum2[100] = {};
	int sum3 = 0;

	cin >> r >> c;
	for (i = 0; i<r; i++) {
		for (j = 0; j<c; j++) {
			cin >> a;
			cout << a << " ";

			sum[i] += a;
			sum2[j] += a;
			sum3 += a;
		}
		cout << sum[i] << endl;
	}
	for (i = 0; i < c; i++)
		cout << sum2[i] << " ";
	cout << sum3 << endl;

	return 0;
}

Measured memory_bytes: 3020
# coding: utf-8
# Your code here!
n = int(input())
a=[]
for j in range(n):
    m=[i for i in input().split()]
    mm = [m[0]]+[-int(m[1])]+[j+1]
    a.append(mm)
    
a.sort()

for i in a:
    print(i[2])



Measured memory_bytes: 3060
/**/
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>

typedef long long LL;
typedef unsigned long long ULL;
using namespace std;

const LL INF = 99999999999999;
const int inf = 999999999;
int a, p;

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	while(scanf("%d%d", &a, &p) == 2) {
		printf("%d\n", (a * 3 + p) / 2);
	}

	return 0;
}
/*
    input:
    output:
    modeling:
    methods:
    complexity:
    summary:
*/

Measured memory_bytes: 256
import math
a,b,x =map(int,input().split( ))
if x >= (a**2*b/2):
    k=2*x/(a**2)-b
    cos=math.sqrt((b-k)**2/((a**2)+(b-k)**2))
else:
    k=2*x/(a*b)
    cos=math.sqrt(b**2/(b**2+k**2))
print(90-math.degrees(math.acos(cos)))

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

#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
#define endl '\n'
// #define int long long

typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int p, q, r;
int32_t main()
{
	IOS
	//freopen("input.txt", "r", stdin);
	cin >> p >> q >> r;
	cout << p+q+r - max({p, q, r}) << endl;
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

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

print(max(aa)-min(aa))

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

int main() {
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  double rate = -1;
  int ans1 = 100 * A, ans2 = 0;
  for (int a = 0; a <= F / (100 * A); a++) {
    for (int b = 0; b <= (F - 100 * A * a) / (100 * B); b++) {
      for (int c = 0; c * C <= E * (a * A + b * B); c++) {
        int d = min(F - 100 * (a * A + b * B) - c * C,
                    (E * (a * A + b * B) - c * C)) /
                D;
        if (c + d > 0 && 100 * a * A + 100 * b * B + c * C + d * D <= F) {
          if (rate < (double)(c * C + d * D) /
                         (100 * (a * A + b * B) + c * C + d * D)) {
            rate = (double)(c * C + d * D) /
                   (100 * (a * A + b * B) + c * C + d * D);
            ans1 = 100 * a * A + 100 * b * B + c * C + d * D;
            ans2 = c * C + d * D;
          }
        }
      }
    }
  }
  cout << ans1 << " " << ans2 << endl;
  return 0;
}

Measured memory_bytes: 256
import Control.Monad
import Data.Array.Unboxed
import Data.Array.ST

main = do
  [n,m,q] <- (map read . words) <$> getLine
  lrlist <- replicateM m (getLine >>= return . (\l -> (head l, head $ tail l)) . map read . words)
  pqlist <- replicateM q (getLine >>= return . (\l -> (head l, head $ tail l)) . map read . words)
  let train2dimsum = train_number_array_from n lrlist
  forM_ pqlist (query train2dimsum)

query train2dimsum (p, q) =
  print answer
  where answer =
          train2dimsum!(q,q) -
            if p == 1 then
              0
            else
              train2dimsum!(q,p-1) + train2dimsum!(p-1,q) - train2dimsum!(p-1,p-1)

train_number_array_from n lrlist = runSTUArray $ do
  tstarray <- newArray ((1,1), (n,n)) (0 :: Int)
  forM_ lrlist (update_train_number_array tstarray)
  forM_ [1 .. n] $ \x -> do
    forM_ [1 .. n] $ \y -> do
      v <- readArray tstarray (x,y)
      s <- if x == 1 then return 0 else readArray tstarray (x-1,y)
      writeArray tstarray (x,y) (s+v)
  forM_ [1 .. n] $ \x -> do
    forM_ [1 .. n] $ \y -> do
      v <- readArray tstarray (x,y)
      s <- if y == 1 then return 0 else readArray tstarray (x,y-1)
      writeArray tstarray (x,y) (s+v)
  return tstarray

update_train_number_array tstarray lr = do
  num <- readArray tstarray lr
  writeArray tstarray lr (num + 1)


Measured memory_bytes: 208124
#include<iostream>
using namespace std;
typedef long long int ll;
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string a;
  ll n,x;
  cin>>n;
  cin>>a;
  for(ll i=0;i<a.size();i++)
  {
    x=(int)a[i];
    ll k=0;
    while(k!=n)
    {
        k++;
		x++;
        if(x==91)
          x=65;
    } 
    a[i]=(char)x;
  }
  cout<<a<<"\n";
  return 0;
}  

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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin >> n;
    int arr[n];
    for (int i = 0; i != n; ++i)
        cin >> arr[i];
    
    int ans[n];
    int m = 0;
    for (int i = n - 1; i != -1; --i)
    {
        ans[i] = arr[i];
        for (int j = 2 * i + 1; j < n; j += (i + 1))
            ans[i] ^= ans[j];
        m += ans[i];
    }
    
    cout << m << '\n';
    for (int i = 0; i != n; ++i)
        if (ans[i])
            cout << i + 1 << '\n';
    
    return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
int main(void){
  int p,i,c[101]={},ans=0;
  for (i=0;i<3;i++){
    scanf("%d",&p);
    c[p]=1;
  }
  for (i=1;i<=100;i++){
    if (c[i]) ans++;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
/* To Kaise Hain Aaplog*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) (x).begin(), (x).end()

void shuru_krte_hai_bina_kisi_bakchodi_ke()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}
const ll m = 998244353;

int main()
{
    //shuru_krte_hai_bina_kisi_bakchodi_ke();

    /* long long yaad se daal de har jagah*/
    # define int long long

    int n,m;
    cin>>n>>m;
    int a[n+1],b[m+1];
    int k;
    cin>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=1;i<=m;i++){
        cin>>b[i];
    }
    b[0] = 0;
    a[0] = 0;
    for(int i=2;i<=n;i++){
        a[i]+=a[i-1];
    }
    int ans = 0;
    int sum = 0;
    for(int i=0;i<=m;i++){
        sum+=b[i];
        int to_find = k-sum;
        if(to_find<0){
            break;
        }
        int l = 1;
        int r = n;
        int mid = l + (r-l)/2;
        int c=0;
        while(l<=r){
            mid = l + (r-l)/2;
            //deb2(mid,c);
            if(a[mid]<=to_find ){
                c = mid;
                l = mid+1;
            }else{
                r = mid-1;
            }
        }
        ans = max(ans,c+i);
    }
    
    cout<<ans;
    return 0;
}


Measured memory_bytes: 6736
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    int x;
    cin>>x;
    cout<<((x==3||x==5||x==7)?"YES":"NO")<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
	char s[11],ans[11]="";
	scanf("%s",s);
	for(int i=0;i<strlen(s);i++){
		if(s[i] == 'B'){
			ans[strlen(ans)-1] = '\0';
		}else{
			ans[strlen(ans)]=s[i];
		}
	}
	printf("%s",ans);
	return 0;
}

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

int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  int count = 0;
  
  if(k <= a){
    count += k;
  }
  else{
    count += a;
    k -= a;
    
    if(k <= b){
      count += 0;
    }
    else{
      k -= b;
      count -= k;
    }
  }
  cout << count << endl;
}

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

int main() {
	int m, f, r, sum;
	char grade;
	while (1) {
		cin >> m >> f >> r;
		if (m == -1 && f == -1 && r == -1)break;
		sum = m + f;
		if (m == -1 || f == -1 || sum < 30)grade = 'F';
		else if (sum >= 80)grade = 'A';
		else if (sum >= 65)grade = 'B';
		else if (sum >= 50 || r >= 50)grade = 'C';
		else grade = 'D';
		cout << grade << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll long long int
#define pb push_back
#define mp make_pair
#define ld long double
#define sz(a) (ll)(a).size()

typedef tree<pair<ll,ll> ,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest
//cout << k << "kth smallest: " << *A.find_by_order(k-1) << endl;
//NO OF ELEMENTS < X
//cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

const int MAXN = 305;

ld n, dp[MAXN][MAXN][MAXN];          // Expected time with val1 1s, val2 2s and val3 3s
ll a[MAXN], n1, n2, n3;

ld rec(ll val1, ll val2, ll val3)
{
	if( (val1 == 0 && val2 == 0 && val3 == 0) || val1 < 0 || val2 < 0 || val3 < 0) return 0;
	if(dp[val1][val2][val3] != -1) return dp[val1][val2][val3];
	return dp[val1][val2][val3] = ((1.00 + ((ld)val1 / n) * rec(val1 - 1, val2, val3) + ((ld)val2 / n) * rec(val1 + 1, val2 - 1, val3) + ((ld)val3 / n) * rec(val1, val2 + 1, val3 - 1)) * n) / ((ld)(val1 + val2 + val3)) ;
}

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

	cin >> n;
	for(int i=0;i<n;i++) 
	{	
		cin >> a[i];
		n1 += (a[i] == 1);
		n2 += (a[i] == 2);
		n3 += (a[i] == 3);
	}	
	memset(dp, -1, sizeof(dp));
	printf("%.15Lf\n", rec(n1, n2, n3));
    return 0;
}

Measured memory_bytes: 443648
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10

    A,V = LMIIS()
    B,W = LMIIS()
    T = II()

    if abs(A-B) <= T * (V-W):
        print('YES')
    else:
        print('NO')
    
main()

Measured memory_bytes: 65176
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
import java.util.Arrays;

public class Main {
	public static void main(final String[] args){
    
    final Scanner sc = new Scanner(System.in);
    final List<Integer> list = new ArrayList<>();
    //final List<Long> list2 = new ArrayList<>();

    String s = sc.next();

    if(s.equals("SSS")){
        System.out.println(0);
    }else if(s.equals("SRS") || s.equals("SSR") || s.equals("RSS") || s.equals("RSR")){
        System.out.println(1);
    }else if(s.equals("SRR") || s.equals("RRS")){
        System.out.println(2);
    }else{
        System.out.println(3);
    }


    

   
    





}
}

Measured memory_bytes: 35632