akhauriyash/Code-Regression huggingface dataset:
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

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

signed main(void)
{
	string s;
	cin >> s;
	s[5] = ' ';
	s[13] = ' ';
	cout << s << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
char x, y;
int main(int argc, const char * argv[]){
    cin>>x>>y;
    if(x < y)cout<<"<"<<endl;
    else if(x == y)cout<<"="<<endl;
    else cout<<">"<<endl;
    return 0;
}

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

int main(){
  int n;
  int num;
  int x[1001] = {0};
  
  cin >> n;
  
  for  ( int i = 1; i * i < 1001; i++ ){
    for ( int j = 2; j < 10; j++ ){
      num = 1;
      
      for ( int k = 0; k < j; k++ ){
        if ( num * i > 1000 ) break;
        num *= i;
      }
      //cout << num << endl;
      x[num] = 1;
    }
  }
  
  for ( int i = n; i > 0; i-- ){
    if ( x[i] == 1 ){
      cout << i << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int mx = max({a,b,c});
  int ans = 0;
  while(a+2<=mx)a+=2,ans++;
  while(b+2<=mx)b+=2,ans++;
  while(c+2<=mx)c+=2,ans++;
  int cnt = 0;
  if(a==mx)cnt++;
  if(b==mx)cnt++;
  if(c==mx)cnt++;
  if(cnt==3){
    //
  }else if(cnt==2){
    ans += 2;
  }else if(cnt==1){
    ans += 1;
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int ans = 0;
		
		for(int i = 1;i < S.length();i++) {
			if(S.charAt(i) == S.charAt(i - 1)) {
				continue;
			}else {
				ans += 1;
			}
		}
		System.out.println(ans);
	}
}


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

using namespace std;



int main()
{
    string a;
    cin>>a;
    if(a[0]!='R'&&a[1]!='R'&&a[2]!='R')cout<<0<<endl;
    else if(a[0]=='R'&&a[1]!='R')cout<<1<<endl;
    else if(a[0]=='R'&&a[1]=='R'&&a[2]=='R')cout<<3<<endl;
    else if(a[0]=='R'&&a[1]=='R'&&a[2]!='R')cout<<2<<endl;
    else if(a[0]!='R'&&a[1]=='R'&&a[2]=='R')cout<<2<<endl;
    else if(a[0]!='R'&&a[1]=='R'&&a[2]!='R')cout<<1<<endl;
    else if(a[0]!='R'&&a[1]!='R'&&a[2]=='R')cout<<1<<endl;
}


Measured memory_bytes: 3612
#include<iostream>
#include<map>
#include<string>
#include<stdlib.h>

int OFA();//Operation of Frequency of Appearance

void listen_nums(int nums[],const int count_nums);
void calc_appearance(int nums[],int appearance[],const int count_nums);
void write_calcedArray(int nums[],int appearance[],const int count_nums);
bool is_notMoved(int nums[],int appearance[],const int count_nums);
void echo_intArray(int array[],const int length);

//-------------------------main-------------------------------
int main()
{
	while(OFA());
	return 0;
}

int OFA()
{
	using namespace std;
	int count_nums;
	cin>>count_nums;
	if(!count_nums)
	{
		return 0;
	}
	int nums[count_nums];
	listen_nums(nums,count_nums);
	int appearance[count_nums];
	
	int calcCount=0;
	for(;1;)
	{
		calc_appearance(nums,appearance,count_nums);
		if(is_notMoved(nums,appearance,count_nums))
		{
			cout<<calcCount<<endl;
			echo_intArray(appearance,count_nums);
			return 1;
		}
		else
		{
			calcCount++;
			write_calcedArray(nums,appearance,count_nums);
		}
	}
	
}
//-----------------------------------------------------------

void listen_nums(int nums[],const int count_nums)
{
	using namespace std;

	for(int i=0;i<count_nums;i++)
	{
		cin>>nums[i];
	}
}

void calc_appearance(int nums[],int appearance[],const int count_nums)
{
	using namespace std;
	
	map<int,int> count_eachNums;
	
	int i;
	for(i=0;i<count_nums;i++)
	{
		if(count_eachNums.find(nums[i])==count_eachNums.end())
		{
			count_eachNums.insert(map<int,int>::value_type(nums[i],1));
		}
		else
		{
			count_eachNums[nums[i]]++;
		}
	}
	for(i=0;i<count_nums;i++)
	{
		appearance[i]=count_eachNums[nums[i]];
	}
}

void write_calcedArray(int nums[],int appearance[],const int count_nums)
{
	for(int i=0;i<count_nums;i++)
	{
		nums[i]=appearance[i];
	}
}

bool is_notMoved(int nums[],int appearance[],const int count_nums)
{
	for(int i=0;i<count_nums;i++)
	{
		if(nums[i]!=appearance[i])
		{
			return false;
		}
	}
	return true;
}
void echo_intArray(int array[],const int length)
{
	using namespace std;
	
	cout<<array[0];
	for(int i=1;i<length;i++)
	{
		cout<<" "<<array[i];
	}
	cout<<endl;
}

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

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

  char s[10];
  sprintf(s, "%d%d", a, b);
  int num=atoi(s);
  int sq = (int)sqrt(num);
  if (sq*sq == num) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N; cin>>N;
  int c=0;
  int t=N;
  while(t>0){
    c+=t%10;
    t=t/10;
  }
  if(N%c==0)
    cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main(){
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    int w = tx - sx;
    int h = ty - sy;
    rep(i,w)cout << 'R';
    rep(i,h)cout << 'U';
    rep(i,w)cout << 'L';
    rep(i,h+1)cout << 'D';
    rep(i,w+1)cout<<'R';
    rep(i,h+1)cout<<'U';
    cout<<'L';
    cout<<'U';
    rep(i,w+1)cout<<'L';
    rep(i,h+1)cout<<'D';
    cout<<'R'<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int m,a,b,x,y,r,g,i;
	for(;scanf("%d%d%d%d",&m,&a,&b,&x)>3;){
		for(g=0,i=1;i<m;i++){
			scanf("%d",&y);
			if(a<=i&&i<=b && x-y>=g)g=x-y,r=i;
			x=y;
		}
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 2672
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
int N, M;
vector<int> G[100005];
int DP[100005];

int dfs(int idx){
  if (DP[idx] > 0) return DP[idx];
  int ans = 0;
  rep(i, G[idx].size()){
    int n = G[idx][i];
    int nxt_dp = dfs(n) + 1;
    ans = max(ans, nxt_dp);
  }
  DP[idx] = ans;
  return ans;
}

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

  cin >> N >> M;
  int a, b;
  rep(i, M) {
    cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
  }

  int ans = 0;
  rep(i, N) {
    ans = max(ans, dfs(i));
  }

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


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

using namespace std;

#define N 100100
#define SIGMA 26

pair<int, int> v[N];
int a[3][3], sel[3][3];
int i, n, j, ok, x, I, J;
int main()
{
    for (i = 0; i < 10000; ++i)
        v[i].first = v[i].second = -1;
    for (i = 0; i < 3; ++i)
    for (j = 0; j < 3; ++j){
        cin >> a[i][j];
        v[a[i][j]].first = i;
        v[a[i][j]].second = j;
    }
    cin >> n;
    for (i = 0; i < n; ++i){
        cin >> x;
        I = v[x].first;
        J = v[x].second;
        if (I > -1 && J > -1)
            sel[I][J] = 1;
    }
    ok = 0;
    for (i = 0; i < 3; ++i){
        if (sel[i][0] + sel[i][1] + sel[i][2] == 3)
            ok  = 1;
        if (sel[0][i] + sel[1][i] + sel[2][i] == 3)
            ok = 1;
        if (sel[0][0] + sel[1][1] + sel[2][2] == 3)
            ok = 1;
        if (sel[2][0] + sel[1][1] + sel[0][2] == 3)
            ok = 1;
    }
    if (ok)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 384
import sys, os
import collections

def solve(input_stream):
  table = {
    "A": "T",
    "T": "A",
    "C": "G",
    "G": "C"
  }
  ans = ""
  for i in input_stream.readline().strip():
    ans += table[i]
  return [ans]

if __name__ == "__main__":
    outputs = solve(sys.stdin)
    for line in outputs:
      print(line)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
    ll x, tmp = 100, result = 0;
    cin >> x;
    while (tmp < x) {
        tmp = tmp * 1.01;
        result++;
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 3636
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll inf = 1e9 + 7;
const ll Mod = 998244353;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);


int main(){
  int D, N; cin >> D >> N;

  if (D == 0){
    if (N != 100) cout << N << endl;
    else cout << 101 << endl;
  }else if (D == 1){
    if (N != 100) cout << N * 100 << endl;
    else cout << 10100 << endl;
  }else{
    if (N != 100) cout << N * 10000 << endl;
    else cout << 1010000 << endl;
  }

  return 0;
}


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

long memo[90];

long rec(int n){
	if(n == 0) return 2;
	if(n == 1) return 1;
	if(memo[n] != 0) return memo[n];
	long ret = rec(n-1) + rec(n-2);
	return memo[n] = ret;
}

int main(){
	int n;
	scanf("%d", &n);
	printf("%ld\n", rec(n));
}


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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    vector<int> ans(n);
    rep(x, 2) {
        int cnt = 0;
        rep(i,n) {
            if(s[i]=='R') cnt++;
            else{
                ans[i] += cnt/2;
                ans[i-1] += (cnt+1)/2;
                cnt = 0;
            }
        }
        reverse(all(ans));
        reverse(all(s));
        rep(i,n) {
            if(s[i]=='L') s[i] = 'R';
            else s[i] = 'L';
        }
    }
    rep(i,n) {
        cout << ans[i] << " ";
    }
    puts("\n");
    return 0;
}


Measured memory_bytes: 1024
def v(n):
    r=1
    for i in range(1,n+1):
        r=(r*i)%1000000007
    return r

m=1000000007
s =int(input())
ans=0
for i in range(1,s//3 +1):
    n=s-i*3
    c=(v(n+i-1)*pow(v(n),m-2,m)*pow(v(i-1),m-2,m))%m
    ans=(ans+c)%m
print(ans)

Measured memory_bytes: 9140
N=int(input())
A=list(map(int,input().split()))
S={}
for i in range(N):
  if A[i] in S: S[A[i]]+=1
  else: S[A[i]]=1
d=0
for i in S.values():
  d+=(i-1)
print(len(set(A))-d%2)

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

#define st first
#define nd second
#define ll long long
#define ld long double
#define pb push_back
#define emp emplace_back
#define pii pair<int, int>
#define usg unsigned
#define sg signed
#define mp make_pair

using namespace std;

void setIO(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

const ld PI = 4*atan((ld)1);
const int INF = 1e9+7;

set<string>s;

int main(){
	setIO();
	int n; cin>>n;
	for(int i=0;i<n;i++){
		string str;
		cin>>str;
		s.insert(str);
	}
	cout<<s.size()<<endl;
}

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

const int MAX_N = 100000;

int main(){
    string n;
    cin >> n;
    int len = n.size();
    for(int i=0;i<len/2;i++){
        if(n[i]==n[len-1-i]){
            
        }else{
            cout <<"No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int len = sc.nextInt();
		String s = sc.next();

		if (len % 2 == 0){
			String first = s.substring(0 , len / 2);
			String second = s.substring(len / 2);
			if (first.equals(second)){
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		} else {
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1e9 + 7;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}

void solve() {
  string s;
  cin >> s;
  int n = sz(s);
  vector<vector<int> > dp(n + 1, vector<int>(15));
  dp[0][0] = 1;
  rep(i, n) rep(j, 13) {
    if (s[i] == '?') {
      rep(k, 10) {
        add(dp[i + 1][(j * 10 + k) % 13], dp[i][j]);
      }
    } else {
      add(dp[i + 1][(j * 10 + s[i] - '0') % 13], dp[i][j]);
    }
  }
  cout << dp[n][5] << endl;
}


Measured memory_bytes: 10576
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const int MOD = 1e9+7;
const int INF = 1<<30;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<ll> a(n + 1), b(n + 1);
    ll sum = 0;
    REP(i, 1, n+1) {
        ll x;
        cin >> x;
        a[i] = x + i;
        b[i] = i - x;
        if (a[i] == b[i]) sum--;
    };
    sort(b.begin(), b.end());

    REP(i, 1, n+1) {
        int t = upper_bound(b.begin(), b.end(), a[i]) - lower_bound(b.begin(), b.end(), a[i]);
        sum += t;
    }

    cout << sum << endl;


    return 0;
}

Measured memory_bytes: 6368
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

const int INF = INT_MAX;

template<typename T>
class SegTree2D {
public:
  int h,w;
  vector<vector<T>> data;
  SegTree2D(const int _h, const int _w){
    h=1;w=1;
    while(h<_h) h*=2;
    while(w<_w) w*=2;
    data.resize(2*h, vector<T>(2*w, INF));
  }
  T query(const int kh, int wl, int wr) const {
    T ret = INF;
    for(wl+=w, wr+=w; wl<wr; wl/=2, wr/=2){
      if(wl&1) ret = min(ret, data[kh][wl++]);
      if(wr&1) ret = min(ret, data[kh][--wr]);
    }
    return ret;
  }
  T query(int hl, int hr, const int wl, const int wr) const {
    T ret = INF;
    for(hl+=h, hr+=h; hl<hr; hl/=2, hr/=2){
      if(hl&1) ret = min(ret, query(hl++,wl,wr));
      if(hr&1) ret = min(ret, query(--hr,wl,wr));
    }
    return ret;
  }
  void updateInner(const int kh, int kw, const T a){
    kw += w;
    data[kh][kw] = a;
    while(kw > 0){
      kw = kw / 2;
      data[kh][kw] = min(data[kh][kw*2], data[kh][kw*2+1]);
    }
  }
  void update(int kh, const int kw, const T a){
    kh += h;
    updateInner(kh, kw, a);
    while(kh > 0){
      kh = kh/2;
      updateInner(kh, kw, min(data[kh*2][kw+w], data[kh*2+1][kw+w]));
    }
  }
};

int main(){
  int r,c,q;
  while(scanf("%d %d %d", &r, &c, &q), r){
    SegTree2D<int> st(r,c);
    rep(i,r) rep(j,c){
      int x;
      scanf("%d", &x);
      st.update(i,j,x);
    }
    rep(i,q){
      int x1,y1,x2,y2;
      scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
      printf("%d\n", st.query(x1, x2+1, y1, y2+1));
    }
  }
  return 0;
}



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

int main()
{
    vector<int> l{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << l[k - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars
    }
    let mut p1 = '0';
    let mut p2 = '1';
    let mut c1 = 0;
    let mut c2 = 0;
    fn flip(p: &mut char) {
        if *p == '0' { *p = '1' } else { *p = '0' }
    }
    for c in s {
        if c != p1 { c1 += 1 }
        if c != p2 { c2 += 1 }
        flip(&mut p1);
        flip(&mut p2);
    }
    println!("{}", std::cmp::min(c1,c2));
}


Measured memory_bytes: 4352
#include <iostream>
#include <cmath>
#include <cstring>
#include <cfloat>
#include <algorithm>
using namespace std;

int id[15], dist[15], ryou[15];
double t[32768][15];
pair<int,int> prv[32768][15];

int main() {
    memset(t, 0, sizeof t);
    int n; cin >> n;
    for (int i=0; i<n; ++i) {
        cin >> id[i] >> dist[i] >> ryou[i];
    }
    int last = (1<<n)-1;
    for (int bt=1; bt<=last; ++bt) {
        for (int i=0; i<n; ++i) {
            if (bt & (1<<i) && bt - (1<<i)) {
                int bt2 = bt - (1<<i);
                t[bt][i] = DBL_MAX;
                int w = 0;
                for (int j=0; j<n; ++j) {
                    if (bt2 & (1<<j)) {
                        w += ryou[j] * 20;
                    }
                }
                for (int j=0; j<n; ++j) {
                    if (bt2 & (1<<j)) {
                        double tt = t[bt2][j] + abs(dist[i] - dist[j]) * (7.0 + w) / 200.0;
                        if (tt < t[bt][i]) {
                            t[bt][i] = tt;
                            prv[bt][i] = make_pair(bt2, j);
                        }
                    }
                }
            }
        }
    }
    double mn = DBL_MAX;
    pair<int,int> key;
    for (int i=0; i<n; ++i) {
        if (t[last][i] < mn) {
            mn = t[last][i];
            key = make_pair(last, i);
        }
    }
    vector<int> res;
    while (0 < key.first) {
        res.push_back(id[key.second]);
        key = prv[key.first][key.second];
    }
    for (int i=n-1; i>=0; --i) {
        cout << (i == n-1 ? "" : " ") << res[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 8896
n,m = map(int, input().split())
l = list(map(int, input().split()))
total_voting = sum(l)


border = total_voting / (4 * m)

ll = []
for i in l:
  if i >= border:
    ll.append(i)

if m <= len(ll):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9060
#include <iostream>  
#include <stdio.h> 
using namespace std;

#include<stdio.h>

int main (void)
{ 
  int a,b,c,i,x;
  int arr[1000] = {0};
  
  scanf("%d %d %d",&a,&b,&x);
  
  c=a;
  if(a>b)c=b;
  int num=0;
  for(i=1;i<=c;i++)
    if(a%i==0&&b%i==0){
      arr[num] = i;
      //printf("%d\n",i);
      num++;
   }   

    
  printf("%d\n",arr[num-x]);
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long fr[200010],n,i,j,nr,v[200010];
int main()
{
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>v[i] , fr[v[i]]++;
    for(i=1;i<=n;i++)
        nr=nr+(fr[i]*(fr[i]-1))/2;
    for(i=1;i<=n;i++)
    {
        j=nr;
        nr=nr-fr[v[i]]*(fr[v[i]]-1)/2;
        nr=nr+((fr[v[i]]-1)*(fr[v[i]]-2)/2);
        cout<<nr<<'\n';
        nr=j;
    }
    return 0;
}


Measured memory_bytes: 4864
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <limits>

using std::cout;
using std::cin;

long long a, b, c, k, mm = (long long)1e18;

void task(){
    cin >> a >> b >> c >> k;
    if(abs(a - b) > 1e18)printf("Unfair\n");
    else {
        printf("%lld\n", (k & 1) ? -(a - b) : a - b);
    }
}
int main(){
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);

    // freopen("/Users/deepsajeda/Projects/input.txt","r", stdin);
    // freopen("/Users/deepsajeda/Projects/output","w",stdout);
    int tc = 1;
    while(tc--)task();
}
//printf("%.5f\n", clock() / (float)CLOCKS_PER_SEC); time in seconds

Measured memory_bytes: 256
x,n = list(map(int, input().split(" ")))
if n!=0:
    p_list = list(map(int, input().split(" ")))
else:
    print(x)
    exit()

p_set = set(p_list)
for i in range(100):
    test_x = x - i;
    if test_x not in p_set:
        print(test_x)
        break
    test_x = x + i;
    if test_x not in p_set:
        print(test_x)
        break



Measured memory_bytes: 9184
import java.util.*;

public class Main {
    static int n;
    static int[] dp;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        dp = new int[100000 + 2];
        for (int i = 0; i < n; i++) {
            int num = sc.nextInt();
            if (num == 0) {
                dp[num]++;
                dp[num+1]++;
            } else {
                dp[num-1]++;
                dp[num]++;
                dp[num+1]++;
            }
        }
        int max = 0;
        for (int i = 0; i < dp.length; i++) {
            if (max < dp[i]) {
                max = dp[i];
            }
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 48148
#include<iostream>
using namespace std;
int v[101][101] = { 0 };
int main() {
	int n; cin >> n;
	int u, k;
	for (int i = 1; i <= n;i++) {
		cin >> u >> k;
		for (int j = 0; j < k;j++) {
			int t; cin >> t;
			v[u][t] = 1;
		}
	}
	for (int i = 1; i <= n;i++) {
		for (int j = 1; j <= n;j++) {
			if (j != n) {
				cout << v[i][j] << ' ';
			}else{
				cout << v[i][j] << endl;
			}
		}
	}
}

Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
ll nod(ll F) { return log10(F) + 1; }
//**定義場所**//
//gcd, isPrime, eratos, modinv, bitSearch, dfs, bfs, dijkstra, UnionFind//
ll i, j, k, l, m, n; ll N, M, K, H, W, L; string S;
ll MOD = 1000000007; ll ans = 0; ll INF = 9999999999999;
vl flag, color; vll path;
//***********//
//main内でCOMinit(N+1)を忘れずに！
vl fac, finv, inv;
ll modinv(ll a, ll m) {
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
void COMinit(ll N) {
	fac.resize(N);
	finv.resize(N);
	inv.resize(N);
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
	cin >> N >> K;
	COMinit(N*2+1);
	for (i = 0; i <= min(N-1,K); i++) {
		ll pre = COM(N, i);
		ll pre2 = COM(i+N-1-i,i);
		//cout << pre << " " << pre2;
		ans = (ans + ((pre * pre2) % MOD)) % MOD;

	}
	cout << ans;
}


Measured memory_bytes: 9728
# 初期入力
import sys
input = sys.stdin.readline
N,Q = (int(x) for x in input().split())
S =input().strip()

# ACのindex(左端)
import re
import numpy as np
x =[m.start() for m in re.finditer('AC', S)]
#x =np.array(x)

import bisect
ans =[]
for i in range(Q):
    l1,r1 = (int(x) for x in input().split())
    l =bisect.bisect_left(x,l1-1)
    r =bisect.bisect_right(x,r1-2)  #"AC"のAの位置と比べるため－２
    ans.append(r -l)
print(*ans,sep="\n")

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

int main(){
	int w, h, n;
	cin >> w >> h >> n;
	pair<int, int> l(0, 0), r(w, h);
	while(n--){
		int x, y, a;
		cin >> x >> y >> a;
		if(a == 1) l.first = max(l.first, x);
		if(a == 2) r.first = min(r.first, x);
		if(a == 3) l.second = max(l.second, y);
		if(a == 4) r.second = min(r.second, y);
	}
	if(r.first - l.first < 0 && r.second - l.second < 0){
		cout << 0 << endl;
		return 0;
	}
	cout << max(0, (r.first - l.first) * (r.second - l.second)) << endl;
}

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

int main(void) {
    int N;
    cin>>N;
    set<int> s;
    for (int i = 0; i < N; i++) {
        int A;
        cin>>A;
        if (s.find(A) != s.end()) {
            cout << "NO" << endl;
            return 0;
        }
        s.insert(A);
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;

int main(){
    long long k, n;
    cin >> k >> n;
    long long arr[n];
    for(long long i = 0; i < n; i++){
        cin >> arr[i];
    }
    long long mi = k - (k - arr[n-1] + arr[0]);
    for(long long i = 1; i < n; i++){
        mi = min(mi, k - (arr[i] - arr[i-1]));
    }
    cout << mi << '\n';
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <typename T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> bool chmin(T &a, const T &b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const long long INFLL = 1LL << 60;
const long long MOD = 1e9 + 7;

int main() {
    int N, K, C;
    string S;
    cin >> N >> K >> C >> S;
    vector<int> f(K, 0), b(K, 0);
    int d = 0;
    for(int i = 0; i < K; i++) {
        while(S.at(d) == 'x')
            d++;
        f[i] = d + 1;
        d += C + 1;
    }
    d = N - 1;
    for(int i = K - 1; i >= 0; i--) {
        while(S.at(d) == 'x')
            d--;
        b[i] = d + 1;
        d -= C + 1;
    }
    rep(i, K) if(f[i] == b[i]) cout << f[i] << endl;
}

Measured memory_bytes: 5128
#include<bits/stdc++.h>
#include<cmath>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#define R register int
#define mm make_pair
using namespace std;
const int manx=300;
#define LL long long
int a[1000050];
int main()
{
    int n, k; cin >> n >> k;

    int ma = 0;
    for (int i = 1; i <= k; i ++)
    {
        cin >> a[i];

    }
    a[k+1] = a[1] + n;

    for (int i = 1; i <= k; i ++)
    {
        ma = max(a[i+1]-a[i], ma);
    }
    cout << n-ma;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
// #define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair<ll,ll>
// #define pii pair< int, pi >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
using namespace std::chrono;

string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void solve(){
  ll n,x,y;
  cin>>n;
  vpii v(n);
  vector<ll> v1,v2;
  rep(i,0,n) {cin>>x>>y; v1.pb(x+y);v2.pb(x-y);}
  sort(all(v1));
  sort(all(v2));
  ll mx=abs(v1[n-1]-v1[0]);
  mx=max(mx,abs(v2[n-1]-v2[0]));
  cout<<mx<<endl;
}
int main(){
    optimizeIO();
    solve();
}


Measured memory_bytes: 9764
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iostream>
#include <algorithm>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)

#define INF 1e9;
#define MOD 1e9+7;
#define INF64 1e18;

#define F first
#define S second


using namespace std;

SINT32 DDDD[90001][2];
SINT32 DPPP[90001];

int main() {

	SINT32 H,W,D;
	SINT32 Q;
	SINT32 S,G;
	SINT64 ans = 0;
	cin >> H >> W >> D;
	
	rep(i,0,H) {
		rep(j,0,W) {
			SINT32 BUF;
			cin >> BUF;
			DDDD[BUF-1][0] = i;
			DDDD[BUF-1][1] = j;
		}
	}

	rep(i,D,H*W) {
		DPPP[i] = 0;
		DPPP[i] += ABS(DDDD[i][0] - DDDD[i-D][0]) + DPPP[i-D];
		DPPP[i] += ABS(DDDD[i][1] - DDDD[i-D][1]);
	}

	cin >> Q;

	rep(i,0,Q) {
		ans = 0;
		cin >> S;
		cin >> G;

		if (S != G) {
			ans = DPPP[G-1] - DPPP[S-1];
		}


		cout << ans << endl;
	}

	
	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());	//ソート後に使用

//	DATA.insert(DATA.begin() + X, 0);	//X番目の要素に0を挿入


//	vector<vector<SINT32>> DP(N,vector<SINT32>(3));　//2次元配列

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;


//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();	//key以上を探す
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();


/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/

/* SET コンテナ
	set<SINT32> DATA;
	for (SINT32 i = 0; i < N; i++) {
		SINT32 buf;
		cin >> buf;
		DATA.insert(buf);
	}

	//全表示
    set<string>::iterator it; //  イテレータを用意
    for(it = DATA.begin(); it != DATA.end(); it++) {
        cout << *it << endl;
    }

	//N番目を一部表示
	set<string>::iterator it; //  イテレータを用意
	it = DATA.begin();
	rep (i,0,N) {
		it++;
	}
	cout << *it << endl;
*/

/* map
	map<string,SINT32> mp;
	SINT32 N = 0;
	SINT32 mx = 0;

	cin >> N;
	for (SINT32 i = 0; i < N; i++) {
		string s;
		cin >> s;
		mp[s]++;
	}
	for(auto it=mp.begin();it!=mp.end();it++) {
		mx=max(mx,it->second);
	}

*/

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

namespace ConsoleApp1
{
    static class CWalkonMultiplicationTable
    {
        static void Main(string[] args)
        {
            // 2 <= n <= 10^12
            var n = long.Parse(Console.ReadLine());

            long moveCount = n - 1;

            for (long i = 2; i * i <= n; i++)
            {
                if (n % i == 0)
                {
                    moveCount = Math.Min(moveCount, (i + n / i) - 2);
                }
            }

            Console.WriteLine(moveCount);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 13140
s = input()
t = input()

ans = {c:[] for c in 'abcdefghijklmnopqrstuvwxyz'}
res = {c:[] for c in 'abcdefghijklmnopqrstuvwxyz'}
cnt = 0
for a,b in zip(s,t):
    ans[b].append(a)
    res[a].append(b)
    # elif ans[a] != a and ans[ans[a]] != ans[b]:
    #     print(a, b, '0', a, b, ans[a],  ans[b], cnt)
    #     print('No')
    #     break
    cnt += 1

aa = [0 for v in ans.values() if len(set(v)) > 1]
bb = [0 for v in res.values() if len(set(v)) > 1]

if len(aa) == 0 and len(bb) == 0:
    print('Yes')
else:
    print('No')
# print(ans)


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

int main(void){
    int a,c,e;
    char b,d;
    cin >> a >> b >> c >> d >> e;
    if(c > 4){
        cout << "TBD" << endl;
    }else{
        cout << "Heisei" << endl;
    }
}

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

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

    rep(i,k) {
        if (b >= c) {
            c = c * 2;
        } else if (a >= b) {
            b = b * 2;
        }
    }

    if ((a < b) && (b < c)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3616
# AOJ 1053: Accelerated Railgun
# Python3 2018.7.7 bal4u

EPS = 1e-7
while True:
	d = float(input())
	if d == 0: break
	px, py, vx, vy = map(float, input().split())
	ans = d+1
	dp = (px*px + py*py)**0.5
	dv = (vx*vx + vy*vy)**0.5
	x = (px*vx + py*vy)/(dp*dv)
	if abs(x+1) <= EPS: ans = dp
	elif abs(1-x) <= EPS: ans = 2-dp
	print(ans if abs(ans-d) <= EPS or ans <= d else "impossible")



Measured memory_bytes: 5640
f=input
from bisect import bisect_left as g, insort as h
n,s=int(f()),list(f())
d={chr(97+i):[] for i in range(26)}
for i in range(n): d[s[i]]+=[i]
for _ in range(int(f())):
  a,b,c=f().split(); b=int(b)-1
  if a>'1': print(sum(1 for l in d.values() if g(l,b)<len(l) and l[g(l,b)]<int(c)))
  elif s[b]!=c: l=d[s[b]]; l.pop(g(l,b)); s[b]=c; h(d[c],b)

Measured memory_bytes: 120308
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int i,j,k,n,m;
void read(int &x){
	char c;x=0;int b=1;do{c=getchar();if(c==45)b=-1;}while(c>57||c<48);
	do x=x*10+c-48,c=getchar();while(c<=57&&c>=48);x*=b;
}
void read(ll &x){
	char c;x=0;int b=1;do{c=getchar();if(c==45)b=-1;}while(c>57||c<48);
	do x=x*10+c-48,c=getchar();while(c<=57&&c>=48);x*=b;
}
const double HD=57.295779513;
double a,b,c,x;
int main() {
	cin>>a>>b>>x;
	x/=a;
	if(a*b/2>x){
		a=x/b*2;
		printf("%.8lf\n",atan(b/a)*HD);
	}else{
		x=a*b-x;
		b=x/a*2;
		printf("%.8lf\n",atan(b/a)*HD);
	}
	//cerr << 1.0*clock()/CLOCKS_PER_SEC << endl;
	return 0;
}


Measured memory_bytes: 256
#define mm(a) memset(a,0,sizeof(a));
#define max(x, y) (x)>(y)?(x):(y)
#define min(x, y) (x)<(y)?(x):(y)
#define Fopen freopen("1.in","r",stdin); freopen("m.out","w",stdout);
#define rep(i, a, b) for(int i=(a);i<=(b);i++)
#define per(i, b, a) for(int i=(b);i>=(a);i--)
#define PII pair<ll,ll>
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const int MAXN = 2e5+5;

int n,a[MAXN],b[MAXN];
int main() {
    while(~scanf("%d",&n)){
        for(int i=1;i<=n;i++)scanf("%d",&a[i]),b[i]=a[i];
        sort(b+1,b+1+n);
        int cnt=0;
        for(int i=1;i<=n;i++)if(a[i]!=b[i])cnt++;
        if(cnt<=2)printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
 
int main() {
	char s[11];
	cin >> s;
	int n = strlen(s);
 
	long long int ans = 0, sum = 0, temp = 0;
	for (int i = 0; i < (1 << (n-1)); i++) {
		sum = 0;
		temp = s[0] - '0';

		for (int j = 0; j < (n-1); j++) {
			if (i >> j & 1) {
				sum += temp;
				temp = s[j + 1] - '0';
			}
			else {
				temp = temp * 10 + s[j + 1] - '0';
			}
		}
		sum += temp;
		ans += sum;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
graph = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(H)]

for k in range(10):
    for i in range(10):
        if graph[i][k] == 0:
            continue
        for j in range(10):
            if graph[k][j] == 0:
                continue
            graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j])
            
print(sum(graph[v][1] for c in A for v in c if v != -1))



Measured memory_bytes: 41180
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[4];
  for(int i=0;i<3;i++)cin>>a[i];
  sort(a,a+3);
  if(a[0]==5&&a[1]==5&&a[2]==7)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return(0);
}


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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000003;

LL mod_inv(LL a, LL md = 1000003) {
	LL b = md, u = 1, v = 0;
	while (b) {
		LL t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= md;
	if (u < 0) u += md;
	return u;
}

LL power(LL a, LL b, LL md = 1000003) {
	assert(b >= 0);
	LL res = 1;
	while (b) {
		if (b & 1) res = res * a % md;
		a = a * a % md;
		b >>= 1;
	}
	return res;
}

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

  vector<LL> fact(2000010, 1);
  FOR(i,1,2000010){
    fact[i] = fact[i - 1] * i;
    fact[i] %= mod;
  }
  fact[0]=0;

  LL Q;
  cin>>Q;
  REP(gjsog,Q){
    LL x,d,n;
    cin >> x >> d >> n;

    if(d==0){
      cout<<power(x, n)%mod<<endl;
      continue;
    }
    if(n>=mod){
      cout << 0 << endl;
      continue;
    }

    LL dinv = mod_inv(d);
    LL m = x * dinv;
    m %= mod;
    m--;
    m += mod;
    m %= mod;

    LL ans = 1;

    LL hoge = 1;
    hoge *= fact[m];
    hoge %= mod;
    LL hogeinv = mod_inv(hoge);
    if(m==0){
      hogeinv = 1;
    }

    ans *= power(d, n);
    ans *= fact[(m+n)];
    ans %= mod;

    cout << (ans*hogeinv)%mod << endl;
  }
}

// d^a*1*2*3*...*a(m=3)(n)
// d*(d+d)*(d+d+d)*{(d*m)=x}*(x+d)*
// d^n* (m+1)* ... * (m+n)

//(m*a)

// x*(x+d)*(x+d+d)*(x+d+d+d)*

// xx
// xd

// d*m == x (mod 1000003)

// x*d^-1


Measured memory_bytes: 16512
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define INF (2 << 28)
#define fr first
#define sc second
using namespace std;

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

int n, L, a[111111];
int sum[111111];

int rec(int idx){
 
  if(idx == n) return 0;
  if(sum[idx]) return sum[idx];
  if(idx == n-1 && a[idx] > a[idx - 1]) return L - a[idx];
  if(a[idx - 1] < a[idx] && a[idx] > a[idx + 1]) return L - a[idx];
  return sum[idx] = rec(idx + 1) + (L - a[idx]);
}

int main(){

  cin >> n >> L;
  for(int i = 0; i < n; i++) cin >> a[i]; 

  for(int i = 0; i < n; i++){
    if(i == 0){
      if(a[i] > a[i + 1]){
        sum[i] = L - a[i];
      }
      else {
        sum[i] = rec(i + 1) + (L - a[i]);
      }
    }
    else if(i == n - 1){
      if(a[i] > a[i - 1]){
        sum[i] = L - a[i];
      } else {
        sum[i] = sum[i - 1] + (L - a[i]);
      }
    }
    else {
       if(a[i - 1] < a[i] && a[i] > a[i + 1]){
         sum[i] = L - a[i];
       }
       else if(a[i - 1] > a[i] && a[i] < a[i + 1])
         sum[i] = max(sum[i - 1], rec(i + 1)) + (L - a[i]);
       else if(a[i] < a[i + 1]) sum[i] = rec(i + 1) + (L - a[i]);
       else if(a[i] < a[i - 1]) sum[i] = sum[i - 1] + (L - a[i]);
    }
  }

  cout << *max_element(sum, sum + n) << endl;  
}

Measured memory_bytes: 2340
#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 <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define TR ","
#define fi first
#define se second
#define rep(i,N) for(int i=0;i<(int)N;++i)
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

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

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

ll waz = 76543217;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (waz - inv(waz % x) * (waz / x)) % waz;
        if (a >= 0) { return a; }
        else { return waz + a; }
    }
}

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

vector<ll> p;

ll phi(ll x) {
    ll a = x;
    ll b = x;
    for (ll k = 0; k != p.size(); ++k) {
        if (a % p[k] == 0) {
            while (a % p[k] == 0) {
                a /= p[k];
            }
            b = b / p[k] * (p[k] - 1);
        }
        if (a == 1) { break; }
    }
    return b;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    IO;

    ll N, K; cin >> N >> K;
    vector<ll> H(N);
    rep(i, N) cin >> H[i];

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

    ll S = 0;

    rep(i, N - K) S += H[i];

    cout << S << endl;

}

Measured memory_bytes: 1792
if __name__ == '__main__':
	S = input()
	Q = int(input())

	c = 1

	A = ''
	B = ''

	for i in range(Q):
		I = input()
		if len(I) == 1:
			c = c * (-1)
		else:
			T, F, C = I.split()
			f = int(F)
			if f == 1 and c == 1:
				A = C + A
			elif f == 1 and c == -1:
				B = B + C
			elif f == 2 and c == -1:
				A = C + A
			else:
				B = B + C

	S = A + S + B

	if c == -1:
		S = S[::-1]

	print(S)

Measured memory_bytes: 4556
#include <iostream>
#include <string>

using namespace std;

int main() {
	int n;
	string s;
	cin >> n >> s;
	for (int i = 0; i < s.size(); ++i) {
		s[i] = (s[i] - 'A' + n) % 26 + 'A';
	}
	cout << s << "\n";
	return 0;
}


Measured memory_bytes: 256