akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;


int main() {
    int h,p,ans,sum;
    ans=0;
    scanf ("%d",&h);
    while(h){
      ans=0;
      vector<vector<int> > a(h+45,vector<int>(5,0));
      for(int s=h-1;s>=0;s--){
        for(int t=0;t<5;t++){
          scanf ("%d",&a[s][t]);
          ans=ans+a[s][t];
        }
      }
      p=100;
      while(p){
        for(int s=0;s<h;s++){
          if(a[s][0]==a[s][1]){
            if(a[s][1]==a[s][2]){
              if(a[s][2]==a[s][3]){
                if(a[s][3]==a[s][4]){
                  for(int t=0;t<5;t++){
                    a[s][t]=0;
                  }
                }
                else{
                  for(int t=0;t<4;t++){
                    a[s][t]=0;
                  }
                }
              }
              else{
                for(int t=0;t<3;t++){
                  a[s][t]=0;
                }
              }
            }
            else{
              if(a[s][2]==a[s][3]){
                if(a[s][3]==a[s][4]){
                  for(int t=2;t<5;t++){
                    a[s][t]=0;
                  }
                }
              }
            }
          }
          else{
            if(a[s][1]==a[s][2]){
              if(a[s][2]==a[s][3]){
                if(a[s][3]==a[s][4]){
                  for(int t=1;t<5;t++){
                    a[s][t]=0;
                  }
                }
                else{
                  for(int t=1;t<4;t++){
                    a[s][t]=0;
                  }
                }
              }
            }
            else{
              if(a[s][2]==a[s][3]){
                if(a[s][3]==a[s][4]){
                  for(int t=2;t<5;t++){
                    a[s][t]=0;
                  }
                }
              }
            }
          }
        }
        for(int t=0;t<5;t++){
          for(int k=0;k<h;k++){
            for(int s=0;s<h;s++){
              if(a[s][t]==0){
                for(int r=s;r<h;r++){
                    a[r][t]=a[r+1][t];
                }
              }
            }
          }
        }
        p--;
      }
      sum=0;
      for(int s=h-1;s>=0;s--){
        for(int t=0;t<5;t++){
          sum=sum+a[s][t];
        }
        //printf("%d %d %d %d %d\n",a[s][0],a[s][1],a[s][2],a[s][3],a[s][4]);
      }
      ans=ans-sum;
      printf("%d\n",ans);
      scanf ("%d",&h);
    }
}



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

int main() {
  int n;
  cin >> n;

  // 辺を何回使うか = x
  //
  // ### 全ての辺についての x の総和
  // sigma(x)
  // 辺
  // = 辺1のx + 辺2のx + ... 辺nのx
  // = 辺の本数 * x
  // ### n 個の町から2個を選び、その間にできる辺の数を数える
  // ### n=3 の場合、3C2 = (3*2) / (2*1) = 3 で、辺の本数は3本となる
  // = nC2 * x ... (a)
  //
  // ### n=3 の場合、3点を結ぶ辺は2本になる。そのため (n-1)
  // ### 町を巡回する経路は n! = 3*2*1 = 6通りある。
  // = (n-1) * n! ... (b)
  //
  // ### (a) (b) より
  //
  // nC2 * x = (n-1) * n!
  // x = ((n-1) * n!) / nC2
  // x = ((n-1) * n!) / (n*(n-1) / (2*1))
  // x = 2((n-1) * n!) / (n*(n-1))
  // x = 2 * (n-1)!
  //
  vector<int> x(n), y(n);
  for (int i = 0; i < n; i++) {
    cin >> x.at(i) >> y.at(i);
  }

  // [&] 参照キャプチャ、vectorコンテナ x, y を lambda 式内で参照している
  auto dist = [&](int i, int j) {
    double dx = x.at(i) - x.at(j);
    double dy = y.at(i) - y.at(j);
    return sqrt(dx*dx + dy*dy);
  };

  // 全パターンの辺の長さの和を求める
  double len = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i+1; j < n; j++) {
      // 特定2点の辺の長さ
      len += dist(i, j);
    }
  }

  // 辺の利用回数
  int num = 2;
  for (int i = 1; i <= (n-1); i++) {
    num = num * i;
  }

  // 巡回のパターン数
  int cnt = 1;
  for (int i = 1; i <= n; i++) {
    cnt = cnt * i;
  }

  // ### 入力例1の場合
  // len = (1,2) の辺の長さ + (2,3) の辺の長さ + (3,1) の辺の長さ
  // num = 全パターンの巡回を行った際、各辺の利用回数 = 4
  // len * num = 全パターンの巡回を行った際の辺の長さの和
  //
  // cnt = 巡回のパターン数
  // (len * num) / cnt = 1パターンごとの経路の平均値
  //
  //
  // ### 経路の長さの平均値である ans を算出する数式を整理する
  //
  // x = 2 * (n-1)!
  //
  // ans = (各辺の長さの和 * 1辺ごとの利用回数) / パターン数
  //     = (sigma(len) * (2 * (n-1)!)) / n!
  //     = (sigma(len) * 2) / n
  //
  // これより、以下の式でもOK
  // double ans = (len * 2) / n;
  // これより平均値
  double ans = (len * num) / cnt;

  printf("%.10f\n", ans);
  return 0;
}


Measured memory_bytes: 3848
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> p;

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    ll mod = pow(10, 9) + 7LL;

    ll N;
    cin >> N;

    vector<ll> x(N);

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

    if(N % 2) {
        if(x[0] != 1) {
            cout << 0 << endl;
            return 0;
        }

        for(int i = 2; i < N; i += 2) {
            if(x[i] != 2) {
                cout << 0 << endl;
                return 0;
            }
        }

        cout << modpow(2LL, N / 2LL, mod) << endl;
    } else {
        for(int i = 1; i < N; i += 2) {
            if(x[i] != 2) {
                cout << 0 << endl;
                return 0;
            }
        }

        cout << modpow(2LL, N / 2LL, mod) << endl;
    }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define ll long long
#define mod 1000000007
#define C 0.5772156649
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define pil pair<int,ll>
#define pii pair<int,int>
#define ull unsigned long long
#define base 1000000000000000000
#define fio ios::sync_with_stdio(false);cin.tie(0)
#define y1 y2
using namespace std;

const double g=10.0,eps=1e-12;
const int N=8000+10,maxn=200000+10,inf=0x3f3f3f3f;

vector<int>v[2];
bool d[2][3*N];
int x1,y1,x,y;
bool solve()
{
    int f=0;
    memset(d,0,sizeof d);
    d[0][x+N]=1;
    for(int i=0;i<v[0].size();i++)
    {
        for(int j=0;j<2*N;j++)
        {
            d[f^1][j]=false;
            if((j>=v[0][i]&&d[f][j-v[0][i]])||d[f][j+v[0][i]])
            {
                d[f^1][j]=1;
            }
        }
        f^=1;
    }
    return d[f][x1+N];
}
bool solve1()
{
    int f=0;
    memset(d,0,sizeof d);
    d[0][y+N]=1;
    for(int i=0;i<v[1].size();i++)
    {
        for(int j=0;j<2*N;j++)
        {
            d[f^1][j]=false;
            if((j>=v[1][i]&&d[f][j-v[1][i]])||d[f][j+v[1][i]])
            {
                d[f^1][j]=1;
            }
        }
        f^=1;
    }
    return d[f][y1+N];
}
int main()
{
    fio;
    string s;
    cin>>s>>x1>>y1;
    int i=0;
    while(i<s.size()&&s[i]=='F')x++,i++;
    int te=0,f=0;
    for(;i<s.size();i++)
    {
        if(s[i]=='T')
        {
//            cout<<i<<" "<<te<<endl;
            if(te)v[f].pb(te);
            te=0;
            f^=1;
        }
        else if(s[i]=='F')te++;
    }
    if(te)v[f].pb(te);
//    for(int i=0;i<v[0].size();i++)cout<<v[0][i]<<endl;
//    cout<<endl;
//    for(int i=0;i<v[1].size();i++)cout<<v[1][i]<<endl;
    if(solve()&&solve1())cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}
/********************
TTTTFTF
0 0
********************/


Measured memory_bytes: 384
// ~/Remember,remember the 6th of March

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double  EPS = 1e-8;
const ll MOD = 1000000007;
const int N = 100000 + 7;

int main()
{
    int n;
    cin>>n;
    vector<int>h(n);
    for(int &i:h)
        cin>>i;
    int ans=0,cnt=0;
    for(int i=0; i<n-1; i++)
    {
        if(h[i+1]<=h[i])
        {
            cnt++;
            ans=max(ans,cnt);
        }
        else
            cnt=0;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep2l(i, s, n) for (ll i = (ll)(s); i < (ll)n; i++)

int main() {
    int N;
    cin >> N;
    vector<vector<ll>> pre(2, vector<ll>(N));
    rep(i, N) {
        ll A;
        cin >> A;
        pre[0][i] = A;
    }
    rep(i, N) {
        ll B;
        cin >> B;
        pre[1][i] = B;
    }
    ll lack = 0;
    ll over = 0;
    priority_queue<ll> lacks;
    priority_queue<ll> overs;
    vector<ll> C(N);
    rep(i, N) {
        ll c = pre[0][i]-pre[1][i];
        if (c < 0) {
            lack -= c;
            lacks.push(c);
        }
        if (c > 0) {
            over += c;
            overs.push(c);
        }
        C[i] = c;
    }
    if (lack > over) {
        cout << -1 << endl;
        return 0;
    }
    int ans = lacks.size();
    while(lack > 0) {
        lack -= overs.top();
        overs.pop();
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4088
while True:
    cards = input()
    if cards == '-':
        break
    a = int(input())
    for i in range(a):
        h = int(input())
        
#        print(cards[h:]) #後ろh文字
#        print(cards[:h]) #残りの文字(頭から)
        cards = cards[h:] + cards[:h]
    print(cards)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll ans = 1;
    constexpr ll mod = 1e9+7;
    ll N;
    cin >> N;
    rep(i, 1, N+1){
        ans *= i;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{

    int i_inputFirst;
    int i_inputSecond;
    int i_inputThird;

    scanf("%d%d%d", &i_inputFirst, &i_inputSecond, &i_inputThird);

    if (i_inputFirst + i_inputSecond + i_inputThird >= 22)
    {
        printf("bust");
    }
    else
    {
        printf("win");
    }

}

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


void solve(long long N, std::vector<float> H){
    sort(H.begin(), H.end());
    float x, y, z;
    for(int i = 0; i < N - 1; ++i){
        if(i == 0) x = H.at(i);
        else x = z;
        y = H.at(i+1);
        z = (x + y) / 2;
    }
    cout << z << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<float> H(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%fd",&H[i]);
    }
    solve(N, std::move(H));
    return 0;
}


Measured memory_bytes: 3792
#include <iostream>
using namespace std;
int main()
{
	string s;
	char tmp='a';
	cin>>s;
	for(int i=0;i<s.length();i++)
	{
		if(tmp=='C'&&s[i]=='F')
		{
			cout<<"Yes";
			return 0;
		}
		if(s[i]=='C')tmp='C';
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a, b, c=0, i;

    scanf("%d %d", &a, &b);

    for(i=1; i<=3; i++){
        if(a*b*i % 2 != 0)
            c = i;
    }

    if(c != 0)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int C;
  for (int i = 0; i < S.size(); i++) {
    C = S.at(i) + N;
    if (C > 'Z') {
      C = C - 26;
    }
    S.at(i) = C;
    cout << S.at(i);
  }
  cout << endl;
}

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

using namespace std;
int main(void){
    map<char, int>abt;
    string s;
    cin >> s;
    rep(i, s.size()) abt[s[i]]+=1;
    
    for(auto itr=abt.begin(); itr !=abt.end(); itr++){
        if (itr->second==2){
            cout << "no";
            return 0;
        }
    }
    cout << "yes" << endl;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC() ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);


int main()
{
    int i = 0, j = 0, cs = 0, in;
    int n; cin>>n;
    int arr[5]; mem(arr,0);
    for(i = 0; i < n; i++){
        string s; cin>>s;
        if(s == "AC") arr[0]++;
        if(s == "WA") arr[1]++;
        if(s == "TLE") arr[2]++;
        if(s == "RE") arr[3]++;
    }
    cout << "AC x " << arr[0] << endl;
    cout << "WA x " << arr[1] << endl;
    cout << "TLE x " << arr[2] << endl;
    cout << "RE x " << arr[3] << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
const int N=500010;
int i,j,k,n,m,x,y,t;
ll ch[N][2],d[N][2],ans,mid,w[N];
struct data{ll x,y;};
vector<data>v[N],t1,t2,t3,t4;
bool cmp1(const data&a,const data&b){return a.x==b.x?a.y<b.y:a.x<b.x;}
bool cmp2(const data&a,const data&b){return a.y==b.y?a.x<b.x:a.y<b.y;}
bool cmp3(const data&a,const data&b){return a.x==b.x?a.y<b.y:a.x>b.x;}
bool cmp4(const data&a,const data&b){return a.y==b.y?a.x<b.x:a.y>b.y;}
bool flag=0;
int read(){
	int x=0,f=1;
	char ch=getchar();
	while (ch<'0'||ch>'9'){f=ch=='-'?-f:f;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}
	return x*f;
}
void solve(int x){
	t1=v[ch[x][0]];t2=v[ch[x][1]];t4.clear();
	t3.clear();
	sort(t1.begin(),t1.end(),cmp4);
	sort(t2.begin(),t2.end(),cmp1);
	int j=-1;w[0]=t2[0].y;for (int i=1;i<t2.size();i++)w[i]=min(w[i-1],t2[i].y);
	for (int i=0;i<t1.size();i++){
		while (j+1<t2.size()&&t2[j+1].x+t1[i].y<=mid)
			j++;
		if (j!=-1)t3.pb((data){t1[i].x,w[j]});
	}
	sort(t2.begin(),t2.end(),cmp4);
	sort(t1.begin(),t1.end(),cmp1);
	j=-1;w[0]=t1[0].y;for (int i=1;i<t1.size();i++)w[i]=min(w[i-1],t1[i].y);
	for (int i=0;i<t2.size();i++){
		while (j+1<t1.size()&&t1[j+1].x+t2[i].y<=mid)j++;
		if (j!=-1)t3.pb((data){t2[i].x,w[j]});
	}
	sort(t3.begin(),t3.end(),cmp1);
	for (int i=0;i<t3.size();i++)if (i==0||t3[i].x!=t3[i-1].x)t4.pb(t3[i]);
	sort(t4.begin(),t4.end(),cmp2);
	for (int i=0;i<t4.size();i++)if (i==0||t4[i].y!=t4[i-1].y)v[x].pb(t4[i]);
}
void dp(int x){
	v[x].clear();
	if (!ch[x][0]){v[x].pb({0,0});return;}
	dp(ch[x][0]);dp(ch[x][1]);
	for (int i=0;i<v[ch[x][0]].size();i++)v[ch[x][0]][i].x+=d[x][0],v[ch[x][0]][i].y+=d[x][0];
	for (int i=0;i<v[ch[x][1]].size();i++)v[ch[x][1]][i].x+=d[x][1],v[ch[x][1]][i].y+=d[x][1];
	solve(x);
}
bool check(ll x){
	dp(1);
	return (int)v[1].size();
}
int main(){
	n=read();
	for (i=2;i<=n;i++){
		x=read();y=read();
		if (!ch[x][0])ch[x][0]=i,d[x][0]=y;else ch[x][1]=i,d[x][1]=y;
	}
	ll l=0,r=1e10;
	while (l<=r){
		mid=l+r>>1;
		if (check(mid))ans=mid,r=mid-1;else l=mid+1;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 47592
#include <string>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long,long long> P;
typedef pair<long long,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
long long n,h[100005];
ll dp[100005];
#define ALL(v)  (v).begin(),(v).end()
std::set<long long> st;
//#define MAX(a,b) if(a>b)
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))

    /*  ペア関連
    //vector<pair<long long, long long> > pairs(N);
    for(long long i=0; i<N; i++){
        long long a, b;
        cin >> a >> b;
        pairs[i] = make_pair(a, b);
    }
    
    //sort(pairs.begin(), pairs.end(),greater<pair<long long,long long> >());
	sort(pairs.begin(), pairs.end());
    */

 	//stack<long long> sta;   
    //queue<long long> que;


int main(){
	
	long long N,M,K;
	string s;
    long long sum,sum1;
	sum=0;
	sum1=0;
	long long flg,flg1,cnt,cnt1;
	flg=0;
	flg1=0;
	cnt=0;
	cnt1=0;
	long long max;
	long long max1;
	max=0;
	max1=0;
	long long min;
	long long min1;
	min=INF;
	min1=INF;

	long long work1,work2,work3,work4;
	work1=0;
	work2=0;
	work3=0;
	work4=0;
    
	//std::cin >> N;
    std::cin >> N >> M;
    //std::cin >> N >> M >> K;
    
	//std::vector<long long> v(N);
	//std::vector<long long> w(N);
    //std::cin >> s;
    
    
    // 配列入力1
    /*
    for(long long i=0; i<N; i++){
		std::cin >> v[i];
	}
	*/
	// 配列入力2
	/*
	for(long long i=0; i<N; i++){
		std::cin >> w[i];
	}
	*/
    
	
	//通常
	/*
    for(long long i=0; i<N; i++){
		
	}
	*/
	

	//文字列入力
	/*
	for(long long i=0; i<s.length(); i++){
		
		if(s[i]!='1'){
	}
	*/

	
	
	//ソート
    //std::sort(v.begin(),v.end());//昇順ソート
    //std::sort(v.begin(),v.end(),std::greater<long long>());//降順ソート
    //std::sort(w.begin(),w.end());//昇順ソート
    //std::sort(w.begin(),w.end(),std::greater<long long>());//降順ソート
    /*
    
    //S.substr(i, 5);
    //S.size();
    
    for(long long i=0; i<N; i++){
		std::cin >> v[i];
		if(st.find(v[i])==st.end()){
			st.insert(v[i]);
		}
		else{
			st.erase(v[i]);
		}
	}
	*/


	/*
	long long a[4];
	long long value;
	value=0;
	
	a[0] = (value % 10); 
	value /= 10;// 1桁目を取り出す
	a[1] = (value % 10); 
	value /= 10;// 2桁目を取り出す
	a[2] = (value % 10); 
	value /= 10;// 3桁目を取り出す
	a[3] = (value % 10); 
	value /= 10;// 4桁目を取り出す
    work1=a[0]+10*a[1];
    work2=a[2]+10*a[3];
    */
	
	
    if(N<M){
    	printf("0");
    	//printf("%lld",N);
    	//puts("Yes");
    	//printf("%d",st.size());
    	//文字列の出力
    	//std::cout << s << std::endl;
    	//printf("%.12f\n",ret);
    	//cout << sum << endl;
	}
	else{
		puts("10");
	}
	return 0;
}


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

int main()
{
    int X, N;
    cin >> X >> N;
    vector<int> p(N);
    for (int i = 0; i < N; i++)
    {
        cin >> p[i];
    }
    sort(p.begin(),p.end());

    for (int i = 0;; i++)
    {
        int x_l = X-i;
        int x_r = X+i;
        if(find(p.begin(),p.end(),x_l)==p.end()){
            cout << x_l << endl;
            return 0;
        }
        if(find(p.begin(),p.end(),x_r)==p.end()){
            cout << x_r << endl;
            return 0;
        }
    }
    return 0;
}

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

int main() {
  int N, tmp = 0;
  string t = "YES";
  cin>>N;
  
  vector<int> a(N);
  rep(i, N) cin>>a[i];
  
  sort(a.begin(), a.end());

  rep(i, N){
    
    if(tmp == a[i]){
      t = "NO";
      break;
    }
  	else{
      tmp = a[i];
    }
  }
  
  cout<<t<<endl;
  
  return 0;
}

Measured memory_bytes: 1024
from math import cos
from math import radians as rad
from math import degrees as dig
from math import sqrt as r

A, B, H, M = map(int, input().split())

H_ = H * 30 + (M / 60 * 30)
M_ = M * 6

if abs(H_ - M_) < 180:
    HM_rad = rad(abs(H_ - M_))
else:
    HM_rad = rad(360 - abs(H_ - M_))

#print(dig(HM_rad))

ans = r(A ** 2 + B ** 2 - 2 * A * B * cos(HM_rad))
print(ans)


Measured memory_bytes: 9388
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long

int main()
{
    ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t=1;
//cin>>t;
while(t--){
string s;
cin>>s;
if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]){cout<<"Bad"<<endl;}
else{cout<<"Good"<<endl;}
}}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <deque>

using namespace std;

vector <vector <int> > G;
deque <int> deq;
int pl;
int viz[100004];

void DF(int node, int &flag) {
    viz[node] = 1;

    if(node != 1) {
        if(pl) {
            deq.push_back(node);
        }
        else {
            deq.push_front(node);
        }
    }

    flag = 1;
    for(auto neg : G[node]) {
        if(viz[neg] == 0) {
            flag = 0;
            DF(neg, flag);
            if(flag) {
                return ;
            }
        }
    }
}

int main() {
//    #ifndef ONLINE_JUDGE
//    freopen("input.txt","r",stdin);
//    #endif // ONLINE_JUDGE

    int N, M, x, y;
    cin >> N >> M;

    G.resize(N + 1);

    for(int i = 1; i <= M; ++i) {
        cin >> x >> y;

        G[x].push_back(y);
        G[y].push_back(x);
    }

    deq.push_back(1);

    pl = 1;
    int flag = 0;
    DF(1, flag);
    pl = 0;
    flag = 0;
    DF(1, flag);

    cout << deq.size() << '\n';

    for(auto x : deq) {
        cout << x << ' ';
    }

    cout << '\n';

    return 0;
}


Measured memory_bytes: 11392
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] N = sc.next().toCharArray();
        int K = sc.nextInt();
        int[][][] dp = new int[N.length+1][K+1][2];
        dp[0][0][1] = 1;
        for (int i = 0; i < N.length; i++) {
            for (int j = 0; j <= K; j++) {
                for (int s = 0; s < 2; s++) {
                    if (dp[i][j][s] == 0)  continue;
                    if (s == 0) {
                        dp[i+1][j][0] += dp[i][j][0];
                        if (j+1 <= K) {
                            dp[i+1][j+1][0] += 9*dp[i][j][0];
                        }
                    } else {
                        int a = N[i]-'0';
                        if (a == 0) {
                            dp[i+1][j][1] += dp[i][j][1];
                        } else {
                            dp[i+1][j][0] += dp[i][j][1];
                            if (j+1 <= K) {
                                dp[i+1][j+1][0] += (a-1)*dp[i][j][1];
                                dp[i+1][j+1][1] += dp[i][j][1];
                            }
                        }
                    }
                }
            }
        }
        System.out.println(dp[N.length][K][0]+dp[N.length][K][1]);
    }
}



Measured memory_bytes: 23764
#include<iostream>

using namespace std;

int main() {
	int X, A, B;	cin >> X >> A >> B;

	if (A >= B) {
		cout << "delicious" << endl;
		return 0;
	}
	else if (X < (B - A)) {
		cout << "dangerous" << endl;
		return 0;
	}
	else {
		cout << "safe" << endl;
		return 0;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please

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

	
	int N, A, B;
	cin >> N >> A >> B;

	int kotae = 0;
	rep1(i, N) {
		int goukei = 0;
		int kari = i;
		while (kari) {
			goukei += kari % 10;
			kari /= 10;
		}
		if (A <= goukei && goukei <= B) kotae += i;
	}
	co(kotae);
	Would you please return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func scanStringToken() (word string) {
	scanner.Scan()
	word = scanner.Text()
	return
}

func scanNumberToken() (num int) {
	scanner.Scan()
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return
}

func main() {
	scanner.Split(bufio.ScanWords)
	h1, m1, h2, m2, k := scanNumberToken(), scanNumberToken(), scanNumberToken(), scanNumberToken(), scanNumberToken()

	from := (m1 * 60) + (h1 * 60 * 60)
	to := (m2 * 60) + (h2 * 60 * 60)

	x := ((to - from) / 60) - k
	fmt.Println(x)
}


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

int main() {
    using namespace std;

    cin.tie(0);
   	ios::sync_with_stdio(false);

    int n, m;
    vector<int> L;
    vector<int> R;

    cin >> n >> m;

    for (int i = 0; i < m; i++) {
        int tmp_l, tmp_r;
        cin >> tmp_l >> tmp_r;
        L.push_back(tmp_l);
        R.push_back(tmp_r);
    }

    int max_l = *max_element(L.begin(), L.end());
    int min_r = *min_element(R.begin(), R.end());

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (max_l <= i && i <= min_r) {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1276
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        int n;
        cin >> n;
        int a[n + 1], b[n + 1];
        for (int i = 1; i <= n; i++) 
            cin >> a[i] >> b[i];
        
        int dp[n + 1] = {};
        for (int i = 1; i <= n; i++) {
            if (a[i] == b[i])
                dp[i] = dp[i - 1] + 1;
            else 
                dp[i] = 0;
        }

        if (*max_element(dp, dp + n + 1) >= 3)
            cout << "Yes\n";
        else
            cout << "No\n";
        
    }
    
    return 0;
}



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

using namespace std;

int main()
{
    int n, l;
    cin >> n >> l;
    vector<int> a(n);
    int sum = 0;
    int mini = 1e9;
    int v, temp;
    for(int i = 0; i < n; i++){
        a[i] = l + i;
        sum += a[i];
    }
    for(int i = 0; i < n; i++){
        temp = sum - a[i];
        if (abs(sum - temp) < mini){
            mini = abs(sum - temp);
            v = temp;
        }
    }
    cout << v;
    return 0;
}


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

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int maxn = 100000+10;
const ll oo = numeric_limits<ll>::max();
int val[maxn][3],N;
ll dp[maxn][3];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N;
	forn(i,0,N)forn(j,0,3)cin >> val[i][j];
	dp[0][0] = val[0][0];
	dp[0][1] = val[0][1];
	dp[0][2] = val[0][2];
	forn(i,1,N){
		forn(j,0,3){
			dp[i][j] = -1;
			forn(k,0,3){
				if(j == k)continue;
				dp[i][j] = max(dp[i][j],dp[i-1][k]+val[i][j]);
			}
		}
	}
	cout << max({dp[N-1][0],dp[N-1][1],dp[N-1][2]}) << '\n';
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


Measured memory_bytes: 3840
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        char[] a = s.toCharArray();
        int ans =0;
        int tmp = 0;
        for(int i =0;i<n;i++){
            if(a[i]=='I'){
                tmp ++;
            }
            if(a[i]=='D'){
                tmp --;
            }
            ans =Math.max(ans,tmp);
        }
        System.out.println(ans);
    }
}

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

using namespace std;

#define sz(a) ((int)a.size())
#define mp make_pair
#define pb push_back
#define fi first
#define se second

const int maxn = 20;

int n;
int vs[maxn];
vector<pair<pair<int, int>, int>> ans;

int main() {
	cin >> n;
	
	int pos = -1;
	for (int i = 0; i < 20; i++) {
		if ((n & (1 << i)) != 0) {
			vs[i] = 1;
			pos = i;
		}
	}

	int totv = pos + 1;

	for (int i = 0; i < pos; i++) {
		int val = (1 << (pos - 1 - i));
		ans.pb(mp(mp(i + 1, i + 2), 0));
		ans.pb(mp(mp(i + 1, i + 2), val));
	}

	int cur = (1 << pos);
	for (int i = pos - 1; i >= 0; i--) {
		if (vs[i]) {
			int dis = pos - i;
			ans.pb(mp(mp(1, dis + 1), cur));
			cur += (1 << i);
		}
	}

	cout << totv << ' ' << sz(ans) << '\n';
	for (auto ed : ans) {
		cout << ed.fi.fi << ' ' << ed.fi.se << ' ' << ed.se << '\n';
	}

	return 0;
}


Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
  
   S = input.trim().split("");
  /// console.log(S);
  var  n = S.length;
   
  // console.log(S,n);
  var a =S[0];
 // console.log(a);
 var m = "";
 for (i = 0;i<n;i++){var a = S[i];
              //        console.log(a);
                    
//   if (a== "R"||a=="U"||a=="D"){
      if (a=="R"||a=="U"||a=="D"){//console.log("aaa",i);
                                 var i = i+1;
                                  var a = S[i];
                       if (a=="L"||a=="U"||a=="D"){
                       //  console.log("bbb",i);
                       }
                        else {if( i == n ){break;}
                              else{var m = "No";
                              console.log(m);
                          //  console.log(i,a);
                              break;}}}
                         else{  var m = "No";console.log(m);
                         break;
                          }
                        }   
  if (m == ""){console.log("Yes");}
 
  }
  //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long a = in.nextLong();
        long b = in.nextLong();
        long k = in.nextLong();

        b = Math.max(b - Math.max((k - a), 0), 0);
        a = Math.max(a - k, 0);
        System.out.println(a + " " + b);
    }
}


Measured memory_bytes: 23124
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayLong();
            var L = input[0];
            var R = input[1];
            var rem = new List<long>();
            for (long i = L; i <= R; i++)
            {
                if (i % 2019 == 0) { Console.WriteLine(0); return; }
                rem.Add(i % 2019);
            }
            rem.Sort();
            var ans = long.MaxValue;
            for (int i = 0; i < rem.Count() - 1; i++)
            {
                for (int j = i + 1; j < rem.Count(); j++)
                {
                    if (rem[i] * rem[j] % 2019 < ans) ans = rem[i] * rem[j] % 2019;
                }
            }

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

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13524
n,k=map(int,input().split())
a=list(map(int,input().split()))
dict={}
for i in range(n):
    dict[i]=a[i]-1 #i番目の町からどこにつくか
tmp=0#現在知
num2city={}
city2num={}
city2num[0]=0#どのまちが何回目か
num2city[0]=0#j回目にどこにいるか
alre=[-1]*n
alre[0]=1
for j in range(1,k+1):
    if tmp==dict[tmp]:
        break
    tmp=dict[tmp]#現在地更新
    if alre[tmp]==-1:#tmp not in num2city.values():#現在地がまだきたことない
        alre[tmp]=1
        num2city[j]=tmp
        city2num[tmp]=j
    else:
        mae=city2num[tmp]
        term=j-mae 
        res=k-j
        r=res%term
  #      print(mae,term,res,r,mae+r,num2city[mae+r])
        tmp=num2city[mae+r]
 #       print(tmp)
        break
   # print(tmp+1)
    
#print(num2city)
#print(city2num)
print(tmp+1)



Measured memory_bytes: 63064
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
	int a;int b;
	scanf("%d %d",&a,&b);
	int total=0;
	if(a==1&&b==1)
	{
		printf("1000000");
	}
	if(a==1&&b>3)
	printf("300000");
	if(a==2&&b>3)
	printf("200000");
	if(a==3&&b>3)
	{
		printf("100000");
	}
	if(a==1&&b==2)
	{
		printf("500000");
	} 
	if(a==1&&b==3)
	printf("400000");
	if(a==2&&b==1)
	printf("500000");
	if(a==2&&b==2)
	printf("400000");
	if(a==2&&b==3)
	printf("300000");
	if(a==3&&b==1)
	printf("400000");
	if(a==3&&b==2)
	{
		printf("300000");
	}
	if(a==3&&b==3)
	{
		printf("200000");
	}
	if(a>3&&b==1)
	printf("300000");
	if(a>3&&b==2)
	printf("200000");
	if(a>3&&b==3)
	printf("100000");
	if(a>3&&b>3)
	{
		printf("0");
	}
	return 0;
} 

Measured memory_bytes: 128
import java.io.IOException;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        int n = s.length();

        if (!isPalindrome(s)) {
            System.out.println("No");
            return;
        }
        if (!isPalindrome(s.substring(0, (n - 1) / 2))) {
            System.out.println("No");
            return;
        }
        if (!isPalindrome(s.substring((n + 3) / 2 - 1, n))) {
            System.out.println("No");
            return;
        }

        System.out.println("Yes");
    }

    public static boolean isPalindrome(String s) {
        int l = 0, r = s.length() - 1;
        while (l < r) {
            if (s.charAt(l) != s.charAt(r)) {
                return false;
            }
            l++; r--;
        }
        return true;
    }
}

Measured memory_bytes: 23124
n = int(input())
res = n
ans = 0
for i in range(n+1):
    t = i
    cc = 0
    while t >= 1:
        cc = cc + t % 6
        t = t // 6

    t = n-i
    while t >= 1:
        cc = cc + t%9
        t = t // 9


    if res > cc:
        res = cc

print(res)

Measured memory_bytes: 3064
H,W,A,B = map(int,input().split())
blk1 = [[0]*(W-A) for _ in range(H-B)]
blk2 = [[1]*(A) for _ in range(H-B)]
blk3 = [[1]*(W-A) for _ in range(B)]
blk4 = [[0]*(A) for _ in range(B)]

for i in range(len(blk2)):
    blk1[i]=blk1[i]+blk2[i]
#print(blk1)
  
for i in range(len(blk4)):
    blk3[i]=blk3[i]+blk4[i]

blk1 = blk1+blk3

#print(blk1)

for i in range(len(blk1)):
    print(''.join(str(x) for x in blk1[i]))

#print(blk3)

Measured memory_bytes: 19468
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#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; }
#define DEBUG_VLL(vec) for(int sz=0;sz<int(vec.size());sz++) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

using PI = P<int, int>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w, m; cin >> h >> w >> m;
    V<int> gyou(h, 0), retsu(w, 0);

    set<PI> hw;
    for (int i = 0; i < m; i++) {
        int hh, ww; cin >> hh >> ww;
        hh--, ww--;
        gyou[hh]++, retsu[ww]++;
        hw.insert(make_pair(hh, ww));
    }
    V<int> ordh(h); iota(ALL(ordh), 0);
    sort(ALL(ordh), [&](int i, int j) {
        return gyou[i] > gyou[j];
    });
    V<int> ordw(w); iota(ALL(ordw), 0);
    sort(ALL(ordw), [&](int i, int j) {
        return retsu[i] > retsu[j];
    });

    int ans = 0;
    for (int i = 0; i < h; i++) {
        if (i > 0 && gyou[ordh[i]] < gyou[ordh[i - 1]]) break;
        for (int j = 0; j < w; j++) {
            if (j > 0 && retsu[ordw[j]] < retsu[ordw[j - 1]]) break;
            int tmp = gyou[ordh[i]] + retsu[ordw[j]];
            if (hw.find(make_pair(ordh[i], ordw[j])) != hw.end()) {
                tmp--; chmax(ans, tmp);
            } else {
                chmax(ans, tmp);
                break;
            }
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 21960
from itertools import permutations
from math import hypot, factorial
n = int(input())
t = [list(map(int,input().split())) for _ in range(n)]

sum = 0
for p in permutations(t):
  for i in range(n-1):
    sum += hypot(p[i+1][0]-p[i][0], p[i+1][1]-p[i][1])
print(sum/factorial(n))



Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <iomanip>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};

int main(void){
    ll n, p;
    cin >> n >> p;
    ll ans;
    if(n==1) ans = p;
    else if (n>=2 && n < 40){
        for(ll i = 1; i <= 1e+12; i++){
        ll check = pow(i, n);
        if(check <= p && p%check==0) {
            ans = i;
            //cout << i << " " << check << endl;
        }
        if(check>p) break;
        }
    }
    else ans = 1;
    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef long long           ll;
typedef vector<int>         vi;
typedef pair<int,int>       ii;

#define endl                '\n'
#define ln                  puts("")
#define fi                  first
#define pf                  printf
#define se                  second
#define MX                  109
#define pb                  push_back
#define DB                  pf("Hi\n")
#define pf1(a)              pf("%d\n",a)
#define sc1(a)              scanf("%d",&a)
#define sz(a)               int((a).size())
#define all(c)              (c).begin(),(c).end()
#define mem(a,b)            memset(a, b, sizeof(a))
#define TC                  int _T;sc1(_T);while(_T--)
#define RD                  freopen("0iuput.txt","r",stdin)
#define WR                  freopen("0uput.txt","w",stdout)
#define rep(i,a,b)          for(int i=int(a)-(a>b);i!=(b)-(a>b);i+=1-2*(a>b))

int main()
{
    int a,b,c,pal=0,sum;

    sc1(a);
    sc1(b);
    sc1(c);

    rep(i,1,100)
    {
        sum=i*a;
        if(sum%b==c)
           {pal=1;break;}
    }
    if(pal)pf("YES\n");
    else pf("NO\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 #define MOD 1000000007
int main()
{
  int n,m;
  cin>>n>>m;
  char a[n][m];
  for(int i=0;i<n;i++)
  for(int j=0;j<m;j++)
   cin>>a[i][j];
  int dp[n][m];
  for(int i=0;i<n;i++){
   for(int j=0;j<m;j++)
   {
     if(i==0 && j==0) 
       dp[i][j]=1;
     else if(i==0) 
     {  if(a[i][j]=='.')
        dp[i][j]=dp[i][j-1];
        else
         dp[i][j]=0;  
     }
     else if(j==0) 
     {  if(a[i][j]=='.')
        dp[i][j]=dp[i-1][j];
        else
         dp[i][j]=0;  
     }
     else if(a[i][j]=='.')
     {
        dp[i][j]=((long long)dp[i-1][j]%MOD+dp[i][j-1]%MOD)%MOD;    
             
     }
     else
     dp[i][j]=0;
             
    }
           }
  cout<<dp[n-1][m-1];
  
  
}

Measured memory_bytes: 5120
Q=int(input())
A=[list(map(int,input().split())) for i in range(Q)]
B,C=zip(*A)
a=max(max(B),max(C))
def get_primenumber(N):
  prime_list=[2]
  for num in range(3,N+1,2):
    if all(num%prime != 0 for prime in prime_list):
      prime_list.append(num)
  return prime_list

X=get_primenumber(a)
P=[False]*(a+1)
L=[False]*(a+1)
for i in X:
  P[i]=True
for i in X:
  if P[(i+1)//2]:
    L[i]=True
C=[]
c=0
for i in range(a+1):
  if L[i]:
    c+=1
  C.append(c)
for s,t in A:
  print(C[t]-C[s-1])

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

int main()
{
    int n;
    cin >> n;
    vector<int> v;
    while (n--)
    {
        int x;
        cin >> x;
        v.push_back(x);
    }
    int q;
    cin >> q;
    while (q--)
    {
        int k;
        cin >> k;
        pair<vector<int>::iterator, vector<int>::iterator> s;
        s = equal_range(v.begin(), v.end(), k);
        cout << distance(v.begin(), s.first) << ' ' << distance(v.begin(), s.second) << endl;
    }
return 0;
}


Measured memory_bytes: 3552
#include"bits/stdc++.h"
#define endl '\n'

using namespace std;

int K, A, B;
int main(){
    cin >> K;
    cin >> A;
    cin >> B;
    int r = 0;
    for(int i = A; i <= B; i++){
        if(i%K == 0)
            r = 1;
    }
    if(r==1)
        cout << "OK";
    else
        cout << "NG";
    return 0;
}

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

int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<char>> c(h,vector<char>(w));
    for(auto& v:c){
        for(auto& e:v){
            cin >> e;
        }
    }
    for(auto& v:c){
        for(int i=0;i<2;i++){
            for(auto& e:v){
                cout << e;
            }
            cout << endl;
        }
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
typedef long long ll;
using namespace std;

int main() {
    ll n, m;
    while(scanf("%lld %lld", &m, &n) != EOF) {
        ll ans;
        if(m * 2 >= n) {
            ans = n / 2;
        } else {
            n -= m * 2;
            ans = m + n / 4;
        }
        printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Convert;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            string rgb = "";
			rgb += cin.Read; rgb += cin.Read; rgb += cin.Read;
			if (int.Parse(rgb) % 4 == 0)
				Console.WriteLine("YES");
			else
				Console.WriteLine("NO");
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 11220
a=int(input())
b=int(input())
c=int(input())
x=int(input())
count=0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      total=500*i+100*j+50*k
      if total==x:
        count+=1
print(count)

Measured memory_bytes: 3064
#include <stdio.h>

int main() {
    int x, a, b;
    scanf("%d %d %d", &x, &a, &b);

    int d_a, d_b;
    if(x-a>0) d_a = x-a;
    else d_a = a-x;

    if(x-b>0) d_b = x-b;
    else d_b = b-x;

    if(d_a>d_b) printf("B\n");
    else printf("A\n");

    return 0;

}

Measured memory_bytes: 128
h, w, d = map(int, input().split())
A = []
for i in range(h) :
    A.append(list(map(int, input().split())))

cost = []
for i in range(h) :
    for j in range(w) :
        cost.append([A[i][j], j+1, i+1])

cost.sort(key=lambda c:c[0])


power = [0 for _ in range(h*w)]
for i in range(d) :
    pos = i
    x1 = cost[pos][1]
    y1 = cost[pos][2]
    while pos + d < h*w :
        x2 = cost[pos+d][1]
        y2 = cost[pos+d][2]
        power[pos+d] = power[pos] + abs(x1-x2) + abs(y1-y2)
        pos += d
        x1 = x2
        y1 = y2


q = int(input())
for _ in range(q) :
    l, r = map(int, input().split())
    print(power[r-1]-power[l-1])

Measured memory_bytes: 21144
N = int(input())
A = list(input())
B = list(input())
C = list(input())

count = 0
for i in range(N):
    dic = {A[i]: 1}
    if B[i] in dic:
        dic[B[i]] += 1
    else:
        dic[B[i]] = 1

    if C[i] in dic:
        dic[C[i]] += 1
    else:
        dic[C[i]] = 1

    if len(dic) == 3:
        count += 2
    elif len(dic) == 2:
        count += 1
    elif len(dic) == 1:
        pass

print(count)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

//#define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << endl
#define LINE cout << "line : " << __LINE__ << endl
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl;
#define STOP assert(false);
#else
#define dump(x) ;
#define LINE 	;
#define dumpV(v);
#define STOP 	;
#endif

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fi<<", "<<a.se<<')';
    return out;
  }
}


int main(){
	int n, m;
	cin >> n >> m;
	vi a(m), b(m), c(m);
	int sum = 0;
	rep(i, m) {
		cin >> a[i] >> b[i];
		c[i] = max(0, n - a[i]);
		sum += c[i];
	}
	int ans = 1e9;
	dump(sum);
	rep(i, m) {
		ans = min(ans, sum - c[i]);
		dump(c[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3040
# include <iostream>
# include <vector>
using namespace std;
bool solve (const vector <string> & W) {
const int n = W .size ();
// condition 1
for (int i = 0; i <n -1; ++ i) {
if (W[i].back()!= W[i +1].front()) {
return false;
}
}
// condition 2
for (int i = 0; i <n; ++ i) {
for (int j = i +1; j <n; ++ j) {
if (W[i] == W[j]) {
return false;
}
}
}
return true;
}
vector <string> input () {
int n; cin >> n;
vector <string> W (n);
for (int i = 0; i <n; ++ i) {
cin >> W [i];
}
return W;
}

int main () {
const vector <string> W = input ();
if (solve (W)) {
cout << "Yes" << endl;
}
else {
cout << "No" << endl;
}
}

Measured memory_bytes: 256