akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };

set<iii> S;
Pi p[100000];
ll ans[100000];
int main() {
	int n;
	scanf("%d",&n);
	fup(i,0,n-1,1)
	{
		scanf("%d",&p[i].X);
		p[i].Y=i;
	}
	sort(p,p+n);
	int a=p[0].X,id=p[0].Y,cnt=1;
	fup(i,1,n-1,1)
	{
		if(p[i].X==a)
		{
			id=min(id,p[i].Y);
			cnt++;
		}
		else
		{
			S.insert(iii(-a,id,cnt));
			a=p[i].X,id=p[i].Y,cnt=1;
		}
	}
	S.insert(iii(-a,id,cnt));
	while(!S.empty())
	{
		if(S.size()==1)
		{
			int aa,ii,cc;
			tie(aa,ii,cc)=*S.begin();
			aa*=-1;
			ans[ii]+=1LL*aa*cc;
			break;
		}
		auto it1=S.begin();
		auto it2=it1;
		it2++;
		int a1,i1,c1,a2,i2,c2;
		tie(a1,i1,c1)=*it1;
		tie(a2,i2,c2)=*it2;
		a1*=-1,a2*=-1;
		S.erase(it1);
		S.erase(it2);
		ans[i1]+=1LL*(a1-a2)*c1;
		c2+=c1;
		i2=min(i2,i1);
		S.insert(iii(-a2,i2,c2));
	}
	fup(i,0,n-1,1)printf("%lld\n",ans[i]);
}

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

lli n;

int main(void){
	cin >> n;
	if(n <= 2){
		cout << 1 << endl;
		return 0;
	}
	vector<lli> a(n);
	rep(i, n) cin >> a[i];

	lli ans = 0;
	for(int i = 0; i < n; i++){
		while(i+1 < n && a[i] == a[i+1])i++;
		if(i+1 < n && a[i] < a[i+1]) while(i+1 < n && a[i] <= a[i+1])i++;
		else if(i+1 < n && a[i] > a[i+1]) while(i+1 < n && a[i] >= a[i+1])i++;
		ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4024
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FI first
#define SE second
#define endl "\n"
#define ciosup cin.tie(0);ios::sync_with_stdio(false);
#define eb emplace_back
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

int cnte[100'000], cnto[100'000];

int main()
{
    ciosup;
    int n;
    cin >> n;
    int v[n];
    REP(i,n)cin >> v[i];
    REP(i,n){
        if (i % 2 == 0)
        {
            cnte[v[i]]++;
        }else
        {
            cnto[v[i]]++;
        }
    }
    set<pint> se,so;
    REP(i,n){
        if (i % 2 == 0)
        {
            se.insert(make_pair(cnte[v[i]], v[i]));
        }else
        {
            so.insert(make_pair(cnto[v[i]], v[i]));
        }
    }
    auto itee = se.rbegin(), iteo = so.rbegin();
    int emax = 0, emax2 = 0, omax = 0, omax2 = 0;
    emax = (*itee).FI;
    omax = (*iteo).FI;
    if ((*itee).SE == (*iteo).SE)
    {
        if (++itee == se.rend())
        {
            emax2 = 0;
        }
        else
        {
            emax2 = (*itee).FI;
        }
        if (++iteo == so.rend())
        {
            omax2 = 0;
        }
        else
        {
            omax2 = (*iteo).FI;
        }
        cout << n - max(emax + omax2, emax2 + omax) << endl;
    }
    else
    {
        cout << n - emax - omax << endl;
    }
}

Measured memory_bytes: 6144
N, A, B = map(int, input().split())

if A % 2 == B % 2 :
  ret = abs(B - A) // 2

else :
  ret = min((A - 1 + B - 1 - 1) // 2, (N - A + N - B - 1) // 2) + 1

print(ret)

Measured memory_bytes: 38384
N = int(input())
l = [-1] * N

def check(v):
    print(v)
    s = input()
    if s=="Male":
        l[v] = 0
    elif s=="Female":
        l[v] = 1
    else:
        exit(0)

check(0)
check(N-1)

left, right = 0, N-1
while right-left>1:
    mid = (left+right)//2
    check(mid)
    if (l[mid]==l[left] and (mid-left)%2) or (l[mid]!=l[left] and (mid-left)%2==0):
        right = mid
    else:
        left = mid


Measured memory_bytes: 9620
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

int main(int argc, char const *argv[])
{
    int n, m;
    cin >> n >> m;
    cout << (pow(2, m)) * (100 * (n - m) + 1900 * m) << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;

#define out(a) cout << a << endl
#define out1(a) cout << a
#define in(a) cin >> a
#define in2(a, b) cin >> a >> b
#define in3(a, b, c) cin >> a >> b >> c
#define rep(i, N) for (ll i = 0; i < (ll)N; i++)
#define rep1(i, N) for (ll i = 1; i <= (ll)N; i++)
#define repi(i, j, N) for (ll j = (ll)i + 1; j < (ll)N; j++)
#define all(v) v.begin(), v.end()

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;
constexpr ll mod = 1e9 + 7;

void solve();

int main()
{
    solve();
}

void solve()
{
    int n;
    in(n);
    out((n + 1) / 2);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define rep1(i,s,e) for(int i=s;i<e;i++)
#define rep2(i,s,e,c) for(int i=s;i>=e;i--)
#define pfi(x) printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
#define pfn() printf("\n")
#define pfs() printf(" ")
#define sfi(x) scanf("%d",&x)
#define sfi1(x,y) scanf("%d%d",&x,&y)
#define sff(x) scanf("%lf",&x)
#define sfl(x) scanf("%lld",&x)
#define memset1(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
const int MAX = 1e4 + 50;
const int mod = 996873654;
int lcase[27],lcase1[27];
vector<int> v[27];
int main(){
	string s,t;
	cin>>s>>t;
	memset1(lcase);
	memset1(lcase1);
	for(int i=0;i<s.length();i++){
		lcase[s[i]-'a']=1;
		v[s[i]-'a'].push_back(i);
	}
	for(int i=0;i<t.length();i++){
		lcase1[t[i]-'a']=1;
	}
	bool flag=true;
	for(int i=0;i<26;i++){
		if(lcase1[i]&&!lcase[i]){
			flag=false;
			break;
		}
	}
	if(flag){
		ll now=-1,cot=0,x;
		for(int i=0;i<t.length();i++){
			int num=t[i]-'a';
			x=upper_bound(v[num].begin(),v[num].end(),now)-v[num].begin();
			if(x!=v[num].size()){
				now=v[num][x];
			}
			else{
				now=-1;
				cot++;
				i--;
			}
		}
		ll len_s=s.length();
		printf("%lld\n",cot*len_s+now+1);
	}
	else{
		printf("-1\n");
	}
	return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
struct UF
{
  vector<int> par;
  vector<int> sz;
  vector<int> rank;
  UF(int n):par(n),sz(n),rank(n){
    for(int i = 0; i < n; i++){
      par[i] = i;sz[i] = 1;rank[i] = 0;
    }
  }
  int find(int x) {
    if (par[x] == x) return x;
    else return par[x] = find(par[x]);
  }
  void merge(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return;
    if(rank[x] < rank[y]){
      par[x] = y;
      sz[y] += sz[x];
    }
    else{
      par[y] = x;
      sz[x] += sz[y];
      if(rank[x] == rank[y])rank[x]++;
    }
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int n){return sz[find(n)];}
};

bool isdig(char c){
  return '0' <= c && c <= '9';
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b;cin>>a>>b;
  if(a%2){
    a++;
    if(a/2 >= b){
      cout<<"YES"<<endl;
    }else{
      cout<<"NO"<<endl;
    }
  }else{
    if(a/2 >= b){
      cout<<"YES"<<endl;
    }else{
      cout<<"NO"<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<functional>
#include<stack>
#include<list>
#include<set>
#include<deque>
#include<climits>
using namespace std;

typedef long long ll;

map<int, int> series;

int main(){
	int N, A, D, M, K;
	cin >> N >> A >> D >> M;
	for (int i = 0; i < M; i++)
	{
		int x, y, z;
		cin >> x >> y >> z;
		y--; z--;
		if (series.find(y) == series.end()) series[y] = y;
		if (series.find(z) == series.end()) series[z] = z;
		if (x == 0) swap(series[y], series[z]);
		if (x == 1) series[y] = series[z];
	}
	cin >> K;
	K--;
	if (series.find(K) == series.end()) series[K] = K;
	printf("%d\n", (ll)A + (ll)D*series[K]);
	return 0;
}

Measured memory_bytes: 1180
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <unordered_set>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const int NIL = -1;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue
 
int gcd(int a, int b) { int c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
int lcm(int a, int b) { int c = gcd(a, b); a /= c; return a*b; }
int nCr(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
int pow(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llpow(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llgcd(long long a, long long b) { long long c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
long long lllcm(long long a, long long b) { long long c = llgcd(a, b); a /= c; return a*b; }
long long llnCr(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
 
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
 
int main(){
    int n;
    int cnt[200];
    string s;
    REP(i, 200) cnt[i] = 50;
    cin >> n;
    REP(i, n){
        int tmp[200];
        REP(j, 200) tmp[j] = 0;
        cin >> s;
        REP(j, s.length()){
                tmp[s[j]]++;
        }
        REP(j, 200){
            cnt[j] = min(cnt[j], tmp[j]);
        }
    }
    REP(i, 200){
        REP(j, cnt[i]) cout << (char)i;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()

void solve(){
 ll n,a,b,c;
  cin >> n >> a >> b >> c;
 vs s(n+1);
 rep(i,0,n) cin >> s[i];
  s[n]="XX";
  
 vector<char> ans;
 rep(i,0,n){
  if(s[i]=="AB"){
   if((a>b)||(a==b&&s[i+1]=="BC")){
    --a;
    ++b; 
    ans.eb('B'); 
   }else{
     --b;
    ++a; 
    ans.eb('A'); 
   }  
   }
  if(s[i]=="AC"){
   if(c>a||(a==c&&s[i+1]=="AB")){
     --c;
    ++a; 
    ans.eb('A'); 
   }else{
    --a;
    ++c; 
    ans.eb('C');
   }          
      }
            
    if(s[i]=="BC"){
   if((b>c)||(b==c&&s[i+1]=="AC")){
    --b;
    ++c; 
    ans.eb('C'); 
   }else{
     --c;
    ++b; 
    ans.eb('B'); 
   }  
   }           
   
   
   
   
   
   
   
  if(a<0||b<0||c<0) {
    cout << "No" << endl; 
    return;
  }
 }
 cout << "Yes" << endl;
 for(auto c:ans) cout << c << endl; 
}

int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}  

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

typedef long long ll;

#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define AA(i) cout << i << endl;
#define AS(i) cout << i << " ";

const int INF = 1001001001;

using namespace std;

int main() {

    int n;
    cin >> n;

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

    sort(a, a+n);

    int now = a[0];
    for (int i = 1; i < n; i++) {

        if (now == a[i]) {
            AA("NO");
            return 0;
        } else {
            now = a[i];
        }
    }

    AA("YES");
}


Measured memory_bytes: 1024
s=input()
a=int(s[0:2])
b=int(s[2:4])
if 1<=a and a<=12 and 1<=b and b<=12:
  print("AMBIGUOUS")
elif 1<=a and a<=12:
  print("MMYY")
elif 1<=b and b<=12:
  print("YYMM")
else:
  print("NA")

Measured memory_bytes: 3060
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
if a[0]*t[0]+a[1]*t[1]==b[0]*t[0]+b[1]*t[1]:
    print('infinity')
elif a[0]*t[0]+a[1]*t[1]>b[0]*t[0]+b[1]*t[1]:
    if a[0]*t[0]>b[0]*t[0]:
        print(0)
    elif a[0]*t[0]==b[0]*t[0]:
        print(1)
    else:
        n=t[0]*(b[0]-a[0])
        m=t[0]*(a[0]-b[0])+t[1]*(a[1]-b[1])
        q=n//m
        if n%m==0:
            print(2*q)
        else:
            print(2*q+1)
else:
    if a[0]*t[0]<b[0]*t[0]:
        print(0)
    elif a[0]*t[0]==b[0]*t[0]:
        print(1)
    else:
        n=-t[0]*(b[0]-a[0])
        m=-t[0]*(a[0]-b[0])-t[1]*(a[1]-b[1])
        q=n//m
        if n%m==0:
            print(2*q)
        else:
            print(2*q+1)

Measured memory_bytes: 38384
#include <stdio.h>

int main(void){
    int n,m,i,o,sum=0,map[100][100],line[100];
    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++)
        for(o=0;o<m;o++)
            scanf("%d",&map[i][o]);
    for(i=0;i<m;i++)
        scanf("%d",&line[i]);
    for(i=0;i<n;sum=0,i++){
        for(o=0;o<m;o++)
            sum+=map[i][o]*line[o];
        printf("%d\n",sum);
    }
    return 0;
}

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

inline void chmax(int &a, int b) { a = max(a, b); }

int main()
{
  int N, M;
  int A[5005], B[5005];
  int maxv = 0;
  
  cin >> N >> M;
  Rep(i,N) cin >> A[i];
  Rep(i,M) cin >> B[i];
  
  Rep(i,M) {
    int now = i, cnt = 0;
    Rep(j,N) {
      if(A[j] == B[now])cnt++, now++;
    }
    chmax(maxv,cnt);
  }

  cout << maxv << endl;
  return 0;
}

Measured memory_bytes: 3136
#include <cstdio>

int main()
{
    int H, W;
    while (true)
    {
        scanf("%d%d",&H,&W);
        if (H == 0 && W == 0)
            break;
        for (int h = 0; h < H; h++)
        {
            for (int w = 0; w < W; w++)
            {
                if((h + w) % 2 == 0) printf("#");
                else printf(".");
            }
            printf("\n");
        }
        printf("\n");
    }
}


Measured memory_bytes: 2568
import scala.io.StdIn.readInt

object Main {
  def sieve(n:Int) = {
    val primes = Array.tabulate(n+1) { _ % 2 }
    primes(1) = 0
    primes(2) = 1

    for( i <- 3 to Math.sqrt(n).toInt by 2 )
      if(primes(i) == 1)
        (i*i to n by i*2).foreach { primes(_) = 0 }
    primes
  }

  def main(args:Array[String]) = {
    val p = sieve(1000001)
    var n = 0
    while( { n = readInt; n} != 0 ) {
      var cnt = 0
      for(i<- 3 to n/2 by 2)
        if((p(i) & p(n-i)) ==1)
          cnt += 1
      println(cnt)
    }
  }
}

Measured memory_bytes: 63892
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;
using p = pair<int, int>;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
  int h, w; cin >> h >> w;
  auto g = make_v(h, w, '0');
  REP(i, h)REP(j, w) cin >> g[i][j];

  queue<p> que;
  auto dis = make_v(h, w, -1);
  REP(i, h)REP(j, w){
    if(g[i][j] == '#'){
      que.push({i, j});
      dis[i][j] = 0;
    }
  }

  constexpr int dy[] = {-1, 0, 1, 0}, dx[] = {0, -1, 0, 1};
  auto in = [&](int y, int x){
    return y >= 0 && y < h && x >= 0 && x < w;
  };

  while(!que.empty()){
    const p now = que.front();
    que.pop();
    const int y = now.first, x = now.second;

    REP(k, 4){
      int ny = y + dy[k], nx = x + dx[k];
      if(in(ny, nx) && dis[ny][nx] == -1){
        que.push({ny, nx});
        dis[ny][nx] = dis[y][x] + 1;
      }
    }
  }

  int ans = 0;
  REP(i, h)REP(j, w) ans = max(ans, dis[i][j]);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 13328
s = input()
n = int(s)
keta = len(s)
cnt = [[0] * (10) for _ in range(10)]
for i in range(1, n + 1):
    a = int(str(i)[0])
    b = i % 10
    cnt[a][b] += 1
ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += cnt[i][j] * cnt[j][i]
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(), v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 1;
vector<int> g[N];
vector<int> vis(N);
void dfs(int v){
    vis[v] = 1;
    for(int &u : g[v]){
        if(!vis[u]){
            dfs(u);
        }
    }
}
void solve(){
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        g[i].clear();
    }
    for(int i = 1; i <= m; i++){
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    int ans = 0;
    vis.assign(n + 1, 0);
    for(int i = 1; i <= n; i++){
        if(!vis[i]){
            ans++;
            dfs(i);
        }
    }
    cout << ans - 1 << '\n';
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        solve();
    }
}

Measured memory_bytes: 38784
n = int(input())
st = []
for _ in range(n):
  si, ti = input().split()
  st.append((si, int(ti)))
name = input()
count = 0
flag = False
for i in range(n):
  if flag:
    count += st[i][1]
  if st[i][0] == name:
    flag = True
print(count)

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

template<typename T>
struct UnionFindWeight {
    vector<int> par;
    vector<int> sz;
    vector<T> W;
    function<T(T, T)> merge;
    function<T(T)> inv;

    UnionFindWeight(int n, function<T(T, T)> merge, function<T(T)> inv):merge(merge), inv(inv){
        if(n > 0) initialize(n);
    }

    void initialize(int n){
        par.resize(n);
        sz.resize(n, 1);
        W.resize(n);
        for(int i=0; i<n; i++){
            par[i] = i;
        }
    }

    int find(int x){
        if(par[x] == x){
            return x;
        }else{
            int r = find(par[x]);
            W[x] = merge(W[x], W[par[x]]);
            return par[x] = r;
        }
    }

    // weight[x] - weight[y] = w
    void unite(int x, int y, T w){
        w = merge(w, inv(weight(x)));
        w = merge(w, weight(y));
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(sz[x] > sz[y]){
            swap(x, y);
            w = inv(w);
        }
        par[x] = y;
        sz[y] += sz[x];
        W[x] = merge(W[x], w);
    }

    T weight(int x){
        find(x);
        return W[x];
    }

    // weight[x] - weight[y]
    T diff(int x, int y){
        return merge(weight(x), inv(weight(y)));
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }
};

int main(){
    int N, M;
    cin >> N >> M;
    UnionFindWeight<int64_t> uf(N, [](int64_t a, int64_t b){ return a+b; }, [](int64_t a){ return -a; });

    bool ok = true;
    for(int i=0; i<M; i++){
        int l, r, d;
        cin >> l >> r >> d;
        l--; r--;
        if(uf.same(l, r)){
            if(uf.diff(r, l) != d) ok = false;
        }else{
            uf.unite(r, l, d);
        }
    }
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}


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

int main(){
	string s;cin>>s;
  if(s=="Sunny"){
  	cout<<"Cloudy\n";
  }
  else if(s=="Cloudy"){
  	cout<<"Rainy\n";
  }
  else if(s=="Rainy"){
  	cout<<"Sunny\n";
  }
  return 0;
}

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

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

    int count = 0;
    for(int i = 0; i < n - 2; i++) {
        for(int j = i + 1; j < n - 1; j++) {
            for (int k = j + 1; k < n; k++) {
                if (i == j || j == k || k == i) continue;
            
                int a = L[i], b = L[j], c = L[k];
                if (a == b || b == c || c == a) continue;
                
                if ((a + b > c) && (b + c > a) && (c + a > b)) count++;
            }
        }
    }
    
    cout << count << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    int n;
    cin >> n;
    vector<int> p(n);
    fore(i,0,n) cin >> p[i];
    bool ok = is_sorted(p.begin(), p.end());
    fore(i,0,n) {
        if (ok) break;
        fore(j,i+1,n) {
            if (ok) break;
            vector<int> aux = p;
            swap(aux[i], aux[j]);
            ok = is_sorted(aux.begin(), aux.end());
        }
    }
    if (ok) cout << "YES\n";
    else cout << "NO\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

ll solve(string s,ll k){
  ll n=s.size();
  ll m=0;
  if(k==1){
    m+=(n-1)*9;
    ll b=s[0]-'0';
    m+=b;
  }
  else if(k==2){
    if(n<=1){
      return 0;
    }
    m+=(n-1)*(n-2)/2*9*9;
    ll b=s[0]-'0';
    m+=(b-1)*(n-1)*9;
    ll c=1;
    while(c<n-1){
      if(s[c]!='0')break;
      c++;
    }
    string t=s.substr(c);
    m+=solve(t,1);
  }
  else{
    if(n<=2){
      return 0;
    }
    m+=(n-1)*(n-2)*(n-3)/6*9*9*9;
    ll b=s[0]-'0';
    m+=(b-1)*(n-1)*(n-2)/2*9*9;
    ll c=1;
    while(c<n-1){
      if(s[c]!='0')break;
      c++;
    }
    string t=s.substr(c);
    m+=solve(t,2);
  }
  return m;
}


int main(){

  string s;
  ll k;
  cin >> s >> k;
  // ll n=s.size();

  // ll m=0;

  // ll a=0;
  // ll b=1;
  // while(a<k){
  //   b*=(n-a);
  //   a++;
  // }
  // while(a>0){
  //   b/=a;
  //   a--;
  // }

  // m+=b*pow(9,k);

  // if(k==1){
  //   ll c=s[0];
  //   m+=c;
  // }
  // else if(k==2){
  //   if(n<=1){
  //     cout << 0 << endl;
  //     return 0;
  //   }
  //   ll c=s[0];
  //   ll d=s[1];
  //   m+=(c-1)*9*(n-1);
  //   m+=9*(n-2)+d;
  // }
  // else{
  //   if(n<=2){
  //     cout << 0 << endl;
  //     return 0;
  //   }
  //   ll c=s[0],d=s[1],e=s[2];
  //   m+=(c-1)*(n-1)*(n-2)/2*9*9;
  //   m+=(d-1);
  // }

  cout << solve(s,k) << endl;



}

Measured memory_bytes: 3428
l, r = STDIN.gets.chomp.split(' ').map(&:to_i)
            
result = 3000
            
if r - l > 2019 - 1 then
  result = 0
else        
  for i in l..(r-1)
    for j in (l+1)..r
      if (((i % 2019) * (j % 2019)) % 2019) < result then
        result = (((i % 2019) * (j % 2019)) % 2019)
      end
    end
  end
end

puts result 

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;

const int mx=200010;
const ll mod=1e9+7;

int main(){
  int n,m;  cin >> n >> m;
  vector<int> a(20);
  int p;
  
  for(int i=0; i<m; i++){
    int k; cin >> k;
    for(int j=0; j<k; j++){
      int x; cin >> x;
      a[x-1] += 1<<i;
    }
  }
  for(int i=0; i<m; i++){
    int x; cin >> x;
    p += x*(1<<i);
  }

  int ans=0;
  for(int bit=0; bit<(1<<n); bit++){
    int ret=0;
    for(int i=0; i<n; i++){
      if((1<<i)&bit){ret ^= a[i];}
    }
    if(ret==p){ans++;}
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pi pair<int,int>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=110,size=1<<20;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

ll a[N][11],s[N][11],n;

void dfs(int x,int y) {
	while(x) {
		putchar(y+'0');
		x--;
		if(y) {
			if(a[x][y-1]>=n) {y--;continue;}
			n-=a[x][y-1];
			if(a[x][y]>=n) continue;
			n-=a[x][y];
			y++;
		}
		else {
			if(a[x][y]>=n) continue;
			n-=a[x][y];
			y++;
		}
	}
}
	
int main() {
	qr(n);
	a[1][0]=1;
	for(int i=1;i<=9;i++) a[1][i]=1,s[1][i]=i;
	for(int i=2;i<=30;i++) {
		s[i][0]=s[i-1][9];
		for(int j=0;j<=9;j++) {
			if(j) {
				a[i][j]=a[i-1][j-1]+a[i-1][j]+a[i-1][j+1];
				s[i][j]+=s[i][j-1]+a[i][j];
			}
			else {
				a[i][j]=a[i-1][j]+a[i-1][j+1];
//				s[i][j]+=a[i][j];
			}
		}
	}
	for(int i=30; i;i--) 
		if(s[i][9]>=n&&s[i-1][9]<n) {
			s[i][10]=s[i][9]+1;
			for(int j=0;j<=9;j++)
				if(s[i][j]>=n) {
					if(j) n-=s[i][j-1];
					dfs(i,j);
					return 0;
				}
		}
	return 0;
}



Measured memory_bytes: 256
#include <cstdio>

const int N=200005,INF=2e9;

int n;
int x[N],y[N];
int px,py,qx,qy;

int abs(int x){return x>0?x:-x;}
int max(int a,int b){return a>b?a:b;}

int d(int i,int j)
{
    return abs(x[i]-x[j])+abs(y[i]-y[j]);
}

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d%d",x+i,y+i);
        if(x[i]-y[i]>x[px]-y[px])px=i;
        if(x[i]-y[i]<x[qx]-y[px])qx=i;
        if(x[i]+y[i]>x[py]+y[py])py=i;
        if(x[i]+y[i]<x[qy]+y[qy])qy=i;
    }
    int res=0,t;
    for(int i=0;i<n;i++)
    {
        t=max(max(d(i,px),d(i,py)),max(d(i,qx),d(i,qy)));
        res=max(res,t);
    }
    printf("%d\n",res);
    return 0;
}

Measured memory_bytes: 3288
n = int(input())
h = list(map(int,input().split()))
num,num_max = 0,0
for i in range(n - 1):
    if h[i] >= h[i + 1]:
        num += 1
    else:
        num = 0
    if num > num_max:
        num_max = num
print(num_max)

Measured memory_bytes: 20360
import sys

x, n = map(int, input().split())
p_list = list(map(int, input().split()))

if n == 0:
    print(x)
    sys.exit()
elif not(x in p_list):
    print(x)
    sys.exit()
elif len(p_list) == 100 and x <= 50:
    print(0)
    sys.exit()
elif len(p_list) == 100 and x > 50:
    print(101)
    sys.exit()

list.sort(p_list, reverse=True)
dis_list = list(range(102))
for p in p_list:
    dis_list.pop(p)

min_dis = 102
ans = 0
for index in dis_list:
    dis = abs(index - x)
    if dis < min_dis:
        min_dis = dis
        ans = index
print(ans)







Measured memory_bytes: 9160
fun main() {
    val stat = Stat()
    repeat(readInt()) {
        when (readLine()!!) {
            "AC" -> stat.ac++
            "TLE" -> stat.tle++
            "WA" -> stat.wa++
            "RE" -> stat.re++
        }
    }
    println(stat)
}

data class Stat(var ac: Int = 0, var tle: Int = 0, var wa: Int = 0, var re: Int = 0) {
    override fun toString(): String {
        return "AC x $ac\nWA x $wa\nTLE x $tle\nRE x $re"
    }
}


private fun readInt() = readLine()!!.toInt()
private fun readInts() = readLine()!!.split(" ").map { it.toInt() }
private fun readLongs() = readLine()!!.split(" ").map { it.toLong() }


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

template <typename T>
inline T read(){
	T x=0,f=1;char c=getchar();
	while(!isdigit(c)){	if(c=='-') f=-f;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+(c-48);c=getchar();}
	return x*f;
}

#define lint long long int
#define ulint unsigned lint
#define readint read<int>()
#define readlint read<lint>()
const int inf=1e9+1e7;

int main(void){

	// freopen("testdata.in","r",stdin);
	// freopen("testdata.out","w",stdout);

	string s;
	cin>>s;
	if(s[s.length()-1]=='s') cout<<s<<"es";
	else cout<<s<<"s";

	return 0;
}

Measured memory_bytes: 3624
class Dice(object):
    def __init__(self,num):
        self.f=num[0]
        self.s=num[1]
        self.e=num[2]
        self.w=num[3]
        self.n=num[4]
        self.b=num[5]
    def create(self,order):
        if order=='N':
            return [self.s,self.b,self.e,self.w,self.f,self.n]
        elif order=='S':
            return [self.n,self.f,self.e,self.w,self.b,self.s]
        elif order=='E':
            return [self.w,self.s,self.f,self.b,self.n,self.e]
        else:
            return [self.e,self.s,self.b,self.f,self.n,self.w]
    def judge(self,dice_2):
        T={0:'N',1:'E',2:'S',3:'W'}
        m=[dice_2.s,dice_2.w,dice_2.n,dice_2.e,dice_2.f,dice_2.b]
        for i in range(6):
            if m[i]==self.f:#?????¢??¨?????´???????????????????????????
                if i==4:temp=dice_2#?????¢??????????????´
                elif i==5:temp=Dice(Dice(dice_2.create('N')).create('N'))#?????¢??¨?????´
                else:temp=Dice(dice_2.create(T[i]))#??´??¢??¨?????´

                if self.b==temp.b:
                        side_1=''.join(list(map(str,[self.s,self.w,self.n,self.e])))*2
                        side_2=''.join(list(map(str,[temp.s,temp.w,temp.n,temp.e])))
                        if side_2 in side_1:return 'accordance'
        return 'discordance'
    @staticmethod
    def isdifferent(dices):
        for i in range(len(dices)):
            for j in range(i+1,len(dices)):
                if dices[i].judge(dices[j])=='accordance':return 'No'
        return 'Yes'

n=eval(input())
dices=[]
for i in range(n):
    dices.append(Dice(list(map(int,input().split()))))
print(Dice.isdifferent(dices))

Measured memory_bytes: 7896
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
//using ll=long long;
const double EPS = 1e-10;
inline bool equals(double a, double b) { return fabs(a - b) < EPS; }
const double PI = 3.141592653589793238;
class Point {
public:
	double x, y;
	Point(double x, double y) :x(x), y(y) {}
	Point() {}
	Point operator +(const Point &p) const{ return Point(x + p.x, y + p.y); };
	Point operator -(const Point &p) const{ return Point(x - p.x, y - p.y); }
	Point operator *(double k) { return Point(x*k, y*k); }
	Point operator /(double k) { return Point(x / k, y / k); }
};
typedef Point Vector;

inline double norm(Vector a) {
	return a.x*a.x + a.y*a.y;
}
double absv(Vector a) {
	return sqrt(norm(a));
}
inline double dot(Vector a, Vector b) {
	return a.x*b.x + a.y*b.y;
}
inline double cross(Vector a, Vector b) {
	return a.x*b.y - a.y*b.x;
}
struct Segment {
	Point p1, p2;
};
typedef Segment Line;

class Circle {
public:
	Point c;
	double r;
	Circle(Point c = Point(), double r = 0.0) :c(c), r(r) {}
};
typedef vector<Point> Polygon;
Point project(Segment s, Point p) {
	Vector base = s.p2 - s.p1;
	double r = dot(p - s.p1, base) / norm(base);
	return s.p1 + base*r;
}
int main() {
	Point p[2];
	int q, x, y;
	cin >> p[0].x >> p[0].y >> p[1].x >> p[1].y;
	Segment seg;
	seg.p1 = p[0]; seg.p2 = p[1];
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> x >> y;
		//cout << x << " " << y << endl;
		Point po = Point(x, y);
		Point proj = project(seg, po);
		printf("%.10lf %.10lf\n", proj.x, proj.y);
	}
}

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

int main() {
  long long n;
  cin >> n;
  long long ans = 1000000000001;

  for (long long i=1; i*i <= n; i++) {
  	if (n % i == 0) {
  		ans = (long long) min(ans, i + n/i - 2);
  	}
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<string>

using namespace std;

int main(){
	
	string in;
	string e;
	stack<double> s;

	while(getline(cin,in)){
		e="";
		while(!s.empty()) s.pop();
		for(int i=0;i<in.size();i++){
			if(in[i]!=' '){
				e+=in[i];
			}
			if(in[i]==' '||i==in.size()-1){
				if(e=="+"){
					double a=s.top();s.pop();
					double b=s.top();s.pop();
					s.push(b+a);
				}
				else if(e=="*"){
					double a=s.top();s.pop();
					double b=s.top();s.pop();
					s.push(b*a);
				}
				else if(e=="/"){
					double a=s.top();s.pop();
					double b=s.top();s.pop();
					s.push(b/a);
				}
				else if(e=="-"){
					double a=s.top();s.pop();
					double b=s.top();s.pop();
					s.push(b-a);
				}
				else{
					s.push(atoi(e.c_str()));
				}
				e="";
			}
		}
		printf("%.12f\n",s.top());
		s.pop();
	}
}

Measured memory_bytes: 1248
input_str = list(map(str, input().split()))
input_num = list(map(int, input().split()))
input_out = str(input())

if input_out == input_str[0]:
    input_num[0] -= 1
elif input_out == input_str[1]:
    input_num[1] -= 1

print(input_num[0],input_num[1])

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

int main(){
  vector<int> vec(3);
  for (int i = 0; i < vec.size(); i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());

  cout << vec.at(2) * 10 + vec.at(1) + vec.at(0) <<endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
main()
{
   int n,i,ans=0;
   cin>>n;
   int a[n+1],b[n+1],c[n+1];
   for(i=1;i<=n;i++)
   {
       cin>>a[i]>>b[i]>>c[i];
   }
   for(i=2;i<=n;i++)
   {
       a[i]=a[i]+max(b[i-1],c[i-1]);
       b[i]=b[i]+max(a[i-1],c[i-1]);
       c[i]=c[i]+max(b[i-1],a[i-1]);
   }
   ans=max(a[n],b[n]);
   ans=max(ans,c[n]);
   printf("%d\n",ans);
}



Measured memory_bytes: 1408
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
int main()
{
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> C(N);
    vector<vector<int>> A(N, vector<int>(M));
    for (int i = 0; i < N; ++i)
    {
        cin >> C[i];
        for (int j = 0; j < M; ++j) cin >> A[i][j];
    }
    long long blim = 1 << N;
    int ans = 1 << 30;
    bool isUpdated = false;
    for (long long bit = 0; bit < blim; ++bit)
    {
        int cost = 0;
        vector<int> score(M, 0);
        for (int i = 0; i < N; ++i)
        {
            if (bit & (1 << i))
            {
                cost += C[i];
                for (int j = 0; j < M; ++j)
                {
                    score[j] += A[i][j];
                }
            }
        }
        bool ok = true;
        for (int j = 0; j < M; ++j)
        {
            if(score[j] < X) ok = false;
        }
        if (ok)
        {
            ans = (std::min)(ans, cost);
            isUpdated = true;
        }
    }
    if (!isUpdated) ans = -1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <math.h>

int	main(void)
{
  	int	r;
  	double c;
  	
  	scanf("%d", &r);
  
  	c = 3.1415926535 * r * 2;
  
  	printf("%f", c);
  	return (0);
}


Measured memory_bytes: 1748
import java.util.*;
class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int H1 = sc.nextInt();
		int A1 = sc.nextInt();
		int H2 = sc.nextInt();
		int A2 = sc.nextInt();
		
		while(true)
		{
			H2 -= A1;
			if(H2 <= 0)
			{
				System.out.println("Yes");
				break;
			}
			
			H1 -= A2;
			if(H1 <= 0)
			{
				System.out.println("No");
				break;
			}
		}
	}
}

Measured memory_bytes: 35792
#include <iostream>

using namespace std;

int main(){
    char A[4];
    for(int i=0;i<4;i++){
        cin>>A[i];
    }
    if(A[0]==A[1]&&A[1]==A[2]||A[1]==A[2]&&A[2]==A[3]){
          cout<<"Yes\n";     
    }else{
          cout<<"No\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    int n;
    string s;
    cin>>n>>s;
    int res[n];
    rep(i,n)res[i]=-1;
    const char circle = 'o';
    const char cross = 'x';
    bool flg=false;
    DEBUG{cout << s[0] << endl;}
    rep(r0,2){
        rep(r1,2){
            DEBUG{cout << "0 : " << r0 << " 1 : " << r1 << endl;}
            res[0]=r0;
            res[1]=r1;
            for(int i=1;i<n-1;i++){
                if(s[i]==circle){
                    if(res[i]){res[i+1]=1-res[i-1];}
                    else {res[i+1]=res[i-1];}
                }else{
                    if(!res[i]){res[i+1]=1-res[i-1];}
                    else {res[i+1]=res[i-1];}
                }
            }
            DEBUG{cout << res[0] << res[n-2] << res[n-1] << endl;}
            DEBUG{cout << "s[n-1] : " << int(s[n-1]) << endl;}
            DEBUG{cout << "flg : " << (res[0]==res[n-2]&&(res[n-1]&&int(s[n-1])==cross||!res[n-1]&&int(s[n-1])==circle)) << endl;}
            flg = ((res[1]==res[n-1]&&(res[0]&&s[0]==cross||!res[0]&&s[0]==circle)) ||
                (res[1]!=res[n-1]&&(res[0]&&s[0]==circle||!res[0]&&s[0]==cross))) &&
                ((res[0]==res[n-2]&&(res[n-1]&&s[n-1]==cross||!res[n-1]&&s[n-1]==circle)) ||
                (res[0]!=res[n-2]&&(res[n-1]&&s[n-1]==circle||!res[n-1]&&s[n-1]==cross)));
            DEBUG{cout << "flag : " << flg << endl;}
            if(flg){
                break;
            }
        }
        if(flg){
            break;
        }
    }
    if(flg){
        rep(i,n){
            cout << (res[i] ? 'W' : 'S');
        }
        cout<<endl;
    }else {
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<cctype>
#include<queue>
#include<cstdio>
#include<cmath>
#include<sstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
#include<ctime>
#include<cstdlib>
#include<map>
#include<utility>
#include<iomanip>
#include<set>
using namespace std;
typedef long long ll;
int n,k;
const int N=4008;
vector<int> g[N];
const int INF=(int)1e7+10;
int ans=N;
int q[4008];
int topQ;
int dist[4008];
inline void bfs()
{
	for(int k=0;k<topQ;k++)
	{
		int v=q[k];
		for(int u : g[v])
		{
			int w=dist[v]+2;
			if(dist[u]<=w)
				continue;
			dist[u]=w;
			q[topQ++]=u;
		}
	}
	return;
}
int solvedian(int v)
{
	for(int i=0;i<n;i++)
		dist[i]=INF;
	dist[v]=0;
	topQ=0;
	q[topQ++]=v;
	bfs();
	int res=0;
	for(int i=0;i<n;i++)
		if(dist[i]>k)
			res++;
	return res;
}
int solvebian(int v,int u)
{
	for(int i=0;i<n;i++)
		dist[i]=INF;
	dist[v]=dist[u]=1;
	topQ=0;
	q[topQ++]=v;
	q[topQ++]=u;
	bfs();
	int res=0;
	for(int i=0;i<n;i++)
		if(dist[i]>k)
			res++;
	return res;
}
int main ()
{
	cin>>n>>k;
	for(int i=1;i<n;i++)
	{
		int u,v;
		cin>>v>>u;
		v--;
		u--;
		g[v].push_back(u);
		g[u].push_back(v);
	}
	for(int v=0;v<n;v++)
		ans=min(ans,solvedian(v));
	for(int v=0;v<n;v++)
		for(int u:g[v])
			if(u>v)
				ans=min(ans,solvebian(v,u));
	cout<<ans;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <climits>
#include <cmath>
#include <cfloat>

using namespace std;

string s;

int main()
{
	getline(cin, s);
	
	for( int i = 0; i < s.size(); i++)
	{
		if( s[i] >= 'a' && s[i] <= 'z' )
		{
			s[i] = s[i] - 'a' + 'A';
		}
		
	}
	
	cout << s << endl;
	
}

Measured memory_bytes: 0
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

@SuppressWarnings("unchecked")
public class Main {
    public static void main(String[] args) throws IOException {
        final String s;

        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            s = reader.readLine();
        }

        for (int i = 0; i < s.length(); i++)
            if (s.charAt(i) == '1') System.out.print("9");
            else if (s.charAt(i) == '9') System.out.print("1");
            else System.out.print(s.charAt(i));

        System.out.println();
    }
}


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

int main()
{
  int n,a,b;
  while(cin >> n)
  {
      if(n == 1)
      cout << "Hello World" << endl;
      else
      {
          cin >> a >> b;
          cout << a + b << endl;
      }
  }
  return 0;
}


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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> S(n);
	for (int i = 0; i < n; ++i)
		cin >> S[i];

	int q;
	cin >> q;
	vector<int> T(q);
	for (int i = 0; i < T.size(); ++i)
		cin >> T[i];

	int count = 0;
	for (int i = 0; i < T.size(); ++i)
	{
		// Binary Search
		int left = 0;
		int right = n;
		while (left < right)
		{
			int mid = (left + right) / 2;
			if (S[mid] == T[i])
			{
				count++;
				break;
			}
			else if (S[mid] > T[i])
				right = mid;
			else
				left = mid + 1;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 1564
import java.io.*;
import java.util.*;

public class Main {
    public static final int MOD = (int) (1e9 + 7);

    class Monster {
        int x, h;

        public Monster(int x, int h) {
            this.x = x;
            this.h = h;
        }
    }

    class Event {
        int x;
        int t;

        public Event(int x, int t) {
            this.x = x;
            this.t = t;
        }
    }

    public void solve(InputReader in, PrintWriter out) {
        int n = in.nextInt(), d = in.nextInt(), a = in.nextInt();
        Monster[] monsters = new Monster[n];
        for (int i = 0; i < n; ++i) {
            monsters[i] = new Monster(in.nextInt(), in.nextInt());
        }

        Arrays.sort(monsters, Comparator.comparingInt(x -> x.x));

        long cost = 0;
        int explosion = 0;
        Queue<Event> q = new LinkedList<>();
        for (int i = 0; i < n; ++i) {
            while (!q.isEmpty() && monsters[i].x > q.peek().x + d) {
                explosion -= q.peek().t * a;
                q.poll();
            }
            if (explosion < monsters[i].h) {
                int t = (monsters[i].h - explosion + a - 1) / a;
                q.add(new Event(monsters[i].x + d, t));
                explosion += t * a;
                cost += t;
            }
        }

        out.println(cost);
    }

    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        new Main().solve(in, out);
        out.flush();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }
    }
}


Measured memory_bytes: 67380
#include<bits/stdc++.h>
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 erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P = pair<int,int>;
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; }

signed main(){
  int n;
  cin >> n;
  vint ans(n,-1);
  vvint to(n),cost(n);
  rep(i,0,n-1){
    int v1,v2,w;
    cin >> v1 >> v2 >> w;
    v1--;v2--;
    to[v1].push_back(v2);
    cost[v1].push_back(w);
    to[v2].push_back(v1);
    cost[v2].push_back(w);
  }
  queue<int> que;
  ans[0] = 0;
  que.push(0);
  while(!que.empty()){
    int v = que.front();
    que.pop();
    rep(w,0,to[v].size()){
      int u = to[v][w];
      int z = cost[v][w];
      if(ans[u] != -1) continue;
      ans[u] = (ans[v]+z) % 2;
      que.push(u);
    }
  }
  rep(i,0,n) cout << ans[i] << endl;
}

Measured memory_bytes: 13184
use proconio::{fastout, input};

#[fastout]
fn main() {
  input! {
    N: usize,
    M: usize,
    H: [u32; N],
    pairs: [(usize, usize); M],
  }

  let mut towers: Vec<Vec<usize>> = vec![vec![]; N];
  for pair in pairs {
    towers[pair.0 - 1].push(pair.1 - 1);
    towers[pair.1 - 1].push(pair.0 - 1);
  }

  let mut count = 0;
  for (tower_i, tower) in towers.iter().enumerate() {
    let max_height_in_adj: u32 =
      tower.iter().fold(0, |acc, &curr| acc.max(H[curr]));
    if max_height_in_adj < H[tower_i] {
      count += 1;
    }
  }
  println!("{}", count);
}


Measured memory_bytes: 11960
#include <bits/stdc++.h>
#define int long long 
using namespace std;

int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, d, cnt = 0; cin >> n >> d;
	for(int i = 1; i <= n; i++) {
		int x, y; cin >> x >> y;
		cnt += x * x + y * y <= d * d;
	}
	cout << cnt << endl;
}

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

int main(){
  int n, a = 0;
  cin >> n;
  vector<int> p(n);
  for (int i=0 ; i<n ; i++){
    cin >> p.at(i);
    if (p.at(i) != i+1)
      a++;
  }
  
  if (a > 2)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
}

Measured memory_bytes: 3636