akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>


int formula();
int min(int,int);
int max(int,int);

int p,q,r;
int position;
    char str[10000];


main(){
    int count=0;
    
    while(1){
        
        scanf("%s",str);
        if(str[0] == '.') break;
        count = 0;
        
    for(p=0; p<3; p++){
        for(q=0; q<3; q++){
            for(r=0; r<3; r++){
                position = 0;
               if(formula() == 2)
               count++;
            }
        }
    }
    printf("%d\n",count);
    }
    
    return 0;
}

int formula(){
    int result;
    
    if(str[position] == '-'){
                position++;

        result = 2-formula();
    }   
    
    else if(str[position] == '('){
    position++;
    result = formula();
    if(str[position] == '*'){
        position++;
        result = min(result,formula());
    position++;
    }
    else if(str[position] == '+'){
        position++;
        result = max(result,formula());
    position++;
	}
}

else{
    if(str[position] >= '0' && str[position] <= '2')
    result = str[position] - '0';
    
    if(str[position] == 'P')
    result = p;
    else if(str[position] == 'Q')
    result = q;
    else if(str[position] == 'R')
    result = r;
    
    position++;
    }
    return result;
}

int min(int x,int y){
    if(x > y)
    return y;
    else return x;
}

int max(int x,int y){
    if(x > y)
    return x;
    else return y;
}

Measured memory_bytes: 540
// C++ program to find Excel
// column name from a given
// column number
#include <bits/stdc++.h>
#define MAX 100
#define int long long int
using namespace std;

// Function to print Excel column name for a given column number
void printString(int n)
{
	char str[MAX]; // To store result (Excel column name)
	int i = 0; // To store current index in str which is result

	while (n > 0) {
		// Find remainder
		int rem = n % 26;

		// If remainder is 0, then a 'Z' must be there in output
		if (rem == 0) {
			str[i++] = 'Z';
			n = (n / 26) - 1;
		}
		else // If remainder is non-zero
		{
			str[i++] = (rem - 1) + 'A';
			n = n / 26;
		}
	}
	str[i] = '\0';

	// Reverse the string and print result
	reverse(str, str + strlen(str));
	for(int i=0;i<strlen(str);i++)
    {
        cout<<char(str[i]+32);
    }
	//cout << str << endl;

	return;
}

// Driver program to test above function
int32_t main()
{
    int n;
    cin>>n;
    printString(n);
}


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


int main() {
  string S; cin >> S;
  int N = S.size();
  
  int a = 0, b = 0;
  rep(i, N) {
    if(S[i] == '0') a++;
    else b++;
  }

  cout << N-abs(a-b) << endl;

}

Measured memory_bytes: 512
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include <string.h>
using namespace std;

int main() {
	long long	A;
	double	B;

	cin >> A >> B;

	long long	tmp = (B + 0.001) * 100;
	long long	tmp2 = A * tmp / 100;

	cout << tmp2 << endl;

	return 0;
}

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

int main(void)
{
    IOS
    int d, n;
    cin >> d >> n;
    if (n == 100) n++;
    int ans = 0;
    switch (d)
    {
    case 0:
        ans = n;
        break;
    case 1:
        ans = 100*n;
        break;
    case 2:
        ans = 10000*n;
        break;
    default:
        break;
    }

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<iostream>
#include<algorithm>//next_permutation

using namespace std;
int main() {
	int N, K;
	cin >> N >> K;
	int C = 0;
	while (N >= K)
	{
		N = N / K;
		C++;
	}
	C++;
	cout << C;
}


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

using namespace std;

int main(){
	long long x;
	cin>>x;
	long long mon=100;
	for(int i=1;i<=4000;i++){
		mon=mon+mon/100;
		if(mon>=x){
			cout<<i<<endl;
			return 0;
		}
	} 
} 

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		if (n == m) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

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

    cout << c / a * b << '\n';
    return 0;
}




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

int main() {
  int M, A, B;
  cin >> A >> B >> M;
  vector<int> a(A);
  vector<int> aa(A);
  vector<int> b(B);
  vector<int> bb(B);
  for(int i = 0; i < A; i++) {
    cin >> a.at(i);
    aa.at(i) = a.at(i);
  }
  for(int i = 0; i < B; i++) {
    cin >> b.at(i);
    bb.at(i) = b.at(i);
  } 
  sort(aa.begin(), aa.end()); 
  sort(bb.begin(), bb.end());
  int ma, mb = 0; 
  ma = aa.at(0);
  mb = bb.at(0);
  vector<int> x(M);
  vector<int> y(M);
  vector<int> c(M);
  for(int i = 0; i < M; i++) {
    cin >> x.at(i) >> y.at(i) >> c.at(i);
  }
  int m = 0;
  for(int i = 0; i < M; i++ ) {
    if(i == 0) {
      m = a.at(x.at(i)-1) + b.at(y.at(i)-1) - c.at(i); 
    }
    else {
      m = min(a.at(x.at(i)-1) + b.at(y.at(i)-1) - c.at(i),m);
    }
  }
  cout << min(m,ma+mb) << endl;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    vector<int> arr(3, 0);
    for(int& val: arr)
        cin >> val;
    sort(arr.begin(), arr.end());
    int ans = arr[2] - arr[1];
    ans += (arr[1]-arr[0]) / 2;
    if ((arr[1] - arr[0]) % 2 == 1)
        ans += 2;
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n; rd(n);
  auto color=new char[](n*2), a=new int[](n*2);  
  auto pos_w=new int[](n*2), pos_b=new int[](n*2);
  fill(pos_w, -1); fill(pos_b, -1);
  foreach(i; 0..(n*2)){
    rd(color[i], a[i]); a[i]--;
    if(color[i]=='W') pos_w[a[i]]=i;
    else pos_b[a[i]]=i;
  }
  
  auto cnt_w=new int[][](n*2, n*2), // [i, n*2)にあるj以下の数の個数（白色の）
       cnt_b=new int[][](n*2, n*2);
  for(int i=n*2-1; i>=0; i--){
    for(int h=0; h<=i; h++){
      if(color[i]=='W') cnt_w[h][a[i]]++;
      else cnt_b[h][a[i]]++;
    }
  }
  foreach(i; 0..(n*2)){
    for(int j=1; j<(n*2); j++){
      cnt_w[i][j]+=cnt_w[i][j-1];
      cnt_b[i][j]+=cnt_b[i][j-1];
    }
  }
  
  auto dp=new int[][](n+1, n+1);
  for(int i=0; i<=n; i++) fill(dp[i], 1_000_000_000);
  dp[0][0]=0;
  for(int i=0; i<=n; i++)for(int j=0; j<=n; j++){ // 白:0, 1, ..., i-1まで置いた；次置くのはi
    if(i<n){
      int cost_w=0;
      if(i-1>=0) cost_w+=cnt_w[pos_w[i]][i-1];
      if(j-1>=0) cost_w+=cnt_b[pos_w[i]][j-1];
      chmin(dp[i+1][j], dp[i][j]+cost_w);
    }
    if(j<n){
      int cost_b=0;
      if(j-1>=0) cost_b+=cnt_b[pos_b[j]][j-1];
      if(i-1>=0) cost_b+=cnt_w[pos_b[j]][i-1];
      chmin(dp[i][j+1], dp[i][j]+cost_b);
    }
  }
  writeln(dp[n][n]);
}

void chmin(T)(ref T l, T r){if(l>r)l=r;}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x) e=l[i].to!(typeof(e));
}


Measured memory_bytes: 147068
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

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

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  string S, T;
  cin >> S >> T;
  ll s = S.size();
  ll t = T.size();
  for(ll i=s-t;i>=0; i--){
    bool ans = true;
    rep(j, t){
      if(S[i+j]==T[j] or S[i+j]=='?'){
        ans = ans and true;
      }else{
        ans = ans and false;
      }
    }
    string tmp="";
    if(ans){
      rep(j, s){
        if(j<i or i+t<=j){
          tmp +=(S[j]=='?'?"a":S.substr(j, 1));}
        else{
          tmp += T.substr(j - i,1);
        }
      }
      cout << tmp;
      return 0;
    }
  }
  cout << "UNRESTORABLE";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
    string a;
    cin>>a;
    string b=a;
    a="";
    int x=b.size();
    int i;
    for (i=0;i<x;i++) a=b[i]+a;
    for(int i=0;i<x;i++)
    {
        if(a[i]=='b') a[i]='d';
        else if(a[i]=='d') a[i]='b';
        else if(a[i]=='p') a[i]='q';
        else if(a[i]=='q') a[i]='p';
    }
    if(a==b) cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 512
const lines: string[] = [];
const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});
reader.on("line", function (line: string) {
  lines.push(line);
});

reader.on("close", function () {
  const rule = lines.shift().split(" ").map(Number);
  const itemNum = rule[0];
  const weightMax = rule[1];

  const data: any = lines.map((line) => {
    return line.split(" ").map((int) => parseInt(int));
  });

  const dp = [];
  dp.push(new Array(weightMax + 1).fill(0));
  for (let i = 0; i < itemNum; i++) {
    dp.push(new Array(weightMax + 1).fill(-1));
  }

  for (let i = 0; i < itemNum; i++) {
    for (let w = 0; w <= weightMax; w++) {
      if (w - data[i][0] >= 0) {
        dp[i + 1][w] = Math.max(
          dp[i + 1][w],
          dp[i][w - data[i][0]] + data[i][1]
        );
      }
      dp[i + 1][w] = Math.max(dp[i + 1][w], dp[i][w]);
    }
  }

  console.log(Math.max.apply(null, dp[itemNum]));
});


Measured memory_bytes: 190736
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin >> s;
  if((s.at(0)==s.at(1) && s.at(1)==s.at(2)) || (s.at(1)==s.at(2) && s.at(2)==s.at(3)))
  cout << "Yes" << endl;
  else
  cout << "No" << endl;
}

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

int main(){
  int a,b;
  cin >>a>>b;
  if(a>b){
    for(int i=0;i<a;i++){
      cout <<b;
    }
  }
  else{
    for(int i=0;i<b;i++){
      cout <<a;
    }
  }
}

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

int main() {
  int N;
  cin >> N;
  int ans = 0;
  for(int i=0; i<N; i++){
    long long A;
    cin >> A;
    for(int i=0; i>-1; i++){
      if(A%2 == 0 && A != 0){
        ans++;
        A /= 2;
      }
      else{
        break;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3596
// #pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define Nmax 10000009
#define INF (ll)1e18
#define pll pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define vv vector
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<(n);i++)
#define repr(i,n) repr2(i,n,0)
#define repr2(i,m,n) for(ll i=m;i>=(n);i--)
#define get(n) ll (n); scanf("%lld",&(n));
#define get2(n,k) ll (n),(k); scanf("%lld%lld",&(n),&(k));
#define get3(n,m,k) ll (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k));
#define gets(s) string (s); cin >> (s);
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) vector<ll> A((n)); for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}
#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); //cout.tie(0);
#define pi 3.1415926535897
#define db double
#define noop
#define flu fflush(stdout)
#define imp {cout<<"No\n"; return 0;}
#define debug_vec(vec,n) {rep(idxi,n) cout<<vec[idxi]<<" "; cout<<"\n";}
#define debug_pvec(vec,n) {rep(idxi,n) cout<<vec[idxi].fi<<"-"<<vec[idxi].se<<"  "; cout<<"\n";}
#define debug_set(seta) {cout<<seta.size()<<"\n"; for(auto idxi:seta) cout<<idxi<<" "; cout<<"\n";}
#define debug_map(mappa) {cout<<mappa.size()<<"\n";for(auto idxi:mappa) cout<<idxi.fi<<"-"<<idxi.se<<"  "; cout<<"\n";}
#define debug_vecvec(vec,n) {rep(idxi,n) {for(auto idxi2:vec[idxi]) cout<<idxi2<<" "; cout<<"\n";}}
 
// LOOK AT THESE BEFORE SUBMISSION
// LOOK AT THESE BEFORE SUBMISSION
// ============================================================
// Nmax value and is index access offset taking it beyond Nmax.
// Precision error in case of real numbers.
// N vs N2 chosen correctly.
// Modulo applied everywhere.
// Flush in case of interactive.
// Don't erase value in multiset.
// Check for array indices out of bound (in pre or suff sums).
// Correct return value for functions.
// Confirm the letter case of yes and no.
// ============================================================

ll dp[Nmax], dp2[Nmax];

int main() {
    rep(i,Nmax) dp[i] = INF;
    dp[0] = 0;
    
    get2(h,n);
    // rep(i,Nmax) dp2[i] = dp[i];
    rep(i,n) {
        get2(a,b);
        rep(i,h+1) 
            if(i+a<Nmax) 
                dp[i+a] = min(dp[i+a], dp[i] + b);
    }

    ll mini = INF;
    rep2(i,h,Nmax) mini = min(dp[i], mini);

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


    return 0;  
}   

Measured memory_bytes: 78720
N = int(input())
A = list(map(int, input().split()))

k = [[0]*2 for i in range(10**5+1)]
g = [[0]*2 for i in range(10**5+1)]
# k = [[0]*2 for i in range(10)]
# g = [[0]*2 for i in range(10)]

_ksum = 0
_gsum = 0

for i in range(N):
    if i % 2 == 0:
        k[A[i]][0] += 1
        k[A[i]][1] = A[i]
        _ksum += 1
    else:
        g[A[i]][0] += 1
        g[A[i]][1] = A[i]
        _gsum += 1

_kmax = 0
_gmax = 0

b_k = k.copy()
b_g = g.copy()

b_k.sort()
b_g.sort()

if b_k[-1][1] != b_g[-1][1]:
    print(_ksum-b_k[-1][0]+_gsum-b_g[-1][0])

else:
    print(min(_ksum-b_k[-1][0]+_gsum-b_g[-2][0], _ksum-b_k[-2][0]+_gsum-b_g[-1][0]))


Measured memory_bytes: 29292
#include <bits/stdc++.h>
using namespace std;
#define forloop(n) for(int i = 0; i < n; i++)
#define ll long long
 
#define mod 1000000007
long long exp(long long taban, long long us) {
    long long carpan = taban;
    long long temp = us;
    long long res = 1;
    for(int i = 0;;i++){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
        if(temp == 0) break;
    }
    return res;
}
ll ebob(ll a, ll b){
	if(!a)return b;
	return ebob(b%a, a);
}
ll ekok(ll a, ll b){
	return (((a*b)%mod)*(exp(ebob(a,b), (ll)mod-2))) % mod;
}

map<pair<int, int>, int> mp;

void fonk(vector<vector<int>>& vec, int cur, int dont, int blocked_color, int& res){
	int i = 1;
	for(auto x: vec[cur]){
		if(x != dont){
			int n1 = max(x, cur), n2 = min(x, cur);
			pair<int, int> p = make_pair(n1, n2);
			if(i == blocked_color) i++;
			mp[p] = i;
			res = max(res, i);
			fonk(vec, x, cur, i, res);
			i++;
		}
	}
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin>>n;
	vector<vector<int>> vec(n+1);
	vector<pair<int, int>> edges(n-1);
	for(int i = 0; i < n-1; i++){
		int a, b; cin>>a>>b;
		vec[a].push_back(b);
		vec[b].push_back(a);
		edges[i] = make_pair(max(a, b), min(a,b));
	}
	int max = 0;
	fonk(vec, 1, -1, -1, max);
	cout<<max<<endl;
	for(auto x: edges){
		cout<<mp[x]<<endl;
	}
	return 0;
}


Measured memory_bytes: 15872
# include "stdio.h"

int main(){
     long int s,t,k,sum=0;
     int c1=0;
     scanf("%ld",&s);
     t=s;
     while(t){
         c1++;
         t/=10;
     }
     int a[c1];
     t=s;
     for(int i=0;i<c1;i++){
         a[c1-1-i]=t%10;
         t/=10;
     }
     for(int bit=0;bit<(1<<(c1-1));bit++){
         k=a[0];
         for(int i=0;i<c1-1;i++){
             if(bit & (1<<i)){
                 sum+=k;
                 k=0;
             }
             k=k*10+a[i+1];
         }
         sum+=k;
     }
     printf("%ld\n",sum);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int> t(N+1), x(N+1), y(N+1);
    for(int i = 1; i <= N; i++) cin >> t.at(i) >> x.at(i) >> y.at(i);
    
    string ans = "Yes";
    for(int i = 0; i < N; i++) {
        int D = abs(x.at(i)-x.at(i+1)) + abs(y.at(i)-y.at(i+1));
        int T = t.at(i+1) - t.at(i);
        if(D>T || D%2!=T%2) ans = "No";
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 1408
#include<stdio.h>
typedef long long int64_t;
int main()
{
    int N, K;
    scanf("%d %d", &N, &K);
    int64_t A[200000+1];
    for(int i =0; i<N;i++){
        scanf("%lld", A+i);
    }
    
    for(int i=0; i<N-K;i++){
        if(A[i]==0){
            printf("No\n");
            return 0;
        }
    }
    for(int i=0; i<N-K; i++){
        int former = A[i];
        int latter = A[i+K];
        if(former < latter){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
    }


    return  0;
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define fore(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;

void Print(string& str){
    int a, b; cin >> a >> b;
    // fore(i, a, b) cout << str[i];
    // cout << endl;
    cout << str.substr(a, b - a + 1) << endl;
}

void Replace(string& str){
    int a, b; cin >> a >> b;
    string s; cin >> s;
    // str = str.substr(0, a) + s + str.substr(b + 1);
    str.replace(a, b - a + 1, s);
}

void Reverse(string& str){
    int a, b; cin >> a >> b;
    reverse(str.begin() + a, str.begin() + b + 1);
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    string s; cin >> s;
    int q; cin >> q;
    forn(i, q){
        string qs; cin >> qs;
        if(qs == "print") Print(s);
        else if(qs == "replace") Replace(s);
        else if(qs == "reverse") Reverse(s);
    }
}


Measured memory_bytes: 3240
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  string s;
  cin>>s;
  reverse(all(s));
  ll ans = 0;
  ll c = 0;
  rep(i,0,s.sz){
  	if(s[i]=='W')c++;
  	else ans += c;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
let fs = require('fs');

const yourAnswerFunctionComesHere = data => {
  const splitedData = data.split(" ");
  const sortedData = splitedData.sort((x, y) => y - x);
  let answerString = "";
  for(let i = 0; i < sortedData.length; i++) {
    answerString += sortedData[i];
    if(i < sortedData.length - 1) {
      answerString += " ";
    }
  }
  console.log(answerString);
}

const readFile = path => {
  fs.readFile(path, 'utf8', (err, data) => {
    yourAnswerFunctionComesHere(data);
  });
}

const readFileWithoutArg = () => {
  var input = require('fs').readFileSync('/dev/stdin', 'utf8');
  var Arr=(input.trim()).split(" ").map(Number);
  Arr.sort(function(a,b){return b-a;});
  console.log(Arr.join(" "));
}

let sampleInputPath = "";

if(process.argv.length > 2) {
  sampleInputPath = process.argv[2];
  readFile(sampleInputPath);
} else {
  readFileWithoutArg();
}



Measured memory_bytes: 17172
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define Graph vector<vector<ll>>
#define INF (ll)(1ll<<60)
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;}

int main(){
	ll d,g;
	cin>>d>>g;
	vector<ll> p(d),c(d);
	rep(i,d)  cin>>p[i]>>c[i];

	ll ans=INF;
	ll score,num;

	rep(i,(1<<d)){
		score=0;num=0;

		vector<bool> selected(d,false);
		rep(j,d){
			if((i>>j)&1){//jの問題は全部解く
				score+=(p[j]*100*(j+1)+c[j]);
				num+=p[j];
				selected[j]=true;
			}
		}

		for(int j=d-1;j>=0;j--){
			if(selected[j]) continue;

			for(int k=0;k<p[j]-1;k++){
				if(score>=g) break;
				
				score+=(100*(j+1));
				num++;
			}
			if(score>=g) break;
		}

		if(score>=g) ans=min(ans,num);
	}

	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N (long long)(1e9 + 7)
using namespace std;

string s;
long long n;
long long memo[100005] = {0};
long long sum[100005][4] = {0};

long long solve();

int main() {
  cin >> s;
  n = s.size();
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0;
  memo[0] = 1;
  for(int i = 1; i <= n; ++i) {
    memo[i] = 3 * memo[i - 1];
    memo[i] %= N;
  }
  for(int i = 0; i < n; ++i) {
    if(i != 0)
      for(int j = 0; j < 4; ++j) sum[i][j] = sum[i - 1][j];
    if(s[i] == '?')
      ++sum[i][3];
    else
      ++sum[i][s[i] - 'A'];
  }
  for(int i = 1; i < n - 1; ++i)
    if(s[i] == '?' || s[i] == 'B') {
      long long l, r, cnt = 0;
      l = sum[i - 1][0] * memo[sum[i - 1][3]] % N;
      if(sum[i - 1][3] != 0)
        l += sum[i - 1][3] * memo[sum[i - 1][3] - 1] % N;
      l %= N;
      cnt = sum[n - 1][3] - sum[i][3];
      r = (sum[n - 1][2] - sum[i][2]) * memo[cnt] % N;
      if(cnt != 0) r += cnt * memo[cnt - 1] % N;
      r %= N;
      ans += l * r % N;
      ans %= N;
    }
  return ans;
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

int main(int argc, char *argv[]){
    int N;
    std::cin >> N;
    std::vector<std::pair<long int,long int> >jobs(N);
    long int A,B;
    for(int i=0; i<N; ++i){
        std::cin >> A >> B;
            jobs[i] = std::pair<long int, long int>(A,B);
    }
    std::sort(jobs.begin(),jobs.end(),[](const auto &a, const auto &b){
                                            return (a.second < b.second) || (a.second==b.second && a.first > b.first);
                                        });
    long int t = 0;
    bool fcomplete = true;
    for(int i=0; i<N; ++i){
        t += jobs[i].first;
        if(t>jobs[i].second){
            fcomplete = false;
            break;
        }
    }

    if(fcomplete){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }

    return 0;
}


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

class UnionFindDS{
private:
    vector<int> p, sz;   // parent, height, size
    int num;
public:
    UnionFindDS(int N){
        p.assign(N,0); for (int i = 0; i < N; i++) p[i] = i;
        sz.assign(N,1); num = N;
    }
    int numSets(){ return num; }
    int findSet(int i){ return p[i] == i ? i : p[i] = findSet(p[i]); }
    int sizeSet(int i){ return sz[findSet(i)]; }
    bool isSameSet(int i, int j){ return findSet(i) == findSet(j); }
    void unionSet(int i, int j){
        if ((i = findSet(i)) == (j = findSet(j))) return;
        
        num--;
        p[j] = i; sz[i] += sz[j];
    }
};

int N, M;

int main() {

    scanf("%d%d",&N,&M); UnionFindDS uf(N);
    for (int i = 0, op, u, v; i < M; i++) {
        scanf("%d%d%d",&op,&u,&v);

        if (op)
            printf("%d\n", uf.isSameSet(u,v) ? 1 : 0);
        else
            uf.unionSet(u,v);
    }

    return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < static_cast<int>(b); i++)
#define FORR(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) FOR (i, 0, n)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
template <typename T>
void print(const vector<vector<T>> matrix);
template <typename T>
void print(const vector<T> vec);
template <typename Arg>
void print(const Arg arg);
template <typename Head, typename... Args>
void print(const Head head, const Args... args);
template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
using ll = long long;

int main() {
    int N, T;
    cin >> N >> T;
    vector<int> c(N), t(N);
    rep (i, N)
        cin >> c[i] >> t[i];

    vector<int> vec;
    rep (i, N)
        if (t[i] <= T) vec.pb(c[i]);

    if (vec.size() > 0) {
        sort(all(vec));
        print(vec[0]);
    } else {
        print("TLE");
    }

    return 0;
}

//---------------------------------------------
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}


Measured memory_bytes: 256
#include <iostream>
#include <random>
#include <chrono>
#include <algorithm>
#include <cstring>

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
using namespace std;
typedef long long ll;
const ll MOD = (ll)1e9 + 7;
const int N = 3000+5, inf = 1e9+5;
ll add(ll x, ll y) { x += y; if (x >= MOD) return x - MOD; return x; }
ll sub(ll x, ll y) { x -= y; if (x < 0) return x + MOD; return x; }
ll mult(ll x, ll y) { return (x * y) % MOD; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll a[N], dp[N][N], n;

ll f(int l, int r) {
    if (l > r) return 0;
    if (dp[l][r] != -1) return dp[l][r];
    ll L = f(l + 1, r);
    ll R = f(l, r - 1);
    if ((n&1) == ((l-r+1)&1))
        return dp[l][r] = max(a[l] + L, a[r] + R);
    else
        return dp[l][r] = min(L - a[l], R - a[r]);
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    rep (i, 0, n) cin >> a[i];
    memset(dp, -1, sizeof(dp));
    cout << f(0, n-1) << endl;
    return 0;
}

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

vector<pair<int,int>> tougou(vector<pair<int,int>> x){
	int siz=x.size();
	pair<int,int> p;
	if(siz!=0)p=x[0];
	vector<pair<int,int>> ans;
	for(int i=1;i<siz;i++){
		if(p.first!=x[i].first){
			ans.push_back(p);
			p=x[i];
		}
		else {
			p.second+=x[i].second;
		}
	}
	ans.push_back(p);
	return ans;
}

int solve(vector<pair<int,int>> x){
	vector<pair<int,int>> vp;
	int siz=x.size();
	bool update;
	for(;;){
		update=false;
		for(int i=0;i<siz;i++){
			if(x[i].second<4){
				vp.push_back(x[i]);
			}
			else update=true;
		}
		if(!update)break;
		x=tougou(vp);
		siz=x.size();
		vp.clear();
	}
	//if(update)return solve(tougou(vp));
	siz=vp.size();
	int ans=0;
	for(int i=0;i<siz;i++){
		ans+=vp[i].second;
	}
	return ans;
}

int main(){
while(1){
	int n,a,ans=100000;
	pair<int,int> p;
	p.second=1;
	vector<pair<int,int>> vp;
	scanf("%d",&n);
	if(n==0)break;
	ans=n;
	for(int i=0;i<n;i++){
		scanf("%d",&p.first);
		vp.push_back(p);
	}
	for(int i=0;i<n;i++){
		int sav=vp[i].first;
		for(int j=1;j<=3;j++){
			bool c=false;
			if(i>=3)if(vp[i-3].first==vp[i-2].first&&vp[i-2].first==vp[i-1].first&&vp[i-1].first==j)c=true;
			if(i>=2)if(vp[i+1].first==vp[i-2].first&&vp[i-2].first==vp[i-1].first&&vp[i-1].first==j)c=true;
			if(i>=1)if(vp[i+1].first==vp[i+2].first&&vp[i+2].first==vp[i-1].first&&vp[i-1].first==j)c=true;
			if(vp[i+1].first==vp[i+2].first&&vp[i+2].first==vp[i+3].first&&vp[i+3].first==j)c=true;
			if(c){
				vp[i].first=j;
				int an=solve(tougou(vp));
				if(an<ans)ans=an;
			}
		}
		vp[i].first=sav;
	}
	printf("%d\n",ans);
}
return 0;
}

Measured memory_bytes: 1568
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <cmath>
#include <map>
#include <algorithm>
#include <stack>
#include <cstring>
 
#define ll long long
#define MP make_pair
#define PB push_back
#define P push
#define f first
#define se second
#define S size()
#define B begin()
#define E end()
#define rB rbegin()
#define rE rend()
#define PI acos(-1)

 
const int N = 1e5 + 100;
const int M = 1e6 + 100;
const ll oo = 1e18;
 
ll n, m, k, t, q, h, a, b, d, c, e, w, x, y, z;
using namespace std;


ll dp[N], ar[N];


int main() {


	cin >> n >> k;


	for(int i = 1; i < n + 10; i++)
		dp[i] = 2e9;



	for(int i = 0; i < n; i++){
		cin >> ar[i];

		for(int j = 1; j <= k && i - j >= 0; j++){
			dp[i] = min(dp[i - j] + abs(ar[i] - ar[i - j]), dp[i]);
		}
	}


	cout << dp[n - 1];
    
	
    
    return 0;
}




Measured memory_bytes: 1792
#include<stdio.h>


long long int a[51], b[51];

long long int func(int n, long long int x){
    if(x >= a[n]){
        return b[n];
    }
    if(x == 1){
        if(n == 0){
            return 1;
        }else{
            return 0;
        }
    }else if(x <= 1+a[n-1]){
        return func(n-1, x-1);
    }else if(x == 2+a[n-1]){
        return func(n-1, x-1) + 1;
    }else{
        return b[n-1] + 1 + func(n-1, x-a[n-1]-2);
    }
}

int main(){
    int n;
    long long int x;
    scanf("%d %lld", &n, &x);
    a[0] = 1;
    b[0] = 1;
    for(int i=1; i<=50; i++){
        a[i] = 2*a[i-1] + 3;
        b[i] = 2*b[i-1] + 1;
    }
    printf("%lld", func(n, x));

    return 0;
}

Measured memory_bytes: 128
n = gets.to_i
judges = []
n.times do
  judges << gets.chomp
end

tally = judges.tally

puts "AC x #{tally['AC'] || 0}"
puts "WA x #{tally['WA'] || 0}"
puts "TLE x #{tally['TLE'] || 0}"
puts "RE x #{tally['RE'] || 0}"


Measured memory_bytes: 20736
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<map>
#include<cmath>
using namespace std;
#define int long long
const int maxn=2e5+5;
const int mod=1e9+7;
int quick_pow(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b&1) res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}
signed main()
{
    int n,a,b;
    scanf("%lld%lld%lld",&n,&a,&b);
    if(a>n/2) a=n-a;
    if(b>n/2) b=n-b;
    if(a>b) swap(a,b);
    int now=1;
    int a_=1,b_=1;
    for(int i=1;i<=b;i++)
    {
        now=(now*(n-i+1))%mod;
        now=(now*quick_pow(i,mod-2))%mod;
        if(i==a) a_=now;
        if(i==b) b_=now;
    }
    int ans=quick_pow(2,n)-1;
    ans=(ans+mod+mod-a_-b_)%mod;
    printf("%lld\n",ans);
    return 0;
}


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

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

int main() {
  ll N, i = 2;
  int S = 0;
  cin >> N;
  map<int, int> v;
  double sN = sqrt(N);
  for(;i <= sN;i += 2) {
    while (N % i == 0) {
      N /= i;
      v[i]++;
    }
    if (i == 2) i--;
    if (N == 1) break;
    sN = sqrt(N);
  }
  if (N > 1) {
    v[N] = 1;
  }
  for(auto m : v) {
    REP(j, 40) {
      if (j * (j + 1) / 2 <= m.second && m.second < (j + 1) * (j + 2) / 2) {
        S += j;
        break;
      }
    }
  }
  cout << S << endl;
}

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

using namespace std;

vector <int> V;
int A[222];
int n;

int main()
{
	int i, j, t;
	
	scanf("%d", &n);
	
	for(i=1; i<=n; i++){
		scanf("%d", A+i);
	}
	
	for(i=1; i<=n; i++){
		t = 1;
		for(j=1; j<n; j++){
			if(A[j] > A[j+1]){
				for(; t<j+1; t++) V.push_back(1);
				swap(A[j], A[j+1]);
				V.push_back(n - 1);
			}
		}
		for(; t<=n; t++) V.push_back(1);
	}
	
	printf("%d\n", (int)V.size());
	
	for(int t: V) printf("%d\n", t);
	
	return 0;
}

Measured memory_bytes: 764
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] s = new int[n];
        for (int i = 0; i < n; i++) {
            s[i] = sc.nextInt();
        }
        int q = sc.nextInt();
        int[] t = new int[q];
        for (int i = 0; i < q; i++) {
            t[i] = sc.nextInt();
        }

        int c = 0;
        for (int i = 0; i < q; i++) {
            for (int j = 0; j < n; j++) {
                if (t[i] == s[j]) {
                    c++;
                    break;
                }
            }
        }
        System.out.println(c);
    }
}

Measured memory_bytes: 40052
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  unsigned long long q, h, s, d, n;
  cin>>q>>h>>s>>d>>n;
  unsigned long long ans=0;
  unsigned long long min_unit_cost=min(s,min(2*h,4*q));
  unsigned long long min_double_cost=min(d,2*min_unit_cost);
  ans = (n%2)*min_unit_cost + (n/2)*min_double_cost;
  cout<<ans;
}

Measured memory_bytes: 256
import itertools

n = int(input())

p = [int(i) for i in input().split()]
q = [int(i) for i in input().split()]

init = sorted(p)


# print(p, q, init)
countp, countq, count = 0, 0, 0

for array in itertools.permutations(init, n):
    # print(array)
    count += 1
    if(list(array) == p):
        countp = count
    if(list(array) == q):
        countq = count


print(abs(countp-countq))


Measured memory_bytes: 9184
n = int(input())
breaker = 0
for s in range(n):
	a = [int(i) for i in input().split()]
	tour = a[1] + a[2]
	if tour > a[0]:
		breaker += 1
	elif tour % 2 != a[0] % 2:
		breaker += 1
	if breaker != 0:
		print("No")
		break
if breaker == 0:
	print("Yes")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#include<iomanip>//浮動小数点数を出力する制度の指定
//使い方　数値をnumとして　cout<<setprecision(n)<<num ;nは桁数
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
using ll =long long;
#define INF 2000000000
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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
/*覚えてないことメaモ
数値型から文字列に変換　to_string(number);これは簡単
文字列から数値型に変換　stoi(number)
文字列からllに変換　stoll(number)*/

//ここから書き始める
int main(){
	int a ; cin >> a;
	string s ; cin >> s;
	if(a>=3200) cout<<s<<endl;
	else cout<<"red"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repq(i,a,n) for(int i=a; i<=n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

// 2?¬????BIT
template <typename T>
struct twodimBIT{
private:
    vector< vector<T> > array;
    const int n;
    const int m;

public:
    // ?????????
    twodimBIT(int _n, int _m) : array(_n+1, vector<T>(_m+1, 0)), n(_n), m(_m) {}

    // (1, 1) ?????? (x, y) ?????§????´???????????±???????
    T sum(int x, int y) {
        T s = 0;
        for(int i=x; i>0; i-=i&(-i))
            for(int j=y; j>0; j-=j&(-j))
                s += array[i][j];
        return s;
    }

    // [(i1, j1), (i2, j2)]???????´??????????
    T sum(int i1, int j1, int i2, int j2) {
        return sum(i2, j2) - sum(i1-1, j2) - sum(i2, j1-1) + sum(i1-1, j1-1);
    }

    // (x, y) ??? ????´? k ?????????
    void add(int x, int y, T k) {
        for(int i=x; i<=n; i+=i&(-i))
            for(int j=y; j<=m; j+=j&(-j))
                array[i][j] += k;
    }
};

signed main() {
    int m, n, k; cin >> m >> n >> k;
    twodimBIT<int> cntJ(m, n), cntO(m, n), cntI(m, n);
    rep(i,0,m) {
        string s; cin >> s;
        rep(j,0,n) {
            if(s[j] == 'J') cntJ.add(i+1, j+1, 1);
            if(s[j] == 'O') cntO.add(i+1, j+1, 1);
            if(s[j] == 'I') cntI.add(i+1, j+1, 1);
        }
    }
    rep(i,0,k) {
        int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
        int ansJ = cntJ.sum(x1, y1, x2, y2);
        int ansO = cntO.sum(x1, y1, x2, y2);
        int ansI = cntI.sum(x1, y1, x2, y2);
        printf("%lld %lld %lld\n", ansJ, ansO, ansI);
    }
    return 0;
}

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

int main() {
	int n;
	cin>>n;
	int c[n],s[n],f[n];
	for(int i=1;i<n;i++){
		cin>>c[i]>>s[i]>>f[i];
	}
	int ans[n];
	for(int i=1;i<n;i++){
		ans[i]=s[i]+c[i];
		for(int j=i+1;j<n;j++){
			if(ans[i]<=s[j]){
				ans[i]=s[j]+c[j];
			}else{
				ans[i]=s[j]+c[j]+((ans[i]-s[j]-1)/f[j]+1)*f[j];
			}
		}
		cout<<ans[i]<<endl;
	}
	cout<<'0'<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<iostream>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
int main()
{

    
    int a, b;
    cin >> a >> b;
    map<int, int> mp1, mp2, mp3;
    mp1.clear();mp2.clear();mp3.clear();
    mp1[1]=1;mp1[3] = 1; mp1[5] = 1; mp1[7] = 1;mp1[8] = 1;mp1[10] = 1;mp1[12] = 1;
    mp2[4] = 1;mp2[6] = 1;mp2[9] = 1;mp2[11] = 1;mp3[2] = 1;
    if(mp1[a] && mp1[b])
        printf("Yes\n");
    else if(mp2[a] && mp2[b])
        printf("Yes\n");
    else if(mp3[a] && mp3[b])
        printf("Yes\n");
    else printf("No\n");
    return 0;
}



Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class CStrangeDance {
public:

    int calc(vector<vector<vector<int>>>& v, int k) {
      int w = 0;
      if (k > 0) {
        w = calc(v, k-1);
      }
      auto ret = v[2][k][w];

      auto w0 = v[0][k][w];
      auto w1 = v[1][k][w];
      auto w2 = v[2][k][w];

      v[1][k][w] = w0;
      v[2][k][w] = w1;
      v[0][k][w] = w2;
      return ret;
    }

    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n;
      cin >> n;
      string t;
      cin >> t;
      vector<vector<vector<int>>> v(3, vector<vector<int>>(n));
      int k = 1;
      rep(i, n) {
        rep(j, 3) {
          v[j][i].resize(k);
        }
        k *= 3;
      }
      int K = k;

      rep(i, n) {
        int idx = 0;
        rep(j, 3) {
          for(auto& e: v[j][i]) {
            e = idx;
            idx++;
          }
        }
      }

      for(auto c: t) {
        if (c=='S') {
          swap(v[1], v[2]);
        } else {
          calc(v, n-1);
        }
      }

      vector<int> ans(K);
      k = 1;
      rep(i, n) {
        rep(j, 3) {
          for(auto e: v[j][i]) {
            for(int idx=e; idx<K; idx+=(k*3)) {
              ans[idx] += j*k;
            }
          }
        }
        k *= 3;
      }

      for(auto e: ans) {
        cout << e << ' ';
      }
      cout << endl;

    }
};

signed main() {
  CStrangeDance solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T,class U>
istream& operator >> (istream&is, P<T,U>&p){
  is >> p.first >> p.second;
  return is;
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v){
    is >> e;
  }
  return is;
}

int main(){
  string s; cin >> s;
  int cnt = 0;
  int l = 0, r = (int)s.size()-1;
  while(l < r && cnt != -1){
    if(s[l] != s[r]){
      if(s[l] == 'x'){
	cnt++;
	l++;
      } else if(s[r] == 'x'){
	cnt++;
	r--;
      }else{
	cnt = -1;
      }
    }else{
      l++;
      r--;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3732
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<deque>
#include<limits>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

int main() {
	for (int N; cin >> N, N;) {
		vector< pair<int, int> > v;
		for (int i = 0; i < N; i++) {
			int a, b; scanf("%d%d", &a, &b);
			v.push_back(make_pair(a, -b));
		}
		int M; cin >> M;
		for (int i = 0; i < M; i++) {
			int a, b; scanf("%d%d", &a, &b);
			v.push_back(make_pair(a, -b));
		}
		sort(v.begin(), v.end());
		for (int i = 0; i < N + M; i++) {
			v[i].second *= -1;
		}

		vector<int> dp(N + M, INF);
		for (int i = 0; i < N + M; i++) {
			*lower_bound(dp.begin(), dp.end(), v[i].second) = v[i].second;
		}
		int ans = find(dp.begin(), dp.end(), INF) - dp.begin();
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1248
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('a1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def solve():
    A, B, C = read_int_list()
    if A == B == C:
      return 'No'
    if A == B or B == C or C == A:
      return 'Yes'
    return 'No'


def main():
    res = solve()
    print(res)


main()


Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve(int T)
{
    string s;
    cin >> s;
    int m=s.size();
    //cout << s[m-1];
    if(s[m-1]=='s')
    {
        s+='e';
        s+='s';
    }
    else
    {
        s+='s';
    }
    cout << s;
}



signed main()
{
    int t=1;
    //scanf("%d",&t);
    for(int i=1;i<=t;i++)
    {
        solve(i);
    }
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (n); i++)
 
int main(){
    long long N;
    cin >> N;
    long long res = 0;
    if(N==0){
        cout  << 0 << endl;
    }else{
        long long i = 1;
        long long e = 0;
        long long res = 0;
        string s="";
        if(N%2){
            res += 1<<(1-1);
            N--;
            i++;
            e++;
            s+="1";
        }
        while(N!=0){
            long long a = N % ((long long)pow(2,i));
            long long b = pow(-2,e);
            if(abs(a) == abs(b)){
                N -= b;
                res+= 1 << (i-1);
                s+="1";
            }else{
                s+="0";
            }
            i++;e++;
        }
        reverse(s.begin(),s.end());
        cout << s << endl;

    }
    return 0;
}

Measured memory_bytes: 256