akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

void solve() {
	string s;
	cin >> s;
	int res = 0;
	for (int i = 0; i < s.length(); ) {
		if (s[i] == 'S') {
			++i;
		} else {
			int j = i;
			while (j < s.length() && s[j] == 'R') {
				++j;
			}
			res = max(res, j - i);
			i = j;
		}
	}
	cout << res << endl;
}

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

	int t;
	//cin >> t;
	t = 1;

	for (int tt = 0; tt < t; ++tt) {
		solve();
	}


	return 0;
}

Measured memory_bytes: 3612
#include "iostream"
#include "vector"
#include "algorithm"

using namespace std;

int main()
{
  int n, m;
  cin >> n >> m;
  int p[100100], y[100100];
  for (int i = 0; i < m; i++)
  {
    cin >> p[i] >> y[i];
  }
  vector<int> yd[100100];
  for (int i = 0; i < m; i++)
  {
    yd[p[i]].push_back(y[i]);
  }
  for (int i = 0; i < n + 1; i++)
  {
    sort(yd[i].begin(), yd[i].end());
  }
  for (int i = 0; i < m; i++)
  {
    int ans_first = p[i];
    int ans_second = lower_bound(yd[p[i]].begin(), yd[p[i]].end(), y[i]) - yd[p[i]].begin() + 1;
    printf("%06d", ans_first);
    printf("%06d", ans_second);
    cout << endl;
  }
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long W,H,x,y;
  cin >> W>>H>>x>>y;
  double s=1.0;
  
  if(W*s/2!=x || H*s/2!=y){
    cout << W*H*s/2 << " " << 0 <<endl;
  }
  
  else{
    cout << W*H*s/2 << " " << 1 <<endl;
  }
}


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

using ll = long long;
using p = pair<char, char>;
constexpr ll INF = 1LL << 62;
ll N, Q;
string S;
vector<p> query;


bool solve(ll g) {
  for (auto q : query) {
    if (S[g] == q.first) {
      if (q.second == 'L') {
        g--;
      } else {
        g++;
      }
      if (g == 0 || g == N + 1) {
        return true;
      }
    }
  }

  return false;
}

int main(void) {
  cin >> N >> Q;
  cin >> S;
  S = " " + S + " ";

  for (ll i = 0; i < Q; i++) {
    char t, d;
    cin >> t >> d;
    query.push_back(p(t, d));
  }

  ll ok = N + 1;
  ll ng = 0;
  while (abs(ok - ng) > 1) {
    ll c = (ok + ng) / 2;
    if (solve(c)) {
      ok = c;
    } else {
      ng = c;
    }
  }

  ll right = ok;

  ok = 0;
  ng = N + 1;
  while (abs(ok - ng) > 1) {
    ll c = (ok + ng) / 2;
    if (solve(c)) {
      ok = c;
    } else {
      ng = c;
    }
  }

  ll left = ok;

  cout << max((right - left - 1), 0LL) << endl;

  return 0;
}


Measured memory_bytes: 1240
from collections import deque
import sys
input = sys.stdin.readline

N,Q = map(int,input().split())
graph = [[] for i in range(N)]

for i in range(N-1):
    a,b = map(int,input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

#print(graph)
v = [0]*N
for i in range(Q):
    p,x = map(int,input().split())
    v[p-1] += x

notv = [True]*N
notv[0] = False
stack = deque([0])

while stack:
    now = stack.pop()
    for i in graph[now]:
        if notv[i]:
            notv[i] = False
            stack.append(i)
            v[i] += v[now]

print(*v)

Measured memory_bytes: 93972
import heapq

N, M = map(int, input().split())

AB = []
can = [[] for i in range(M+1)]
for i in range(N):
    a, b = map(int, input().split())
    AB.append([a, b])
    if M - a >= 0:
        can[M-a].append(-b)

que = []
ans = 0
for i in range(M, -1, -1):
    now_list = can[i]
    for j in range(len(now_list)):
        heapq.heappush(que, now_list[j])
    if que:
        ans += heapq.heappop(que)

print(-ans)


Measured memory_bytes: 36900
#include <iostream>
#include <algorithm>
using namespace std;
int gcd(int a, int b){
	return b==0 ? a : gcd(b, a%b);
}
int main(){
	int x,y;
	cin >> x >> y;
	cout << (x+1) + (y+1) - 1 - gcd(x,y) << endl;
}

Measured memory_bytes: 3084
#define _CRT_SECURE_NO_WARNINGS
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
//#define int ll
//#define endl "\n"
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> ostream & operator<<(ostream & os, vector<T> const &);
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream & os, tuple<T...> const & t){ _ot<0>(os, t); return os; }
template<class T, class U> ostream & operator<<(ostream & os, pair<T,U> const & p){ return os << "(" << p.first << ", " << p.second << ") "; }
template<class T> ostream & operator<<(ostream & os, vector<T> const & v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; }
template<class T> inline bool chmax(T & x, T const & y){ return x<y ? x=y,true : false; }
template<class T> inline bool chmin(T & x, T const & y){ return x>y ? x=y,true : false; }
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl)
#else
#define dump(...)
#endif
// ll const mod = 1000000007;
// ll const inf = 1LL<<60;

bool dp[6000][1<<13];

ll const B = 1000000007;
ull p[6000], thash[6000];
ull shash[13];

int n,m;
int len;
char t[6000];
char ss[13][22];
int sslen[13];

int solve(){
    rep(i,n){
        ull x = 0;
        for(int j=0;ss[i][j];j++) x = x*B + ss[i][j];
        shash[i] = x;
    }
    p[0] = 1;
    thash[0] = 0;
    rep(i,len) thash[i+1] = thash[i]*B + t[i];

    rep(i,len+1)rep(j,1<<n) dp[i][j] = false;
    rep(i,len+1) dp[i][0] = true;
    rep(pos,len){
        rep(mask,1<<n){
            if(!dp[pos][mask]) continue;
            rep(i,n){
                if(mask>>i&1) continue;
                if(pos+sslen[i] > len) continue;
                ull h1 = shash[i];
                ull h2 = thash[pos+sslen[i]] - thash[pos] * p[sslen[i]];
                // if(h1 != h2) continue;
                dp[pos+sslen[i]][mask|1<<i] |= h1 == h2; // t.substr(pos,ss[i].size()) == ss[i];
            }
        }
    }

    int ans = 0;
    rep(i,len+1){
        if(dp[i][(1<<n)-1]){
            ++ans;
        }
    }
    return ans;
}

signed main(){
    p[0] = 1;
    rep(i,5001) p[i+1] = p[i]*B;

    while(scanf("%d%d",&n,&m), n){
        len = 0;
        rep(i,n){
            scanf("%s",ss[i]);
            sslen[i] = strlen(ss[i]);
        }
        rep(i,m){
            static char buf[22];
            scanf("%s",buf);
            int l;
            for(l=0; buf[l]; l++) t[l+len] = buf[l];
            len += l;
        }
        cout << solve() << endl;
    }
}

Measured memory_bytes: 42156
from sys import stdin
import sys

# A, B, C = [int(x) for x in stdin.readline().rstrip().split()]
# A,B = [int(x) for x in stdin.readline().rstrip().split()]
# U = input().split()
# A, B = [str(x) for x in stdin.readline().rstrip().split()]
s = list(input())
if s[0] == '7' or s[1] == '7' or s[2] == '7':
    print("Yes")
else:
    print("No")

# print("YES")
# print("NO")


Measured memory_bytes: 9088
#include "bits/stdc++.h"
//#include <algorithm>
#define ll long long 
#define mod 1000000007
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define umap unordered_map
#define uset unordered_set
#define lb lower_bound
#define ub upper_bound
#define endll "\n";
#define all(x) (x).begin(), (x).end()
#define forr(it,x) for(auto it=x.begin();it!=x.end();it++)
#define for1(i,a,b) for(int i=a;i<b;i++)
#define for2(i,a,b) for(int i=a;i>=b;i--)
#define for3(i,a,b) for(long long int i=a;i<b;i++)
#define for4(i,a,b) for(long long int i=a;i>=b;i--)
#define pp pair<int,int>
#define ld long double
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpp vector<pp>
#define vi vector<int>
#define vpll vector<pll>
#define vld vector<ld>
#define vvld vector<vld>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define vvpp vector<vpp>
#define I insert
#define mem(a,x) memset(a,x,sizeof(a))
#define p_queue(a) priority_queue<a,vector<a>,greater<a>>
using namespace std;
//const int dx[8]={1,0,-1,0,1,1,-1,-1},dy[8]={0,1,0,-1,-1,1,-1,1};
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1}; 
const int N=2e5+5;
/*vector<bool> p(N+1, true);
void sieve()
{
    p[0] = p[1] = false;
    int i,j;
    for (i = 2; i*i <= N; i++) 
    {
        if (p[i]) 
        {
            for (j = i * i; j <=N; j += i)
            {
                p[j] =false;
            }
        }
    }
}*/
/*int power(int a, int b){
    int res = 1;
    while(b > 0){
        if(b % 2){
            res = 1LL * res * a % mod;
        }
        a = 1LL * a * a % mod;
        b /= 2;
    }
    return res;
}*/
/*int gcd(int a,int b){
    if(a<b) swap(a,b);
    a%=b;
    if(a==0) return b;
    return gcd(b,a);
}*/
/*int lcm(int a,int b){
   return (a*1LL*b)/gcd(a,b);
}*/
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int x,ans;
    for1(i,0,5){
        cin>>x;
        if(!x){
            ans=i+1;
        }
    }
    cout<<ans<<endll;
    return 0;
}

/*

*/




Measured memory_bytes: 3612
N=int(input())
A=list(map(int,input().split()))

l=[0]*60
for i in A:
  for j in range(60):
    if i&(1<<j):l[j]+=1
ans=0
for i in range(60):
  ans+=l[i]*(N-l[i])*(1<<i)
  ans%=10**9+7
print(ans)

Measured memory_bytes: 124452
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
int main(){
    ll n;
    cin>>n;
    vector<ll> x(n),y(n);
    map<pair<ll,ll>,bool> dic;
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
        dic[make_pair(x[i],y[i])]=true;
    }
    if(n==1){
        cout<<1<<endl;return 0;
    }
    vector<pair<ll,ll>> p_cand;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j)    continue;
            p_cand.push_back(make_pair(x[i]-x[j],y[i]-y[j]));
        }
    }
    ll ans=n;
    for(int i=0;i<p_cand.size();i++){
        pair<ll,ll> p=p_cand[i];
        ll tmp=n;
        for(int j=0;j<n;j++){
            if(dic[make_pair(p.first+x[j],p.second+y[j])]){
                tmp--;
            }
        }
        ans=min(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4096
//verma_ankit484

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
const int mod = (int) 1e9+7;

using namespace std;
//using namespace __gnu_pbds;

//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


int32_t main() {
  IOS
  #ifdef AV
  freopen("input.txt", "r", stdin);
  #endif
  int n, d, cnt = 0;
  cin >> n >> d;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    double dist = a * a + b * b;
    dist = sqrt(dist);
    if (dist <= (double)d) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[100002],cnt[100002],i,j,n,m,p,q;
    while(cin>>n)
    {
        p=0;
        memset(cnt,0,sizeof(cnt));
        for(i=0; i<n; i++)
        {
            cin>>a[i];
            cnt[a[i]]++;
        }
        //for(i=0;i<n;i++) cout<<cnt[i]<< " "; cout<<endl;
        for(i=1; i<n; i++)
        {
            if(cnt[i]!=2&&cnt[i]!=0)
            {
                p=1;
                break;
            }
        }
        q=1;
        //cout<<cnt[0]<<endl;
        if(n&1 &&cnt[0]!=1) p=1;
        if(p) cout<<0<<endl;
        else
        {
            for(i=0; i<n/2; i++) q = (q*2)%1000000007;
            cout<<q<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	int n;
	string s;
	cin >> n >> s;
	
	int r = 0, b = 0;
	rep(i,n){
		if(s[i] == 'R')r ++;
		else b ++;
	}
	if(r > b)puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt(),m=sc.nextInt();
        
        int[][] lst = new int[m][n];
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                lst[j][i]=sc.nextInt();
            }
        }
        
        int[] x = new int[m];
        for(int i=0;i<m;i++){
            x[i] = sc.nextInt();
        }
        
        int sum;
        for(int i=0;i<n;i++){
            sum=0;
            for(int j=0;j<m;j++){
                sum+=lst[j][i]*x[j];
            }
            System.out.println(sum);
        }
    }
}


Measured memory_bytes: 40656
#include <stdio.h>
#define MAX 100000
#define SENTINEL 2000000000
 
struct Card {
  char suit;
  int value;
};
 

struct Card L[MAX / 2 + 2], R[MAX / 2 + 2];


 
void merge(struct Card A[], int n, int left, int mid, int right) {
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
   
  for(i = 0; i < n1; i++) 
    L[i] = A[left + i];
   
  for(i = 0; i < n2; i++) 
    R[i] = A[mid + i];
   
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
   
  for(k = left; k < right; k++) {
    if(L[i].value <= R[j].value) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}
 
void mergeSort(struct Card A[], int n, int left, int right) {
  int mid;
   
  if(left + 1 < right) {
    mid = (left + right) / 2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}
 
int partition(struct Card A[], int n, int p, int r) {  
  int i, j;
  struct Card t, x;
   
  x = A[r];
  i = p - 1;
   
  for(j = p; j < r; j++) {
    if(A[j].value <= x.value) {
      i++;
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }


  t = A[i + 1];
  A[i + 1] = A[r];
  A[r] = t;
   
  return i + 1;
}
 
void quickSort(struct Card A[], int n, int p, int r) {  
  int q;
   
  if(p < r) {
    q = partition(A, n, p, r);
    quickSort(A, n, p, q - 1);
    quickSort(A, n, q + 1, r);
  }
}
 
int main(){
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;
   
  scanf("%d", &n);
   
  for(i = 0; i < n; i++) {
    scanf("%s %d", S, &v);
    A[i].suit = B[i].suit = S[0];
    A[i].value = B[i].value = v;
  }
   
  mergeSort(A, n, 0, n);
  quickSort(B, n, 0, n - 1);
   
  for(i = 0; i < n; i++) {
    if(A[i].suit != B[i].suit) 
      stable = 0;
  }
   
  if(stable == 1) printf("Stable\n");
  else printf("Not stable\n");
   
  for(i = 0; i < n; i++) {
    printf("%c %d\n", B[i].suit, B[i].value);
  }
   
  return 0;
}

Measured memory_bytes: 2956
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fr(a,b) for(ll i = a; i < b; i++)
#define mod 1000000007
#define prllDouble(x) cout << fixed << setprecision(10) << x
#define triplet pair<ll,pair<ll,ll>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

struct Box
{
    ll str, wt, val;

    Box(int w, int s, int v)
    {
        str = s;
        wt = w;
        val = v;
    }

    bool operator < (Box B)
    {
        return str + wt > B.str + B.wt;
    }
};

ll solve(vector<Box>& boxes)
{
    ll dp[boxes.size() + 1][10001];

    for(int str = 0; str <= 10000; str++)
        dp[0][str] = (str <= boxes[0].str) ? boxes[0].val : 0;

    for(int box = 1; box < boxes.size(); box++)
    {
        for(int str = 10000; str >= 0; str--)
        {
            ll op1 = boxes[box].val +
                ((str + boxes[box].wt <= 10000) ? dp[box - 1][str + boxes[box].wt] : 0);

            ll op2 = dp[box - 1][str];

            op1 = (str <= boxes[box].str) ? op1 : 0;
            dp[box][str] = max(op1, op2);
        }
    }

    return dp[boxes.size() - 1][0];
}

int main(){
    ll i,j,t,n,m,x,p,k;
    fast_io;
    //cin>>t;
    t=1;
    while(t--)
    {
        cin>>n;
        vector<Box> boxes;
        for(int i = 0 ; i < n; i++)
        {
            ll w,s,v;
            cin >> w >> s >> v;
            boxes.push_back(Box(w,s,v));
        }
        sort(boxes.begin(), boxes.end());
        cout << solve(boxes);
    }
    return 0;
}


Measured memory_bytes: 78464
#include<iostream> 
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a<b){
        if(b<c){
            cout<<a<<" "<<b<<" "<<c<<endl;
        }else if(c<a){
            cout<<c<<" "<<a<<" "<<b<<endl;
        }else{
            cout<<a<<" "<<c<<" "<<b<<endl;
        }
    }else{
        if(a<c){
            cout<<b<<" "<<a<<" "<<c<<endl;
        }else if(c<b){
            cout<<c<<" "<<b<<" "<<a<<endl;
        }else{
            cout<<b<<" "<<c<<" "<<a<<endl;
        }
    }
}


Measured memory_bytes: 3104
#include "bits/stdc++.h"
using namespace std;

#define say(obj) (cout << (obj) << endl)
#define endline (cout << endl)
#define all(container) (container).begin(), (container).end()
#define sortall(container) (sort((container).begin(), (container).end()))
#define yn(cond) ((cond) ? (cout << "yes" << endl) : (cout << "no" << endl))
#define Yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))

typedef long long       ll;

typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<char>    vc;
typedef vector<string>  vs;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvll;
typedef vector<vd>		vvd;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;
typedef vector<vs>		vvs;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;

typedef struct edge_ {
	ll to, cost;
	edge_(ll to, ll cost) : to(to), cost(cost) {}
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

template <typename T>
using mat2d = vector<vector<T>>;

constexpr double	PI = 3.14159265358979323846;
constexpr int		INF = (int)1e7;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template <typename T>
T getSum(std::vector<T>& v) {
	T ret = 0;
	for (T& x : v) ret += x;
	return ret;
}

template <typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;  return is;
}

template <typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second; return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;          return is;
}

template <typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " "; return os;
}

template <typename T>
ostream& operator << (ostream& os, const vector<vector<T>>& mat) {
	for (const vector<T>& m : mat)
		os << m << endl; return os;
}
template <typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " : " << p.second << "}";
	return os;
}

template <typename T>
ostream& operator << (ostream& os, const set<T>& s) {
	for (const T& x : s) os << x << " ";
	return os;
}

ostream& operator << (ostream& os, const edge e) {
	os << "{to: " << e.to << ", cost: " << e.cost << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/

int main()
{
	string S;
	cin >> S;

	if (S == "ABC") say("ARC");
	else say("ABC");






	return 0;
}


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

int main() {

  long long int a,b;

  while ( cin >> a >> b ) {

    long long int k = a+b;

    for ( int i = 1; true; i++ ) {
      if ( k < 10 ) {
	cout << i << endl;
	break;
      }
      k /= 10;
    }

  }

  return 0;

}

Measured memory_bytes: 1164
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ABC088_Csharp
{
    class Program
    {
        static void Main(string[] args)
        {
            int N;
            string line;
            int sumA=0, sumB=0;
            line = Console.ReadLine();
            N = int.Parse(line);

            string[] str = Console.ReadLine().Split(' ');
            List<int> A = new List<int>();
            foreach (string s in str)
            {
                A.Add(int.Parse(s));
            }

            int turn=0;

            while(A.Count>0)
            {
                int max = A.Max();
                A.Remove(max);

                if (turn % 2 == 0) sumA += max;
                else sumB += max;

                turn++;
            }

            int dif = sumA - sumB;

            Console.WriteLine(dif);

        }
    }
}


Measured memory_bytes: 13152
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m;scanf("%d%d",&n,&m);
	int t=sqrt(m),Mx=1;
	for (int i=1;i<=t;i++){
		if (m%i==0)
			if (m/i>=n) Mx=max(Mx,i);
		int p=m/i;
		if (m%p==0)
			if (m/p>=n) Mx=max(Mx,p);
	}
	printf("%d\n",Mx);
	return 0;
}

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

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

	int	n;
	cin >> n;
	vector<double> V(n);
	rep(i, n)
		cin >> V.at(i);
	double	avg;
	avg = round(accumulate(V.begin(), V.end(), 0.0) / (V.size() * 1.0));
	int	sum;
	sum = 0;
	rep(i, n)
		sum += pow(V.at(i) - avg, 2);
	cout << sum << endl;
}


Measured memory_bytes: 256
N = int(input())
S = input()
max_cnt = 0

S_rev = S[::-1]
for i in range(N):
    count = 0
    for c in set(S[:i]):
        if c in S_rev[:-i]:
            count += 1
    max_cnt = max(max_cnt, count)

print(max_cnt)

Measured memory_bytes: 3060
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);

// ===

fn main() {
    let (a, b): (i32, i32) = read();
    if a > b {
        println!("{}", a-1);
    } else {
        println!("{}", a);
    }
}



Measured memory_bytes: 4352
def main(n,h):
    #初期化
    inf = 2 ** 31 -1
    dp = [inf] * n
    dp[0] = 0
    #dp[i+1]とdp[i+2]に配る
    for i in range(n):
        if i+1 <= n-1:
            dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1] - h[i]))
        if i+2 <= n-1:    
            dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2] - h[i]))
    return dp[n-1]

n = int(input())
h = list(map(int, input().split()))
print(main(n,h))

Measured memory_bytes: 13924
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  long long n;
  cin>>n;
  long long a[n];
  REP(i, n) cin>>a[i];
  map<long long, long long> cnt;
  long long ans = 0;
  for(long long i = 0; i < n; i++){
    long long key = i - a[i];
    ans += cnt[key];
    cnt[a[i] + i]++;
  }
  cout << ans << endl;
  return 0;
}


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

signed main(){
	int n,m,x,ans1 = 0,ans2 = 0;
	cin >> n >> m >> x;
	for(int i = 0;i < m;i++){
		int a;
		cin >> a;
		if(a < x) ans1++;
		else ans2++;
	}
	cout << min(ans1,ans2) << endl;
	return 0;
}


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

int main() {
	int resi[5][4][11];
	int n,b,f,r,v;
	for (int b = 1; b <= 4; b++)
		for (int f = 1; f <= 3; f++)
			for (int r = 1; r <= 10; r++)
				resi[b][f][r] = 0;
	cin >> n;
	for (int s = 0; s < n; s++) {
		cin >> b >> f >> r >> v;
		resi[b][f][r] += v;
	}
	for (int b = 1; b <= 4; b++) {
		for (int f = 1; f <= 3; f++) {
			for (int r = 1; r <= 10; r++) {
				cout << " " << resi[b][f][r];
			}
			cout << endl;
		}
		if(b<4) cout << "####################" << endl;
	}
	return 0;
}

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

int a[100010];

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

    int n;cin>>n;

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

    int ans=1;

    int sn=0;
    int pos=0;

    for(int i=0;i<n;i++)if(a[i]!=a[0]){sn=a[i]>a[0]?1:-1;pos=i;break;}

    if(sn!=0)
    {
        for(int i=pos;i<n;i++)
        {
            if((a[i]-a[i-1])*sn<0)
            {
                for(int j=i;j<n;j++)if(a[j]!=a[i]){sn=a[j]>a[i]?1:-1;i=j;break;}
                ans++;
            }
        }
    }

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 4052
#include<stdio.h>

/*構造体の定義*/
typedef struct {
	char suit;
	int value;
} Card ;


void swap_Card(Card *x, Card *y)
{
	Card temp = *x;
	*x = *y;
	*y = temp;
}


int main()
{
	int N;
	scanf("%d\n", &N);

	int i,j;
	Card BC[N];
	Card SC[N];

	for (i = 0; i < N; i++) {
		Card c;
		scanf("%c", &c.suit);
		scanf("%d ", &c.value);
		BC[i] = c;
		SC[i] = c;
	}

	/* Bubble Sort */
    for (i = 0; i < N - 1; i++) {
        for (j = N - 1; j > i; j--) {
            if (BC[j].value < BC[j - 1].value)
                swap_Card(&BC[j], &BC[j - 1]);
        }
    }
	
	/* Selection Sort */
    for (i = 0; i < N - 1; i++) {
        int minj = i;
        for (j = i + 1; j < N; j++) {
            if (SC[j].value < SC[minj].value)
                minj = j;
        }
        swap_Card(&SC[i], &SC[minj]);
    }
	
	/* Output */
	for (i = 0; i < N - 1; i++) {
		printf("%c%d ", BC[i].suit, BC[i].value);
	}
	printf("%c%d\n", BC[N - 1].suit, BC[N - 1].value);
	puts("Stable");

	for (i = 0; i < N - 1; i++) {
		printf("%c%d ", SC[i].suit, SC[i].value);
	}
	printf("%c%d\n", SC[N - 1].suit, SC[N - 1].value);

	for (i = 0; i < N; i++) {
		if (BC[i].suit != SC[i].suit) {
			puts("Not stable");
			return 0;
		}
	}
	puts("Stable");

	return 0;
}


Measured memory_bytes: 2024
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

bool used[26];

int main() {
  string s;
  cin >> s;
  if (s == "zyxwvutsrqponmlkjihgfedcba") {
    cout << -1 << endl;
    return 0;
  }

  if (s.size() < 26) {
    for (int i = 0; i < 26; ++i) used[i] = false;
    for (int i = 0; i < s.size(); ++i) used[s[i]-'a'] = true;
    for (int i = 0; i < 26; ++i) {
      if (!used[i]) {
        s += 'a'+i;
        cout << s << endl;
        return 0;
      }
    }
  }

  if (s.size() == 26){
    for (int i = 0; i < 26; ++i) used[i] = true;

    for (int i = s.size()-1; i > 0; --i) {
      if (s[i-1] > s[i]) {
        used[s[i]-'a'] = false;
      } else {
        used[s[i]-'a'] = false;
        s = s.substr(0, i);
        break;
      }
    }
    
    for (int i = 0; i < 26; ++i) {
      if (!used[i] && 'a' + i > s[s.size()-1]) {
        s[s.size()-1] = 'a' + i;
        cout << s << endl;
        return 0;
      }
    }
  }
}


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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n - 1); i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define each(i, x) for (auto &i : x)
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ld = long double;
template <class T>
using priority_queuel = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-9;
ll mod = static_cast<ll>(1e9 + 7);
template <class T>
constexpr int sz(const T &a) { return (int)a.size(); }
template <class T>
constexpr T pow2(const T a) { return a * a; }
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class A, int N, class T>
void fillArray(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

int n;
void solve() {
    cin >> n;
    map<string, bool> mp;
    rep(i, n) {
        string s;
        cin >> s;
        mp[s] = true;
    }
    cout << mp.size() << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout.flush();
    return 0;
}


Measured memory_bytes: 19236
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
template< typename T >
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;
template< typename T >
T prim(WeightedGraph< T > &g) {
  using Pi = pair< T, int >;
  T total = 0;
  vector< bool > used(g.size(), false);
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  que.emplace(0, 0);
  while(!que.empty()) {
    auto p = que.top();
    que.pop();
    if(used[p.second]) continue;
    used[p.second] = true;
    total += p.first;
    for(auto &e : g[p.second]) {
      que.emplace(e.cost, e.to);
    }
  }
  return total;
}
void dfs(vector<vector<int>> &g2, const vector<vector<int>> &tr, vector<int> &d2, int now, int prev) {
  for(int i=0;i<(int)(tr[now].size());++i) {
    dfs(g2, tr, d2, tr[now][i], now);
  }
  if(now == 0) return;
  if(d2[now] % 2) {
    g2[now].push_back(prev);
  } else {
    g2[prev].push_back(now);
    d2[prev]++;
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n, m; cin >> n >> m;
  vector<vector<int>> g1(n);
  vector<int> d1(n);
  for(int i=0;i<m;++i) {
    int a, b; cin >> a >> b;
    a--; b--;
    g1[a].push_back(b);
    g1[b].push_back(a);
    d1[a]++;
    d1[b]++;
  }
  if(m % 2) {
    cout << -1 << endl;
    return 0;
  }
  vector<vector<int>> tr(n);
  queue<int> que;
  vector<bool> sel(n);
  que.push(0);
  sel[0] = true;
  while(!que.empty()) {
    int now = que.front(); que.pop();
    for(int i=0;i<(int)(g1[now].size());++i) {
      int next = g1[now][i];
      if(sel[next]) continue;
      sel[next] = true;
      tr[now].push_back(next);
      que.push(next);
    }
  }
  vector<vector<int>> g2(n);
  vector<int> d2(n);
  for(int i=0;i<n;++i) {
    for(int j=0;j<(int)(g1[i].size());++j) {
      if(find(tr[i].begin(), tr[i].end(), g1[i][j]) == tr[i].end() &&
        find(tr[g1[i][j]].begin(), tr[g1[i][j]].end(), i) == tr[g1[i][j]].end() &&
        i < g1[i][j]) {
        g2[i].push_back(g1[i][j]);
        d2[i]++;
      }
    }
  }
  dfs(g2, tr, d2, 0, -1);
  for(int i=0;i<n;++i) {
    for(int j=0;j<(int)(g2[i].size());++j) {
      cout << i+1 << " " << g2[i][j] + 1 << endl;
    }
  }
}


Measured memory_bytes: 22020
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
vvl g;
vi a,b;

ll dfs(int v,ll d,int t,int N){
	if(t==N-1) return d;
	a[v]++;
	ll M=0;
	for(int u=0;u<N;u++) if(!a[u]) M=max(M,dfs(u,d+g[v][u],t+1,N));
	a[v]--;
	return M;
}

int main(){
	cin>>n;
	g=vvl(n,vl(n));
	a=b=vi(n);
	g[0][1]=g[1][0]=b[0]=1;
	set<int> st;
	st.insert(1);
	for(int i=1;i<n;i++){
		for(int j=0;j<i-1;j++) st.insert(b[j]+b[i-1]);
		int t=0;
		while(1){
			bool B=1;
			if(st.find(t)!=st.end()) B=0;
			for(int j=0;j<i;j++) if(st.find(b[j]+t)!=st.end()) B=0;
			if(B){
				b[i]=t;
				st.insert(t);
				break;
			}
			t++;
		}
	}
	for(int i=2;i<n;i++){
		ll M=0;
		for(int j=0;j<i;j++){
			a=vi(n);
			M=max(M,dfs(j,0,0,i));
		}
		for(int j=0;j<i;j++) g[i][j]=g[j][i]=(M+1)*b[j];
	}
	for(int i=0;i<n;i++) for(int j=0;j<n;j++) cout<<g[i][j]<<" \n"[j==n-1];
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define x first
#define y second

const int N=1e5+5,C=3;
int n,a[N],ans[N];
set<int> rest;
map<int,int> du;

void dfs(int x,int last,set<int> rest){
	if(x>n){
		for(int i=1;i<=n;i++) write(ans[i]),putchar(' ');
		exit(0);
	}
	for(auto i:rest) if(i!=last){
		ans[x]=i;
		set<int> tp=rest;
		tp.erase(i);
		dfs(x+1,a[i],tp);
	}
}

int check(){
	if(du.size()==2) for(auto i:du) if(i.y==rest.size()-1&&rest.count(i.x)) return i.x;
	return 0;
}

signed main(){
	read(n);
	for(int i=1;i<=n;i++) du[read(a[i])]++,rest.insert(i);
	if(n==2) return write(-1),0;
	int last=0;
	for(int i=1;i<=n-C;i++){
		int cur=check();
		if(cur) ans[i]=cur;
		else{
			auto it=rest.begin();
			if(*it==last) it++;
			ans[i]=*it;
		}
		if(!--du[a[ans[i]]]) du.erase(a[ans[i]]);
		rest.erase(ans[i]);
		last=a[ans[i]];
	}
	dfs(max(1,n-C+1),last,rest);
	write(-1);
}

Measured memory_bytes: 13668
def main():
    n = int(input())
    a = sorted(list(map(int,input().split())))
    ans = []
    for i in range(1,n-1):
        if a[i]>0:
            ans.append([a[0],a[i]])
            a[0] -= a[i]
        else:
            ans.append([a[-1],a[i]])
            a[-1] -= a[i]
    ans.append([a[-1],a[0]])
    print(a[-1]-a[0])
    for x,y in ans:
        print(x,y)

if __name__ == "__main__":
    main()


Measured memory_bytes: 24816
n = int(input())

temp = [1 for i in range(n + 1)]
ans = 1
for i in range(2, n + 1):
    temp[i] += 1
    ans += i * temp[i]
    count = 2
    while i * count <= n:
        temp[i * count] += 1
        count += 1

print(ans)

Measured memory_bytes: 219172
import sys, math, re
from functools import lru_cache
from collections import defaultdict
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    s = input()
    print(s[:4]+' '+s[4:])


if __name__ == '__main__':
    main()

Measured memory_bytes: 9884
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
 
//strcmp : compare function
 
int main(void) {
	int n;
	char str[200000][11];
 
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%s", str[i]);
	qsort(str, n, 11, strcmp);
	int count[200000];
    for (int i = 0; i < n; i++)
        count[i] = 0;
	for (int i = 0; i < n - 1; i++)
		if (strcmp(str[i], str[i + 1])==0) {
			count[i]++;
			count[i + 1] += count[i];
			count[i + 1]++;
		}
	int max = 0;
	for (int i = 0; i < n; i++)
		if (count[i] > max)
		max = count[i];
 
	for (int i = 0; i < n; i++)
		if (count[i] == max)
			printf("%s\n", str[i]);
	return 0;
}

Measured memory_bytes: 5244
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <numeric>
#include <chrono>
#include <bitset>
#include <tuple>
#include <queue>
#include <map>
#include <cstring>
#include <cassert>
using namespace std;
#define ll long long

const int N = 2e5 + 10, mod = 1e9 + 7;


int main() {
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int tc = 1; 
    // scanf("%d", &tc);
    for(int cn = 1; cn <= tc; cn++) {
        int x; scanf("%d", &x);
        map<ll, int> vis;
        map<ll, bool> have;
        for(int i = 0; i <= 4e3; i++) {
            ll cur = 1ll * i * i * i * i * i;
            vis[cur] = i;
            have[cur] = 1;
            int l = i + 1, r = 4e3;
            while(l <= r) {
                int mid = (l + r) >> 1;
                ll cur1 = 1ll * mid * mid * mid * mid * mid;
                if(cur1 - cur > x) r = mid - 1;
                else if(cur1 - cur < x) l = mid + 1;
                else {
                    printf("%d %d\n", mid, i);
                    return 0;
                }
            }
        }
        for(int i = 0; i <= 4e3; i++) {
            ll cur = 1ll * i * i * i * i * i;
            if(have[x - cur]) {
                printf("%d %d\n", i, -vis[x - cur]);
                return 0;
            }
        }
    }  
    return 0;
}

Measured memory_bytes: 4108
s = raw_input()
p = raw_input()
i = 0
while i<len(s):
	k = 0
	while k < len(p):
		if s[(i+k)%len(s)] == p[k]:
			k += 1
		else:
			break
	if k >= len(p):
		print 'Yes'
		break
	i += 1
if k < len(p):
	print 'No'

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

vector<char> v;

void C(){
	v.push_back(v[0]);
	v.erase(v.begin());
}

void J(){
	v.insert(v.begin(),v[v.size()-1]);
	v.pop_back();
}

void E(){
	stack<char> st[2];
	for(int i=0;i<v.size()/2;i++){
		st[0].push(v[i]);
		st[1].push(v[v.size()-1-i]);
	}
	for(int i=0;i<v.size()/2;i++){
		v[i]=st[1].top();
		v[v.size()-1-i]=st[0].top();
		st[0].pop(),st[1].pop();
	}
}

void A(){
	stack<char> st;
	for(int i=0;i<v.size();i++)st.push(v[i]);
	for(int i=0;i<v.size();i++){
		v[i]=st.top();
		st.pop();
	}
}

void M(){
	for(int i=0;i<v.size();i++){
		if(v[i]>='0'&&v[i]<='9'){
			v[i]=((v[i]-'0')+1)%10+'0';
		}
	}
}

void P(){
	for(int i=0;i<v.size();i++){
		if(v[i]>='0'&&v[i]<='9'){
			v[i]=((v[i]-'0')+9)%10+'0';
		}
	}
}

int main(){
	int n;
	string s,q;
	cin>>n;
	while(n--){
		cin>>s>>q;
		v.clear();
		for(int i=0;i<q.size();i++)v.push_back(q[i]);
		for(int i=s.size()-1;i>=0;i--){
			if(s[i]=='J')J();
			if(s[i]=='C')C();
			if(s[i]=='E')E();
			if(s[i]=='A')A();
			if(s[i]=='P')P();
			if(s[i]=='M')M();
		}
		for(int i=0;i<v.size();i++)cout<<v[i];
		cout<<endl;
	}
	return 0;
}

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

int main() {
	int N;
	cin >> N;
	long long res = 0;
	int former = -1;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		if (i == 0) {
			former = a;
		}
		else {
			if (former > a) {
				res += former - a;
			}
			else if (a > former) {
				former = a;
			}
		}


	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define inf 1e10
using namespace std;

//辺。つながっている頂点と辺の重み
struct edge {
  long long req;
  long long v;
};
//入力等々
long long n, m, u, p, s, maxn = inf, minn = 0, uniquen = -1;
bool nothing = 0;
//条件のメモ。元と同じ値を取っていたらアウトなのでnothingを1に。偶奇違うパターンの時は答えが一意に決まる。
long long memo[2][100005] = {0};
//辺のデータリスト
vector<edge> data[100005];
//再帰。偶奇、現在の地点、一個前の頂点、一個前の合計値
void solve(bool eo, long long now, long long bfreq, long long bfv);

int main() {
  long long i, j;
  edge dummy;
  //入力
  cin >> n >> m;
  for(j = 0; j < 2; ++j)
    for(i = 1; i <= n; ++i) memo[j][i] = inf;
  for(i = 0; i < m; ++i) {
    cin >> u >> p >> s;
    dummy.req = u;
    dummy.v = s;
    data[p].push_back(dummy);
    dummy.req = p;
    data[u].push_back(dummy);
  }
  // memo[0][1] = 0;
  solve(1, 1, -1, 0);
  //解は存在するか＞
  if(nothing || (maxn == inf && minn == 0) || (maxn - minn - 1 < 0)) {
    maxn = 1;
    minn = 0;
  }
  //解は唯一であるか？
  else if(uniquen >= 0) {
    //その解は条件を満たしているか？
    if(uniquen > minn && uniquen < maxn) {
      maxn = 2;
      minn = 0;
    }
    else {
      maxn = 1;
      minn = 0;
    }
  }
  cout << maxn - minn - 1 << endl;
  return 0;
}

void solve(bool eo, long long now, long long bfreq, long long bfv) {
  if(nothing) return;
  memo[!eo][now] = bfv;
  long long i, nextv;
  //今いる頂点につながっているすべての辺を通り別の頂点に行く。
  for(i = 0; i < data[now].size(); ++i) {
    //一個前の頂点に戻るか？
    if(data[now][i].req == bfreq) continue;
    //次の頂点の条件の計算
    nextv = bfv;
    if(eo)
      nextv += data[now][i].v;
    else
      nextv -= data[now][i].v;
    //ある頂点で条件が重複しありえないパターンになっていないか？辺の重みがあり得ない値になっていないか？
    if((memo[eo][data[now][i].req] != inf &&
        memo[eo][data[now][i].req] != nextv)) {
      nothing = 1;
      return;
    }
    //すでに通ってたら中断して次の辺へ
    else if(memo[eo][data[now][i].req] == nextv)
      continue;
    // memo[eo][data[now][i].req] = nextv;
    //頂点に偶奇両方のデータが存在するとき、その和の半分が唯一の答えとなる。
    if(memo[!eo][data[now][i].req] != inf) {
      long long test = nextv + memo[!eo][data[now][i].req];
      if(test <= 0 || test % 2 != 0 || (uniquen != -1 && uniquen != test / 2)) {
        nothing = 1;
        return;
      }
      uniquen = test/2;
    }
    //minn,maxnの更新。できるだけ条件を厳しくする。
    if (eo && maxn > nextv)maxn = nextv;
    if (!eo && minn < nextv)minn = nextv;
    //再帰
    solve(!eo, data[now][i].req, now, nextv);
  }
}

Measured memory_bytes: 24064
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int stx,sty;
int n;
bool ans=false;
P sp[12];
int dx[12]={2,2,2,1,1,0,0,-1,-1,-2,-2,-2};
int dy[12]={1,0,-1,2,-2,2,-2,2,-2,1,0,-1};
bool ok(int num,int x,int y)
{
	return (abs(sp[num].fi-x)<2)&&(abs(sp[num].sec-y)<2);
}
void dfs(int num,int x,int y)
{
	if(ans==true)return;
	if(num==n)
	{
		ans=true;
		return;
	}
	for(int i=0;i<12;i++)
	{
		int sx=dx[i]+x,sy=dy[i]+y;
		if(sx<0||sx>9||sy<0||sy>9)continue;
		if(!ok(num,sx,sy))continue;
		//cout << num << " OK" << endl;
		dfs(num+1,sx,sy);
	}
	return ;
}
int main()
{
	while(1)
	{
		ans=false;
		scanf("%d %d",&stx,&sty);
		if(stx==0&&sty==0)break;
		scanf("%d",&n);
		for(int i=0;i<n;i++)
		{
			scanf("%d %d",&sp[i].fi,&sp[i].sec);
		}
		dfs(0,stx,sty);
		if(ans)
		{
			cout << "OK" << endl;
		}
		else
		{
			cout << "NA" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1200