akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout<<"Case #"<<x<<": ";
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat

int main(int argc, char const *argv[])
{
	sync;
	ll n, k;
	cin >> n >> k;
	ll a[n+5];
	rep(i,n){
		cin >> a[i];
	}
	for (int i = k; i < n; i++){
		if (a[i] > a[i-k]){
			cout << "Yes" << endl;
		}
		else{
			cout << "No" << endl;
		}
	}
	return 0;
}


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

long long N, A, B, C, D;

int main() {
  scanf("%lld%lld%lld%lld%lld", &N, &A, &B, &C, &D);
  vector<long long> left;
  for(long long k = 0; k <= N - 1; ++k) {
    long long l = N - 1 - k;
    left.push_back(k * C - l * D);
  }
  int a = (upper_bound(left.begin(), left.end(), B - A) - left.begin()) - 1;
  if(a < 0) printf("NO\n");
  else {
    printf("%s\n", B - A <= left[a] + (D - C) * (N - 1) ? "YES" : "NO");
  }
  return 0;
}


Measured memory_bytes: 6512
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int rows = input.nextInt(); // rows
        int cols = input.nextInt(); // cols
        int[][] house = new int[12][10];
        int[][] a = new int[rows][cols];
        int[] b = new int[cols];
        // Build matrix A
        for(int row = 0; row < rows; row++){
            for(int col = 0; col < cols; col++){
                a[row][col] = input.nextInt();
            }
        }

        // Build vector B
        for(int col = 0; col < cols; col++){
            b[col] = input.nextInt();
        }

        // Multiple out
        int[] result = new int[rows];

        for(int row = 0; row < rows; row++){
            for(int col = 0; col < cols; col++){
                int temp =  a[row][col] * b[col];
                result[row] += a[row][col] * b[col];
            }
        }

        // Display result
        for(int i : result){
            System.out.println(i);
        }
    }
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define endl "\n"     
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

const int mod=1e9+7;

int n,k,a[102];
int dp[102][100005],sum[102][100005];

int32_t main()
{
	IOS;
	
	cin>>n>>k;
	
	for(int i=1;i<=n;i++)
	     cin>>a[i];
	
	for(int i=0;i<=k;i++)
	     sum[0][i]=1;
	
	for(int i=1;i<=n;i++)
	{
	     for(int j=0;j<=k;j++)
	     {
	          dp[i][j]=(sum[i-1][j]-(j-a[i]-1>=0?sum[i-1][j-a[i]-1]:0)+mod)%mod;
	          sum[i][j]=((j?sum[i][j-1]:0)+dp[i][j])%mod;
	     }
	}
	cout<<dp[n][k];
	
	return 0;
}

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

int Hukuri(int y, int m, double n, int t) {
	// printf("hukuri,  %d, %d, %lf, %d\n", y, m, n, t);
	for (int i=0; i<y;i++) {
		m += m*n;
		m -= t;
	}
	// printf("\n Ans %d \n", m);
	return m;
}

int Tanri(int y, int m, double n, int t) {
	// printf("tanri,  %d, %d, %lf, %d\n", y, m, n, t);
	int risi=0;
	for (int i=0; i<y; i++) {
		risi += m*n;
		m -= t;
	}
	// printf("\n Ans %d \n", m+risi);
	return m+risi;
}

int main() {
	int m, M, Y, n, type, T;
	double Nenri;
	scanf("%d", &m);
	for (int i=0; i<m; i++) {
		int max=0;
		scanf("%d%d%d", &M, &Y, &n);
		for (int j=0; j<n;j++) {
			int L;
			scanf("%d%lf%d", &type, &Nenri, &T);
			if(type) {
				L = Hukuri(Y, M, Nenri, T);
			} else {
				L = Tanri(Y, M, Nenri, T);
			}
			if (max < L) {max = L;}
		}
		printf("%d\n", max);
	}
}

Measured memory_bytes: 1216
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Usize1},
};

fn main() {
    input!{
        n : usize,
        a : [i64; n]
    }
    let mut now: i64 = 0;
    let mut ans: i64 = 0;
    for i in a {
        if now > i {
            ans += now-i;
        }else{
            now = i;
        }
    }
    println!("{}",ans);
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int a[5];
    int k;
    inc(i, 0, 5) cin >> a[i];
    cin >> k;
    string ans = "Yay!";
    inc(i, 0, 5){
        inc(j, i+1, 5){
            if(a[j]-a[i] > k) ans = ":(";
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//Compete against Yourself.
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, d, maxHealth, pref[N];
vector<vector<int>> X;


int32_t main(){_
   
   cin>>n>>d>>maxHealth;

   for (int i = 0; i < n; ++i)
   {
      int x, h;
      cin >> x >> h;
      X.push_back({x, h});
   }

   X.push_back({-inf, -inf});
   sort(X.begin(), X.end());

   int ans = 0;
   for (int i = 1; i <= n; ++i)
   {
      pref[i] += pref[i-1];
      int curr = X[i][1] - pref[i];
      if(curr <= 0)
         continue;
      int x = X[i][0]; 
      vector<int> tt = {x + 2*d, inf};
      auto it = upper_bound(X.begin(), X.end(), tt);
      --it;
      int idx = it - X.begin();
      int amt = (curr + maxHealth - 1) / maxHealth;
      ans += amt;
      int vals = amt * maxHealth;
      pref[i] += vals;
      pref[idx+1] -= vals;
   }
   
   cout<<ans;

   return 0;
}

Measured memory_bytes: 13740
n = STDIN.gets.to_i
array = STDIN.gets.split.map(&:to_i)

array.each_with_index do |num, idx|
  printf("node %d: key = %d,", idx + 1, num)
  printf(" parent key = %d,", array[(idx - 1) / 2]) if idx != 0
  printf(" left key = %d,", array[idx * 2 + 1]) if idx * 2 + 1 < array.size
  printf(" right key = %d,", array[idx * 2 + 2]) if idx * 2 + 2 < array.size
  printf(" \n")
end

Measured memory_bytes: 8680
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = new Date();
  Main();
  var end = new Date() - start;
  
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var one = nextIntArray();
	var N = one[0];
	var M = one[1];
	var output = [];
	var max = M * 2 + 1;
	var max2 = Math.floor(max / 2);
	for(var i = 0; i < Math.floor(M / 2); i++){
		output.push((i + 1) + " " + (max2 - i));
	}
	var min = max2 + 1;
	for(var i = 0; i < Math.ceil(M / 2); i++){
		output.push((min + i) + " " + (max - i));
	}
	
	myout(myconv(output,9));
}


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

int main(){
  int N,Q; cin>>N>>Q;
  string s; cin>>s;
  vector<int> l(Q),r(Q);
  for(int i=0;i<Q;i++){
    cin>>l[i]>>r[i];
  }
  vector<int> sum(N+1,0);
  for(int i=1;i<N;i++){
    sum[i+1]=sum[i];
    if(s[i-1]=='A' && s[i]=='C'){
      sum[i+1]++;
    }
  }
  for(int i=0;i<Q;i++){
    int ans=sum[r[i]]-sum[l[i]];
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 2176
from collections import Counter
import sys
n=int(input())
a=sorted(list(map(int,input().split())))
 
c=[1 for i in range(10**6+1)]
d = Counter(a)
s = list(set(a))
count = 0
if d[1] == 1:
  print(1)
  sys.exit()
elif d[1] >=2:
  print(0)
  sys.exit()
for x in s:
  t = x * 2
  while t <= 10 ** 6:
    c[t] = 0
    t += x
 
for x in a:
  if d[x] == 1 and c[x] == 1:
    count += 1
print(count)

Measured memory_bytes: 52924
#include<bits/stdc++.h>
#define FOR0(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define FORl(i,l,n) for(ll i=l;i<n;i++)
using namespace std;
#define pi pair<ll,ll>
#define pb push_back
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<int>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e18



int main(){
	int n;
	cin >> n;
	string s;
	int mx = 0;
	map <string, int> ma;
	FOR0(i, n){
		cin >> s;
		ma[s]++;
		mx = max(mx, ma[s]);
	}
	vector <string> ans;
	for (auto x: ma){
		if (x.ss==mx){
			ans.pb(x.ff);
		}
	}
	sort(ans.begin(), ans.end());
	FOR0(i, ans.size()){
		cout << ans[i] << endl;
	}


}

Measured memory_bytes: 26868
#include <stdio.h>

int main(){

  int N,i,j,a,flag,count,minj,A[100];
  count=0;
  flag=0;
  
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<=N-1;i++){
    minj=i;
    for(j=i;j<=N-1;j++){
      if(A[j]<A[minj]){
	minj=j;
	flag=1;
      }
    }
    if(flag==1){
      count++;
      flag=0;
    }
    a=A[i];
    A[i]=A[minj];
    A[minj]=a; 
  }
  for(i=0;i<N-1;i++){
    printf("%d ",A[i]);
  }  
  printf("%d\n",A[N-1]);
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
int gcd(int p, int q){//アルゴリズムを実験で明確にしてから実装
  if (p % q == 0){
    return q;
  }
  return gcd(q, p%q);
}
int main(void){
  int K;
  cin >> K;
  int sum =0;
  for (int i=1; i<=K; i++){//ゼロ割に注意
    for (int j=1; j<=K; j++){
      for (int k=1; k<=K; k++){
        sum += gcd(gcd(i, j), k);
      }
    }
  }
  cout << sum << endl;
}

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

int N,A,B;

int main()
{       
        cin >> N >> A >> B;
        int ans = 0;
        for(int i=1;i<=N;i++){
                int tmp = i;
                int sum10 = 0;
                while(tmp!=0){
                        sum10+=tmp%10;
                        tmp /= 10;
                }       
                if(A<=sum10&&sum10<=B){
                        ans += i;
                }       
        }       
        cout << ans << endl;
}       

Measured memory_bytes: 256
// Veryfied
// AOJ ALDS1_1 A Getting Started - Insertion Sort
#include <iostream>
#include <vector>

using namespace std;

void Print(const vector<int> &a)
{
    for (int i = 0; i < a.size(); ++i)
        cout << a[i] << (i == a.size() - 1 ? '\n' : ' ');
}

// 挿入ソート
void insertion_sort(vector<int> &a)
{
    Print(a);
    for (int j = 1; j < a.size(); ++j) {
        int key = a[j];
        int i = j - 1;

        while (i >= 0 && key < a[i]) {
            a[i + 1] = a[i];
            i--;
        }
        a[i + 1] = key;
        Print(a);
    }
}

int main()
{
    int N;

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

    return 0;
}

Measured memory_bytes: 1200
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL F;
	in >> F;
	out << (F - 30) / 2 << std::endl;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a[100010];
  long long sum = 1, ans = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  for (long long i = 0; i < n; i++) {
    if (a[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
    if (sum > 1000000000000000000 / a[i]) {
      ans = -1;
      break;
    }
    sum *= a[i];
  }
  if (ans != -1) {
    ans = sum;
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 4548
#include<stdio.h>
#include<math.h>
int main(void){
    double a,b,c,d,e,f,A,x,y,X,Y,Z;
 
    while(scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f)!=EOF){
 
 
    Y=a*e-b*d,Z=f*a-c*d;
    y=Z/Y;
 
    x=(c-b*y)/a;
 
   printf("%.3lf %.3lf\n",x,y);
    }
 
    return 0;
}

Measured memory_bytes: 1080
#include <iostream>
#include <utility>
#include <algorithm>
using namespace std;

int main(void) {
int a, b, c, x, y;
long long p1, p2, p3;

std::cin >> a >> b >> c >> x >> y;

//少ない方までABを買う時
p1 = c*2*min(x,y) + a*(x-min(x,y)) + b*(y-min(x,y));


//多い方までABを買う時
p2 = c*2*max(x,y);


//そのまま買う時
p3 = a*x + b*y;


std::cout << min(p3,min(p1,p2)) << '\n';

return 0;
}


Measured memory_bytes: 256
#include<map>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
string a[200009];
 
map<string,int>rr;
string b[200009];
int main(){
	int n;
	cin>>n;
	int maxn=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		rr[a[i]]++;
		if(rr[a[i]]>maxn){
			maxn=rr[a[i]];
		}
	}
	int ans=0;
	for(int i=0;i<n;i++){
		if(rr[a[i]]==maxn){
			b[ans]=a[i];
			rr[a[i]]=0;
			ans++;
		} 
	}
	sort(b,b+ans);
	for(int i=0;i<ans;i++){
		cout<<b[i]<<endl;
	}
}


Measured memory_bytes: 28288
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
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[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n;
  cin >> n;
  vector<int>vec(n);
  rep(i,n) cin >> vec[i];
  
  vector<int>num(1e6+1,0);
  rep(i,n)num[vec[i]]++;
  
  int ans = 0;
  for(auto i:vec){
    int add = 1;
    num[i]--;
    for(int j=1;j*j<=i;j++){
      if(i%j!=0)continue;
      if(num[j]){
        add = 0;
        break;
      }
      if(num[i/j]){
        add = 0;
        break;
      }
    }
    num[i]++;
    ans += add;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7960
#include<bits/stdc++.h>
#define ll long long
using namespace std;
void solve()
{
	ll x;cin>>x;
	ll ans=0;
	if(x>=500)
		ans+=(1000)*(x/500);
	x-=(x/500)*500;
	if(x>5)
	{
		ans+=(5)*(x/5);
	}
	cout<<ans;

}
int main()
{
//	int t;cin>>t;
	//while(t--)
	solve();
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] x = new int[N+1];
    long min =300000000; 
    for (int i =1; i<=N; i++) {
      x[i] = sc.nextInt();
    }
    for (int i =1; i<=N-K+1; i++) {
      long ans =0;
      if (x[i] <=0 && x[i+K-1] >= 0) {
        ans = Math.min(Math.abs(x[i]) + (x[i+K-1] - x[i]),
                       Math.abs(x[i+K-1]) + (x[i+K-1] - x[i]));
      }
      if (x[i] <=0 && x[i+K-1] <=0) ans = Math.abs(x[i]);
      if (x[i] >=0 && x[i+K-1] >=0) ans = Math.abs(x[i+K-1]);
      min = Math.min(ans,min);
    }
    System.out.print(min);
  }
}

Measured memory_bytes: 59364
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

int Ask(int x){
	char buf[10];
	printf("%d\n", x);
	fflush(stdout);
	scanf("%s", buf);
	if(buf[0] == 'V') exit(0);
	return buf[0] == 'M';
}

int main()
{
	int n;
	read(n);
	
	int z = Ask(0);
	
	Ask(n-1);
	
	int l = 0, r = (n-1);
	while(l < r){
		int m = (l+r)/2;
		if(z == (Ask(m)^(m&1))) l = m;
		else r = m;
	}
	
	return 0;
}


Measured memory_bytes: 852
#include<bits/stdc++.h>
using namespace std;
#define INF (1<<30)

int main(){
  int N,R,T;
  cin >> N >> R >> T;
  int p[111];
  int t[1111]={0};
  int u[1111]={0};
  for(int i=0;i<N;i++){
    cin >> p[i];
  }
  int ans = 0;
  for(int i=0;i<T;i++){
    for(int j=0;j<N;j++){
      int now = p[j]*(i+1)%R;
      u[j] = now;
      if(t[now] == 0){
	ans++;
	t[now] = 1;
      }
      t[now]--;
    }
    if(i) for(int j=0;j<N;j++) t[u[j]]++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1168
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = Integer.parseInt(scanner.nextLine());

		List<List<Integer>> points = new ArrayList<>();
		List<Integer> start = new ArrayList<>();
		start.add(0);
		start.add(0);
		start.add(0);
		points.add(start);
		for (int i = 0; i < n; i++) {
			List<Integer> point = new ArrayList<>();
			String[] txy = scanner.nextLine().split(" ");
			point.add(Integer.parseInt(txy[0]));
			point.add(Integer.parseInt(txy[1]));
			point.add(Integer.parseInt(txy[2]));
			points.add(point);
		}

		for (int i = 1; i < n + 1; i++) {
			List<Integer> current = points.get(i - 1);
			List<Integer> target = points.get(i);
			int manhattan = manhattanDist(current.get(1), current.get(2), target.get(1), target.get(2));
			int seconds = target.get(0) - current.get(0);

			if (manhattan > seconds) {
				System.out.println("No");
				System.exit(0);
			}
			if ((seconds - manhattan) % 2 == 1) {
				System.out.println("No");
				System.exit(0);
			}
		}
		System.out.println("Yes");
	}

	public static int manhattanDist(int currentX, int currentY, int targetX, int targetY) {
		return Math.abs(targetX - currentX) + Math.abs(targetY - currentY);
	}
}

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

int main(void){
    long long n, m, ans=1, wa=1000000007;
    cin >> n >> m;
    if(abs(n-m) >= 2){
        cout << "0\n";
        return 0;
    }
    for(int i=1;i<=n;++i){
        ans *= i;
        ans %= wa;
    }
    for(int i=1;i<=m;++i){
        ans *= i;
        ans %= wa;
    }
    if(n==m) ans *= 2;
    ans %= wa;
    cout << ans << endl;
}

Measured memory_bytes: 256
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}
fn even(x: usize) -> bool {
    x % 2 == 0
}
fn odd(x: usize) -> bool {
    x % 2 == 1
}
fn main() {
    let s1 = read::<String>();
    let s = s1.chars().collect::<Vec<char>>();
    let n = s.len();
    //println!("{:?}", s);

    let mut dp = vec![0u64; n];
    let mut next_l = 0;
    let mut last_r = n-1;
    for i in 0..n {
        if s[i] == 'L' {
            next_l = i;
            last_r = i - 1;
            break;
        }
    }

    for i in 0..n {
        if s[i] == 'R' {
            if i > next_l {
                for j in i + 1..n {
                    if s[j] == 'L' {
                        next_l = j;
                        break;
                    }
                }
            }
            if even(next_l - i) {
                dp[next_l] += 1;
            } else {
                dp[next_l - 1] += 1;
            }
            last_r = i;
            //println!("{:?} {}", dp, first_L);
        } else {
            if even(i - last_r) {
                dp[last_r] += 1;
            } else {
                dp[last_r + 1] += 1;
            }
        }
    }
    let ans = dp.into_iter().map(|i| i.to_string()).collect::<Vec<String>>().join(" ");
    println!("{}", ans);
}


Measured memory_bytes: 10492
#include<iostream>
using namespace std;
int main(){
	int n,m;
	int i,j,k;
	int s=0;
	cin>>n>>m;
	s=(n-m)*100+m*1900;
	for(i=0;i<m;i++){s*=2;}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int x = scan.nextInt();
        int n = scan.nextInt();
        
        int minDiff = 10000;
        int closest = -2;
        boolean[] vals = new boolean[101];
        for(int i = 0 ; i < n ; i++) {
            vals[scan.nextInt()] = true;
            
        }

        
        for(int i = -1 ; i <= 101 ;i++) {
            if(i == -1 || i == 101 || !vals[i]) {
                if(minDiff > Math.abs(x-i)) {
                    minDiff = Math.abs(x-i);
                    closest = i;
                }    
            }
        }
        System.out.println(closest);
    }
}

Measured memory_bytes: 35844
#include "bits/stdc++.h"
using namespace std;
int main() {
    long long N; cin >> N;
    vector<long long>A(N);
    for (long long i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    vector<bool>B(N);
    for (long long i = 0; i < N; i++) {
        if (A.at(i) == i + 1) B.at(i) = false;
        else B.at(i) = true;
    }
    long long ans = 0;
    for (long long i = 0; i < N; i++) {
        if (!B.at(i)) {
            ans++;
            if (i != N - 1) {
                B.at(i) = true;
                B.at(i + 1) = true;
            }
            else {
                B.at(i - 1) = true;
                B.at(i) = true;
            }
        }
    }
    cout << ans << endl;
}

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

typedef struct Card {
    char suit, value;
} C;

void bubbleSort(C Card[], int N);
void selectionSort(C Card[], int N);
void Print(C Card[], int N);
bool judge(C B[], C S[], int N);

int main() {
    int N;
    cin >> N;
    C Bubble[40], Select[40];
    for (int i = 0 ; i < N; i++) {
        cin >> Bubble[i].suit >> Bubble[i].value;
        Select[i] = Bubble[i];
    }

    bubbleSort(Bubble, N);
    selectionSort(Select, N);
    
    Print(Bubble, N);
    cout << "Stable\n";
    Print(Select, N);
    if (judge(Bubble, Select, N)) {
        cout << "Stable\n";
    }
    else {
        cout << "Not stable\n";
    }

}

void Print(C Card[], int N) {
    for (int i = 0; i < N; i++) {
        if (i) cout << " ";
        cout << Card[i].suit << Card[i].value;
    }
    cout << '\n';
}


void bubbleSort(C Card[], int N) {
    for (int i = 0; i < N; i++) {
        for (int j = N - 1; j >= 0; j--) {
            if (Card[j].value < Card[j-1].value) {
                swap(Card[j], Card[j-1]);
            }
        }
    }
}

void selectionSort(C Card[], int N) {
    int  minj;
    for (int i = 0; i < N; i++) {
        minj = i;
        for (int j = i; j < N; j++) {
            if (Card[j].value < Card[minj].value) {
                minj = j;
            }
        }
        swap(Card[i], Card[minj]);
    }
}

bool judge(C B[], C S[], int N) {
    bool flag = true;
    for (int i = 0; i < N; i++) {
        if (B[i].suit != S[i].suit) {
            flag = false;
        }
    }
    return flag;
}



Measured memory_bytes: 3104
#include <stdio.h>
#include <math.h>
int main(){
  long n,m;
  float root;
  scanf("%ld",&n);
  root=sqrt(n);
  m=root;
  for(m;m>0;m--){
    if(0==n%m){
      printf("%ld",m+n/m-2);
      return 0;
    }
  }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
bool cmp(int a,int b){
	return a>b;
}
int main(){
int n,k,maxx=0;
cin>>n>>k;
int a[n];
for(int i=0;i<n;i++){
	cin>>a[i];
}
sort(a,a+n,cmp);
for(int i=0;i<k;i++){
	maxx+=a[i];
}
cout<<maxx<<endl;
return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
int main(void)
{
	char a[100];
	cin >> a;
	if (a[0] == a[2])
	{
		cout<<"Yes";
	}
	else
	{
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  int n,a,b,c,i;

  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%d %d %d", &a, &b, &c);
    if (a*a + b*b == c*c) {
       printf("YES\n");
       }
    else if (a*a + c*c == b*b) {
       printf("YES\n");
       }
    else if(b*b + c*c == a*a) {
       printf("YES\n");
       }
    else {
      printf("NO\n");
    }
}
  return 0;
}

Measured memory_bytes: 580
N = int(input())
string = input()
r2w = string.count("R")
w2r = 0
ans_list = [max(r2w, w2r)]
for c in string:
    if c == "W":
        w2r += 1
    else:
        r2w -= 1
    ans_list.append(max(r2w, w2r))
print(min(ans_list))

Measured memory_bytes: 17132
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <complex>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>

using namespace std;

int main() {
	int N, H, W;
	cin >> N;
	cin >> H;
	cin >> W;

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

	int count = 0;


	for (int i = 0; i < N; ++i)
	{
		if (H > A[i]) continue;
		if (W > B[i]) continue;
		++count;
	}

	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
#ユークリッドの互除法
def gcd(x, y):
    if x % y == 0:
        return y
    else:
        return gcd(y, x % y)
#入力
N = int(input())
A = list(map(int, input().split()))
MAXA=1000000
#カウントしていく
count= [0] * (MAXA + 1)
setwise_gcd=0
for i in range(0, N):
    count[A[i]]+= 1
    setwise_gcd = gcd(setwise_gcd, A[i])

#全体のgcdが1でないならnot coprime
if setwise_gcd != 1:
    print("not coprime")
    sys.exit(0)
#A[x] % i == 0 && A[y] % i == 0 となるx, y が存在しないならpairwise coprime
for i in range(2,MAXA + 1):
    divided_count = count[i]
    now_number = 2 * i
    while(now_number < MAXA + 1):
        divided_count += count[now_number]
        now_number += i
    if(divided_count >= 2):
        print("setwise coprime")
        exit(0)
print("pairwise coprime")

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    vector<bool> dp(a[n-1]+1,true);
    vector<int> b(a[n-1]+1);
    int ans=0;

    for(int i = 0; i < n; i++) {
        b[a[i]]++;
    }

    for(int i = 0; i < n; i++) {
        
        if(dp[a[i]]==true){
            if(b[a[i]]==1){
                ans++;
            
                for(int j = a[i]; j < a[n-1]+1; j += a[i]) {
                    
                        dp[j]=false;
                    
                }
            }
            else if(b[a[i]]>1){
                for(int j = a[i]; j < a[n-1]+1; j += a[i]) {
                    
                        dp[j]=false;
                    
                }
                b[a[i]]=-1;
            }

        }
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 7972
#JMD
#Nagendra Jha-4096

 
import sys
import math

#import fractions
#import numpy
 
###File Operations###
fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile

###Defines...###
mod=1000000007
 
###FUF's...###
def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 
##### Main ####
t=1
for tt in range(t):
    n=int(input())
    a=[]
    for i in range(3):
        a.append(str(input()))

    ans=0

    for i in range(n):
        l=set()
        l.add(a[0][i])
        l.add(a[1][i])
        l.add(a[2][i])

        ans+=len(l)-1
    print(ans)
    #n,k,s= map(int, sys.stdin.readline().split(' '))
    #a=list(map(int,sys.stdin.readline().split(' ')))
    
    
#####File Operations#####
if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

Measured memory_bytes: 3064
/*
ID: barish21
LANG: C++14
TASK: test
*/

/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define intt long long

#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

#define IO ios_base::sync_with_stdio(false);cin.tie();

const intt max1 = 11;
const intt max2 = 102;
const intt max3 = 1003;
const intt max4 = 10004;
const intt maxx = 100005;
const intt max6 = 1000006;
const intt max7 = 10000007;
const intt lg2 = 7;
const intt lg3 = 10;
const intt lg4 = 13;
const intt lg5 = 17;
const intt lg6 = 20;
const intt lg7 = 24;
const intt lg8 = 27;
const intt lg9 = 30;
const intt lg18 = 60;
const intt INF = 2LL * 1000000000;
/***************/

/***Additional Functions***/
intt powmod(intt a,intt b,intt mod){intt res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
intt gcd(intt a, intt b) { while(b) b ^= a ^= b ^= a %= b; return a;}
intt lcm(intt a,intt b){return a*b/gcd(a,b);}
intt is_prime(intt n){if(n==1)return 0;if(n==2)return 1;if(n%2==0)return 0;for(intt i=3;i<=sqrt(n);i+=2)if(n%i==0)return 0;return 1;}
intt is_integer(double n){if(floor(n)==ceil(n))return 1;return 0;}

intt sto_int(string s){stringstream ss(s);intt n;ss>>n;return n;}
string to_string(intt n){stringstream ss;ss<<n;string s=ss.str();return s;}
/**************************/

intt arr[maxx], cnt[2];
int main() {
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    IO;
    intt pw[55];
    pw[0] = 1;
    pw[1] = 2;
    for (intt i = 2; i <= 50; i++)
        pw[i] = pw[i - 1] + pw[i - 1];
    intt n, p;
    cin >> n >> p;
    for (intt i = 1; i <= n; i++)
        cin >> arr[i], cnt[arr[i] % 2] ++;
    if (p == 1 && cnt[1] == 0) {
        cout << 0 << endl;
        return 0;
    }
    if (p == 0 && cnt[1] == 0) {
        cout << pw[cnt[0]] << endl;
        return 0;
    }
    if (p == 0) {
        cout << pw[cnt[0]] * pw[cnt[1] - 1] << endl;
    } else {
        cout << pw[cnt[0]] * pw[cnt[1] - 1] << endl;
    }
    return 0;
}
/*
45 0
17 55 85 55 74 20 90 67 40 70 39 89 91 50 16 24 14 43 24 66 25 9 89 71 41 16 53 13 61 15 85 72 62 67 42 26 36 66 4 87 59 91 4 25 26
*/


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:256000000")
#include<utility>
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head
#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

// belik's shit
ll const mod = 1e9 + 7;
namespace {
	ll mult(ll& a, ll& b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) {
			val += mod;
		}
		if (val >= mod) {
			val -= mod;
		}
		return val;
	}
	ll poww(ll a, ll b)
	{
		ll val = 1;
		a %= mod;
		while (b > 0){
			if (b % 2) val = mult(a, val);
			a = mult(a, a);
			b >>= 1;
		}
		return val % mod;
	}
	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 5e5 + 5;
ld dp[5000][5000];
signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n; cin >> n; vector<ld>a(n + 1); for (ll i = 1; i <= n; i++) cin >> a[i];
	dp[0][0] = 1.0;
	for (ll i = 1; i <= n; i++) {
		for (ll j = 0; j <= i; j++) {
			dp[i][j] += dp[i - 1][j] * (1 - a[i]);
			if (j > 0) dp[i][j] += dp[i - 1][j - 1] * (a[i]);
		}
	}
	ld ans = 0;
	for (ll i = 0; i <= n / 2; i++) {
		ans += dp[n][i];
	}
	cout << fixed; cout.precision(10);
	cout << 1.0 - ans << endl;
	return 0;
}
/*

*/

Measured memory_bytes: 233984
#include "bits/stdc++.h"
using namespace std;

int a,b;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>a>>b;
	if(b%a==0)
		cout<<a+b;
	else
		cout<<b-a;
	return 0;
}

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

int main(){
    ll n;
    cin >> n;
    
    string s,ans;
    int a;
    while(n!=0){
        --n;
        a=n%26;
        n/=26;
        if(a==0){
            s="a";
        }
        if(a==1){
            s="b";
        }
        if(a==2){
            s="c";
        }
        if(a==3){
            s="d";
        }
        if(a==4){
            s="e";
        }
        if(a==5){
            s="f";
        }
        if(a==6){
            s="g";
        }
        if(a==7){
            s="h";
        }
        if(a==8){
            s="i";
        }
        if(a==9){
            s="j";
        }
        if(a==10){
            s="k";
        }
        if(a==11){
            s="l";
        }
        if(a==12){
            s="m";
        }
        if(a==13){
            s="n";
        }
        if(a==14){
            s="o";
        }
        if(a==15){
            s="p";
        }
        if(a==16){
            s="q";
        }
        if(a==17){
            s="r";
        }
        if(a==18){
            s="s";
        }
        if(a==19){
            s="t";
        }
        if(a==20){
            s="u";
        }
        if(a==21){
            s="v";
        }
        if(a==22){
            s="w";
        }
        if(a==23){
            s="x";
        }
        if(a==24){
            s="y";
        }
        if(a==25){
            s="z";
        }
        
        ans=s+ans;
    }

    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
int main()
{
    int i, j, k, h, w;
   
    cin >> h >> w;
    while(h>0 || w>0)
    {
        for(i=1; i<=h; i++)
        {
            for(j=1; j<=w; j++)
            {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
        cin >> h >> w;
    }
}


Measured memory_bytes: 3092
#include <iostream>
#include<stdio.h>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
int book1[30],book2[30];
string s;
int n,ans=0,t;

int judge(int a,int b)
{
    int result=0;
    memset(book1,0,sizeof(book1));
    memset(book2,0,sizeof(book2));
    for(int i=0;i<a;i++)
    {
        book1[(int)s[i]-(int)'a']=1;
    }
    for(int i=a;i<b;i++)
    {
        book2[(int)s[i]-(int)'a']=1;
    }
    for(int i=0;i<27;i++)
        if(book1[i]==1&&book2[i]==1)
            result++;
    return result;
}

int main()
{
   scanf("%d",&n);
   cin>>s;
   for(int i=1;i<n;i++)
   {
       t=judge(i,n);
       if(t>ans)
        ans=t;
   }
   printf("%d",ans);

    return 0;
}


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

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

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n; cin >> n;
  vector<int> x(n), y(n), h(n); rep(i, n) cin >> x[i] >> y[i] >> h[i];
  
  rep(i, 101) {
    rep(j, 101) {
      int aa = -1;
      rep(k, n) {
	if(h[k] > 0) {
	  int cp = h[k] + abs(x[k]-i) + abs(y[k]-j);
	  if(aa == -1) {
	    aa = cp;
	  } else {
	    if(aa != cp) {
	      aa = -2;
	      break;
	    }
	  }
	}
      }
      if(aa == -2) continue;
      
      rep(k, n) {
	if(h[k] == 0) {
	  int cp = h[k] + abs(x[k]-i) + abs(y[k]-j);
	  if(aa > cp) {
	    aa = -2;
	    break;
	  }
	}
      }
      if(aa == -2) continue;
      cout << i << ' ' << j << ' ' << aa << endl;
    }
  }
}


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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define rep(i, n) rep2(i,0,n)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  string s;cin>>s;
  int a,z;
  for(int i=0;i<s.size();i++){if(s[i]=='A'){a=i;break;}}
  repr(i,0,s.size()-1){
    //cout<<i<<endl;
    if(s[i]=='Z'){z=i;break;}
  }
  cout<<z-a+1<<endl;
}

Measured memory_bytes: 720
#define  _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}


unsigned long xor128() {
    static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned long t = (x ^ (x << 11));
    x = y; y = z; z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}


#define int long long

int powing(int a, int b,int mod) {
    int ans = 1;
    while (b) {
        if (b % 2) {
            ans *= a;
            ans %= mod;
        }
        a *= a;
        a %= mod;
        b /= 2LL;
    }
    return ans;
}

void solve() {
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    int l = 0, r = 0;
    set<pair<int, int>> inputs;
    pair<int, int> now = mp(s[0] - 'a' + 1, s[0] - 'a' + 1);
    REP(i, m) {
        string b;
        cin >> b;
        if (b == "R++") {
            now.first *= 27LL;
            now.second *= 27LL;
            r++;
            now.first += s[r] - 'a' + 1;
            now.second += s[r] - 'a' + 1;
            now.first %= MAX_MOD;
            now.second %= MOD;
        }
        if (b == "R--") {
            now.first -= s[r] - 'a' + 1;
            now.second -= s[r] - 'a' + 1;
            now.first += MAX_MOD;
            now.second += MOD;
            r--;
            now.first *= powing(27LL, MAX_MOD - 2LL, MAX_MOD);
            now.second *= powing(27LL, MOD - 2LL, MOD);
            now.first %= MAX_MOD;
            now.second %= MOD;
        }
        if (b == "L--") {
            l--;
            now.first += powing(27LL, r - l, MAX_MOD) * (ll)(s[l] - 'a' + 1);
            now.second += powing(27LL, r - l, MOD) * (ll)(s[l] - 'a' + 1);
            now.first %= MAX_MOD;
            now.second %= MOD;
        }
        if (b == "L++") {
            now.first -= (powing(27LL, r - l, MAX_MOD) * (ll)(s[l] - 'a' + 1)) % MAX_MOD;
            now.second -= (powing(27LL, r - l, MOD) * (ll)(s[l] - 'a' + 1))%MOD;
            l++;
            now.first += MAX_MOD;
            now.second += MOD;
            now.first %= MAX_MOD;
            now.second %= MOD;
        }
        inputs.insert(now);
    }
    cout << inputs.size() << endl;
}

#undef int
int main() {
    init();
    solve();
}


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

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    int a, n, q;
    cin>>n;
    set<int> S;
    rep(i, n) {
        cin>>a;
        S.insert(a);
    }
    cin>>q;
    set<int> T;
    rep(i, q) {
        cin>>a;
        T.insert(a);
    }

    set<int> res;
    set_intersection(S.begin(), S.end(), T.begin(), T.end(), inserter(res, res.end()));
    cout<<res.size()<<endl;
}


Measured memory_bytes: 10152
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;


signed main(){
  string S,T;cin>>S>>T;
  REP(i,0,S.size()){
    if(S==T){
      print("Yes"); re 0;
    }
    S=S[S.size()-1]+S;
    S.pop_back();
  }
  print("No");


}


Measured memory_bytes: 256
#include <stdio.h>
#define swap(a,b) a^=b^=a^=b
int main(){
  int x,y,r;
  scanf("%d%d",&x,&y);
  if(x<y)
    swap(x,y);
  while(y>0){
    r=x%y;
    x=y;
    y=r;
      }
    printf("%d\n",x);
  return 0;
}

Measured memory_bytes: 1764
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < n;i++)
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}


signed main(){
	int N;
	cin >> N;
	vector<int>a(N),ans,id(N),def(N*N,-1);
	queue<int>q,ok;
	REP(i,N){
		cin >> a[i];a[i]--;
		def[a[i]] = i;
	}
	iota(id.begin(),id.end(),0);
	sort(id.begin(),id.end(),[&](int l,int r){return a[l]<a[r];});
	REP(i,N){
		REP(j,N-1-id[i])ok.push(id[i]);
		REP(j,N-1-(N-1-id[i]))q.push(id[i]);
	}
	REP(i,N*N){
		if(def[i] != -1)ans.push_back(def[i]);
		else{
			if(q.size()){
				ans.push_back(q.front());
				q.pop();
			}else{
				ans.push_back(ok.front());
				ok.pop();
			}
		}
	}
	vector<int>cnt(N,0);
	REP(i,N*N){
		cnt[ans[i]]++;
		if(def[i] != -1){
			if(cnt[def[i]] - 1 != def[i]){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	REP(i,ans.size())cout << ans[i] + 1 << " \n"[i+1 == ans.size()];
}


Measured memory_bytes: 7280
import itertools
import numpy as np


N, M, X = map(int, input().split())
books = np.array([list(map(int, input().split())) for i in range(N)])
minsum = N * 10**5
count = 0
check_array = []
success_array = []
for x in range(1, N + 1, 1):
    combi_list = list(itertools.combinations(range(N), x))
    for y in combi_list:
        sum_array = [0] * (M + 1)
        for z in y:
            sum_array = sum_array + books[z]
        beyond_check = True
        for zz in range(len(sum_array) - 1):
            if sum_array[zz + 1] < X:
                beyond_check = False
                break
        if beyond_check:
            success_array.append(sum_array[0])

    lenlist = len(combi_list)
    count += lenlist
if len(success_array) > 0:
    print(min(success_array))
else:
    print(-1)


Measured memory_bytes: 27624
n, q = map(int, input().split())
g = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    g[a].append(b)
    g[b].append(a)
l = [0]*n
for i in range(q):
    p, x = map(int, input().split())
    p = p-1
    l[p] += x

from collections import deque
s = deque()
s.append(0)
visit = [False]*n
visit[0] = True

while s:
    x = s.pop()
    for new_x in g[x]:
        if visit[new_x] == True:
            continue
        l[new_x] += l[x]
        s.append(new_x)
        visit[new_x] = True

print(*l)

Measured memory_bytes: 105876