akhauriyash/Code-Regression huggingface dataset:
// Last Change: 03/26/2019 23:47:38.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

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

  if (N > 999) {
    cout << "ABD" << endl;
  } else {
    cout << "ABC" << endl;
  }

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,k;
string s;
P p[100005];

int main(void){
    scanf("%d%d",&n,&k);
    cin >> s;
    int prev=(s[0]-'0');
    int cnt=0;
    int sz=0;
    for(int i=0;i<n;i++){
        if(prev!=(s[i]-'0')){
            p[sz++]=P(prev,cnt);
            cnt=0;
        }
        cnt++;
        prev=(s[i]-'0');
    }
    p[sz++]=P(prev,cnt);
    int l=0;
    int zero=0;
    int sum=0;
    int ans=0;
    for(int i=0;i<sz;i++){
        //printf("%d %d\n",p[i].first,p[i].second);
        if(p[i].first==0){
            zero++;
            while(zero>k){
                sum-=p[l].second;
                zero-=1-p[l].first;
                l++;
            }

        }
        sum+=p[i].second;
        ans=max(ans,sum);
    }
    printf("%d\n",ans);
    return 0;
}





Measured memory_bytes: 1280
k = int(input())
q = (k-1)//50
s = (k-1)%50+1
ans = [0]*50
if k == 0:
    pass
elif k<50:
    for i in range(50):
        if i<s:
            ans[i] = 50
        else:
            ans[i] = 0
else:
    for i in range(50):
        if i<s:
            ans[i] = q+50
        else:
            ans[i] = q+(49-s)
print(50)
print(*ans,sep = " ")

Measured memory_bytes: 3064
num = {0: 'A', 1: 'B', 2: 'C', 3: 'D', 4: 'E'}
while True:
    n = [0] * 5
    for i in range(5):
        s1, s2 = map(int, input().split())
        if s1 == s2 == 0: exit()
        n[i] += s1 + s2
    ans = max(n)
    print(num[n.index(ans)], ans)



Measured memory_bytes: 5600
#include <iostream>
#include <set>
#include <map>
using namespace std;
int main(){
  int n;
  while(cin >> n, n){
    string S, g;
    cin >> S;
    set<string> St;
    for(int i = 0; i < S.size(); ++i){
      if(S[i] == ':') g = "";
      else if(S[i] == ',' || S[i] == '.'){
	St.insert(g);
	g = "";
      }else{
	g += S[i];
      }
    }
    map<string, string> M;
    string S_[n];
    for(int i = 1; i < n; ++i){
      cin >> S_[i];
    }
    for(int k = 0; k < n; ++k){
      for(int i = 1; i < n; ++i){
	S = S_[i];
	  g = "";
	for(int j = 0; j < S.length(); ++j){
	  if(S[j] == ':'){
	    if(St.find(g) == St.end()) break;
	    else{
	      St.erase(g);
	    }
	    g = "";
	  }else if(S[j] == ',' || S[j] == '.'){
	    St.insert(g);
	    g = "";
	  }else{
	    g += S[j];
	  }
	}
      }
    }
    cout << St.size() << endl;
  }
  return 0;
}

Measured memory_bytes: 3216
#include<iostream>
using namespace std;
int main()
{
  int r,g,b,n,i,j;
  long long dem=0;
  cin >> r >> g >> b >> n;
  for (i=0; i<=n/r; i++)
    for (j=0; j<=(n-i*r)/g; j++)
        if ((n-i*r-j*g)%b==0) dem++;
  cout << dem;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main( void )
{
int i;
int j;
for( i = 0; i < 9; i++ )
{
for( j = 0; j < 9; j++ )
{
printf( "%dx%d=%d\n", i + 1, j + 1, (i+1)*(j+1) );
}
}

return (0);
}

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

int main() {
  int n,ans=0;
  cin>>n;
  int a[10][10];
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      a[i][j]=0;
    }
  }
  for(int i=1;i<n+1;i++){
    int k=i%10;
    int l=i;
    for(int j=0;j<6;j++){
      if(l>9)l/=10;
      else break;
    }
    a[k][l]++;
  }
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      ans+=(a[i][j]*a[j][i]);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair

#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
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;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
int main(){
    int x,y,a,b,c;
    ll ans=0;
    cin >>x>>y>>a>>b>>c;
    V p(a);
    V q(b);
    V r(c);
    rep(i,a){
        cin>>p[i];
    }
    rep(i, b)
    {
        cin >> q[i];
    }
    rep(i, c)
    {
        cin >> r[i];
    }
    sort(all(p));
    sort(all(q));
    sort(all(r),greater<ll>());
    priority_queue<ll,V,greater<ll>>green;
    priority_queue<ll, V, greater<ll>> red;
    rep(i,a){
        red.push(p[i]);
        if(red.size() > x){
            red.pop();
        }
    }
    rep(i, b)
    {
        green.push(q[i]);
        if (green.size() > y)
        {
            green.pop();
        }
    }
    rep(i,c){
        if(green.top() >red.top()){
            red.push(r[i]);
            red.pop();
        }else{
            green.push(r[i]);
            green.pop();
        }
    }
    while(!red.empty()){
        ans+=red.top();
        clog<<red.top()<<" ";
        red.pop();
    }
    clog<<endl;
    while (!green.empty())
    {
        ans += green.top();
        clog << green.top() << " ";
        green.pop();
    }
    clog << endl;
    cout<<ans<<endl;
}

Measured memory_bytes: 4852
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
pI(x)=parse(Int,x)
pM(x::Array{SubString{String},1})=map(pI,x)
function main()
  x,y=pM(split(readline()))
  i=0
  ans=0
  while x*2^i<=y
    i+=1
  end
  print(i)
end
main()
if isdefined(Base, :mystdin);close(mystdin);end


Measured memory_bytes: 110892
#include<stdio.h>
#include<string.h>

void rotation(char *p);

int main()
{
    char s[101], t[101];
    
    gets(s);
    gets(t);
    
    int l=strlen(s);
    while(l--){
        if(strcmp(s, t)==0) {
            printf("Yes\n");
            return 0;
        }
        rotation(s);
    }
    printf("No\n");
    return 0;
}

void rotation(char *p)
{
    int l= strlen(p)-1;
    char *p1=p+l-1, *p2=p+l, lc=*(p+l);
    while(l--){
        *p2=*p1;
        p1--;
        p2--;
    }
    *++p1=lc;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;

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

const int INF = 1e9 + 7;

int main()
{
	IO_OP;
	
	int n, ans = 0;
	cin >> n;
	for(int i=0;i<n;i++) {
		int t;
		cin >> t;
		ans = __gcd(ans, t);
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
M = 2019
s = input()
tot, ten, ans = 0, 1, 0
cnt = [0] * M
for si in s[::-1]:
    cnt[tot] += 1
    tot += int(si) * ten
    tot %= M
    ans += cnt[tot]
    ten *= 10
    ten %= M
print(ans)

Measured memory_bytes: 9212
#include <bits/stdc++.h>
#define INF 100000007
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define print(x) cout << x << "\n"
#define print2(x, y) cout << x << " " << y << "\n"
#define printv(vec) rep(i, vec.size()) cout << vec[i] << " "; print("");
#define ALL(v) v.begin(), v.end()
#define SUM(v) accumulate(ALL(v), 0)
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SORT(v) sort(ALL(v))
#define REV(v) reverse(ALL(v))
typedef long long ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;

void Main(){
	
	ll H, W;
	cin >> H >> W;
	vvl v(H, vl(W));
	rep(i, H) rep(j, W) cin >> v[i][j];
	
	vvl A(H * W + 10, vl(2));
	ll flg = 1;
	ll cnt = 0;
	ll ans = 0;
	rep(i, H){
		rep(j, W){
			A[cnt][0] = i;
			if(flg) A[cnt][1] = j;
			else A[cnt][1] = W - 1 - j;
			cnt++;
		}
		flg ^= 1;
	}
	
	vvl vv = v;
	
	rep(i, H * W - 1){
		
		ll nx = A[i][0];
		ll ny = A[i][1];
		ll nnx = A[i + 1][0];
		ll nny = A[i + 1][1];
		
		if(vv[nx][ny] % 2){
			vv[nnx][nny] += 1;
			ans += 1;
		}
		
	}
	
	print(ans);
	
	rep(i, H * W - 1){
		
		ll nx = A[i][0];
		ll ny = A[i][1];
		ll nnx = A[i + 1][0];
		ll nny = A[i + 1][1];
		
		if(v[nx][ny] % 2){
			v[nnx][nny] += 1;
			cout << nx + 1 << " " << ny + 1  << " " << nnx + 1  << " " << nny + 1 ;
			print("");
		}
		
	}
		
}

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	Main();
    
	return 0;
	
}





Measured memory_bytes: 20864
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

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

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{	
	#ifndef ONLINE_JUDGE
	freopen(".in.txt", "r", stdin);
	freopen(".out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, rc = 0, wrc = 0, wwc = 0; cin >> n;
	string s; cin >> s;
	for(int i = 0; i < n; i++) if(s[i] == 'R') rc++;
	for(int i = 0; i < rc; i++) wrc += s[i] == 'W';
	for(int i = rc; i < n; i++) wwc += s[i] == 'R';
	cout << max(wrc, wwc);

	return 0;
}

Measured memory_bytes: 3780
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i,n) for(long long i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
    long long n,cnt;
    cin>>n;
    vector<long long>waru(n+1),yak(n+1,1);
    rep(i,n+1)waru[i]=i;
    for(int i=2;i<5000;i++){
        //eras roller
        if(yak[i]==1){//if prime
            for(int j=i;j<=n;j+=i){
                cnt=0;
                while(waru[j]%i==0){
                    waru[j]/=i;
                    cnt++;
                    
                }
                yak[j]*=(cnt+1);
            }
        }
    }
    for(int i=5000;i<=n;i++){
        if(waru[i]>1)yak[i]*=2;
    }
    
    long long ans=0,plus;
    rep(i,n+1){
        plus=i*yak[i];
        ans+=plus;
    }
    cout<<ans;
    //cout<<yak[2162160];
	return 0;
}


Measured memory_bytes: 159480
#include<bits/stdc++.h>
using namespace std;
int A,B,C,ans;
int main(){
    cin>>A>>B>>C;
    if(A==B&&B==C){
        cout<<(A%2?0:-1)<<endl;
        return 0;
    }
    for(;!(A%2)&&!(B%2)&&!(C%2);++ans){
        int a{A},b{B},c{C};
        A=b/2+c/2,B=a/2+c/2,C=a/2*b/2;
    }
    cout<<ans<<endl;
}
    


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
#define int long long
const int MAXN=200010;
int n,a[MAXN],ans=0;
#undef int
int main()
{
	#define int long long
	scanf("%lld",&n);
	for(int i=1;i<=n;++i)
		scanf("%lld",&a[i]);
	int l=1,r=1,sumx=a[1],sum=a[1];
	for(int i=1;i<=n;++i)
	{
		while((sumx==sum)&&r<=n)
		{
			sum+=a[r+1];
			sumx^=a[r+1];
			++r;
		}
		ans+=(r-1)-l+1;
		sumx^=a[l];
		sum-=a[l];
		++l;
		if(r<l)
			r=l;
	}
	printf("%lld",ans);
	return 0;
} 

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;

#define MOD 998244353


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

int main(){
    string t,s;
    cin>>s>>t;
    
    cout<<t<<s<<endl;
    return 0;
}


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

using namespace std;


int main() {

  int n;

  while(1) {

  cin >> n;
  if(n == 0) break;

  int count = 0;

  while(n != 1) {

    count ++;

    if(n % 2 == 0) n /= 2;
    else n = 3*n +1;
    
  }

  cout << count << endl;

  }

  return 0;

}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long x,y,sum=0;
    cin>>x;
    y=x;
    while(y!=0)
    {
        sum+=y%10;
        y=y/10;
    }

    if(x%sum==0)
    {
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;





    return 0;
}


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

int main(){
	int W, H, x, y, r;
	cin>>W>>H>>x>>y>>r;

	if((x >= r) && (x <= W-r) && (y >= r) && ( y <= H-r))
		cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    string s;
    uint64_t dp[100100][13];

    cin >> s;
    const uint64_t n = s.size();

    dp[0][0] = 1;
    for (uint64_t i = 0; i < n; ++i) {
        const uint64_t c = (s[i] == '?') ? 100 : s[i] - '0';
        for (uint64_t k = 0; k < 13; ++k) {
            dp[i+1][k] = 0;
        }
        for (uint64_t j = 0; j < 10; ++j) {
            if (c != 100 && c != j) continue;
            for (uint64_t k = 0; k < 13; ++k) {
                dp[i+1][(10 * k + j) % 13] += dp[i][k];
                dp[i+1][(10 * k + j) % 13] %= 1000000007;
            }
        }
    }

    cout << dp[n][5] << endl;

    return 0;
}

Measured memory_bytes: 10624
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long

using namespace std;

const int N=1e5+10;
int n,m,a[N]; ll sum[N],sum2[N],ans;

int main(){
	scanf("%d%d",&n,&m);
	rep (i,1,n){
		scanf("%d",&a[i]);
		sum[i]=sum[i-1]+max(a[i],0);
		sum2[i]=sum2[i-1]+a[i];
	}
	rep (i,1,n-m+1)
		ans=max(ans,sum[i-1]+sum[n]-sum[i+m-1]+max(sum2[i+m-1]-sum2[i-1],0ll));
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2176
program ABC045B
    implicit none
    character(100),dimension(3)::S
    character(3)::R="ABC"
    character(1)::out
    integer(8),dimension(3)::L
    integer(8)::i,a,b,c,flg
    read(5,*)(S(i),i=1,3)
    a=1
    b=1
    c=1
    flg=0!1:A, 2:B, 3:C
    L(1)=len_trim(S(1))
    L(2)=len_trim(S(2))
    L(3)=len_trim(S(3))
    out=S(1)(a:a)
    a=a+1
    do
        if(out=='a')then
            if(a==L(1)+1)then
                flg=1
                exit
            else
                out=S(1)(a:a)
                a=a+1
            end if
        else if(out=='b')then
            if(b==L(2)+1)then
                flg=2
                exit
            else
                out=S(2)(b:b)
                b=b+1
            end if
        else if(out=='c')then
            if(c==L(3)+1)then
                flg=3
                exit
            else
                out=S(3)(c:c)
                c=c+1
            end if
        end if
    end do

    print'(A)',R(flg:flg)
end program ABC045B

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <vector>

#define rep(i,a,b) for(long long i=a;i<b;i++)

using namespace std;


int main(void) {

	long long N = 0, K = 0, A = 0, B = 0, C = 0;
	long long a[300] = {0};
	long long b[300] = { 0 };
	long long c[300] = { 0 };
	long long d[300] = { 0 };
	//long long y[20] = {};
	string s;
	
	long long min = 0, min2 = 0;
	long long dif = 0;
	long long hoge = 0;
	long long sum = 0;

	cin >> N >> K;
	


	/*rep(i, 0, N) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}*/

	if(N%K == 0)
			cout << 0 << endl;
	else
		cout << 1 << endl;
	return 0;

}

Measured memory_bytes: 256
N,K = map(int,input().split())
a = list(map(int,input().split()))
s = []
for i in range(N):
    total = 0
    for j in range(i,N):
        total += a[j]
        s.append(total)
s.sort(reverse=True)
m,n = 1,1
while s[0]>=m:
    n += 1
    m *= 2
for i in range(n)[::-1]:
    t = list(filter(lambda x:x-m>=0,s))
    l = len(t)
    if l>=K:
        break
    else:
        m //= 2
n = i+1
for i in range(n):
    u = list(filter(lambda x:(x//m)%2==1,t))
    l = len(u)
    if l>=K:
        t = u[:]
        if l==K:
            break
    m //= 2
ans = t[0]
for i in range(1,K):
    ans &= t[i]
print(ans)


Measured memory_bytes: 66300
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

int main(void) {
    string S;
    cin>>S;
    
    // 小文字の集合
    string small = "abcdefghijklmnopqrstuvwxyz";
    map<char, int> mp;
    for (int i = 0; i < small.size(); i++) mp[small[i]] = 1;

    if (S[0] != 'A') {
        cout << "WA" << endl;
        return 0;
    }
    
    int c_count = 0;
    for (int i = 1; i < S.size(); i++) {
        if (mp.find(S[i]) == mp.end()) {
            if (i >= 2 && i <= S.size() - 2) {
                if (S[i] != 'C') {
                    cout << "WA" << endl;
                    return 0;
                }
                c_count++;
                continue;
            }
            cout << "WA" << endl;
            return 0;
        }  
    }
    if (c_count != 1) cout << "WA" << endl;
    else cout << "AC" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;

int main(){
    string s;
    cin >> s;
    rep(i, s.size()){
	if(i%2==0){
	    cout << s[i];
	}
    }
    cout << endl;
}



Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
using namespace std;
int main(void)
{
	int a,b,x,cnt,len;
	char y[10000];
	while(scanf("%d %d",&a,&b)!=EOF){
		x=a+b;
		cnt=0;
		while(x>0){
			x=x/10;
			cnt++;
		}
		printf("%d\n",cnt);
		
	}
	return 0;
}

Measured memory_bytes: 1028
#include <iostream>

using namespace std;

int main()
{
    char* x="CODEFESTIVAL2016";
    string a;
    cin>>a;
    int res = 0;
    for(int i=0;i<16;i++){
        if(x[i]!=a[i]){
            res+=1;
        }
    }
    cout<<res;
    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

int main(void){
    ll n, k;
    cin >> n >> k;
    vector<ll> h(n);
    for(int i=0; i<n; i++){
        cin >> h[i];
    }
    sort(h.rbegin(), h.rend());

    ll ans = 0;
    for(int i=0; i<n; i++){
        if(i+1 <= k) continue;
        ans += h[i];
    }
    cout << ans << endl;
    return 0;
}

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

int x, k;

int wf(int i, int sum) {
  if (i == x) {
    return sum;
  }
  return min(wf(i+1, sum*2), wf(i+1, sum+k));
}

int main() {
  cin >> x >> k;
  p(wf(0,1));
}


Measured memory_bytes: 256
# include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {

	
	string str, revstr;
	cin >> revstr;
	str = revstr;
	int cnt = 0;
	reverse(revstr.begin(), revstr.end());
	for (int i = 0; i < str.size(); i++) {
		if (str.at(i) != revstr.at(i)) {
			cnt++;
		}
	}
	cout << cnt / 2 << endl;

}


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


int main(){
	
	int n;
	
	map <string, int> mp;
	
	cin >> n;
	
	for (int i = 0; i < n; i++){
		
		string s;
		
		cin >> s;
		
		mp[s]++;
	}
	
	int maxv = 0;
	
	for (auto x: mp){
		int v = x.second;
		if (v > maxv){
			maxv = v;
		}
	}
	
	for (auto x = mp.begin(); x != mp.end(); x++){
		if (x -> second == maxv){
			cout << x -> first << endl; 
		}
	}
	
}


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

#define fori(i,k,n) for(int i = k; i<n; i++)
#define ll long long
#define all(k) k.begin(),k.end()
#define ff first
#define ss second
#define pb push_back

const ll mod = 998244353;

const int mxn = 1e5+1;
ll n;
vector<int> a(n);

ll power(ll x,ll y,ll p){
    ll res = 1;
    x%=p;
    while(y>0){
        if(y&1)res = (res*x)%p;
        y>>=1;
        x = (x*x)%p;
    }
    return res;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin>>s;
	ll num = 0;
	map<int,ll> mp;
	mp[0] = 1;
	ll ans = 0;
	for(int i = s.size()-1; i>=0; i--){
		num = (num+(s[i]-'0')*power(10,s.size()-i-1,2019))%2019;
		if(mp.find(num)!=mp.end())ans+=mp[num];
		mp[num]+=1;
	}
	//for(auto it:mp)cout<<it.ff<<' '<<it.ss<<endl;
	cout<<ans<<endl;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
#define rep2(i,m,n) for(int i=int(m);i<int(n);i++)
#define drep2(i,m,n) for(int i=int(m-1);i>=int(n);i--)
#define rep(i,n) rep2(i,0,n)
#define drep (i,n) drep2(i,n,0)
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int MOD = int(1e9)+7;


int main()
{
    int n,h,w;cin >>n>>h>>w;
    h--;w--;
    cout <<(n-h)*(n-w)<< endl;
        return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        boolean flg = true;        
        for(int i = 0; i < N/2; i++){
            if(S.charAt(i) == S.charAt(i + N/2)){
                flg = true;
                continue;
            }else{
                flg = false;
                break;
            }
        }
        if(flg && N != 1 && N%2 != 1){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	scanf("%d", &N);
	vector<int> A(N);
	int M;
	int sum = 0, sum_odd = 0;
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
		sum += A[i];
		if (i % 2 == 1) {
			sum_odd += A[i];
		}
	}
	// cout << sum << " " << sum_odd << "\n";
	M = sum - sum_odd * 2;
	printf("%d", M);
	for (int i = 0; i < N - 1; i++) {
		M = A[i] * 2 - M;
		printf(" %d", M);
	}

	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
#define maxn 300005
#define mo 1000000007
#define int ll
inline ll read()
{
	ll x=0,w=0;char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
struct op
{
    ll x,y;
    inline void read()
    {
        x=::read(),y=::read();
        ll g=__gcd(abs(x),abs(y));
        if(g==0)return ;
        x/=g,y/=g;
    }
    bool operator ==(op b)const{return x==b.x&&y==b.y;}
    bool operator <(op b)const{return x==b.x?y<b.y:x<b.x;}
    op inv(){return op{-x,-y};}
}a[maxn];
map<op,int>mp;
int n;
int ans;
inline void Add(int &x,int y){x+=y;x-=(x>=mo?mo:0);}
inline ll get(op x){return mp.count(x)?mp[x]:0;}
int po[maxn];
signed main()
{
    n=read();reg int i;reg int tmp1=-1;
    for(i=1;i<=n;++i)a[i].read();
    for(i=1;i<=n;++i)
    {
        if(a[i]==op{0,0}){++tmp1;continue;}
        mp[a[i]]++;
    }
    po[0]=1;
    for(i=1;i<=200000;++i)po[i]=po[i-1]*2%mo;
    int res;op u,v;
    ans=1;
    for(auto tmp:mp)
    {
        if(tmp.second==-1)continue;
        res=1;v=tmp.first;
        u=op{-v.y,v.x};
        Add(res,po[get(v)]-1);
        Add(res,po[get(u)]-1);
        Add(res,po[get(v.inv())]-1);
        Add(res,po[get(u.inv())]-1);
        Add(res,1ll*(po[get(v)]-1)*(po[get(v.inv())]-1)%mo);
        Add(res,1ll*(po[get(u.inv())]-1)*(po[get(u)]-1)%mo);
        mp[u]=-1;mp[v]=-1;mp[u.inv()]=-1;mp[v.inv()]=-1;
        res+=mo;res%=mo;
        ans=1ll*ans*res%mo;
    }
    Add(ans,tmp1);ans%=mo;ans+=mo;ans%=mo;
    cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 58132
#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 <math.h>
#include <iomanip>
using namespace std;
#define int long long

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

    string s; cin >> s;
    int n = s.size();
    vector<int> cnt(n);

    for(int i = 0;i < n-1; i ++){
        if(s.at(i) == 'R' && s.at(i+1) == 'L'){
            int j = 0;
            while(i - j >= 0 && s.at(i-j) == 'R'){
                if(j % 2 == 0) cnt.at(i) ++;
                else cnt.at(i+1) ++;
                j ++;
            }

            j = 1;
            while(i+j < n && s.at(i+j) == 'L'){
                if(j % 2 == 0) cnt.at(i) ++;
                else cnt.at(i+1) ++;
                j ++;
            }
        }
    }

    for(int i = 0;i < n;i ++){
        cout << cnt.at(i) << " " ;
    }
    cout << endl;
}

Measured memory_bytes: 4244
S = input()
lenS = len(S)
def isPalin(Si):
    Slen = len(Si)
    firHalf = list(Si[:Slen//2])
    secHalfKai = list(Si[::-1][:Slen//2])
    palin = True
    for i in range(0,Slen//2):
        if firHalf[i] != secHalfKai[i]:
            palin = False
    return palin
good = False
if isPalin(S)==isPalin(S[:int((lenS-1)/2)])==isPalin(S[int((lenS+3)/2)-1:]) == True:
    good = True
if good:
    print('Yes')
else:
    print('No')

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

int main(){
	while(1){
		int N;
		cin>>N;

		if(N==0)
			break;

		int p[10]={0};
		char c[100];
		int field=0;
		int j=0;

		for(int i=0;i<100;i++){
			cin>>c[i];		
			if(c[i]=='M'){
				p[j]++;
			}
			else if(c[i]=='S'){
				field=field+p[j]+1;
				p[j]=0;
			}
			else if(c[i]=='L'){
				p[j]=p[j]+field+1;
				field=0;
			}
			j++;
			if(j==N)
				j=0;
		}

		sort(p,p+N);

		for(int i=0;i<N;i++)
				cout<<p[i]<<" ";
		
		cout<<field<<endl;
	}

	return 0;
}
				
				

				

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


int main() {
    ll N; cin >> N;
    double ans;
    if(N % 2 == 1){
        ans = ceil((double)N/2)/N; 
    }
    else{
        ans = floor((double)N/2)/N; 
    }
    cout << defaultfloat;
    cout << ans << endl;
}

Measured memory_bytes: 256
package main
 
import (
	"fmt"
)

func main() {
	var a string
	var o int
	fmt.Scan(&a)
	list := map[string]int{"SUN":7, "MON":6, "TUE":5, "WED":4, "THU":3, "FRI":2, "SAT":1}
	v, ok := list[a]
	if ok == true {
		o = v
	}
	fmt.Print(o)
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cmath>
#include <set>
#include <utility>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cstdio>
#include <cstring>

using namespace std;

constexpr long long mod = 1000000007;
constexpr double eps = 0.0000000001;

typedef long long ll;
typedef long long unsigned ull;

int main() {
    string s;
    cin >> s;
    s = "0000" + s;
    int r[1000010][2];
    memset(r,0,sizeof(int[1000010][2]));
    r[0][1] = 1;
    for(int i = 1;i <= s.length()-1;i++) {
        int p = s[s.length()-i] - '0';
        r[i][0] = min(r[i-1][0]+p,r[i-1][1]+p+1);
        r[i][1] = min(r[i-1][0]+(10-p),r[i-1][1]+(9-p));
    }
    cout << r[s.length()-1][0]<< endl;
}

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


int main() {
  int n,a,b;
  string s;
  cin>>n>>a>>b>>s;
  rep(i,n){
    if(s.at(i)=='a'&&a+b>0){
      cout<<"Yes"<<endl;
      if(a>0){a--;}
      else{b--;}
    }
    else if(s.at(i)=='b'&&b>0){cout<<"Yes"<<endl;b--;}
    else{cout<<"No"<<endl;}
  }
}

Measured memory_bytes: 3764
N,M=map(int, input().split())
array1=list(map(int, input().split()))
array2=sorted(array1, reverse=True)
Sum=0
for i in range(N):
        Sum += array2[i]
flg=0
for i in range(M):
    if array2[i] < Sum/(4*M):
        print('No')
        flg=1
        break
if flg == 0:
    print('Yes')

Measured memory_bytes: 3064
n = int(input())
k = int(input())
a = list(map(int,input().split()))

#リストaに対し、全ての要素をk-a[all]したリストBを作る
b = list(map(lambda x: k-x, a))

#print(b)

ans = 0

for i in range(n):
	if a[i]<=b[i]:
		#print(a[i])
		ans = ans + a[i]*2
	else:
		#print(b[i])
		ans = ans + b[i]*2

print(ans)




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

string str;

int main(void){
  cin >> str;
  for (int i = 0; i < str.size() - 1; ++i) {
    if (str[i] == 'A' && str[i + 1] == 'C') {
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
using namespace std;
#define ll long long
#include <cstdint>

int main() {
	int a, b;
	cin >> a >> b;
	if (a * b % 2 == 0)cout << "Even" << endl;
	else cout << "Odd" << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())

N_list = []
M_list = []
answer = 0

for i in range(N):
	s = input()
	N_list.append(s)

M = int(input())

for i in range(M):
	t = input()
	M_list.append(t)

for i in range(N):
	S = N_list[i]
	plus  = N_list.count(S)
	minus = M_list.count(S)
	if answer < (plus - minus):
		answer = (plus - minus)

print(answer)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <sstream>
#include <utility>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cmath>
#include <functional>
#include <chrono>
#include <cstring>
#include <bits/stdc++.h>


using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef pair<int,int> pii;

typedef vector<lint> vl;
typedef pair<lint,lint> pll;

#define mpr make_pair


int main()
{
    ios_base::sync_with_stdio(0);    cin.tie(NULL);    cout.tie(NULL);

    int n; cin>>n;
    vi a(n);
    for (int &i : a) cin>>i;
    sort(a.rbegin(), a.rend());

    lint sum = 0;
    for (int i = 0; i< n; ++i){
        sum += a[i/2];
    }
    cout<<sum - a[0];
}


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

using namespace std;

const int N = 1e5 + 5;

int n;
int l;
int a[N];
long long sum;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> l;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int k = -1;
  for (int i = 0; i < n - 1; ++i) {
    if (a[i] + a[i + 1] >= l) {
      k = i;
      break;
    }
  }
  if (k == -1) {
    cout << "Impossible" << endl;
  } else {
    cout << "Possible" << endl;
    for (int i = 0; i < k; ++i) {
      cout << i + 1 << endl;
    }
    for (int i = n - 2; i >= k + 1; --i) {
      cout << i + 1 << endl;
    }
    cout << k + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 1280
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <queue>

#pragma warning( disable: 4996 )

using namespace std;

typedef long long ll;

#define INF 1000000000
#define EPS 1e-10

string str;

string S[10];

vector<string> ans_list;

int main(){

	S[1] = ".,!? ";
	S[2] = "abc";
	S[3] = "def";
	S[4] = "ghi";
	S[5] = "jkl";
	S[6] = "mno";
	S[7] = "pqrs";
	S[8] = "tuv";
	S[9] = "wxyz";

	int N;
	cin >> N;

	while (N > 0){

		N--;
		cin >> str;

		int num = 0;
		int end = 0;
		char tmp[2];
		tmp[1] = '\0';
		string ans;

		while (true){
			if (str[num] == '0'){
				num++;
				if (str.length() == num)
					break;
			}

			else{
				tmp[0] = str[num];
				bool flag = false;
				for (int i = num; i < str.length(); i++){
					if (str[i] == '0'){
						end = i;
						flag = true;
						break;
					}
				}
				if (!flag)
					break;
				int count = end - num;
				count--;
				int n = S[atoi(tmp)].length();
				ans += S[atoi(tmp)][count%n];
				num = end;
			}

		}

		ans_list.push_back(ans);

	}

	for (int i = 0; i < ans_list.size(); i++){
		cout << ans_list[i] << endl;
	}

	return 0;

}

Measured memory_bytes: 1232
while true
	m,f,r = gets.chomp.split(" ").map(&:to_i)
	break if m == -1 && f == -1 && r == -1
	if m == -1 || f == -1
		puts "F" 
	elsif m + f >= 80
		puts "A"
	elsif m + f >= 65
		puts "B"
	elsif m + f >= 50
		puts "C"
	elsif m + f >= 30
		if r >= 50
			puts "C"
		else
			puts "D"
		end
	else
		puts "F"
	end
end

Measured memory_bytes: 8660
n = int(input())
R = []
for i in range(0,n):
    R.append(int(input()))
maxv = -1000000000
minv = R[0]
for j in range(1,n):
    maxv = max(maxv,R[j]-minv)
    minv = min(minv,R[j])
print(maxv)


Measured memory_bytes: 13592
import std.stdio;
import core.stdc.stdio;
import std.algorithm;

int n,m;
int[][] map;
int ans=0;

void DFS(int y,int x,int count){
	map[y][x] = 0;
	int[] dx=[0,-1,0,1];
	int[] dy=[-1,0,1,0];
	for(int k=0;k<4;k++){
		int ny = y+dy[k];
		int nx = x+dx[k];
		if(0<=ny&&ny<n&&0<=nx&&nx<m&&map[ny][nx] == 1)
			DFS(ny,nx,count+1);
	}
	map[y][x] = 1;
	ans = max(count,ans);
}

void main(){
	while(1){
		ans = 0;
		scanf("%d%d",&m,&n);
		if(m==0&&n==0)
			break;
		map = new int[][n];
		for(int i=0;i<n;i++){
			map[i] = new int[m];
			for(int j=0;j<m;j++){
				scanf("%d",&map[i][j]);
			}
		}
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				if(map[i][j] == 1)
					DFS(i,j,1);
			}
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 3000
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  string a,b;
  cin>>a>>b;
  char x[2*n];
  int k=0;
  for(int i=0;i<n;i++){
    x[k] = a[i];
    k=k+2;
  }
  k=1;
  for(int i=0;i<n;i++){
    x[k] = b[i];
    k=k+2;
  }
  for(int i=0;i<2*n;i++){
    cout<<x[i];
  }
  return 0;
} 

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

using namespace std;
#define rep(i,n) for (int i = 0; i < n; i++)
#define vi vector<int>

int main(){
  int n; cin >> n;
  vi a(n); rep(i, n) cin >> a[i];

  //a[0], a[1], a[2]
  vi lm(n);// lm[i]; iより左にある者たちの中でのmax。 便宜上 lm[0]=0 としておく
  vi rm(n);// rm[i]; iより右にある者たちの中でのmax。 便宜上 rm[n-1] = 0
  // 求める値は max(lm[i],rm[i]) (i = 0,1,2,...,n-1) の最大値

  for(int i = 1; i < n; i++) lm[i] = max(lm[i-1],a[i-1]);
  for(int i = n-2; i >= 0; i--) rm[i] = max(rm[i+1],a[i+1]);

  rep(i, n) cout << max(lm[i], rm[i]) << '\n';
}

Measured memory_bytes: 5604
{-# LANGUAGE OverloadedStrings #-}

import Control.Monad
import Control.Applicative
import qualified Data.Text as T
import qualified Data.Text.IO as T

main :: IO()
main = do
    input <- map (read :: String -> Int) <$> replicateM 4 getLine
    putStrLn $ solve input

solve :: [Int] -> String
solve [a,b,c,d] = show $ (a `min` b) + (c `min` d) 

Measured memory_bytes: 508
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
char s[100001],ss[100001];
int main(){
	scanf("%s",s);
	memcpy(ss,s,sizeof(s));
	int n=strlen(s);
	reverse(s,s+n);
	for(int i=0; i<n; ++i)
		switch(s[i]){
			case 'd':
				s[i]='b';
				break;
			case 'b':
				s[i]='d';
				break;
			case 'p':
				s[i]='q';
				break;
			case 'q':
				s[i]='p';
				break;
		}
	puts(strcmp(ss,s)?"No":"Yes");
	return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
// typedef tuple<int, int, int> T;
#define FOR(i, s, x) for (int i = s; i < (int)(x); i++)
#define REP(i, x) FOR(i, 0, x)
#define ALL(c) c.begin(), c.end()
#define DUMP(x) cerr << #x << " = " << (x) << endl
#define UNIQUE(c) sort(ALL(c)), c.erase(unique(ALL(c)), c.end())

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  string S;
  std::cin >> S;
  int N = S.size();

  std::vector<int> dp(N + 1), dp2(1 << 26, N);
  dp2[0] = 0;
  int bit = 0;
  for (int i = 0; i < N; i++) {
    bit ^= 1 << (S[i] - 'a');
    int ans = dp2[bit];
    for (int j = 0; j < 26; j++) {
      ans = min(ans, dp2[bit ^ (1 << j)]);
    }
    dp[i + 1] = ans + 1;
    dp2[bit] = min(dp2[bit], dp[i + 1]);
  }
  cout << dp[N] << endl;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  string color;
  int p=0,w=0,g=0,y=0;
  for (int i = 0;i < N;i++){  
    cin >> color;
    if (color=="P")
      p++;
    else if (color=="W")
      w++;
    else if (color=="G")
      g++;
    else if (color=="Y")
      y++;
    else{
      cout <<"error";
      break;
    }
  }
  if (((p>0)+(w>0)+(g>0)+(y>0))==3) 
    cout << "Three";
  else if (((p>0)+(w>0)+(g>0)+(y>0))==4)
    cout << "Four";
  else
    cout << "error";
}

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

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

    int p[n-1];
    for(int i=0;i<n-1;i++) p[i]=i+2;

    int a[m],b[m];
    for(int i=0;i<m;i++) cin>>a[i]>>b[i];

    int ans=0;
    do{
        int count=0;
        for(int j=0;j<m;j++){
            if(1==a[j]&&p[0]==b[j]) count++;
            else if(1==b[j]&&p[0]==a[j]) count++;
        }
        for(int i=0;i<n-2;i++){
            for(int j=0;j<m;j++){
                if(p[i]==a[j]&&p[i+1]==b[j]) count++;
                else if(p[i]==b[j]&&p[i+1]==a[j]) count++;
            }
        }
        if(count==n-1) ans++;
    }while(next_permutation(p,p+n-1));

    cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, Q, s[200000], t[200000], x[200000], D[200000], tree[1 << 21];
vector<int>v;

void update(int l, int r, int p, int q, int k, int x) {
	if (q < l || r < p)return;
	if (p <= l&&r <= q) {
		if (tree[k]) {
			tree[k] = min(tree[k], x);
		}
		else {
			tree[k] = x;
		}
	}
	else {
		update(l, (l + r) / 2, p, q, k * 2, x);
		update((l + r) / 2 + 1, r, p, q, k * 2 + 1, x);
	}
}

int calc(int x) {
	x += (1 << 20);
	int a = intmax;
	while (x) {
		if (tree[x])a = min(a, tree[x]);
		x /= 2;
	}
	if (a == intmax)return -1;
	return a;
}

int main() {
	cin >> N >> Q;
	for (int i = 0; i < N; ++i) {
		cin >> s[i] >> t[i] >> x[i];
		s[i] -= x[i];
		t[i] -= x[i];
		v.push_back(s[i]);
		v.push_back(t[i] - 1);
	}
	for (int i = 0; i < Q; ++i) {
		cin >> D[i];
		v.push_back(D[i]);
	}
	sort(v.begin(), v.end());
	for (int i = 0; i < N; ++i) {
		update(0, (1 << 20) - 1, lower_bound(v.begin(), v.end(), s[i]) - v.begin(), lower_bound(v.begin(), v.end(), t[i] - 1) - v.begin(), 1, x[i]);
	}
	for (int i = 0; i < Q; ++i) {
		cout << calc(lower_bound(v.begin(), v.end(), D[i]) - v.begin()) << endl;
	}
}

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

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

	vector<pair<int, int>> sc(m);
	int temp_s, temp_c;
	for (int i = 0; i < m; ++i) {
		cin >> temp_s;
		cin >> temp_c;
		sc[i] = make_pair(temp_s, temp_c);
	}

	unordered_map<int, int> um;
	for (auto t : sc) {
		if (um.find(t.first) != um.end()) {
			if (um.at(t.first) != t.second) {
				cout << -1 << endl;
				return 0;
			}
		}
		else {
			um.emplace(t.first, t.second);
		}
	}

	if (n > 1) {
		if (um.find(1) != um.end()) {
			if (um.at(1) == 0) {
				cout << -1 << endl;
				return 0;
			}
		}
	}

	string result = "";
	for (int i = 1; i <= n; ++i) {
		if (um.find(i) != um.end()) {
			result += to_string(um.at(i));
		}
		else {
			if (i == 1) {
				if (n > 1) {
					result += "1";
				}
				else {
					result += "0";
				}
			}
			else {
				result += "0";
			}
		}
	}

	cout << result << endl;

	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#define MAX 100000

int A[MAX], n;

void swap(int x, int y){
    int v;
    v=A[x];
    A[x]=A[y];
    A[y]=v;
}


int partition(int p, int r){
    int x, i, j;
    x=A[r];
    i=p-1;
    for(j=p;j<r;j++){
        if(A[j]<=x){
            i++;
            swap(i,j);
        }
    }
    swap(i+1,r);
    return i+1;
}

int main(void){
    int i, q;
    
    scanf("%d", &n);
    for(i=0;i<n;i++) scanf("%d",&A[i]);
    
    q= partition(0,n-1);

    for(i=0; i < n; i++){
        if(i) printf(" ");
        if(i==q) printf("[");
        printf("%d",A[i]);
        if(i==q) printf("]");
    }
    printf("\n");

    return 0;
}


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

using namespace std ; 

int main () { 
	int  t ; 
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ;
	int a , b ; 
	cin >> a  >> b;  
	for ( int i = 0 ; i <  2000  ; i ++ ) {
		if  ( floor(i * 0.08) == a && floor(i * 0.1) == b ) {
			
			cout << i << endl ;
			return 0 ; }
	}
	cout << -1 << endl ; 
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const double PI = acos(-1);  

int main(){
  int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
  

  int disx=abs(tx-sx), disy=abs(ty-sy);

  bool flag=false;
  for(int p=0; p<4; p++){
    if(2<=p){
      if(!flag && sy<ty) cout << 'D';
      else cout << 'U';
      if(!flag){disx += 1; disy += 1;}
    }
    for(int i=0; i<disx; i++)
      if(!flag && sx<tx) cout << 'R';
      else cout << 'L';
    
    for(int i=0; i<disy; i++)
      if(!flag && sy<ty) cout << 'U';
      else cout << 'D';
    
    if(2<=p){
      if(!flag && sx<tx) cout << 'L';
      else cout << 'R';
    }
    flag = !flag;
  }


}

Measured memory_bytes: 256
#include<stdlib.h>
#include<iostream>
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
const int N = 2e5+10;
int a[N];
int main()
{
	stack<int> s;
	int a , b , x;
	string c;
	while(cin >> c)
	{
		if(c[0] == '+')
		{
			a = s.top();
			s.pop();
			b = s.top();
			s.pop();
			s.push(a+b);
		}
		else if(c[0] == '-')
		{
			b = s.top();
			s.pop();
			a = s.top();
			s.pop();
			s.push(a-b);
		}
		else if(c[0] == '*')
		{
			b = s.top();
			s.pop();
			a = s.top();
			s.pop();
			s.push(a*b);
		}
		else
		{
			s.push(atoi(c.c_str()));
		}
	}
	cout << s.top() << endl;
	return 0;
}


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

using namespace std;

using i32 = int32_t;
using u32 = uint32_t;
using f32 = float;
using f64 = double;
using i64 = int64_t; 
using u64 = uint64_t; 

#define SELECTER(_1, _2, _3, _4, _5, _6, _7, _8, SELECT, ...) SELECT

#define _FC1(func, type, _1)      func(type, _1) 
#define _FC2(func, type, _1, ...) func(type, _1); _FC1(func, type, __VA_ARGS__)
#define _FC3(func, type, _1, ...) func(type, _1); _FC2(func, type, __VA_ARGS__) 
#define _FC4(func, type, _1, ...) func(type, _1); _FC3(func, type, __VA_ARGS__)
#define _FC5(func, type, _1, ...) func(type, _1); _FC4(func, type, __VA_ARGS__)
#define _FC6(func, type, _1, ...) func(type, _1); _FC5(func, type, __VA_ARGS__)
#define _FC7(func, type, _1, ...) func(type, _1); _FC6(func, type, __VA_ARGS__)
#define _FC8(func, type, _1, ...) func(type, _1); _FC7(func, type, __VA_ARGS__)

#define _FCN(func, type, ...) SELECTER(__VA_ARGS__, _FC8, _FC7, _FC6, _FC5, _FC4, _FC3, _FC2, _FC1)(func, type, __VA_ARGS__)

constexpr const char *type2fmt(const char *fmt) {
  if(strcmp(fmt, "i32") == 0) return "%d";
  if(strcmp(fmt, "u32") == 0) return "%u";
  if(strcmp(fmt, "f32") == 0) return "%f";
  if(strcmp(fmt, "f64") == 0) return "%lf";
  if(strcmp(fmt, "i64") == 0) return "%lld";
  if(strcmp(fmt, "u64") == 0) return "%llu";
  return "";
}

#define _R(type, _1) type _1; { type _t; scanf(type2fmt(#type), &_t); _1 = _t; }
#define _P(type, _1) { const type _t = (_1); printf(type2fmt(#type), _t); putchar('\n'); }

#define RI(...)   _FCN(_R, i32, __VA_ARGS__)
#define RUI(...)  _FCN(_R, u32, __VA_ARGS__)
#define RF(...)   _FCN(_R, f32, __VA_ARGS__)
#define RD(...)   _FCN(_R, f64, __VA_ARGS__)
#define RLL(...)  _FCN(_R, i64, __VA_ARGS__)
#define RULL(...) _FCN(_R, u64, __VA_ARGS__)

#define PI(...)   _FCN(_P, i32, __VA_ARGS__)
#define PUI(...)  _FCN(_P, u32, __VA_ARGS__)
#define PF(...)   _FCN(_P, f32, __VA_ARGS__)
#define PD(...)   _FCN(_P, f64, __VA_ARGS__)
#define PLL(...)  _FCN(_P, i64, __VA_ARGS__)
#define PULL(...) _FCN(_P, u64, __VA_ARGS__)

#define REP(n) for (int _i = 0; _i < n; _i++)

const u64 mod = 1000000007;

int main() {
  RD(T, X)
  PD(T / X)
}


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

//Function Macros:
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;
typedef struct
{
    int id, no;
} stud;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

bool cmpNo(const stud &a, const stud &b)
{
    return a.no < b.no;
}

bool cmpId(const stud &a, const stud &b)
{
    return a.id < b.id;
}

//================ Main Loop ================
int main()
{
    int n;
    cin >> n;
    vector<stud> a(n);
    rep(i, n)
    {
        a[i].id = i;
        cin >> a[i].no;
    }
    sort(all(a), cmpNo);
    rep(i, n - 1)
    {
        cout << a[i].id + 1 << " ";
    }
    cout << a[n - 1].id + 1 << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}

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

using namespace std;
typedef long long ll;
const ll MOD=1e9+7;           /*******MOD***********超过long long 一点不要紧*****/

const int maxn = 123456;
typedef pair<int,int> pii;

//class Solution {
//public:
//    string decodeAtIndex(string S, int K) {
//        int n = S.size();
//        ll sum = 0, tmp = 0, t;
//        string str = "";
//        while (K){
//            sum = 0;
//            tmp = 0;
//            t = 0;
//            for (int i = 0; i < n; ++i) {
//                if(isdigit(S[i])){
//                    t = sum;
//                    sum += tmp;
//                    int c = S[i] - '0';
//                    if(c*sum == K){
//                        K = sum;
//                        break;
//                    } else if(c * sum > K) {
//                        K = K % sum;
//                        break;
//                    }
//                    tmp = 0;
//                    sum = c * sum;
//                } else {
//                    tmp ++;
//                    if(sum + tmp == K)return str+S[i];
//                }
//                cerr << K << endl;
//            }
//        }
//        return str + S[0];
//    }
//};


class Solution {
public:
    int projectionArea(vector<vector<int>>& grid) {
        int n = grid.size();
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < grid[i].size(); ++j) {

            }
        }
    }
};

char a[maxn], b[maxn];
int main(){
    int n ;
    cin >> n;
    if(n < 1200)cout << "ABC" << endl;
    else if(n < 2800)cout << "ARC" << endl;
    else cout << "AGC" << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
hlist = list(map(int, input().split()))

def watering(lst, count):
  if lst == [] or max(lst) == 0:
    return count
  if min(lst) == 0:
    return count + watering(lst[:lst.index(0)], 0) + watering(lst[lst.index(0)+1:], 0)
  else:
    count += 1
    lst = list(map(lambda x:x-1, lst))
    return watering(lst, count)
print(watering(hlist, 0))

Measured memory_bytes: 3188