akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;

int main(){
    ll n; cin >> n;
    for(ll b=1;b<=3500;b++){
        for(ll c=1;c<=3500;c++){
            long double bo = 4*b*c - n*c - n*b;
            if(bo == 0) continue;
            long double si = n*b*c;
            long double a = si/bo;
            if(floor(a) == a && a>0){
                cout << (ll)a << " " << b << " " << c ;
                return 0;
            }
        }
    }
} 

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>
#include<deque>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl

ll n,m,a,b,c,x,y,z,aa[200010],ab[200010],ac[1010][1010];
bool r,ra,rb,rc;
string s,sa,sb,sc;
char ca,cb,cc,cd[1010][1010];
vector<ll> va,vb,vc;

int main(){
    cin>>a>>b;
    C (b%a==0 ? a+b:b-a) E;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;

class Main {
	public static void main(String args[]) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		String buf;

		try {
			while ((buf = br.readLine())!=null) {
				StringTokenizer st = new StringTokenizer(buf);
				int a = Integer.parseInt(st.nextToken());
				int b = Integer.parseInt(st.nextToken());
				int c = Integer.parseInt(st.nextToken());
				int d = Integer.parseInt(st.nextToken());
				int e = Integer.parseInt(st.nextToken());
				int f = Integer.parseInt(st.nextToken());
	
				double det1 = (double)a*e-b*d;
				double det2 = (double)c*e-b*f;
				double det3 = (double)a*f-c*d;
				if (det1 == 0.000) System.out.println("解なしor解がたくさん");
				else {
					String x = String.format("%.3f",(double)Math.round((det2/det1)*1000)/1000);
					String y = String.format("%.3f",(double)Math.round((det3/det1)*1000)/1000);
					System.out.println(x+" "+y);
				}
			}
		} catch (Exception e) {
			System.out.println("Exception!");
		}
	}
}

Measured memory_bytes: 16960
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int t; cin >> t; cin.ignore(); while(t--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}
 
int main(){
    fast();
 
/* you get what you work for not what you wish for */
    
    ll x;
    cin >> x;
    for(ll i=1; i<=500000; i++){
        if(floor(i*1.08)==x){
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
}

Measured memory_bytes: 256
X, N = map(int,input().split())
if N == 0:
  print(X)
else:
  plist = list(map(int,input().split()))
  ans = -2000
  dist1 = 1000
  for i in range(-200,200):
    dist2 = abs(X-i)
    if dist2 < dist1 and not(i in plist):
      ans = i
      dist1 = dist2
  print(ans)




Measured memory_bytes: 8948
a=input()
n=len(a)
if a[n-1]=='2'or a[n-1]=='4'or a[n-1]=='5'or a[n-1]=='7'or a[n-1]=='9':
  print("hon")
elif a[n-1]=='0'or a[n-1]=='1'or a[n-1]=='6'or a[n-1]=='8':
  print("pon")
else:
  print("bon")

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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (int i = j; i < (n); i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1e9;

int main(){

  int n;cin>>n;
  int a[n+10],b[n+10];
  rep(i,0,n)cin>>a[i]>>b[i];
  int c[n+10],d[n+10];
  rep(i,0,n)cin>>c[i]>>d[i];

  map<int,int>mp;
  vector<int>v[n+10];
  rep(i,0,n){
    rep(j,0,n){
      if(a[i]<c[j]&&b[i]<d[j]){
        v[i].push_back(j);
        mp[j]++;
      }
    }
  }

  sort(v,v+n,greater<vector<int>>());

  bool num[n+10];CLR(num);
  int ans=0;
  rep(i,0,n){
    int mi=200,k=INF;
    map<int,int>::iterator mit;
    rep(j,0,v[i].size()){
      map<int,int>::iterator it=mp.find(v[i][j]);
      if(it!=mp.end()){
        if(mi>=it->second){
          mi=it->second;
          k=j;
          mit=it;
        }
      }
    }
    if(k!=INF){
      mp.erase(mit);
      ans++;
      num[v[i][k]]=true;
    }
  }

  out(ans);

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;


int main() {
	int n, m;
	cin >> n >> m;
	cout << abs((ll)(n - 2)*(m - 2)) << endl;;
}



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

int main() {
  int H ,N;
  cin >> H >> N;
  
  vector<string> pic(H);
  for(int i=0; i<H; i++){
    cin >> pic.at(i) ;
  }
  
  for(int i=0; i<(N+2); i++){
    cout << "#" ;
  }
  cout << endl;
      
  for(int i=0; i<H; i++){
    cout << "#" << pic.at(i) << "#" <<endl;
  }
  
  for(int i=0; i<(N+2); i++){
    cout << "#" ;
  }
  cout << endl;
}

Measured memory_bytes: 256
/*
 #pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
*/
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")

#define NDEBUG
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
#include <climits>
#include <list>
#include <functional>
#include <numeric>

//find out the use of the below
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <cassert>

using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define EPS 1e-6
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define PI acos(-1)

int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt","w", stdout);

    int n;
    scanf("%d", &n);
    int sh[n][n-1];
    for (int i = 0; i < n; ++i){
        for (int j = 0; j < n-1; ++j){
            scanf("%d", &sh[i][j]);
            sh[i][j]--;
        }
    }
    int day = 0;
    int id[n];//index
    bool gg[n];
    MEM(id);
    int ms = 1;
    while (1){
        MEM(gg);
        ms = 0;
        for (int i = 0; i < n; ++i){
            if (gg[i])
                continue;
            int y = id[i] < n-1 ?sh[i][id[i]]:-1; //i wants to play with this
            if (y != -1 && !gg[y] && sh[y][id[y]] == i){
                id[i]++;
                id[y]++;
                gg[i] = gg[y] = 1;
                ms++;
            }
        }
        if (ms == 0)
            break;
        day++;
    }
    for (int i = 0; i < n; ++i){
        if (id[i] != n-1){
            printf("-1");
            return 0;
        }
    }
    printf("%d", day);
    





    

    return 0;
}
/* BEFORE submitting, check for:
 *  1. Integer overflow
 *  2. Float/Double precision errors
 *  3. Array index out of bounds
 *  4. Edge cases.(n=1, n=max, etc.)
 *  5. Time complexity. No TLEs
 */



Measured memory_bytes: 4224
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
using namespace std;

int main() {
  int m,n,x, l, r;
  cin >> n >> m >> x;
  vector<int> a(m);
  for (int i = 0; i <m; i++){
    cin >> a[i];
  }
  
  for (int i = 0; i<a.size(); i++){
    if(a[i] < x){
      l++;
    }
    else{
      r++;
    }
  }
  cout << min(r,l) << endl;
}


Measured memory_bytes: 768
void main() {
	auto N = ri;
	alias Pair = Tuple!(ulong, "index", ulong, "num");
	"%(%d %)".writefln(readAs!(int[]).enumerate.array.sort!((a, b) => a[1] < b[1]).map!(p => p[0]+1));
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 7612
#include<stdio.h>
int main()
{
  int k,n,ma=0;
  scanf("%d",&k);
  scanf("%d",&n);
  int a[n],d[n],i;
  scanf("%d",&a[0]);
  for(i=1;i<n;i++)
  {
    scanf("%d",&a[i]);
    	d[i]=a[i]-a[i-1];
  }
  d[0]=k+a[0]-a[n-1];
  for(i=2;i<n;i++)
  {
    if(d[ma]<d[i])
      ma=i;
  }
  printf("%d\n",k-d[ma]);
  return 0;
}


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

const int mod = 998244353;

int P(int a, int b) {
	if(b == 0) return 1;
	if(b & 1) return (long long)P(a, b - 1) * a % mod;
	int t = P(a, b / 2);
	return (long long)t * t % mod;
}

const int O = P(2, mod - 2);

int H(int a) {
	return (long long)a * O % mod;
}

const int S = 3003;
int n, s, x, dp[S];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> s; dp[0] = P(2, n);
	for(int i = 1; i <= n; ++i) {
		cin >> x;
		for(int i = s; i >= x; --i) {
			(dp[i] += H(dp[i - x])) %= mod;
		}
	}
	cout << dp[s] << endl;
	return 0;
}


Measured memory_bytes: 3680
#include<iostream>
#include<set>

int main(void){
    int x, n;
    std::cin >> x >> n;
    std::set<int> p;
    for(int i = 0; i < n; i++){
	int tmp;
	std::cin >> tmp;
	p.insert(tmp);
    }
    if(p.find(x) == p.end()){
	std::cout << x << std::endl;
	return 0;
    }

    for(int i = 1; ; i++){
	int can1 = x - i;
	int can2 = x + i;
	if(p.find(can1) == p.end()){
	    std::cout << can1 << std::endl;
	    return 0;
	}
	if(p.find(can2) == p.end()){
	    std::cout << can2 << std::endl;
	    return 0;
	}
    }
}


Measured memory_bytes: 3640
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
 
//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
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; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end

int mod = 1;
struct Mint {
  int val;
  Mint inv() const {
    int tmp, a = val, b = mod, x = 1, y = 0;
    while(b) tmp = a / b, a -= tmp * b, swap(a, b), x -= tmp * y, swap(x, y);
    return Mint(x);
  }
public:
  Mint() :val(0) {}
  Mint(ll x) :val(x >= 0 ? x % mod : x % mod + mod) {}
  int mtoi() { return this->val; }
  Mint pow(ll t) { Mint res = 1,b = *this; while(t){if(t&1)res *= b;b *= b;t >>= 1;}return res; }
  Mint& operator+=(const Mint& x) { if ((val += x.val) >= mod) val -= mod; return *this; }
  Mint& operator-=(const Mint& x) { if ((val += mod - x.val) >= mod) val -= mod; return *this; }
  Mint& operator*=(const Mint& x) { val = (ll)val * x.val % mod; return *this; }
  Mint& operator/=(const Mint& x) { return *this *= x.inv(); }
  bool operator==(const Mint& x) const { return val == x.val; }
  bool operator!=(const Mint& x) const { return val != x.val; }
  bool operator<(const Mint& x) const { return val < x.val; }
  bool operator<=(const Mint& x) const { return val <= x.val; }
  bool operator>(const Mint& x) const { return val > x.val; }
  bool operator>=(const Mint& x) const { return val >= x.val; }
  Mint operator+(const Mint& x) const { return Mint(*this) += x; }
  Mint operator-(const Mint& x) const { return Mint(*this) -= x; }
  Mint operator*(const Mint& x) const { return Mint(*this) *= x; }
  Mint operator/(const Mint& x) const { return Mint(*this) /= x; }
};
struct factorial {
  vector<Mint> Fact, Finv;
public:
  factorial(int maxx) {
    Fact.resize(maxx+1,Mint(1)),Finv.resize(maxx+1); rep(i,0,maxx)Fact[i+1]=Fact[i]*Mint(i+1);
    Finv[maxx]=Mint(1)/Fact[maxx]; rrep(i,maxx,0)Finv[i-1]=Finv[i]*Mint(i);
  }
  Mint fact(int n,bool inv) { if(inv) return Finv[n]; else return Fact[n]; }
  Mint nPr(int n,int r) { if(n<0||n<r||r<0) return Mint(0); else return Fact[n]*Finv[n-r]; }
  Mint nCr(int n,int r) { if(n<0||n<r||r<0) return Mint(0); else return Fact[n]*Finv[r]*Finv[n-r]; }
};

int main(){
  scanf("%d",&mod);
  vector<Mint> ans(mod,0);
  factorial fact(mod-1); Mint pow;
  rep(i,0,mod){
    int p; scanf("%d",&p);
    if(p){
      ans[0]+=1; pow=1;
      rrep(j,mod-1,-1){
        ans[j]-=fact.nCr(mod-1,j)*pow;
        pow*=(-i);
      }
    }
  }
  rep(i,0,mod)printf("%d ",ans[i].mtoi());
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int sol[3];
    cin >> sol[0] >> sol[1] >> sol[2];
    sort(sol,sol+3);
    if(sol[0] == sol[1]&&sol[1] == sol[2]){
        cout << "No" << endl;
        return 0;
    }
    if(sol[0] == sol[1] && sol[1] != sol[2])cout << "Yes";
    else if(sol[1] == sol[2] && sol[0] != sol[2])cout << "Yes";
    else cout << "No";
    cout << endl;
}

Measured memory_bytes: 256
import itertools
n = int(input())
M = []
A = []
R = []
C = []
H = []
for i in range(n):
    s = str(input())
    if s[0] == "M":
        M.append(s)
    elif s[0] == "A":
        A.append(s)
    elif s[0] == "R":
        R.append(s)
    elif s[0] == "C":
        C.append(s)
    elif s[0] == "H":
        H.append(s)
L = []
if len(M) > 0:
    L.append(M)
if len(A) > 0:
    L.append(A)
if len(R) > 0:
    L.append(R)
if len(C) > 0:
    L.append(C)
if len(H) > 0:
    L.append(H)
ans = 0
for i in itertools.combinations(L, 3):
    #print(i)
    ans += len(i[0])*len(i[1])*len(i[2])

print(ans)

Measured memory_bytes: 10100
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5 + 10;
ll d[N], v[N];
ll Lm[N], Rm[N];

int main() {
  int n;
  ll C;
  cin >> n >> C;
  for(int i = 1; i <= n; ++i) {
    scanf("%lld%lld", &d[i], &v[i]);
  }  
  ll ans = 0, qz = 0;
  for(int i = 1; i <= n; ++i) {
    qz += v[i];
    Lm[i] = max(Lm[i - 1], qz - d[i]);
  }
  qz = 0;
  for(int i = n; i >= 1; --i) {
    qz += v[i];
    Rm[i] = max(Rm[i + 1], qz - (C - d[i]));
  }
  ans = max(ans, max(Lm[n], Rm[1]));
  qz = 0;
  for(int i = 1; i <= n; ++i) {
    qz += v[i];
    ans = max(ans, qz - d[i] * 2 + Rm[i + 1]);
  }
  qz = 0;
  for(int i = n; i >= 1; --i) {
    qz += v[i];
    ans = max(ans, qz - (C - d[i]) * 2 + Lm[i - 1]);
  }
  printf("%lld\n", ans);
  return 0;
}
/*
3 20
2 80
9 120
16 1
*/

Measured memory_bytes: 3328
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n;i++)
#define ll long long
#include <bits/stdc++.h>
using namespace std;
#define mo 1000000007
#define ull unsigned long long 
int main(){ 
  string s,t;cin>>s>>t;
  int a,b;cin>>a>>b;
  string u;cin>>u;
  if(u==s)
    cout<<a-1<<" "<<b;
  else
    cout<<a<<" "<<b-1;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#define ll long long
#define N 330000
using namespace std;
inline int read(){
	int x=0,f=1;char c=getchar();
	while(c<'0' or '9'<c) f=(c=='-'?-1:f),c=getchar(); 
	while('0'<=c and c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
int w,h,n,ans;
int mx[N*4],flag[N*4];
struct node{
	int x,y;
	node(int _x=0,int _y=0):x(_x),y(_y){};
}p[N],a[N],b[N]; 
void change(int x,int l,int r,int v,int ql,int qr){
    if(ql<=l and r<=qr){
		mx[x]+=v;flag[x]+=v;
		return;
	}
    int mid=(l+r)>>1;
    if(ql<=mid) change(x<<1,l,mid,v,ql,qr);
    if(qr>mid) change(x<<1|1,mid+1,r,v,ql,qr);
    mx[x]=max(mx[x<<1],mx[x<<1|1])+flag[x];
}
bool cmp(node a,node b){
	return a.x<b.x or (a.x==b.x and a.y<b.y);
}
inline void work(){
    memset(mx,0,sizeof mx);
    memset(flag,0,sizeof flag);
    sort(p+1,p+n+1,cmp);
    int l=0,r=0;
    for(int i=1;i<n;i++){
        if(p[i].y<=h/2){
            int ed=i-1;
            while(l and a[l].y<p[i].y){
                change(1,1,n,a[l].y-p[i].y,a[l].x,ed);
				ed=a[l].x-1;l--; 
            }
            if(ed!=i-1) a[++l]=node(ed+1,p[i].y);
        }
        else{
            int ed=i-1;
            while(r and b[r].y>p[i].y){
                change(1,1,n,p[i].y-b[r].y,b[r].x,ed);
				ed=b[r].x-1;r--;
            }
            if(ed!=i-1) b[++r]=node(ed+1,p[i].y);
        }
        a[++l]=node(i,0);b[++r]=node(i,h);
        change(1,1,n,h-p[i].x,i,i);
        ans=max(ans,mx[1]+p[i+1].x);
    }
}
int main(){
//	freopen("a.in","r",stdin);
    w=read();h=read();n=read();
    for(int i=1;i<=n;i++) p[i].x=read(),p[i].y=read();
    p[++n]=node(0,0);p[++n]=node(w,h);
	work();
	swap(w,h);
    for(int i=1;i<=n;i++) swap(p[i].x,p[i].y);
    work();
    printf("%d",ans*2);
    return 0;
}

Measured memory_bytes: 18176
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N; cin>>N;
  set<ll> S;
  for(ll i=0; i<N; i++){
    ll a; cin>>a;
    S.insert(a);
  }
  if(S.size()<N) cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
}

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

int main() {
  int a[4], b[4];
  while (cin >> a[0] >> a[1] >> a[2] >> a[3]) {
    cin >> b[0] >> b[1] >> b[2] >> b[3];
    int hit = 0, blow = 0;
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < 4; j++) {
        if (a[i] == b[j]) {
          i == j ? hit++ : blow++;
          break;
        }
      }
    }
    cout << hit << " " << blow << "\n";
  }
}


Measured memory_bytes: 2976
#include <stdio.h>

int main(void)
{
    int a, b, d, r;
    double f;
    
    scanf("%d %d", &a, &b);
    
    d = a / b;
    r = a % b;
    f = (double)a / b;
    
    printf("%d %d %f\n", d, r, f);
    
    return 0;
}

Measured memory_bytes: 632
#include<cstdio>
#include<algorithm>

using namespace std;

int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	if((a+b)&1) 
	{
		printf("IMPOSSIBLE");
		return 0;
	}
	if(a>b) swap(a,b);
	printf("%d",a+b>>1);
} 

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int MAXN=100;
char s[MAXN];
char a[MAXN];
int main()
{
	scanf("%s",s+1);
	int len=strlen(s+1);
	for(int i=1;i<=len-8;i++)
	{
		printf("%c",s[i]);
	}
	return 0;
}


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

using namespace std;

int main()
{
    int32_t n;
    cin >> n;
    
    string str;
    cin >> str;

    int32_t output{ 0 }, x{ 0 };
    for(auto itr = str.cbegin(); itr != str.cend(); ++itr) {
        if(*itr == 'I') {
            ++x;
        }
        else {
            --x;
        }
        if(x > output) {
            output = x;
        }
    }

    cout << output << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    for(int i = 0;i <= 1250;i++){
      if(A == Math.floor(i*0.08) && B == Math.floor(i*0.1)){
        System.out.print(i);
        break;
      }else if(i == 1250){
        System.out.print(-1);
      }
    }
  }
}

Measured memory_bytes: 25172
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  int N, X;
  cin >> N >> X;
  vector <int> m(N);
  rep(i,N) cin >> m[i];

  int sum = accumulate(all(m), 0);
  X -= sum;  //全種類1個ずつ作ったあとの残り
  int num = X / *min_element(all(m));  //お菓子の素が最小のドーナツの個数
  int ans = N + num;
  cout << ans << endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using namespace chrono;
#define int long long
#define ld double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define sz(x) ((long long)x.size())
#define all(x) (x).begin(), (x).end()
#define popcount(x) __builtin_popcountll(x)
const int MOD =1e9+7;

mt19937_64 rng(high_resolution_clock::now().time_since_epoch().count());
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> istream& operator >> (istream &in,vector<T> &A){ for(auto &x:A) in>>x; return in; };
template<typename T> ostream& operator << (ostream &out,vector<T> &A){ for(auto &x:A) out<<x<<" "; return out; };
template<typename T,typename W> istream& operator >> (istream &in,pair<T,W> &A){ in>>A.fi>>A.se; return in; };
const int N = 100;
// vector<int> g[N];
// bool vis[N];
void solve()
{
	// int n;
	// cin>>n;
	// string a,b;
	// cin>>a>>b;
	// for(int i=0;i<N;i++)
	// {
	// 	g[i].clear();
	// 	vis[i]=false;
	// }
	// for(int i=1;i<n;i++)
	// {
	// 	if(a[i-1]=='Y'&&b[i]=='Y')
	// 	{
	// 		g[i+1].pb(i);
	// 	}
	// 	if(b[i-1]=='Y'&&a[i]=='Y')
	// 	{
	// 		g[i].pb(i+1);
	// 	}
	// }
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	
	int mx=0;
	// int p=-1;
	int ans=1000;
	set<int> s;
	for(int i=0;i<n;i++)
	{
		int x=a[i];
		int j=i+1;
		while(j<n&&a[j]>=a[j-1]) j++;
		j--;
		// cout<<i<<" "<<j<<"\n";
		// cout<<ans<<" ";
		ans=(ans/a[i])*a[j]+(ans%a[i]);
		// cout<<ans<<"\n";
		i=j;
	}
	cout<<ans<<"\n";
}
// dp[i][j] 
int32_t main(){
	cin.tie(0)->sync_with_stdio(0);
	#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	#endif

	int t=1;
	// cin>>t;
	for(int _t=1;_t<=t;_t++){
		// cout<<"Case #"<<_t<<": ";
		solve();
	}
} 


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
using namespace std;
using llong = long long;

const llong mod = (llong)(1e9) + 7;
llong n, k;
vector<vector<llong>> tree;
vector<llong> par;
vector<llong> sz;

llong dfs(int u, int k, int depth) {
    llong ret = 1;
    if (depth >= 2) k += sz[par[u]];
    if (depth >= 3) k++;
    ret *= k;
    ret %= mod;

    llong cnt = 0;
    for (auto v:tree[u]) {
        if (v == par[u]) continue;
        par[v] = u;
        sz[v] = cnt;
        cnt++;
        ret *= dfs(v, k - cnt, depth + 1);
        ret %= mod;
    }
    return ret;
}

int main() {
    cin >> n >> k;
    tree.resize(n + 1);
    par.resize(n + 1);
    sz.resize(n + 1);
    for (int i = 0; i < n - 1; i++) {
        llong a, b;
        cin >> a >> b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    cout << dfs(1, k, 0) << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

bitset<4000010> dp;

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

    int n;
    cin >> n;
    vector<int> a(n);
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    dp.set(0);
    for (int i = 0; i < n; i++)
    {
        dp |= (dp << a[i]);
    }
    for (int i = 1; i <= 4000000; i++)
    {
        if (dp[i] && 2 * i >= sum)
        {
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 1792
import java.lang.reflect.Array;
import java.util.*;

public class Main {


    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int N = Integer.parseInt(scan.next());

        String S = scan.next();

        int count1 = 0;
        int count2 = 0;

        int[] countW = new int[S.length()];
        Arrays.fill(countW, 0);
        int[] countE = new int[S.length()];
        Arrays.fill(countE, 0);

        int i = 0;
        int j = S.length()-1;

        while(i <= S.length()-1 && 0 <= j){

            if( (0 <= i-1) && S.substring(i-1, i-1+1).equals("W")) count1++;

            countW[i] += count1;

            if( (j+1 <= S.length()-1) && S.substring(j+1, j+1+1).equals("E")) count2++;

            countE[j] += count2;

            i++;
            j--;
        }

        int min = 1111111111;
        int[] sum = new int[S.length()];
        for(int k = 0; k < S.length(); k++){
            //System.out.println(k +"番目の左側のWの数"+countW[k]);
            //System.out.println(k +"番目の右側のEの数"+countE[k]);
            sum[k] = countW[k] + countE[k];
            //System.out.println(sum[k]);
            if(sum[k] < min) min = sum[k];
        }
        
        System.out.println(min);
    }
}

Measured memory_bytes: 48248
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#define F first
#define S second
using namespace std;

int n, m, ans;
pair<int, int> a[100005];
priority_queue<int> pq;
int main() {
	int i, j;
	cin >> n >> m;
	for(i=0; i<n; i++) scanf("%d%d", &a[i].F, &a[i].S);
	sort(a, a+n);
	for(i=0, j=m-1; j>=0; j--) {
		while(i<n && a[i].F + j <= m) pq.push(a[i++].S);
		if(!pq.empty()) ans += pq.top(), pq.pop();
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 1660
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	var s []byte
	fmt.Scan(&s)
	if n%2 == 0 {
		var ng bool
		for i := 0; i < n/2; i++ {
			if s[i] != s[i+n/2] {
				ng = true
			}
		}
		if !ng {
			fmt.Println("Yes")
			return
		}
	}

	fmt.Println("No")
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 1776
n, m = (int(i) for i in input().split())
if (n == 1) and (m == 1):
    print(1)
elif n == 1:
    print(max(m-2, 0))
elif m == 1:
    print(max(n-2, 0))
else:
    print((n-2)*(m-2))

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
	int w,h;
	typedef struct{
		int x;
		int y;
		int step;
	}P;
int main(){
	while(cin>>w>>h, w|h){
	bool wall;
	vector<vector<bool> > wmap(h),hmap(h-1);
	for(int j=0;j<h;j++){
		for(int i=0;i<w-1;i++){
			cin>>wall;
			wmap[j].push_back(wall);
		}
	if(j==h-1)break;
		for(int i=0;i<w;i++){
			cin>>wall;
			hmap[j].push_back(wall);
		}
	}
	queue<P> q;
	P p1;
	p1.x=0;
	p1.y=0;
	p1.step=1;
	q.push(p1);
	P p;
	int step=0;
	while(!q.empty()){
	p=q.front();q.pop();
	//left
	if(p.x-1>=0&&!wmap[p.y][p.x-1]){
	wmap[p.y][p.x-1]=1;
	p1.x=p.x-1;
	p1.y=p.y;
	p1.step=p.step+1;
	q.push(p1);
	}
	//up
	if(p.y-1>=0&&!hmap[p.y-1][p.x]){
	hmap[p.y-1][p.x]=1;
	p1.x=p.x;
	p1.y=p.y-1;
	p1.step=p.step+1;
	q.push(p1);
	}
	//right
	if(p.x+1<w&&!wmap[p.y][p.x]){
	wmap[p.y][p.x]=1;
	p1.x=p.x+1;
	p1.y=p.y;
	p1.step=p.step+1;
	q.push(p1);
	}
	//down
	if(p.y+1<h&&!hmap[p.y][p.x]){
	hmap[p.y][p.x]=1;
	p1.x=p.x;
	p1.y=p.y+1;
	p1.step=p.step+1;
	q.push(p1);
	}
	if(p.x==w-1&&p.y==h-1){
		step=p.step;
		break;
	}
	}

	cout<<step<<endl;
	}
	return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const int mod = 1000000007;
const int max_n = 200005;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
    ll n;cin >> n;
    string s;cin >> s;
    vector<vector<mint>> dp(n,vector<mint>(n));dp[0][0]=1;
    rep(i,n-1){
        if(s[i]=='<'){
            rep(j,n){
                dp[i+1][j+1]+=dp[i][j];
                if(i+2<n)dp[i+1][i+2]-=dp[i][j];
            }
        }
        else{
            rep(j,n){
                dp[i+1][0]+=dp[i][j];dp[i+1][j+1]-=dp[i][j];
            }
        }
        rep(j,n-1)dp[i+1][j+1]+=dp[i+1][j];
    }
    /*rep(i,n){
        rep(j,n){
            cout << dp[i][j] <<" ";
        }
        cout << endl;
    }*/
    mint ans=0;rep(i,n)ans+=dp[n-1][i];
    cout << ans <<endl;
}

Measured memory_bytes: 73648
//Robs Code

/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <iomanip>

/***********MACROS***************/
#define int long long int
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define pii pair<int,int>

using namespace std;

const int N = 1e5 + 1;
int n,m,i,j,k,l,x,y,z,cnt[3],sum[3];

/***********MAIN**************/
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin >> n;
	vector<char> ans;
	if(n == 1){
		cout << "a";
		return 0;
	}
	while(n){
		ans.push_back(((char)((n)%26 + 'a')));
		n--;
		n /= 26;
	}
	reverse(all(ans));
	for(auto x : ans){
		if(x == 'a'){
			cout << "z";
			continue;
		}
		cout << ((char)(x - 1));
	}
}
//.........

Measured memory_bytes: 3644
# -*- coding: utf-8 -*-
#ALDS1_4_A_Linear Search

import sys
from collections import deque

def input_lines():
    return sys.stdin.readlines()

def liner_search(lines):
    s = sorted(map(int, lines[1].split()))
    t = deque(sorted(map(int, lines[3].split())))
    
    idx, count = 0, 0
    while len(t) > 0:
        nt = t.popleft()
        found = False
        while idx < len(s):
            if nt == s[idx]:
                found = True
                break
            else:
                idx += 1
        if found:
            count += 1
        else:
            idx = 0
        
    return count
lines = input_lines()
print(liner_search(lines))


Measured memory_bytes: 6836
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vll a(n);
  rep(i,n)cin>>a[i];
  ll ans=0;
  ll r=0;
  ll l=0;
  ll s=a[0];
  for(;l<n;l++){
    while(r<n-1&&(s&a[r+1])==0){
      s+=a[r+1];
      r++;
    }
    ans+=r-l+1;
    s-=a[l];
  }
  COUT(ans);
}

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

int main() {
  string S;
  cin >> S;
  int start = 0;
  int end = 0;
  for(int i = 0;i < S.size();i++) {
    if(S.at(i) == 'A') {
      start = i;
      break;
    }
  }
  for(int j = 0;j < S.size();j++) {
    if(S.at(S.size() - 1 - j) == 'Z') {
      end = S.size() - 1 - j;
      break;
    }
  }
  cout << end - start + 1 << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
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 (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll n;
cin >> n;
vector<ll> h(n+1,0);
rep(i, n) cin >> h[i];
rep(i,n){
    if(h[i]>h[i+1]){
        h[i] = h[i] - h[i + 1];
    }
    else{
        h[i] = 0;
    }
}
ll ans = accumulate(h.begin(), h.end(),0);

cout << ans << endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	var x, n int
	fmt.Scan(&x, &n)
	num := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&num[i])
	}

	p := map[int]bool{}
	for i := 0; i < n; i++ {
		p[num[i]] = true
	}
	ans := -100
	for i := 0; i <= 101; i++ {
		if p[i] {
			continue
		}
		if abs(x-i) < abs(x-ans) {
			ans = i
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1844
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

long long A[100010][3];
long long dp[100010][3];

int main()
{
    int N; cin >> N;
    rep (i, 0, N) {
        rep (j, 0, 3) {
            cin >> A[i][j];
        }
    }

    rep (i, 0, N) {  // 0日目から開始
        rep (j, 0, 3) {  // 活動j
            rep (k, 0, 3) {  // 活動k
                if (j == k) continue;  // i日目とi+1日目の活動は異なる
                dp[i+1][k] = max(dp[i+1][k], dp[i][j] + A[i][k]);
            }
        }
    }

    long long ans = -1;
    rep (j, 0, 3) {  // N日目の幸福度が最大になる活動を探索
        ans = max(ans, dp[N][j]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
N = int(input())
S = [input() for i in range(N)]

for i in range(N):
    S[i] = ''.join(sorted(S[i])) # sort characters in each word

list.sort(S) # sort S in alphabetical order

ans = 0
m = 1  # 同一の（同じ文字の組み合わせの）アナグラムの数
for i in range(N - 1): # i = 0, 1, ..., N - 2
    if S[i + 1] == S[i]:
        m += 1
    else:
        ans += m * (m - 1) // 2
        m = 1

ans += m * (m - 1) // 2

print(ans)


Measured memory_bytes: 63448
use whiteread::parse_line;

fn main() {
    let s: String = parse_line().unwrap();
    let t: String = parse_line().unwrap();
    let mut ss: Vec<char> = s.chars().collect();
    let tt: Vec<char> = t.chars().collect();

    for _ in 0..s.len() {
        ss.rotate_left(1);
        if ss == tt {
            println!("Yes");
            return;
        }
    }
    println!("No");
}


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

using namespace std;

int main(void)
{
	string s;
	cin >> s;
	
	int ans = 0, cnt = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'A' || s[i] == 'T' || s[i] == 'C' || s[i] == 'G') cnt++;
		else cnt = 0;
		ans = max(ans, cnt);
	}
	
	cout << ans << endl;
	
	return 0;
}

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

using ll = long long;
#define repi(n) for (int i = 0; i < (n); i++)
#define repj(n) for (int j = 0; j < (n); j++)
#define repk(n) for (int k = 0; k < (n); k++)
#define rep(i, n) for (int i = 0; (i) < (n); i++)
#define repr(i, a, b) for (auto i = (a); i < (b); i++)
#define repv(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = max((t), (v)))
#define updatemin(t, v) (t = min((t), (v)))
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}

int main() {
  int n;
  double t, a;
  cin >> n >> t >> a;
  vector<double> h(n);
  repi(n) cin >> h[i];
  int re;
  double ms = 1e+300;
  repi(n) {
    double s = abs((t - h[i] * 0.006) - a);
    if (s < ms) {
      ms = s;
      re = i + 1;
    }
  }
  cout << re << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <cassert>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>
#include <random>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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; }

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int h, w, n; cin >> h >> w >> n;
  int sr, sc; cin >> sr >> sc;

  string s, t; cin >> s >> t;

  reverse(s.begin(), s.end());
  reverse(t.begin(), t.end());

  int miw = 1;
  int maw = w;
  int mih = 1;
  int mah = h;

  rep(i, n) {
    if (t[i] == 'L') {
      maw++;
      if (maw>w) maw=w;
    } else if (t[i] == 'R') {
      miw--;
      if (miw<1) miw=1;
    } else if (t[i] == 'U') {
      mah++;
      if (mah>h) mah=h;
    } else {
      mih--;
      if (mih<1) mih=1;
    }

    if (s[i] == 'L') {
      miw++;
    } else if (s[i] == 'R') {
      maw--;
    } else if (s[i] == 'U') {
      mih++;
    } else {
      mah--;
    }
    //debug(miw); debug(maw); debug(mih); debugln(mah);
    if (miw > maw || mih > mah) {
      cout << "NO" << endl;
      return 0;
    }
  }
  if (mih <= sr && sr <= mah && miw <= sc && sc <= maw) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 920
N = gets.to_i
X = gets.chomp
# N = 2 * 10**5
# X = "1"*(N-1) + "0"
xcnt = X.count('1')

@fmap = {
    0 => 0,
    1 => 1
}

def popcount(x)
  m1 = 0x55555555
  m2 = 0x33333333
  m4 = 0x0f0f0f0f
  x -= (x >> 1) & m1
  x = (x & m2) + ((x >> 2) & m2)
  x = (x + (x >> 4)) & m4
  x += x >> 8
  return (x + (x >> 16)) & 0x3f
end

def f x
    return @fmap[x] if @fmap[x] != nil
    pc = popcount(x)
    if pc == 0
        return @fmap[x] = 0
    end
    m = x % pc
    unless @fmap[m]
        @fmap[m] = f(m)
    end
    @fmap[x] = @fmap[m] + 1
end

pdiff = 1
mdiff = 1
intx = X.to_i(2)
xar = X.split('').reverse
pl_mod = intx % (xcnt + 1)
mi_mod = false
if xcnt > 1
    mi_mod = intx % (xcnt - 1)
end
results = xar.map do |i|
    mo = nil
    if i == "0"
        mo = (pl_mod + pdiff) % (xcnt + 1)
    elsif !mi_mod
        next 0
    else
        mo = (mi_mod - mdiff) % (xcnt - 1)
    end
    next f(mo) + 1
ensure
    pdiff =  (pdiff * 2) % (xcnt + 1)
    mdiff =  (mdiff * 2) % (xcnt - 1) if mi_mod
end

puts results.reverse.join("\n")

Measured memory_bytes: 35956
from collections import deque
class csr:
    def __init__(self,N,edges):
        self.start = [0]*(N+1)
        self.elist = [0]*len(edges)
        for e in edges:
            self.start[e[0]+1] += 1
        for i in range(1,N+1):
            self.start[i] += self.start[i-1] 
        counter = self.start[:]
        for e in edges:
            self.elist[counter[e[0]]] = e[1]
            counter[e[0]] += 1

class scc_graph:
    def __init__(self,N):
        self.N = N
        self.edges = []
    
    def add_edge(self,v,w):
        self.edges.append((v,w))

    def scc_ids(self):
        g = csr(self.N,self.edges)
        N = self.N
        now_ord = group_num = 0
        visited = deque()
        low = [0]*N
        order = [-1]*N
        ids = [0]*N
        parent = [-1]*N
        stack = deque()
        for i in range(N):
            if order[i] == -1:
                stack.append(i)
                stack.append(i)
                while stack:
                    v = stack.pop()
                    if order[v] == -1:
                        low[v] = order[v] = now_ord
                        now_ord += 1
                        visited.append(v)
                        for i in range(g.start[v],g.start[v+1]):
                            to = g.elist[i]
                            if order[to] == -1:
                                stack.append(to)
                                stack.append(to)
                                parent[to] = v
                            else:
                                low[v] = min(low[v],order[to])
                    else:
                        if low[v] == order[v]:
                            while True:
                                u = visited.pop()
                                order[u] = self.N
                                ids[u] = group_num
                                if u == v:
                                    break
                            group_num += 1
                        if parent[v] != -1:
                            low[parent[v]] = min(low[parent[v]],low[v])
        for i,x in enumerate(ids):
            ids[i] = group_num-1-x

        return group_num,ids
    
    def scc(self):
        group_num,ids = self.scc_ids()
        groups = [[] for _ in range(group_num)]
        for i,x in enumerate(ids):
            groups[x].append(i)
        return groups
    
import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
N,M = map(int,readline().split())
ab = list(map(int,read().split()))
sg = scc_graph(N)

it = iter(ab)
for a,b in zip(it,it):
    sg.add_edge(a,b)

scc = sg.scc()
print(len(scc))
for group in scc:
    print(str(len(group))+' '+' '.join(map(str,group)))


Measured memory_bytes: 213716
from collections import defaultdict
s = input()
t = input()
ds = defaultdict(list)
dt = defaultdict(list)
for i in range(len(s)):
  ds[s[i]].append(i)
  dt[t[i]].append(i)
dss = set()
dts = set()
for i in ds.values():
  dss.add(tuple(i))
for i in dt.values():
  dts.add(tuple(i))
print('YNeos'[dss!=dts::2])

Measured memory_bytes: 17456