akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main() {
    int m;
    cin>>m;
    for(int i=0;i<m;i++) {
        string s;
        cin>>s;
        set<string> S;
        for(int i=1;i<=s.size()-1;i++) {
            string first=s.substr(0,i);
            string second=s.substr(i);
            string r_first=first;
            string r_second=second;
            reverse(r_first.begin(),r_first.end());
            reverse(r_second.begin(),r_second.end());
            S.insert(first+second);
            S.insert(second+first);
            S.insert(r_first+second);
            S.insert(second+r_first);
            S.insert(first+r_second);
            S.insert(r_second+first);
            S.insert(r_first+r_second);
            S.insert(r_second+r_first);
        }
        cout<<S.size()<<endl;
    }
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
using namespace std;
string str;
bool is_pal(string s){
	for(int i = 0; i < s.size() / 2; i++){
		if(s[i] == s[s.size() - i - 1])
			continue;
		else
			return false;
	}
	return true;
}
void solve(){
	int n = str.size();
	if(is_pal(str)){
		int x = (n - 1) / 2;
		int y = (n + 3) / 2;
		if(is_pal(str.substr(0, x)) && is_pal(str.substr(y - 1, n))){
			puts("Yes");
		}
		else
			puts("No");
	}
	else
		puts("No");
}
int main()
{
	cin>>str;
	solve();
	return 0;
}


Measured memory_bytes: 256
Public Class Program
  Shared Sub Main()
    Dim ab As Integer() = Array.ConvertAll(Of String, Integer)(Console.ReadLine().Split(" "), AddressOf Integer.Parse)
    Dim a As Integer = ab(0)
    Dim b As Integer = ab(1)
    Dim outlet As Integer = 1
    Dim ans As Integer = 0
    While outlet < b
      ans += 1
      outlet = (a * ans) - (ans - 1)
    End While
    Console.WriteLine(ans.ToString())
  End Sub
End Class

Measured memory_bytes: 11092
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/agc026/tasks/agc026_b

//ポイント：
//X増やしてY減らすみたいな操作では、XとYのgcdに注目してみる

//参考：
//https://betrue12.hateblo.jp/entry/2018/07/15/010448
//↑で紹介している風に実験するとわかるが
//C<A-Bx+Dy<B
//が成立するようなx,yの組が存在すれば永遠に買い続けられない
//これはつまりC<A+gcd(B,D)z<Bが成立するようなzが
//存在するかを確かめればいいことになる

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL gcd(LL a,LL b) { return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b) { return a/gcd(a,b)*b;}

int T;
LL A[300],B[300],C[300],D[300];

string ans[300];

void solve(){
	for(int i=0;i<T;i++){
		if(B[i]>D[i] || A[i]<B[i]){
			ans[i] = "No";
			continue;
		}
		if(B[i]<=C[i]+1){
			ans[i] = "Yes";
			continue;
		}
		LL G = gcd(B[i],D[i]);

		LL lower;
		if((C[i]-A[i])%G==0) lower = (C[i]-A[i])/G + 1LL;
		else{
			lower = (C[i]-A[i])/G;
			if(C[i]-A[i]>0) lower++;
		}

		LL upper;
		if((B[i]-A[i])%G==0) upper = (B[i]-A[i])/G - 1LL;
		else{
			upper = (B[i]-A[i])/G;
			if(C[i]-A[i]<0) upper--;
		}

		if(upper-lower>=0) ans[i] = "No";
		else ans[i] = "Yes";
	}
}

int main(){
    cin >> T;
    for(int i=0;i<T;i++) cin >> A[i] >> B[i] >> C[i] >> D[i];

    solve();

    for(int i=0;i<T;i++)cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cassert>
#include<map>

#define MAX_V 5000
#define INF (1<<29)

using namespace std;

struct edge{int to,cap,rev;};

vector<edge>g[MAX_V];
bool used[MAX_V];

void add_edge(int from,int to,int cap){
  g[from].push_back((edge){to,cap,g[to].size()});
  g[to].push_back((edge){from,0,g[from].size()-1});
}

int dfs(int v,int t,int f){
  if(v==t)return f;
  used[v]=true;
  for(int i=0;i<g[v].size();i++){
    edge &e=g[v][i];
    if(!used[e.to] && e.cap>0){
      int d=dfs(e.to,t,min(f,e.cap));
      if(d>0){
        e.cap-=d;
        g[e.to][e.rev].cap+=d;
        return d;
      }
    }
  }
  return 0;
}

int max_flow(int s,int t){
  int flow=0;
  for(;;){
    fill(used,used+MAX_V,false);
    int f=dfs(s,t,INF);
    if(f==0)return flow;
    flow+=f;
  }
}

int main(void){

  int n;
  while(cin >> n,n){

    for(int i=0;i<MAX_V;i++)g[i].clear();

    vector<int>a;
    map<int,int>mp;
    int m,in,tmp;
    cin >> tmp;
    for(int i=0;i<tmp;i++){
      cin >> in;
      add_edge(n+tmp,i,1);
      a.push_back(in);
      mp[in]=i;
    }

    for(int i=0;i<n;i++){
      cin >> m;
      vector<int>b(m);
      for(int j=0;j<m;j++)cin >> b[j];
      for(int j=0;j<m;j++){
        if(mp.count(b[j])){
          add_edge(mp[b[j]],i+tmp,1);
        }
      }
    }

    for(int i=0;i<n;i++){
      add_edge(i+tmp,n+tmp+1,1);
    }
    cout << max_flow(n+tmp,n+tmp+1) << endl;
  }
  return 0;
}

Measured memory_bytes: 1532
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define pb push_back
#define all(v) v.begin(),v.end()
const int N=100005;
const int MOD=1e9+7;
 

// lower_bound - which does not compare less than val
// upper_bound - which compares greater than val
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
 
int32_t main()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  /* stuff you should look for
  * int overflow, array bounds
  * special cases (n=1?)
  * do smth instead of nothing and stay organized
*/




int n;
cin>>n;
	int x=360;
	while(x%n!=0)
	{
		x=x+360;

	}
	cout<<x/n;
}



Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <queue>
#define in(a) a=read()
#define REP(i,k,n) for(int i=k;i<=n;i++)
using namespace std;
inline int read(){
    int x=0,f=1;
    char ch=getchar();
    for(;!isdigit(ch);ch=getchar())
        if(ch=='-')
            f=-1;
    for(;isdigit(ch);ch=getchar())
       x=x*10+ch-'0';
    return x*f;
}
int main(){
	int a,b,c;
	in(a),in(b),in(c);
	if((c>a && c<b) || (c>b && c<a))  cout<<"Yes";
	else  cout<<"No";
	return 0;
}

Measured memory_bytes: 256
n=int(input())
X=list(map(int,input().split()))
M=int(input())
A=list(map(int,input().split()))

for i in range (len(A)):
    for j in range(len(X)):
        cnt=0
        if A[i]==j+1:
            X[j]+=1
            for k in range (len(X)):
                if X[j]==X[k] and k!=j:
                    X[j]=X[j]-1
            if X[j]>2019:
                X[j]=X[j]-1
      
            
for i in range (len(X)):
    print(X[i])



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

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

  bool ok = false;
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    int d1, d2; cin >> d1 >> d2;
    if (d1 == d2) {
      cnt++;
      if (cnt == 3) {
        ok = true;
        break;
      }
    } else {
      cnt = 0;
    }
  }

  cout << (ok ? "Yes" : "No") << endl;
}


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

int n,dp[1008][1008],x[1008],y[1008];

int dfs(int l,int r){
  if(dp[l][r]!=1e9)return dp[l][r];
  int res=1e9;
  for(int i=l;i<r;i++){
    dp[l][r]=min(dp[l][r],dfs(l,i)+dfs(i+1,r)+ (y[i]-y[r])+(x[i+1]-x[l]) );
  }
  return dp[l][r];
}

int main(){
  cin>>n;
  r(i,n) cin>>x[i]>>y[i];
  r(i,n)r(j,n) dp[i][j] = (i==j?0:1e9);
  cout<<dfs(0,n-1)<<endl;
}



Measured memory_bytes: 7120
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	int xa, xb;
	xa = abs(x - a);
	xb = abs(x - b);
	if (xa <= xb) cout << "A" << endl;
	else cout << "B" << endl;
	return 0;
}

Measured memory_bytes: 3560
input_lines = $stdin.read.split("\n")
l_1 = input_lines[0].split(' ')

X = l_1[2].to_i
Y = l_1[3].to_i
x_want = input_lines[1].split(' ').map {|str| str.to_i}.sort
y_want = input_lines[2].split(' ').map {|str| str.to_i}.sort

x_will = x_want << X
y_will = y_want << Y

if x_will.max < y_will.min
	puts 'No War'
else
	puts 'War'
end

Measured memory_bytes: 1788
using System;
using System.Collections.Generic;
public class ABG035A {
    public static void Main() {
        int N, sum = 0;
        List<int> a = new List<int>();
        N = int.Parse(Console.ReadLine());
        string[] str = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++) {
            a.Add(int.Parse(str[i]));
        }
        for (int i = 0; i < N; i++) {
            sum = sum ^ a[i];
        }
        if (sum == 0) Console.WriteLine("Yes");
        else Console.WriteLine("No");
    }
}


Measured memory_bytes: 20576
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,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 fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int 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())
const ll mod = 998244353;
int n,k;
ll t[1005][2005];
ll s[1005][2005];
ll modpow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
ll F[4005],R[4005];
void make(){
	F[0] = 1;
	for(int i=1;i<4005;i++) F[i] = F[i-1]*i%mod;
	for(int i=0;i<4005;i++) R[i] = modpow(F[i],mod-2);
}
ll C(int a,int b){
	if(a == -1 && b == -1) return 1;
	if(a < 0 || b < 0) return 0;
	return F[a]*R[b]%mod*R[a-b]%mod;
}
int main(){
	t[0][0] = 1; make();
	t[1][0] = 1; for(int i=1;i<2005;i++) t[1][i] = 2;
	for(int i=2;i<1002;i++){
		ll rui = 0;
		for(int j=0;j<2005;j++){
			rui += t[i-1][j];
			rui %= mod;
			t[i][j] = (rui*2LL-t[i-1][j])%mod;
		}
	}
	rep(i,1002){
		rep(j,2005){
			s[i][j] = t[i][j];
			if(j) s[i][j] = (s[i][j]+t[i][j-1])%mod;
		}
	}
	cin >> k >> n;
	for(int i=2;i<=2*k;i++){
		ll ans = 0;
		if(i <= k+1){
			int use = (i-1)/2;
			int ce = 1-i%2;
			int pos = k-use*2-ce;
			if(!ce){
				rep(i,n+1){
					ans += t[use][i] * C(n-i+pos-1,pos-1) % mod;
				}
			}
			else{
				rep(i,n+1){
					ans += s[use][i] * C(n-i+pos-1,pos-1) % mod;
				}
			}
		}
		else{
			int use = (2*k+1-i)/2;
			int ce = 1-i%2;
			int pos = k-use*2-ce;
			if(!ce){
				rep(i,n+1){
					ans += t[use][i] * C(n-i+pos-1,pos-1) % mod;
				}
			}
			else{
				rep(i,n+1){
					ans += s[use][i] * C(n-i+pos-1,pos-1) % mod;
				}
			}
		}
		cout << (ans%mod+mod)%mod << endl;
	}
}

Measured memory_bytes: 31744
#include<iostream>
#include<string>
#include<utility>
#include<queue>
using namespace std;
int main(){
  int n,q,time,cnt_time = 0;
  string name;
  queue<pair<string,int> > que;
  cin >> n >> q;
  for(int i=0;i<n;i++){
    cin >> name >> time;
    que.push(make_pair(name,time));
  }
  while(!que.empty()){
    pair<string,int> top = que.front();
    que.pop();
    if(top.second <= q){
      cnt_time += top.second;
      cout << top.first << " " << cnt_time << endl;
    }else{
      cnt_time += q;
      que.push(make_pair(top.first,top.second-q));
    }
  }
}



Measured memory_bytes: 6328
#include <iostream>
#include <tuple>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define int long long

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T>
bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }

template<class T>
bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int K = 30;
const int maxn = 2000010;
const i64 P = 1000000000 + 7;
i64 sm[K + 1][maxn + 1];
i64 l[maxn + 1];
i64 d_26[maxn + 1], d26[maxn + 1], d25[maxn + 1], fact[maxn + 1], tcaf[maxn + 1];

i64 deg(i64 x, i64 d) {
    d %= P - 1;
    if (d < 0) d += P - 1;
    i64 y = 1;
    while (d) {
        if (d & 1) y *= x, y %= P;
        x *= x, x %= P;
        d /= 2;
    }
    return y;
}

void add(i64 &x, i64 y) {
    x += y;
    x %= P;
}

i64 cnk(int n, int k) {
    return fact[n] * tcaf[k] % P * tcaf[n - k] % P;
}

int k;

void recount() {
    if (k <= K) return;
    forn(i, maxn + 1) l[i] = 0;
    for (int i = k; i <= maxn; ++i) {
        l[i] = (l[i - 1] + d_26[i] * d25[i - k] % P * cnk(i - 1, k - 1)) % P;
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);

    fact[0] = tcaf[0] = d25[0] = d_26[0] = d26[0] = 1;
    for1(i, maxn) {
        fact[i] = i * fact[i - 1] % P;
        tcaf[i] = deg(fact[i], -1);
        d25[i] = d25[i - 1] * 25 % P;
        d_26[i] = d_26[i - 1] * deg(26, -1) % P;
        d26[i] = d26[i - 1] * 26 % P;
    }

    for1(k, K) for (int i = k; i <= maxn; ++i) {
            sm[k][i] = (sm[k][i - 1] + d_26[i] * d25[i - k] % P * cnk(i - 1, k - 1)) % P;
        }

    int m;
    string s;
    int n;
    cin >> n >> s;
    k = s.size();
    n += k;
    recount();
    cout << d26[n] * (k <= K ? sm[k][n] : l[n]) % P << '\n';
}

Measured memory_bytes: 566580
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};
//fixed << setprecision(2)
bool  Array_check(ll y, ll x,ll d,ll w) {
	if (x < 0 || x >= w || y<0 || y>=d) {
		return false;
	}
	else {
		return true;
	}
	
}

//小文字=大文字+32

int main() {
	ll n;
	cin >> n;
	vector<ll>a(n);
	vector<ll>b(n);
	cin >> a[0];
	b[0] = a[0];
	ll sum = 0;
	sum += a[0];
	for(int i=1;i<n;i++) {
		cin >> a[i];
		b[i] = a[i] + b[i - 1];
		sum += a[i];
	}
	ll ans=0;
		ll tmp;
	rep(i, n) {
		tmp = sum - b[i];
		tmp %= mod;
		ans += a[i] * tmp;
		ans %= mod;
	}
	cout << ans;
}
	



Measured memory_bytes: 6424
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
int K,X;

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

  cin >> K >> X;
  for (int i=X-K+1;i<=X+K-1;i++){
    cout << i << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;

int main(){
    int n,k,s[13]={0},h[13]={0},c[13]={0},d[13]={0};cin>>n;
    for(int i=0;i<n;i++){
        string op;cin>>op>>k;
        if(op=="S") s[k-1]=1;
        else if(op=="H") h[k-1]=1;
        else if(op=="C") c[k-1]=1;
        else if(op=="D") d[k-1]=1;
    }
    for(int i=0;i<13;i++){
        if(s[i]==0) cout<<"S"<<" "<<i+1<<endl;
    }
    for(int i=0;i<13;i++){
        if(h[i]==0) cout<<"H"<<" "<<i+1<<endl;
    }
    for(int i=0;i<13;i++){
        if(c[i]==0) cout<<"C"<<" "<<i+1<<endl;
    }
    for(int i=0;i<13;i++){
        if(d[i]==0) cout<<"D"<<" "<<i+1<<endl;
    }
}


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

using namespace std;
typedef long long ll;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n;
    cin>>n;
    vector<ll> xs(n),ys(n);
    for(ll i=0; i<n; i++) cin>>xs[i]>>ys[i];

    double ans=0;
    for(ll i=0; i<n; i++){
        ll gx=xs[i],gy=ys[i];
        for(ll k=0; k<4; k++){
            ll nx=-gy,ny=gx;
            gx=nx;
            gy=ny;

            ll sx=0,sy=0;
            ll px=0,py=0;
            ll qx=0,qy=0;

            auto dot=[&](ll x1,ll y1,ll x2,ll y2){return x1*x2+y1*y2;};
            auto cross=[&](ll x1,ll y1,ll x2,ll y2){return x1*y2-x2*y1;};
            for(ll j=0; j<n; j++) {
                ll res=dot(xs[j],ys[j],gx,gy);
                if(res<0) continue;
                if(res>0){
                    sx+=xs[j];
                    sy+=ys[j];
                    continue;
                }
                if(cross(xs[j],ys[j],gx,gy)>0) {
                    px+=xs[j];
                    py+=ys[j];
                } else {
                    qx+=xs[j];
                    qy+=ys[j];
                }
            }

            for(ll t=0; t<4; t++){
                double bx=sx,by=sy;
                if(t&1) bx+=px,by+=py;
                if(t&2) bx+=qx,by+=qy;
                chmax(ans,bx*bx+by*by);
            }
        }
    }

    cout<<fixed<<setprecision(12)<<sqrt(ans)<<endl;

    return 0;
}


Measured memory_bytes: 256
package main

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

var (
	BufferSize = 7 + 100000 + (7+1+7)*100000 + 1
	Pattern    = "AC"
)

func scanStr(sc *bufio.Scanner) string {
	if !sc.Scan() {
		panic(nil)
	}

	return sc.Text()
}

func scanInt(sc *bufio.Scanner) int {
	if !sc.Scan() {
		panic(nil)
	}

	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func count() {
	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, BufferSize)
	sc.Split(bufio.ScanWords)

	n := scanInt(sc)
	q := scanInt(sc)
	s := scanStr(sc)

	targetIndex := make([]int, n+1)
	for i := 0; i < n; i++ {
		if i+2 > n {
			break
		}
		if target := string(s[i : i+2]); target == "AC" {
			targetIndex[i+1] = targetIndex[i] + 1
			targetIndex[i+2] = targetIndex[i] + 1
			i++
			continue
		}
		targetIndex[i+1] = targetIndex[i]
	}

	for i := 0; i < q; i++ {
		l := scanInt(sc)
		r := scanInt(sc)
		fmt.Printf("%d\n", targetIndex[r-1]-targetIndex[l-1])
	}
}

func main() {
	count()
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} 
#define rep(i, l, n) for (int i = l; i < (int)(n); i++)
#define repn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
#define sort(v) sort(v.begin(), v.end())
#define sortr(v) sort(v.rbegin(), v.rend())
void chmin(int &a, int b) {if(a > b) a = b;}
void chmax(int &a, int b) {if(a < b) a = b;}

const int mod = 1000000007;
const int inf = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};


int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1 ; i <= n ; i+=2){
        int cnt = 0;
        repn(j,1,i){
            if(i%j==0)cnt++;
        }
        if(cnt==8)ans++;
    }
    cout << ans;
    
}

Measured memory_bytes: 256
#include <stdio.h>

int a;
int b;
int coin;

int main(void){
scanf("%d %d", &a, &b);
if(a>b){
    coin = a+a-1;
    printf("%d\n",coin);
}else if(a<b){
    coin = b+b-1;
    printf("%d\n",coin);
}else{
    coin = a+b;
    printf("%d\n",coin);
}
return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main(){
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    queue<string> que;
    que.push("a");
    int cnt = 1;
    set<string> ans;
    while(1){
        string fa = que.front();
        if(que.front().size() >= n) break;
        char maxc = 'a';
        rep(i,fa.size()){
            chmax(maxc,fa[i]);
        }
        rep(i,int(maxc - 'a' + 2)){
            que.push(fa + char('a' + i));
        }
        que.pop();
        cnt++;
    }
    while(!que.empty()){
        cout << que.front() << endl;
        que.pop();
    }
    return 0;
}

Measured memory_bytes: 7208
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <cstring>
#include <climits>
#include <queue>
#include <map>
#include <sstream>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define EPS 1e-9

void parseUL(const string& s, vector<string>& v){
	string ts = s;
	int i;
	for(i=0; i<ts.size();){
		string tmp;
		ts[i] = tolower(ts[i]);
		for(;i<ts.size() && islower(ts[i]); i++)tmp+=ts[i];
		v.push_back(tmp);
	}
}
void parseD(const string& s, vector<string>& v){
	int i;
	for(i=0; i<s.size(); i++){
		string tmp;
		for(;i<s.size() && s[i]!='_'; i++)tmp+=s[i];
		v.push_back( tmp );
	}
}

string ext(vector<string>& v, const string& type){
	string ret;
	if( type=="L" ){
		rep(i,v.size()){
			if( i!=0 )v[i][0]=toupper(v[i][0]);
			ret += v[i];
		}
	}else if( type=="U" ){
		rep(i,v.size()){
			v[i][0]=toupper(v[i][0]);
			ret += v[i];
		}
	}else{
		rep(i,v.size()){
			if( i!=0 )ret+="_";
			ret += v[i];
		}
	}
	return ret;
}

int main(){
	string s,type;
	while(cin>>s>>type,type!="X"){
		vector<string> v;
		if( s.find('_') != string::npos ){
			parseD(s,v);
		}else{
			parseUL(s,v);
		}
		
		cout << ext(v,type) << endl;

	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
  int level;
  char t[] = {'J','O','I'};
  string s;
  int mx = 0;
  cin >> s;
  for(int i = 0;i < s.size();i++){
    if(s[i] == 'J'){
      level = INT_MAX;
      int j;
      int cnt[3] = {0};
      for(j = 0;j < 3;j++){
	if(s[i] != t[j])break;
	while(s[i] == t[j]){
	  i++;
	  cnt[j]++;
	}
      }
      if(cnt[1] > cnt[2] || cnt[1] > cnt[0] || j != 3)i--;
      else{
	sort(cnt,cnt + 3);
	mx = max(cnt[0],mx);
	i--;
      }
    }
  }
  cout << mx << endl;
  return 0;
}

Measured memory_bytes: 2052
import static java.lang.System.out;
import java.util.Scanner;
import java.util.Arrays;

public class Main{
   static Scanner sc = new Scanner(System.in);
   public static void main(String[] args){
      double a = sc.nextDouble();
      double b = sc.nextDouble();
      out.println((int)(Math.ceil((a+b)/2)));
      
   }
}

Measured memory_bytes: 21076
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <array>
#include <vector>

using namespace std;

int main() {
  while( true ) {
    int r, c;
    cin >> r >> c;
    if( r == 0 and c == 0 ) break;
    if ( r % 2 == 1 and c % 2 == 1 ) {
      cout << "no" << endl;
    } else {
      cout << "yes" << endl;
    }
  }
}

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

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

    vector<int> like(M,0);
    for(int i=0; i<N; i++){
        int K,A;
        cin >>K;
        for(int j=0; j<K; j++){
            cin >> A;
            A--;
            like[A]++;
        }
    }

    int ans=0;
    for(int i=0;i<M;i++){
        if(like[i]==N) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int n;
vector<pair<int, int>> v;

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    cin >> n;
    v.resize(n);
    for (auto &i : v) {
        cin >> i.first >> i.second;
    }
    int cnt = 0;
    for (auto i : v) {
        if (i.first == i.second) {
            cnt++;
        } else {
            cnt = 0;
        }
        if (cnt == 3) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3616
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
dics = defaultdict(str)
dict = defaultdict(str)
s = input()
t = input()
for i in range(len(s)):
    if dics[s[i]]:
        if dics[s[i]] == t[i]:
            pass
        else:
            print('No')
            exit()
    else:
        dics[s[i]] = t[i]
    if dict[t[i]]:
        if dict[t[i]] == s[i]:
            pass
        else:
            print('No')
            exit()
    else:
        dict[t[i]] = s[i]
print('Yes')


Measured memory_bytes: 10604
n = int(input())
a = list(map(int, input().split()))
l = [0] * (10**5+1)
for a_i in a:
    l[a_i] += 1
s = sum(a)
q = int(input())
ans = []
for i in range(q):
    b, c = map(int, input().split())
    s = s - l[b] * b + l[b] * c
    ans.append(s)
    l[c] += l[b]
    l[b] = 0
for ans_i in ans:
    print(ans_i)

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

using namespace std;

#define FOR(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define REP(i,n) FOR(i,0,n)

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using ll = long long;

ll dp[52][5003];

int main() {
  int n, a; cin >> n >> a;
  vector<int> x(n); REP(i,n) cin >> x[i];
  int max = *whole(max_element, x);
  chmax(max, a);
  REP(i,n) x[i]-=a;
  dp[0][n*max] = 1;
  REP(i,n) REP(j,2*n*max+1) {
    dp[i+1][j] = dp[i][j];
    if (0 <= j-x[i] && j-x[i] <= 2*n*max) dp[i+1][j] += dp[i][j-x[i]];
  }
  cout << dp[n][n*max]-1 << endl;
  return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int main(){
  int H,W;
  cin>>H>>W;
  string A[8];
  for (int i(0);i<H;i++)cin>>A[i];
  for (int h(0);h<H;h++){
    for (int w(0);w<W;w++){
      if (A[h][w]=='#'){
        for (int hi(h+1);hi<H;hi++){
          for (int wi(0);wi<=w-1;wi++){
            if (A[hi][wi]=='#'){
              cout << "Impossible" << endl;
              return 0;
            }
          }
        }
      }

    }
  }
  cout << "Possible" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std; //头文件和命名空间
int main(){
    ios::sync_with_stdio(false); //输入输出加速
    int nCount,iStart,iEnd; //nCount-团体个数；iStart-座位号起始；iEnd-座位号结束
    register int i,nTotal=0; //循环计数器和总和
    cin >> nCount; //读入团体数
    for (i = 1; i <= nCount; ++i){ //读入每个团体占用的座位
        cin >> iStart >> iEnd; //读入起始和结束
        nTotal += iEnd - iStart + 1; //计算占用了多少个座位，加总
    }
    cout << nTotal << endl; //输出，勿忘换行
    return 0; //结束
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=Integer.parseInt(sc.nextLine());
		int[] r=new int[N];
		String[] a=sc.nextLine().split(" ");
		for(int i=0,c=0;i<N-1;i++) {
			int now=Integer.parseInt(a[i]);
			int next=Integer.parseInt(a[i+1]);
			if(now<next) {
				c=0;
			}else {
				r[i]=++c;
			}
		}
		Arrays.parallelSort(r);
		System.out.println(r[N-1]);
	}
}

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

using namespace std;
const int N=1e5+100;
const int mod=1e9+7;
typedef long long ll;

int p[10][10];
int main()
{
    int n;scanf("%d",&n);
    for(int i=1;i<=n;i++){
        int bac=i%10;
        int k=i;
        while(1){
            if(k/10) k/=10;
            else break;
        }
        p[k][bac]++;
    }
    ll ans=0;
    for(int i=1;i<=9;i++)
        for(int j=1;j<=9;j++)
          ans+=p[i][j]*p[j][i];
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using P = pair<ll, ll>;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<ll> x(n), y(n);
  rep(i, n) cin >> x[i] >> y[i];
  vector<P> p(n);
  rep(i, n) p[i] = {x[i]+y[i], x[i]-y[i]};
  ll mn = LINF, mx = -LINF, idx1, idx2;
  rep(i, n) {
    if (chmin(mn, p[i].first))
      idx1 = i;
    if (chmax(mx, p[i].first))
      idx2 = i;
  }
  ll ans = abs(x[idx1]-x[idx2])+abs(y[idx1]-y[idx2]);
  mn = LINF, mx = -LINF;
  rep(i, n) {
    if (chmin(mn, p[i].second))
      idx1 = i;
    if (chmax(mx, p[i].second))
      idx2 = i;
  }
  chmax(ans, abs(x[idx1]-x[idx2])+abs(y[idx1]-y[idx2]));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9472
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;

// [l, r]の累積min
int h_accum_min(vector<vector<int> > &c, int y, int l, int r, int v, int h) {
    int ret = INF;
    for (int i = l; i <= r; ++i) {
        ret = min(ret, c[y][i]);
    }
    return ret;
}

// [u, d]の累積min
int v_accum_min(vector<vector<int> > &c, int x, int u, int d, int v, int h) {
    int ret = INF;
    for (int i = u; i <= d; ++i) {
        ret = min(ret, c[i][x]);
    }
    return ret;
}

int main(int argc, char const *argv[]) {
    while (true) {
        int d, w;
        cin >> d >> w;
        if (d == 0 && w == 0) break;
        vector<vector<int> > c(d, vector<int>(w));
        vector<vector<int> > v(d, vector<int>(w, 0));
        vector<vector<int> > h(d, vector<int>(w, 0));
        REP(i,d) {
            REP(j,w) {
                cin >> c[i][j];
            }
        }
        int ans = 0;
        // 縦横に動く左上
        for (int i = 0; i < d-2; ++i) {
            for (int j = 0; j < w-2; ++j) {
                // 右上は右に動くだけ。下降は左上に追随する
                for (int ru = j+2; ru < w; ++ru) {
                    // 左下は下に動くだけ。右に動くのは左上に追随する
                    for (int ld = i+2; ld < d; ++ld) {
                        int tmp = 0;
                        bool ok = true;
                        int U = h_accum_min(c, i, j, ru, d, w);
                        int D = h_accum_min(c, ld, j, ru, d, w);
                        int L = v_accum_min(c, j, i, ld, d, w);
                        int R = v_accum_min(c, ru, i, ld, d, w);
                        int MIN = min(U, min(D, min(L, R)));
                        // printf("i = %d, j = %d, ru = %d, ld = %d\n", i, j, ru, ld);
                        // cout << "MIN = " << MIN << endl;
                        // 内部を探索する。右下は左下と右上に追随するので記述しなくて良い
                        for (int in = i+1; in < ld; ++in) {
                            if (!ok) break;
                            for (int jn = j+1; jn < ru; ++jn) {
                                // printf("in = %d, jn = %d, c[in][jn] = %d\n", in, jn, c[in][jn]);
                                if (c[in][jn] >= MIN) {
                                    ok = false;
                                    break;
                                }
                                tmp += (MIN-c[in][jn]);
                                // cout << "tmp = " << tmp << endl;
                            }
                        }

                        if (ok) {
                            ans = max(ans, tmp);
                        }
                    }
                }
            }
        }

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


Measured memory_bytes: 3152
#include<bits/stdc++.h>
int m,d,i,ans;
int main(){
	scanf("%d%d",&m,&d);
	for(i=1;i<=d;++i){
		int x=i%10,y=i/10;
		if(x>=2 && y>=2 && x*y<=m)++ans;
	}
	printf("%d\n",ans);
}

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

#define N_MAX 2000

int main(void){
	int n;
	int z, w, a[N_MAX], result;

	cin >> n >> z >> w;
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}

	for (int i = 0; i < n; i++){
		if (i == 0) {
			result = abs(a[i] - w);
		}
		else {
			result = int(max(abs(a[i] - w), abs(a[i - 1] - a[i])));
		}
	}

	cout << result << endl;

	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <string>
#include <iostream>
//#include <algorithm>
using namespace std;

#define NUMBEROF(rist) (sizeof(rist)/sizeof(rist[0]))

int main(void)
{
	int quizNum, ValueNum, lastNum;
	cin >> quizNum >> ValueNum >> lastNum;

	// 添え字取得
	std::vector<int> vSuffix;
	for (int i = 0; i < ValueNum; ++i)
	{
		int tmp;
		cin >> tmp;
		vSuffix.push_back(tmp);
	}

	struct SOURCE
	{
	public:
		int value[20];
		SOURCE()
		{
			for (int i = 0; i < NUMBEROF(value); ++i)
			{
				value[i] = 0;
			}
		}
	};
	std::vector<SOURCE> vSource;
	for (int i = 0; i < quizNum; ++i)
	{
		SOURCE tmp;
		for (int i = 0; i < ValueNum; ++i)
		{
			int num;
			cin >> num;
			tmp.value[i] = num;
		}
		vSource.push_back(tmp);
	}

	int resultNum = 0;
	for (int i = 0; i < quizNum; ++i)
	{
		int ans = 0;
		for (int j = 0; j < ValueNum; ++j)
		{
			ans += vSource.at(i).value[j] * vSuffix.at(j);
		}

		ans += lastNum;

		if (ans > 0)
		{
			++resultNum;
		}
	}


	cout << resultNum<< endl;
	return 0;
}

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


void solve();

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

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

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

void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;

  set<int> st;

  vector<vector<int> > v(10);
  rep(i, n) v[s[i] - '0'].eb(i);

  int cnt = 0;
  rep(i, 10) rep(j, 10) rep(k, 10) {
    if (sz(v[i]) == 0) continue;
    int it = v[i][0];

    it = ub(v[j], it);
    if (it == sz(v[j])) continue;
    it = v[j][it];

    it = ub(v[k], it);
    if (it == sz(v[k])) continue;

    cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 512
#include<stack>
#include<iostream>
#include<vector>
#include<map>
#include<unordered_map>
#include<string>
#include<algorithm>
#define rep(i,n) for(int i=0;(int) (n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;
int main(){
  int n;
  cin >> n;
  cout <<(n%2==0?n/2:n/2+1) << endl;
  return 0;
  
}

Measured memory_bytes: 256
S = input()

ans = [0]*(len(S)+1)

for i in range(len(S)):
    if S[i] == "<":
        ans[i+1] = max(ans[i+1], ans[i]+1)
    
for i in range(len(S)):
    i = len(S)-1 - i
    if S[i] == ">":
        ans[i] = max(ans[i],ans[i+1]+1)

print(sum(ans))

Measured memory_bytes: 29036
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <map>
#include <climits>
#include <bitset>
using namespace std;
#define MATH_PI 3.14159265358979323846
int main(){
	ios::sync_with_stdio(false);
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	cout << s1[0] << s2[0] << s3[0] << endl;
endapp:
	//system("pause > nul");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;

int main() {
  double a, b, c, d, e, f;
  while(cin >> a >> b >> c >> d >> e >> f) {
    double y = (d*c-a*f)/(d*b-a*e);
    double x = (c-b*y)/a;
    char buff[100];
    sprintf(buff, "%.3f", x);
    if(!strcmp(buff, "-0.000")) x = 0;
    sprintf(buff, "%.3f", y);
    if(!strcmp(buff, "-0.000")) y = 0;
    printf("%.3f %.3f\n", x, y);
  }
  return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define se second
#define fi first
#define pb push_back
const int N=1e5 + 5;
int v[N],freq[N];

int main(){

//	freopen("in.txt","r",stdin);

	int n;
	scanf("%d",&n);
	int ans =1;
	for(int i=0;i < n;i++){
		scanf("%d",&v[i]);
		ans=max(ans,++freq[v[i]]);
		ans=max(ans,++freq[1 + v[i]]);
		ans=max(ans,++freq[v[i] - 1]);
	}
	cout <<ans <<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
bool is_prime(int x)
{
  for(int i = 2; i < x; ++i) {
    if(x % i == 0) {
      return false;
    }
  }
  return true;
}

int main() {
  int x;
  cin >> x;
  int i = x;
  while(true) {
    if(is_prime(i)) {
      cout << i << endl;
      return 0;
    }
    i++;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define FAST ios::sync_with_stdio(false);cin.tie(NULL),cout.tie(NULL);
typedef long long ll;
#define pi acos(-1.0)
using namespace std;

int main()
{
    long double r;
    cin>>r;
    cout<<2*pi*r<<endl;
    return 0;
}


Measured memory_bytes: 3768
from sys import stdin


def main() -> int:
    o = next_str()
    e = next_str()

    ans = ""
    for i in range(max(len(o), len(e))):
        if i < len(o):
            ans += o[i]
        if i < len(e):
            ans += e[i]
    print(ans)
    return 0


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    int H,W;
    while(1){
        cin>>H>>W;
        if (H==0&&W==0)break;
        for (int a=1;a<=H;a++){
            for(int b=1;b<=W;b++){
            cout<<"#";
            }
        cout<<endl;
        }
    cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3076
import re
a = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"
A = re.split("[, ]",a)
K = int(input())
k = 0
for i in A:
    if i!="":k+=1
    if k==K:
        print(i)
        break

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int N = 2E5;
int n;
LL k;
int a[N], f[N];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> k;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    for (int i = 0; i < n; ++i)
        cin >> f[i];
    sort(a, a + n);
    sort(f, f + n, greater<int>());
    LL l = 0, r = 1E12;
    while (l < r) {
        LL x = (l + r) / 2;
        LL need = 0;
        for (int i = 0; i < n; ++i)
            need += max(0LL, a[i] - x / f[i]);
        if (need <= k)
            r = x;
        else
            l = x + 1;
    }
    cout << l << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

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

bool judge(ll S){
    bitset<50> ok[51];
    for(int i = 0; i <= 50; i++){
        ok[i][i] = 1;
    }
    for(int i = 1; i <= 50; i++){
        for(int j = 1; j <= i; j++){
            if(S >> j & 1){
                ok[i] |= ok[i % j];
            }
        }
    }
    for(int i = 0; i < N; i++) if(!(ok[a[i]][b[i]])) return false;
    return true;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N;
    for(int i = 0; i < N; i++) cin >> a[i];
    for(int i = 0; i < N; i++) cin >> b[i];
    ll S = (1LL << 51) - 1;
    for(int i = 50; i >= 0; i--){
        S ^= 1LL << i;
        if(!judge(S)) S |= 1LL << i;
    }
    if(!judge(S)) S = -1;
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
write = sys.stdout.write
N, Q = map(int, readline().split())
 
N0 = 2**(N-1).bit_length()
data = [None]*(2*N0)
INF = (-1, 2**31-1)
def update(l, r, v):
    L = l + N0; R = r + N0
    while L < R:
        if R & 1:
            R -= 1
            data[R-1] = v
 
        if L & 1:
            data[L-1] = v
            L += 1
        L >>= 1; R >>= 1
def _query(k):
    k += N0-1
    s = INF
    while k >= 0:
        if data[k]:
            s = max(s, data[k])
        k = (k - 1) // 2
    return s
def query(k):
    return _query(k)[1]
 
 
ans = []
for q in range(Q):
    t, *cmd = map(int, readline().split())
    if t:
        ans.append(str(query(cmd[0])))
    else:
        s, t, x = cmd
        update(s, t+1, (q, x))
write("\n".join(ans))
write("\n")


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

int main(){
    int a,b;
    cin >> a >> b;
    string s;
    cin >> s;
    bool ok = true;
    if(s.size() != a+b+1)ok = false;
    if(s[a] != '-')ok = false;
    rep(i,a){
        if(s[i] != '0' && s[i] != '1' && s[i] != '2' && s[i] != '3' && s[i] != '4' && s[i] != '5' && s[i] != '6' && s[i] != '7' && s[i] != '8' && s[i] != '9')ok = false;

    }
    rep(j,b){
        int i = j + a +1;
        if(s[i] != '0' && s[i] != '1' && s[i] != '2' && s[i] != '3' && s[i] != '4' && s[i] != '5' && s[i] != '6' && s[i] != '7' && s[i] != '8' && s[i] != '9')ok = false;
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True  and False
BIG = 10**18 if not DBG else 99999
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)


# # # # class Segtree # # # #

#      0
#   1     2
# 3   4  5  6
#       :
# leaf i - n-1+i
# parent   - (i-1)//2
# children - 2*i+1, 2*i+2

class Segtree:
    # modify UNIT and oper depending on the reduce operation

    #UNIT = 0  # sum/or:0 and:fff..f min:BIG max:-BIG gcd:0 lcm:1 ..

    #@classmethod
    #def oper(c,x,y):
    #    return x|y  # sum:+ or/and/min/max/gcd/lcm:(same)

    # call like this: sgt = Segtree(n, 0, lambda x,y: max(x,y))

    def __init__(s,l,unit,oper):
        s.unit = unit
        s.oper = oper
        s.n = 1
        while s.n<l:
            s.n *= 2
        s.ary = [s.unit for i in range(2*s.n-1)]

    def get(s,i):
        return s.ary[i+s.n-1]

    def set(s,i,v):
        k = i+s.n-1
        s.ary[k] = v
        while k>0:
            k = (k-1)//2
            s.ary[k] = s.oper( \
                        s.ary[2*k+1], s.ary[2*k+2])

    def setary(s,a):
        for i,v in enumerate(a):
            s.ary[i+s.n-1] = v
        for k in range(s.n-2,-1,-1):
            s.ary[k] = s.oper( \
                        s.ary[2*k+1], s.ary[2*k+2])

    def query(s,x,y):
        l = x+s.n-1
        r = y+s.n-1
        res = s.unit
        while l<r:
            if not l%2:
                res = s.oper(res,s.ary[l])
                l += 1
            if not r%2:
                r -= 1
                res = s.oper(res,s.ary[r])
            l >>= 1
            r >>= 1
        return res


# # # # class Segtree end # # # #

n,q = inm()
xs = set([])
stx = []
for i in range(n):
    s,t,x = inm()
    xs.add(x)
    xs.add(s-x)
    xs.add(t-x)
    stx.append((s-x,t-x,x))
stx.sort()

di = []
ans = [-1]*q
for i in range(q):
    d = inn()
    xs.add(d)
    di.append(d)

x2i = {}
i2x = list(xs)
m = len(xs)
i2x.sort()
for i,x in enumerate(i2x):
    x2i[x] = i

stx2 = []
for i in range(n):
    s,t,x = stx[i]
    stx2.append((x2i[s],x2i[t],x2i[x]))
d2 = [x2i[d] for d in di]

sgt = Segtree(m,BIG,lambda x,y: min(x,y))
top = 0
for j in range(q):
    d = d2[j]
    while top<n:
        s,t,x = stx2[top]
        if s>d:
            break
        if x<sgt.get(t-1):
            sgt.set(t-1,x)
        top += 1
    x = sgt.query(d,m)
    if x==BIG:
        print(-1)
    else:
        print(i2x[x])


Measured memory_bytes: 315048