akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main(){
	
	ios::sync_with_stdio(false); cin.tie(0);
	int N; cin >> N;
	string a, b; cin >> a >> b;

	for(int i = 0; i < (int) a.size(); i++)
		cout << a[i] << b[i];
	cout << '\n';

	return 0;
}

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

using namespace std;
using pi=pair<int, int>;
const int inf = 0x3f3f3f3f;

const int V = 512;
const int E = 10010<<2;
int sson[V], pre[V], dis[V], trk[V];
int cnt;

struct node{
    int to, bro, cap, flow, cost;
} edge[E];

void init(){
    cnt = 0;
    memset(sson, -1, sizeof sson);
}

void add_edge(int u, int v, int cap, int cost){
    edge[cnt] = {v, sson[u], cap, 0, cost};
    sson[u] = cnt++;
    edge[cnt] = {u, sson[v], 0, 0, -cost};
    sson[v] = cnt++;
}

bool spfa(int s, int t){
    queue<int> q;
    memset(pre, -1, sizeof pre);
    memset(dis, inf, sizeof dis);
    memset(trk, 0, sizeof trk);
    dis[s] = 0; trk[s] = 1; q.push(s);
    while(!q.empty()){
        int u = q.front(); q.pop(); trk[u] = 0;
        for (int e=sson[u]; ~e; e=edge[e].bro){
            int v = edge[e].to;
            if (edge[e].cap > edge[e].flow && dis[v] > dis[u] + edge[e].cost){
                dis[v] = dis[u] + edge[e].cost;
                pre[v] = e;
                if (!trk[v]){
                    trk[v] = 1;
                    q.push(v);
                }
            }
        }
    }
    return pre[t] != -1;
}

pi mcmf(int s, int t){
    int flow = 0, cost = 0;
    while (spfa(s, t)){
        int f = inf;
        for (int e=pre[t]; ~e; e=pre[edge[e^1].to])
            f = min(f, edge[e].cap - edge[e].flow);
        for (int e=pre[t]; ~e; e=pre[edge[e^1].to]){
            edge[e].flow += f;
            edge[e^1].flow -= f;
            cost += edge[e].cost * f;
        }
        flow += f;
    }
    return {flow, cost};
}


void solve() {
    int n,m;
    cin >> n >> m;
    vector<string> s(n);    
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    pair<int, int> Sp, Tp;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (s[i][j] == 'S') Sp ={i,j};
            if (s[i][j] == 'T') Tp ={i,j};
        }
    }
    if (Sp.first == Tp.first || Sp.second == Tp.second) {
        cout << -1; return;
    }

    init();
    int S = 0, T = n+m+1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (s[i][j]=='o') {
                add_edge(i+1, n+j+1, 1, 0);
                add_edge(n+j+1, i+1, 1, 0);
            }
            if (s[i][j]=='S') {
                add_edge(S, i+1, inf, 0);
                add_edge(i+1, S, inf, 0);
                add_edge(S, n+j+1, inf, 0);
                add_edge(n+j+1, S, inf, 0);
            }
            if (s[i][j]=='T') {
                add_edge(T, i+1, inf, 0);
                add_edge(i+1, T, inf, 0);
                add_edge(T, n+j+1, inf, 0);
                add_edge(n+j+1, T, inf, 0);
            }
        }
    }

    int res = mcmf(S,T).first;
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<ll, ll>
#define SZ(x) ((int)(x).size())
// #define endl "\n"
#define vvi vector<vector<int> >
#define vvl vector<vector<long long> >
ll mod = 1e9 + 7;
//const double pi = acos(-1.0);
/*
ll kmp(string x)
{
    ll n= x.length();
    //cout<<x<<endl;
    vector<ll> lcp(x.length(), 0);
    for(ll i=1;i<n;i++)
    {
        ll j=lcp[i-1];
        while(j>0 && x[j]!=x[i])
            j=lcp[j-1];
        if(x[i]==x[j])
            j++;
        lcp[i]=j;
    }
    return lcp[n-1];
}

int N = 1000002;
int ar[100002];
void sieve()
{
    for(int i=1;i<=N;i++)
        ar[i] = 1;
    ar[0] = 0;
    for(int i=2;i*i<=N;i++)
    {
        if(ar[i] && i*i<=N)
        {
            for(int j = i*i; j<=N;j+=i)
                ar[j] = 0;
        }
    }
}

ll modex(ll a,ll b){
    if(b<=0){
        return 1;
    }
    if(b%2==0)
    {
        ll x = modex(a, b/2);
        return ((x*x)%mod);
    }
    else
        return ((a%mod * modex(a, b-1))%mod);
}

ll c[1010][1010];

ll combina(ll i, ll j){
        for (int i=0;i<=1005;i++)
        for (int j=0;j<=i;j++)
        {
            if (j==i||j==0)
                c[i][j]=1;
            else
            c[i][j]=c[i-1][j-1]+c[i-1][j];
            c[i][j]%=mod;
        }
        return c[i][j];
}
void find_fac(int x){
    vector<ll> di;
    for(ll i = 2; i*i <= x; i++)
    {
        if(x%i==0){
            di.push_back(i);
            while(x%i==0)
                x/=i;
        }
    }
    if(x > 1)
        di.push_back(x);
}
*/



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed;
    cout.precision(12);
    ll k;
    cin>>k;
    if(k%7==0)
        k/=7;
    int l = 0;
    for(int i=0;i<=k;i++){
        l = (l*10 + 1)%k;
        if(l==0)
        {
            cout<<i+1;
            return 0;
        }
    }
    cout<<-1;
    return 0;
}


Measured memory_bytes: 3604
#include <stdio.h>

int main(void) {
  int n,b[101]={},ans[101]={},N,t_N,flag;
  scanf("%d",&N);
  t_N=N;
  for(int i=1;i<=t_N;i++){scanf("%d",&b[i]);}
  while(t_N!=0){
    flag=1;
    for(int i=t_N;i>=1;i--){
      if(b[i]==i){
        for(int j=i;j<=t_N-1;j++){b[j]=b[j+1];}
        ans[t_N]=i;
        b[t_N]=0;
        t_N--;
        flag=0;
        break;
      }
    }
    if(flag){
      printf("-1");
      return 0;
    }
  }
  for(int i=1;i<=N;i++){printf("%d\n",ans[i]);}
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  string ans;
  if(e-a<=k){
    ans="Yay!";
  }else{
    ans=":(";
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int x,y,a;
	int i = 0;
	
	while(1){
		i++;
		scanf("%d %d",&x,&y);
		if(x == 0 && y == 0)break;
		
		if(x > y){
			a = x;
			x = y;
			y = a;
		}
		printf("%d %d\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 596
N=int(input())
a=[]
visitflag=0
count=0
for i in range(N):
    suc=int(input())
    a.append([suc,visitflag])

i=0
#print(a)
#input()
while True:
    if a[i][1]==0:
        a[i][1]=1
        success=(a[i][0])-1
        i=success
        count=count+1
        if i==1:
            print(count)
            break
    else:
        print("-1")
        break
    #print(a)
    #input()

Measured memory_bytes: 57560
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

const int mx = 200010;
int n;
int q;
vector<int> g[mx];
long long cnt[mx];
long long ans[mx];

void dfs(int v = 0, int p = -1, int now = 0){
    now += cnt[v];
    ans[v] += now;
    for(int i : g[v]){
        if(i != p)dfs(i, v, now);
    }
}

// AtCoder Beginner Contest 138
//オーバーフローに注意！！
//焦らずに！！
int main(){

    cin >> n >> q;
    rep(i, n - 1){
        int a, b; cin >> a >> b; a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    rep(i, q){
        int p; cin >> p; p--;
        long long x; cin >> x;
        cnt[p] += x;
    }

    dfs();
    rep(i, n){
        if(i)cout << ' ';
        cout << ans[i];
    }
    cout << endl;

}

Measured memory_bytes: 25600
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
//template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
//template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e9+7;


int main()
{
    string s;
    cin >> s;
    ll cnt=0;
    ll ans=0;
    ll n=s.length();
    rep(i,n){
        if(s[i]=='S'){
            cnt++;
        }
        else{
            if(cnt){
                cnt--;
                ans+=2;
            }
        }
    }
    cout << n-ans << endl;
    return 0;
} 


Measured memory_bytes: 640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class BJudgeStatusSummary {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        map<string, int> cnt;
        REP(i, N) {
            string s;
            cin >> s;
            cnt[s]++;
        }
        cout << "AC x " << cnt["AC"] << endl;
        cout << "WA x " << cnt["WA"] << endl;
        cout << "TLE x " << cnt["TLE"] << endl;
        cout << "RE x " << cnt["RE"] << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BJudgeStatusSummary solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3660
MOD = 10 ** 9 + 7

def fact(n)
  @memo ||= []
  @memo[n] ||= (n==0) ? 1 : (n * fact(n-1)) % MOD;
end

def modpow(x,n)
  ret = 1
  while n > 0
    ret = (ret * x) % MOD if n&1 == 1
    x = (x*x) % MOD
    n >>= 1
  end
  return ret
end

def combin(n,k)
  return (((fact(n) * modpow(fact(n-k),MOD-2)) % MOD) * modpow(fact(k),MOD-2)) % MOD
end

n,m = gets.split.map(&:to_i)

(n+100).times do |i|
  fact(i)
end
exp = []
2.upto((m**0.5).to_i) do |i|
  e = 0
  while m % i == 0
    e += 1
    m /= i
  end
  exp << e if e > 0
end
exp << 1 if m != 1

ans = 1
exp.each do |k|
  ans = (ans * combin(n+k-1,k)) % MOD
end
p ans


Measured memory_bytes: 2756
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<random>
#include<ctime>
#include<cstdlib>
#include<complex>
#include<fstream>
using namespace std;

int main(){

  string n;
  int f=0, x=0;

  cin >> n;

  int y=n.size();

  for(int i=0; i<y; i++){
    if(n[i]=='0'){
      f+=0;
      x+=0*pow(10, y-i-1);
    } else if(n[i]=='1'){
      f+=1;
      x+=1*pow(10, y-i-1);
    } else if(n[i]=='2'){
      f+=2;
      x+=2*pow(10, y-i-1);
    } else if(n[i]=='3'){
      f+=3;
      x+=3*pow(10, y-i-1);
    } else if(n[i]=='4'){
      f+=4;
      x+=4*pow(10, y-i-1);
    } else if(n[i]=='5'){
      f+=5;
      x+=5*pow(10, y-i-1);
    } else if(n[i]=='6'){
      f+=6;
      x+=6*pow(10, y-i-1);
    } else if(n[i]=='7'){
      f+=7;
      x+=7*pow(10, y-i-1);
    } else if(n[i]=='8'){
      f+=8;
      x+=8*pow(10, y-i-1);
    } else if(n[i]=='9'){
      f+=9;
      x+=9*pow(10, y-i-1);
    }
  }

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

  return 0;
}

Measured memory_bytes: 256
def g(A,l,m,r):
 global c
 L,R=A[l:m]+[1e9],A[m:r]+[1e9]
 i=j=0
 for k in range(l,r):
  if L[i]<R[j]:A[k]=L[i];i+=1;c+=j
  else:A[k]=R[j];j+=1
def s(A,l,r):
 if l+1<r:m=(l+r)//2;s(A,l,m);s(A,m,r);g(A,l,m,r)
def m():
 n,A=int(input()),list(map(int,input().split()))
 s(A,0,n);print(c)
if'__main__'==__name__:c=0;m()


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

int main(){
  long long N, Y;
  cin >> N >> Y;
  long long res10000 = -1, res5000 = -1, res1000 = -1;
  for (long long a = 0; a <= N; a++) {
    for (long long  b = 0; b + a <= N; b++) {
      long long c = N - a - b;
      long long total = 10000*a + 5000*b + 1000*c;
      if (total == Y) {
        res10000 = a;
        res5000 = b;
        res1000 = c;
      }
    }
  }

  cout << res10000 << " " << res5000 << " " << res1000 << endl;
}


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

#define INF 1e18;
#define MAX_N 100005
long long N, h[MAX_N], memo[MAX_N];

int main() {
  cin >> N;
  for (int i = 1; i <= N; i++) {
  	cin >> h[i];
  }
  memo[2] = abs(h[2] - h[1]);
  for (int i = 3; i <= N; i++) {
  	memo[i] += min(abs(h[i] - h[i - 1]) + memo[i - 1], abs(h[i] - h[i - 2]) + memo[i - 2]);
  }
  /*
  for (int i = 1; i <= N; i++) {
  	cout << i << ' ' << memo[i] << '\n';
  }
  */
  cout << memo[N] << '\n';
}

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

#define gc getchar()
inline int read(){
	int x=0;char c=gc;
	for(;c<48||c>57;c=gc);
	for(;c>47&&c<58;c=gc)
		x=x*10+c-48;
	return x;
}
#define io read()

#define maxn 100005
#define maxm 200005
int n,m,q;
int st[maxn],pv[maxm],p1[maxm],tot;
inline void side(int u,int v){
	pv[++tot]=v;
	p1[tot]=st[u];
	st[u]=tot;
}

struct data{
	int t,c;
	data(int tm=0,int cl=0):t(tm),c(cl){}
	inline void operator=(const data &d){
		if(t<d.t)t=d.t,c=d.c;
	}
}a[maxn][11];

inline void init(){
	n=io;m=io;
	for(int i=1;i<=m;++i){
		int u=io,v=io;
		side(u,v);side(v,u);
	}
	q=io;
	for(int i=1;i<=q;++i){
		int x=io,d=io,c=io;
		a[x][d]=data(i,c);
	}
}

inline void solve(){
	for(int d=10;d;--d)
		for(int x=1;x<=n;++x){
			a[x][d-1]=a[x][d];
			for(int i=st[x];i;i=p1[i]){
				int v=pv[i];
				a[v][d-1]=a[x][d];
			}
		}
	for(int i=1;i<=n;++i)printf("%d\n",a[i][0].c);
}

int main(){
	init();
	solve();
	return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//get the biggest element.
template<typename KeyType, typename ValueType>
std::pair<KeyType,ValueType> get_max( const std::map<KeyType,ValueType>& x ) {
  using pairtype=std::pair<KeyType,ValueType>;
  return *std::max_element(x.begin(), x.end(), [] (const pairtype & p1, const pairtype & p2) {
        return p1.second < p2.second;
  });
}
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;

int main() {
  int n;
  cin >> n;
  vector<int> a(100);
  rep (i, n) {
    int x;
    cin >> x;
    --x;
    a[x] += 1;
  }

  int ans = 1e6;
  int total;
  rep (i, 100) {
    total = 0;
    rep (j, 100) {
      if (a[j] == 0) continue;
      total += pow(i - j, 2) * a[j];
    }
    ans = min(ans, total);
  }

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


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n,k;cin>>n>>k;
    ll res = 1;
    rep(i,n){
        res = min(res*2,res+k);
    }
    out(res);
}


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();
    int k = sc.nextInt();
    double ans=0;
    for(int i = 1;i<=n;i++){
      int pt = i;
      for(int j = 0;;j++){
        if(pt>=k){
          ans += Math.pow(0.5,j);
          break;
        }else{
          pt = pt*2;
        }
        
      }
    }
    ans = ans/n;
    System.out.println(String.format("%.10f", ans));
  }
}

Measured memory_bytes: 21076
#include<iostream>
using namespace std;
int A[100000];
int main(){
  for(int i = 2;i < 317;++i){
    int j = 2;
    while(i * j < 100000){
      A[i * j] = 1;
      j += 1;
    }
  }

  int X;cin >> X;
  for(int i = X;i < 100000;++i){
    if(A[i] == 0){
      cout << i;
      return 0;
    }
  }
  cout << 100003;
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time 

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(A, B, X):
    for x in X:
        i = bisect.bisect_left(A, x)
        la = A[i-1] if i > 0 else sys.maxsize
        ra = A[i] if i < len(A) else sys.maxsize

        i = bisect.bisect_left(B, x)
        lb = B[i-1] if i > 0 else sys.maxsize
        rb = B[i] if i < len(B) else sys.maxsize

        # print(x, la, ra, lb, rb, abs(rb-x))
        e =  max(abs(x-la), abs(x-lb)) 
        f =  max(abs(ra-x), abs(rb-x))
        g = min(abs(la-x), abs(rb-x))*2 + max(abs(la-x), abs(rb-x))
        h = min(abs(ra-x), abs(lb-x))*2 + max(abs(ra-x), abs(lb-x))
        print(min(e, f, g, h))


def main():
    # N = read_int()
    AN, BN, Q = read_int_n()
    A = [read_int() for _ in range(AN)]
    B = [read_int() for _ in range(BN)]
    X = [read_int() for _ in range(Q)]
    slv(A, B, X)


if __name__ == '__main__':
    main()


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

int main(){
    int n;
    string s;
    cin >> n >> s;
    int rn = 0;
    int bn = 0;
    for(auto&& c : s)
    {
        if (c == 'R') {
            rn++;
        }
        else {
            bn++;
        }
    }
    cout << (rn > bn ? "Yes" : "No") << "\n";
}

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

lint gcd(lint a, lint b) {
  lint tmp;
  while(a % b != 0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}

lint lcm(lint a, lint b) {
  return a * b / gcd(a, b);
}

int main() {
  lint A, B, C, D;
  cin >> A >> B >> C >> D;

  lint all = B - A + 1;
  lint Cn = B / C - (A-1) / C;
  lint Dn = B / D - (A-1) / D;

  lint E = lcm(C, D);
  lint En = B / E - (A-1) / E;

  cout << all - (Cn + Dn - En) << "\n";
}


Measured memory_bytes: 256
n = int(input())
l = input().split(" ")
L = l[:]
for k in range(n - 1):
    for j in range(n - 1, 0, -1):
        if L[j][1:] < L[j - 1][1:]:
            L[j], L[j - 1] = L[j - 1], L[j]
    m = l[k:].index(min(l[k:], key=lambda x: x[1]))
    if m != 0:
        l[k], l[m + k] = l[m + k], l[k]
print(*L)
print("Stable")
print(*l)
print(['Not s', 'S'][l == L] + 'table')


Measured memory_bytes: 5612
n = int(input())
ans = ''
alf = ['a', 'b', 'c', 'd', 'e','f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' ]
order = 0
def func(m):
    return int(26 * (26**m-1) / 25 + 0.5)
# print(func(12))
for i in range(11, 0, -1):
    if n > func(i):
        n = n-func(i)
        order = i
        break
for i in range(order, 0, -1):
    if n % 26**i == 0:
        m = n//(26**i) - 1
        n -= m * 26 ** i
        ans += alf[m]
    # print(n)
    # print(m)
    else:
        m = n // 26**i
        n %= 26**i
        ans += alf[m]
ans += alf[n-1]
print(ans)


Measured memory_bytes: 9232
// 0226
#include <iostream>
#include <string>
using namespace std;

int main(){
	while(1){
		int hit = 0, blow = 0;
		string num[2];

		cin>>num[0]>>num[1];
		if((num[0] == "0") && (num[1] == "0"))
			break;
		
		for(int i=0;i<4;i++)
			for(int j=0;j<4;j++)
				if(num[0][i] == num[1][j])
					if(i == j)
						hit++;
					else
						blow++;
		
		cout<<hit<<" "<<blow<<endl;
	}
	return 0;
}

Measured memory_bytes: 1188
# -*- coding: utf-8 -*-
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
F = int(input())

X = [A, B, C, D]
X.sort()
ans = X[1] + X[2] + X[3] + max(E, F)
print(ans)



Measured memory_bytes: 5600
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

H,W = LI()
Ch,Cw = LI()
Dh,Dw = LI()

Q = [list(map(str,input())) for _ in range(H)]
D = [(0,1),(0,-1),(-1,0),(1,0)]

visited = [[-1]*W for _ in range(H)]

s = (Ch-1,Cw-1)
c = 0
visited[Ch-1][Cw-1] = c
S = [s]
Sc = [s]
while True:
    while S:
        v = S.pop()
        for d in D:
            new = (v[0]+d[0],v[1]+d[1])
            if new[0] == Dh-1 and new[1] == Dw-1:
                print(c)
                exit()
            if 0 <= new[0] < H and 0 <= new[1] < W and Q[new[0]][new[1]] == '.' and visited[new[0]][new[1]] == -1:
                visited[new[0]][new[1]] = c
                S.append(new)
                Sc.append(new)
    c += 1
    S = []
    for v in Sc:
        for i in range(-2,3):
            for j in range(-2,3):
                new = (v[0]+i,v[1]+j)
                if new[0] == Dh-1 and new[1] == Dw-1:
                    print(c)
                    exit()
                if 0 <= new[0] < H and 0 <= new[1] < W and visited[new[0]][new[1]] == -1 and Q[new[0]][new[1]] == '.':
                    S.append(new)
                    visited[new[0]][new[1]] = c
    if not S:
        break
    Sc = S[:]
    
print(-1)

Measured memory_bytes: 127152
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        SimpleStringQueries solver = new SimpleStringQueries();
        solver.solve(1, in, out);
        out.close();
    }

    static class SimpleStringQueries {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            char[] s = in.next().toCharArray();
            List<TreeSet<Integer>> list = new ArrayList<>();
            for (int i = 0; i < 26; i++) {
                list.add(new TreeSet<>());
            }

            for (int i = 0; i < s.length; i++) {
                TreeSet<Integer> set = list.get(s[i] - 'a');
                set.add(i);
            }
            int q = in.nextInt();
            for (int j = 0; j < q; j++) {

                int num = Integer.parseInt(in.next());
                if (num == 1) {
                    int i = Integer.parseInt(in.next()) - 1;
                    char c = in.next().charAt(0);
                    Set<Integer> fromTarget = list.get(s[i] - 'a');
                    fromTarget.remove(i);

                    Set<Integer> toTarget = list.get(c - 'a');
                    toTarget.add(i);

                    s[i] = c;
                } else {
                    int l = Integer.parseInt(in.next()) - 1;
                    int r = Integer.parseInt(in.next());
                    long result = 0;
                    for (int i = 0; i < 26; i++) {
                        TreeSet<Integer> set = list.get(i);
                        if (set.isEmpty()) {
                            continue;
                        }
                        int lpos = set.ceiling(l) == null ? Integer.MAX_VALUE : set.ceiling(l);
                        int rpos = set.ceiling(r) == null ? Integer.MAX_VALUE : set.ceiling(r);
                        if (lpos < rpos) {
                            result++;
                        }
                    }
                    out.println(result);
                }
            }
        }

    }
}



Measured memory_bytes: 105584
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
typedef long long int ll;

const int MAX_C=16;
const int MAX_Y=256;
const int MAX_N=20000;
const ll INF=(ll)MAX_Y*MAX_Y*MAX_N;
ll c[MAX_C];
ll x[MAX_N];
ll dp[MAX_Y][MAX_N+1];
int n,m;

ll sq(ll a){return a*a;}
void solve(){
  REP(i,MAX_Y) dp[i][n]=0;
  for(int j=n-1;j>=0;j--){
    REP(i,MAX_Y){
      dp[i][j]=INF;
      REP(k,m){
	int yn1 = i+c[k]; yn1=min(max(yn1,0),MAX_Y-1);
	dp[i][j]=min(dp[i][j],dp[yn1][j+1]+sq(i-x[j]));
      }
    }
  }
  ll result=INF;
  REP(k,m){
    int yn1=128+c[k]; yn1=min(max(yn1,0),MAX_Y-1);
    result=min(result,dp[yn1][0]);
  }
  cout<<result<<endl;
}


int main(){ _;
  while(cin>>n>>m,(n|m)!=0){
    REP(i,m) cin>>c[i];
    REP(i,n) cin>>x[i];
    solve();
  }
}

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

int main(){
    int a, b;
    cin >> a >> b;
    int big;
    int small;
    if (a > b){
        big = a;
        small = b;
    } else {
        big = b;
        small = a;
    }

    if ((big - small)%2==0){
        cout << (big + small) / 2 << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;

}

Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N,C;
	cin >> N >> C;
	vector< vector< vector<int> > > sj(C);
	for(int i=0;i<N;++i){
		vector<int> dat(2);
		int ch;
		cin>>dat[0]>>dat[1]>>ch;
		dat[0] *=2;
		dat[1] *=2;
		--ch;
		sj[ch].push_back( dat );
	}
	vector< vector<int> > time;

	for(int c=0;c<C;++c){//各チャンネルの幅をまとめる
		sort( sj[c].begin(), sj[c].end() );
		int size = sj[c].size();
		
		int start,end;
		start=0;end=0;//[start,end)
		for(int i=0;i<size;++i){
			if( end != sj[c][i][0] ){//前の終わりと次の始まりが不一致
				if( start!=end ){//初期値回避
					//[start,end)を改良版として登録
					vector<int> temp(2);
					temp[0] = start;
					temp[1] = end;
					time.push_back( temp );
				}
				start = sj[c][i][0];
				end = sj[c][i][1];
			}else{
				//連続で撮る。終了時間の更新
				end = sj[c][i][1];
			}
		}
		if( start != end ){
			vector<int> temp(2);
			temp[0] = start;
			temp[1] = end;
			time.push_back( temp );
		}
	}

	sort( time.begin(), time.end() );
	
	vector<int> REC;
	priority_queue<int,vector<int>,greater<int> >minpq;
	int num = time.size();
	for(int i=0;i<num;++i){
		bool SetFlag = false;
		int ter = time[i][0]-1;
		if( minpq.size() ){
			if( minpq.top() <= ter ){
				minpq.pop();
				minpq.push( time[i][1] );
				SetFlag = true;
			}
		}

		if( SetFlag == false ){
			minpq.push( time[i][1] );
		}
	}
	cout << minpq.size() << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 12980
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int n, m;

main(){
	cin >> n >> m;
	vi d(n), c(n);
	REP(i, n) cin >> d[i];
	REP(i, m){
		int x;
		cin >> x;
		for(int j=0;d[j]>x||!(++c[j]);j++);
	}
	cout << (max_element(ALL(c)) - c.begin() + 1) << endl;
	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const double PI=3.14159265358979323846;
const int64_t waru = 1000000007;
const in INF=1<<30;
#define vec2(a,y,x) vector<vector<int>> a(y,vector<int>(x))
#define vec1(a,n) vector<in> a(n);rep(i,n)cin>>a[i]

int main(){
in n;
  cin>>n;
  vec1(a,n);
  sort(all(a));
  bool x=false;
  rep(i,n-1){
     if(a[i]==a[i+1]){x=true;break;}
  }
  if(x) cout<<"NO";
  else cout<<"YES";
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
using namespace std;





int main() {
	//cout << fixed << setprecision(10);
	
	
	long long int n, m, a, b, c, d,k,cou=1;
	string str;
	cin >> a >> b >> k;
	for (int i = max(a, b); i >= 1; i--) {
		if (cou == k && a%i == 0 && b%i == 0){
			cout << i;
			return 0;
		}else if (a%i == 0 && b%i == 0) {
			cou++;
		}
	}
}

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

int main(void) {
	int n, x, y, t;
	int ox = 0, oy = 0;
	bool flag = true;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t >> x >> y;

		if (t % 2 != (x + y) % 2)flag = false;

		if (abs(x - ox) + abs(y - oy) > t)flag = false;
		ox = x;
		oy = y;
	}
	
	if(flag)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<vector>
#include<tuple>
#include<queue>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>

using namespace std;

int main(int argc, char* argv[]){
  int n,t,a;
  cin >> n >> t >> a;
  double h[1001];
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  double c[1001];
  for(int i=0;i<n;i++){
    c[i] = t - h[i]*0.006;
  }
  int ans = 0;
  for(int i=0;i<n;i++){
    if(fabs(a-c[ans]) > fabs(a-c[i])){
      ans = i;
    }
  }
  cout << ans+1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
long long n,f=log10(n)+1,b;
  cin>>n;
  double m=sqrt(n);
  for(long long i=1;i<=m;i++){
  if(n%i==0){
  b=log10(n/i)+1;
	f=b;
  }
  }
    cout<<f<<endl;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 2e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    string S; cin >> S;
    vi count(26, 0);
    REP(i, S.length())
    {
        if(count[S[i]-'a'] == 1)
        {
            cout << "no" << endl;
            return;
        }
        count[S[i]-'a']++;
    }
    cout << "yes" << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();

    return 0;
}

Measured memory_bytes: 256
S = list(map(str,input()))
gap =1000 #初期gap、最大753

for i in range(len(S)-2):
    target=S[int(i):int(i)+3]#ターゲットの切り出し
    # print('target:',target)
    # print(abs(753 - int(''.join(target))))
    if gap > abs(753 - int(''.join(target))):
        gap = abs(753 - int(''.join(target)))

print(gap)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main()
{
  int n;
  cin >> n;
  
  int v[n];
  rep(i,n) cin >> v[i];
  int c[n];
  rep(i,n) cin >> c[i];
  
  int ans = 0;
  rep(i,n){
    if(v[i] - c[i] > 0){
      ans += v[i] - c[i];
    }
  }
  
  cout << ans << endl;
}

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

int main()
{
  string s;
  cin >> s;
  int i;
  int ch = 0;
  string t = "YAKI";
  if(s.size() < 4)
  {
    ch = 1;
  }
  if(ch == 0)
  {
    for(i = 0; i < 4; i++)
    {
      if(s.at(i) != t.at(i))
      {
        ch = 1;
        break;
      }
    }
  }
  if(ch == 0)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
/*
 * main.c
 *
 *  Created on: 2019/07/21
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int A[100001] = {0};

int main()
{
	int N = 0, i = 0;
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		int num = 0;
		scanf("%d", &num);
		A[num-1] = i;
	}
	for (i = 0; i < N; i++) {
		printf("%d ", A[i]+1);
	}
	printf("\n");
    return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}

int H,W;
string grid[2000];
int L[2000][2000],R[2000][2000],U[2000][2000],D[2000][2000];

void make_table(){
    // left
    REP(i,H){
        int cnt = 0;
        REP(j,W){
            if(grid[i][j]=='#') cnt=0;
            else L[i][j] = cnt++;
        }
    }
    // right
    REP(i,H){
        int cnt = 0;
        for(int j=W-1;j>=0;--j){
            if(grid[i][j]=='#') cnt=0;
            else R[i][j] = cnt++;
        }
    }
    // up
    REP(i,W){
        int cnt = 0;
        REP(j,H){
            if(grid[j][i]=='#') cnt=0;
            else U[j][i] = cnt++;
        }
    }
    // down
    REP(i,W){
        int cnt = 0;
        for(int j=H-1;j>=0;--j){
            if(grid[j][i]=='#') cnt=0;
            else D[j][i] = cnt++;
        }
    }   
    return;
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> H >> W;
    REP(i,H) cin >> grid[i];
    make_table();
    int ans = 0;
    REP(i,H) REP(j,W) chmax(ans,L[i][j]+R[i][j]+U[i][j]+D[i][j]+1);
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 67072
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;


class Program
{
    public static long Read()
    {
        return long.Parse(Console.ReadLine());
    }

    public static long[] Reads()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }


    public static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);

        var s = Console.ReadLine();
        var L = new List<long>();
        var count = 0;
        for(int i = 0; i < s.Length; i++)
        {
            if(s[i]=='A'|| s[i] == 'T' || s[i] == 'G' || s[i] == 'C')
            {
                count++;
            }
            else
            {
                L.Add(count);
                count = 0;
            }
        }
        L.Add(count);

        Console.WriteLine(L.Max());


        Console.Out.Flush();
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

struct Data{
	int id, ans, penalty;
	bool operator < ( const Data &right ) const {
		if(ans < right.ans) return 1;
		else if(ans == right.ans){
			if(penalty > right.penalty) return 1;
			else if(penalty == right.penalty) return id > right.id;
		}
		return 0;
	}
};

int main(){
	int t, p, r;
	while(cin >> t >> p >> r, t){

		Data d[50];
		rep(i,t){
			d[i] = Data{i + 1, 0, 0};
		}
		int wa[50][10] = {};

		rep(i,r){
			int tid, pid, time;
			string message;
			cin >> tid >> pid >> time >> message;
			tid--; pid--;

			if(message == "CORRECT"){
				d[tid].ans++;
				d[tid].penalty += wa[tid][pid] * 1200 + time;
			}else{
				wa[tid][pid]++;
			}
		}


		sort(d, d + t);
		for(int i = t - 1; i >= 0; i--){
			cout << d[i].id << ' ' << d[i].ans << ' ' << d[i].penalty << endl;
		}
	}
}



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

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

    sort(d.begin(), d.end());

    int current_mochi = d[d.size() - 1], count = 1;
    d.pop_back();
    //cout << "initial mochi " << current_mochi << endl;

    while (!d.empty()) {
        if (current_mochi > d[d.size() - 1]) {
            current_mochi = d[d.size() - 1];
            count++;
            //cout << "added " << d[d.size() - 1] << endl;
            d.pop_back();
        } else d.pop_back();
    }

    cout << count << endl;
}

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

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 1000000007

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define print(v) for (auto i: v) cout << i << " ";

vvi st;
string s;
ll n;

void make(ll l, ll r, ll i, ll j) {
    if (l == r) {
        if(s[l] == j + 'a')
            st[j][i] = 1;
        return;
    }
    ll mid = (l+r)/2;
    make(l, mid, 2*i, j);
    make(mid + 1, r, 2*i + 1, j);
    st[j][i] = st[j][2*i] + st[j][2*i + 1];
}

void upd(ll l, ll r, ll i, ll j, ll c, ll p) {
    if (l == r && l == p) {
        st[j][i] += c;
        return;
    }
    ll mid = (l + r)/2;
    if (p >= l && p <= mid)
        upd(l, mid, 2*i, j, c, p);
    else
        upd(mid + 1, r, 2*i + 1, j, c, p);
    st[j][i] = st[j][2*i] + st[j][2*i + 1];
}

void update(ll l, char c) {
    upd(0, n-1, 1, s[l] - 'a', -1, l);
    upd(0, n-1, 1, c - 'a', 1, l);
}

ll query(ll s, ll e, ll l, ll r, ll i, ll j) {
    if (l > r)
        return 0;
    if (s == l && r == e)
        return st[j][i];
    ll mid = (s+e)/2;
    ll a = query(s, mid, l, min(mid, r), 2*i, j);
    ll b = query(mid + 1, e, max(mid+1, l), r, 2*i + 1, j);
    return a + b;
}

int main() {
    fast
    cin >> n;
    cin >> s;
    st.resize(26, vi(4*n, 0));
    REP(i, 0, 26)
        make(0, n-1, 1, i);
    ll q, t, l, r;
    char c;
    cin >> q;
    REP(i, 0, q) {
        cin >> t >> l;
        l--;
        if (t == 1) {
            cin >> c;
            if (s[l] != c)
                update(l, c);
            s[l] = c;
        }
        else {
            cin >> r;
            r--;
            ll ans = 0;
            REP(i, 0, 26)
                if (query(0, n-1, l, r, 1, i) > 0)
                    ans++;
            cout << ans << endl;
        }
    }
}


Measured memory_bytes: 422812
#include <algorithm>
#include <iostream>
#include <vector>

int main() {
  int N;
  std::cin >> N;
  std::vector<int> A(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> A[i];
  }
  std::sort(A.begin(), A.end());
  std::vector<bool> excluded(1000001);
  for (int i = 0; i < N; ++i) {
    if (excluded[A[i]]) continue;
    for (int j = A[i] * 2; j < static_cast<int>(excluded.size()); j += A[i]) {
      excluded[j] = true;
    }
    while (i + 1 < N && A[i + 1] == A[i]) {
      excluded[A[i]] = true;
      ++i;
    }
  }
  int count = 0;
  for (int i = 0; i < N; ++i) {
    count += excluded[A[i]] == false;
  }
  std::cout << count << std::endl;
  return 0;
}


Measured memory_bytes: 4312
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll ans=a-b;
    if(k%2==1) ans=-ans;
    if(ans>1e18) cout<<"Unfair"<<endl;
    else cout<<ans<<endl;
}

Measured memory_bytes: 256
fn read_vec<T: std::str::FromStr> () -> Vec<T> {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().split_whitespace().map(|x| x.parse().ok().unwrap()).collect()
}

fn main(){
  let mut data: Vec<i32> = read_vec();
  let mut k = data.pop().unwrap();
  let mut out = 0;
  for (i, val) in data.into_iter().enumerate(){
    if k - val < 0{
      out += (1 - i as i32) * k;
      break
    }
    out += (1 - i as i32) * val;
    k -= val;
  }
  println!("{}", out);
}


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

using namespace std;

int main(){
	int m,n;
	cin >> n >> m;
int a[100000];
int sum = 0;
	for(int i = 0;i < m;i++){
		cin >> a[i];
		sum += a[i];
	}

	if(n-sum < 0){
		cout << -1 <<endl;
	}
	else{
		cout << n-sum <<endl;
	}
}


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

int main() {
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int distX = x2 - x1;
	int distY = y2 - y1;
	cout << x2 - distY << " " << y2 + distX << " " <<
		x2 - distY -distX << " " << y2 + distX - distY;
}

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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int n;
	cin >> n;
	vector<int>a(n);
	set<int>ret;
	rep(i, n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	vector<int>cnt(a[n-1]+1,0);
	for (int x : a) {
		if (cnt[x] != 0) {
			cnt[x] = 2;
			continue;
		}
		for (int i = x; i <= a[n - 1]; i += x)cnt[i]++;
	}
	int ans = 0;
	for (int x : a) {
		if (cnt[x] == 1)ans++;
	}
	print(ans);
}

Measured memory_bytes: 12764
// C - Otoshidama
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int N,Y; cin>>N>>Y;
	Y /= 1000;
	rpz(x, min(N+1, Y/10+1)){
		rpz(y, min(N-x+1, Y/5+1)){
			int z = N - x - y;
			if(x*10 + y*5 + z != Y) continue;
			printf("%d %d %d\n", x, y, z);
			return 0;
		}
	}
	puts("-1 -1 -1");
}

Measured memory_bytes: 256