akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

int main(){
  int n,m;
  cin >> n >> m;
  if (n == m) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
char chess(int h,int w){
    if((h+w)%2==0){
    return '#' ;
    }
    return'.';
}
int main( ){
    int H,W;
    while(true){
        cin>>H;
        cin>>W;
         if(H==0 && W==0){
             break;
         }
     for ( int i = 0; i < H; i++ ){
         for ( int j = 0; j < W; j++ ){
           cout<<chess(i,j);
       }
       cout <<endl;
   }
   cout<<endl;
     }
}


Measured memory_bytes: 3032
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var S = sc.ReadStr();
        var a = S.Split(',');
        var ans = string.Join(" ", a);
        Console.WriteLine(ans);
    }
    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}


Measured memory_bytes: 11092
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;
const ll M=998244353;
int n,x[200005],i,y[200005],tree[200005];
ll ans,s[200005][4],p[200005];
struct str{
	int x,y;
}a[200005];
bool cmp(str a,str b)
{
	return a.x<b.x;
}
int lb(int x)
{
	return -x&x;
}
void Push(int x)
{
	while(x<=n)
	{
		tree[x]++;
		x+=lb(x);
	}
}
int Query(int x)
{
	int s=0;
	while(x>0)
	{
		s+=tree[x];
		x-=lb(x);
	}
	return s;
}
int main(){
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d %d",&x[i],&y[i]);
		a[i].x=x[i];
		a[i].y=y[i];
	}
	sort(x+1,x+1+n);
	sort(y+1,y+1+n);
	sort(a+1,a+1+n,cmp);
	p[0]=1;
	for(i=1;i<=n;i++)
		p[i]=p[i-1]*2%M;
	for(i=1;i<=n;i++)
	{
		int o=lower_bound(y+1,y+1+n,a[i].y)-y;
		s[i][0]=Query(o);
		s[i][1]=i-Query(o)-1;
		Push(o);
	}
	memset(tree,0,sizeof(tree));
	for(i=n;i>=1;i--)
	{
		int o=lower_bound(y+1,y+1+n,a[i].y)-y;
		s[i][2]=Query(o);
		s[i][3]=n-i-Query(o);
		Push(o);
	}
	for(i=1;i<=n;i++)
		ans=(ans+p[n-1]+(p[s[i][0]]-1)*(p[s[i][3]]-1)%M*p[s[i][1]]%M*p[s[i][2]]%M+(p[s[i][1]]-1)*(p[s[i][2]]-1)%M*p[s[i][0]]%M*p[s[i][3]]%M-(p[s[i][0]]-1)*(p[s[i][1]]-1)%M*(p[s[i][2]]-1)%M*(p[s[i][3]]-1)%M)%M;
	cout<<(ans%M+M)%M;
}


Measured memory_bytes: 11904
#include<iostream>
#include<map>
using namespace std;
#define df 0
typedef long int li;
const li MAX=10000000000;
#define rep(i,n) for(int i=0;i<n;i++)




int main(){
  if(df) printf("*debug mode*\n");

  string s1,s2; cin >>s1 >>s2;
  int len=s1.size();
  map<char,char> m1,m2;
  rep(i,len){
    if(m1.find(s1.at(i))!=m1.end()){
      if(m1[s1.at(i)]!=s2.at(i)){
	printf("No\n");
	return 0;
      }
    }else{
      m1[s1.at(i)]=s2.at(i);
    }
    if(m2.find(s2.at(i))!=m2.end()){
      if(m2[s2.at(i)]!=s1.at(i)){
	printf("No\n");
	return 0;
      }
    }else{
      m2[s2.at(i)]=s1.at(i);
    }
  }
  printf("Yes\n");
}

/// confirm df==0 ///


Measured memory_bytes: 776
#include <stdio.h>

const int MAX_V = 1000000;
int prime[MAX_V+1];
int sum[MAX_V+2];
void init(){
    int i, k, v;
    for(i=2; i<=MAX_V; i++){
        prime[i] = 1;
    }
    for(i=2; i*i<=MAX_V; i++){
        if(prime[i]){
            for(k=2*i; k<=MAX_V; k+=i){
                prime[k]=0;
            }
        }
    }   
}

void accumulate(){
   for(int i=1; i<MAX_V+2; i++){
        if(i==1){
            sum[i]=0;
        }else{
            sum[i]=sum[i-1]+prime[i];
        }
    }
}


int main(){
    init();
    accumulate();
    int num;
    while(scanf("%d", &num) != EOF){
        printf("%d\n", sum[num]);
    }
    return 0;
}

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

template <typename T,typename E>
struct SegmentTree{
  using F = function<T(T,T)>;
  using G = function<T(T,E)>;
  using H = function<E(E,E)>;
  using P = function<E(E,size_t)>;
  Int n;
  F f;
  G g;
  H h;
  T ti;
  E ei;
  P p;
  vector<T> dat;
  vector<E> laz;
  SegmentTree(Int n_,F f,G g,H h,T ti,E ei,
	      P p=[](E a,size_t b){b++;return a;}):
    f(f),g(g),h(h),ti(ti),ei(ei),p(p){
    init(n_);
  }
  void init(Int n_){
    n=1;
    while(n<n_) n*=2;
    dat.assign(2*n-1,ti);
    laz.assign(2*n-1,ei);
  }
  void build(Int n_, vector<T> v){
    for(Int i=0;i<n_;i++) dat[i+n-1]=v[i];
    for(Int i=n-2;i>=0;i--)
      dat[i]=f(dat[i*2+1],dat[i*2+2]);
  }
  inline void eval(Int len,Int k){
    if(laz[k]==ei) return;
    if(k*2+1<n*2-1){
      laz[k*2+1]=h(laz[k*2+1],laz[k]);
      laz[k*2+2]=h(laz[k*2+2],laz[k]);
    }
    dat[k]=g(dat[k],p(laz[k],len));
    laz[k]=ei;
  }
  T update(Int a,Int b,E x,Int k,Int l,Int r){
    eval(r-l,k);
    if(r<=a||b<=l) return dat[k];
    if(a<=l&&r<=b){
      laz[k]=h(laz[k],x);
      return g(dat[k],p(laz[k],r-l));
    }
    return dat[k]=f(update(a,b,x,k*2+1,l,(l+r)/2),
		    update(a,b,x,k*2+2,(l+r)/2,r));
  }
  T update(Int a,Int b,E x){
    return update(a,b,x,0,0,n);
  }
  T query(Int a,Int b,Int k,Int l,Int r){
    eval(r-l,k);
    if(r<=a||b<=l) return ti;
    if(a<=l&&r<=b) return dat[k];
    T vl=query(a,b,k*2+1,l,(l+r)/2);
    T vr=query(a,b,k*2+2,(l+r)/2,r);
    return f(vl,vr);
  }
  T query(Int a,Int b){
    return query(a,b,0,0,n);
  }
  void update(Int k,T x){
    query(k,k+1);//evaluate
    k+=n-1;
    dat[k]=x;
    while(k){
      k=(k-1)/2;
      dat[k]=f(dat[k*2+1],dat[k*2+2]);
    }
  }
};

//INSERT ABOVE HERE
signed main(){
  Int n,q;
  cin>>n>>q;

  auto f=[](Int a,Int b){return a+b;};
  auto g=[](Int a,Int b){a++;return b;};
  auto p=[](Int a,size_t b){return a*b;};

  SegmentTree<Int, Int> seg(n,f,g,g,0,0,p);

  for(Int i=0;i<q;i++){
    Int a,b;
    cin>>a>>b;

    Int l=-1,r=a;
    while(l+1<r){
      Int m=(l+r)>>1;
      Int k=seg.query(m,m+1);
      if(k*(a-m)<=seg.query(m,a)+b) r=m;
      else l=m;
    }
    
    Int k=seg.query(r,r+1);
    b-=k*(a-r)-seg.query(r,a);
    seg.update(r,a,k);
    k+=b/(a-r);b%=(a-r);
    seg.update(r,a,k);
    seg.update(r,r+b,k+1);

    continue;
    cout<<r<<":"<<a<<":"<<b<<endl;
    for(Int j=0;j<n;j++)
      cout<<seg.query(j,j+1)<<" ";
    cout<<endl;
  }
  
  for(Int i=0;i<n;i++)
    cout<<seg.query(i,i+1)<<endl;
  
  return 0;
}


Measured memory_bytes: 5760
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        sc.close();

        if (b<a){
            System.out.println(a-1);
        }else {
            System.out.println(a);
        }
    }
}

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

int N;
constexpr int maxA = 1000001;
vector<int> input;
vector<bool> table(maxA, true);


int main() {
    cin >> N; input.resize(N);
    for (int i = 0; i < N; i++) cin >> input[i];
    sort(input.begin(), input.end());
    for (int i = 0; i < N; i++) {
        if (!table[input[i]] || (i != 0 && input[i] == input[i-1])) continue;
        for(int j = 2; j*input[i] < maxA; j++) {
            table[j*input[i]] = false;
        }
    }
    long long counter = 0;
    for (int i = 0; i < N; i++) {
        if (table[input[i]]) {
            if (i != 0 && input[i] == input[i-1]) continue;
            if (i != N-1 && input[i] == input[i+1]) continue;
            counter++;
        }
    }
    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 3956
/*---------------Go Code GO---------------*/

#include<bits/stdc++.h>
using namespace std;

#define     PI              acos(-1.0)
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define     precision(a)    fixed<<setprecision(a)
#define     endl            '\n'
#define     Flush           cout<<flush
#define     LLMX            0x3fffffffffffffff
#define     PW2(a)          (long long)1<<a


int main()
{
    long long i,j,k,l,m,n,o,p,q,tst,csin=0;
    cin>>n>>m;
    if(n>m) swap(n,m);

    for(i=0; i<m; i++)
        cout<<n;






    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>

int a,b,c;
long long k;

int main()
{
	scanf("%d%d%d%lld",&a,&b,&c,&k);
	if (k&1) printf("%d",b-a);
	else printf("%d",a-b);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define ve vector

int main(){
    int n;
    cin >> n;
    ve<double> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    ve<ve<double>> dp(n+1,ve<double>(n+1,0));
    dp[0][0] = 1;
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= i; j++){
            dp[i+1][j] += dp[i][j] * (1-a[i]);
            dp[i+1][j+1] += dp[i][j] * a[i];
        }
    }
    double ans = 0;
    for(int i = (n+1)/2; i < n+1; i++){
        ans += dp[n][i];
    }
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 70656
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}


int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); ++i) {
        if(s[i] == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)
    val n, m = sc.nextLong()
    if (n == m && n == 1) {
      println(1)
    } else if (math.min(n, m) == 1L) {
      println(math.max(0L, n * m - 2L))
    } else {
      println(n * m - 2 * n - 2 * m + 4)
    }
  }
  def debug(args: Any*): Unit = {
    Console.err.println(args.mkString(" "))
  }
}


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

using namespace std;

int main() {
    int a, b;
    char op;
    while (cin >> a >> op >> b) {
        if (op == '?') break;
        int ans;
        switch (op) {
            case '+':
                ans = a + b;
                break;

            case '-':
                ans = a - b;
                break;

            case '*':
                ans = a * b;
                break;

            case '/':
                ans = a / b;
                break;

            default:
                break;
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(int i=0;i<N;++i)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

bool comp(const PII& l, const PII& r){
  return (double)l.second/l.first > (double)r.second/r.first;
}

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

  ll N;cin >> N;
  int N_MAX = 2.5e7;
  vector<PLL> x(3);
  cin >> x[0].first >> x[1].first >> x[2].first;
  cin >> x[0].second >> x[1].second >> x[2].second;
  int M = x.size();
  //dp[i+1][j]:i番目まで見て,j個ある時の変換後の最大数
  vector<vector<ll> > dp(M+1,vector<ll>(N_MAX+1));
  REP(j,N+1) dp[0][j] = N;
  REP(i,M){
    REP(j,N+1){
      if(j < x[i].first){
        dp[i+1][j] = dp[i][j];
      }else{
        dp[i+1][j] = max(dp[i][j], dp[i+1][j-x[i].first] + x[i].second - x[i].first);
      }
    }
  }
  N = dp[M][N];

  REP(j,N+1) dp[0][j] = N;
  REP(i,M){
    REP(j,N+1){
      if(j < x[i].second){
        dp[i+1][j] = dp[i][j];
      }else{
        dp[i+1][j] = max(dp[i][j], dp[i+1][j-x[i].second] + x[i].first - x[i].second);
      }
    }
  }
  N = dp[M][N];

  cout << N << endl;
  return 0;
}


Measured memory_bytes: 976896
import sys
l,r = map(int,input().split())
mn = 2018
for i in range(l,r+1):
    for j in range(i+1,r+1):
        mod = (i * j) % 2019
        if mod == 0:
            print(0)
            sys.exit()
        
        mn = min(mn,mod)
print(mn)

Measured memory_bytes: 3060
#include<iostream>

using namespace std;
int main(){
    int K, S;
    cin >> K >> S;
    int count = 0;
    for (int i = 0; i <= K; i++)
    {
        for (int j = 0; j <= K; j++)
        {
            if(S - i - j >= 0 && S - i - j <= K) count++;
        }
    }
    cout << count << endl;
}

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

int INF = 999999;

int main(){
  int N;
  vector<int> a(200010);

  int cur = 1; int cnt = 0;

  cin >> N;
  for(int i=0; i<N; i++){
    cin >> a[i];
    if(a[i] == cur){
      cur++; cnt++;
    }
  }

  if(cnt == 0){
    cout << -1 << endl;
  } else {
    cout << N - cnt << endl;
  }

}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

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

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<ll> ans(n);
    ll count = 0;
    for(int i = n - 1; i >= 0; --i){
        ll num = i + 1;
        ll sum = 0;
        ll tmp = 2;
        while(num * tmp <= n){
            ll ind = num * tmp;
            sum += ans[ind - 1];
            tmp++;
        }
        if(sum % 2 != a[i]){
            ans[i]++;
            count++;
        }
    }
    print(count);
    rep(i, n){
        if(ans[i]) print(i + 1);
    }

}



Measured memory_bytes: 3968
#include<iostream>
#include<map>
#include<vector>
#include<queue>
using namespace std;

int main() {
  int N; cin >> N;
  pair<int, int> edges[N-1]; map<pair<int, int>, int> color;
  vector<int> E[N];
  for (int i = 0; i < N; i++) E[i] = vector<int>();
  for (int i = 0; i < N-1; i++) {
    int a, b; cin >> a >> b;
    edges[i] = make_pair(a-1, b-1);
    E[a-1].push_back(b-1); E[b-1].push_back(a-1);
  }
  int k = 0;
  bool visited[N]; for (int i = 0; i < N; i++) visited[i] = false;
  // pair of:
  // node id, and color of edge between current and parent nodes
  queue<pair<int, int>> q;
  q.push(make_pair(0, 0));
  while (!q.empty()) {
    pair<int, int> node = q.front(); q.pop();
    visited[node.first] = true;
    int c = 0;
    for (int i = 0; i < E[node.first].size(); i++) {
      if (!visited[E[node.first][i]]) {
        if (++c == node.second) c++;
        q.push(make_pair(E[node.first][i], c));
        color[make_pair(node.first, E[node.first][i])] = c;
        color[make_pair(E[node.first][i], node.first)] = c;
      }
    }
    k = max(k, c);
  }
  cout << k << endl;
  for (int i = 0; i < N-1; i++) cout << color[edges[i]] << endl;
}

Measured memory_bytes: 19456
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll num[30101][10];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n;
	cin >> n;
	string s;
	cin >> s;
	rep(i, n) {
		ll res = s[i] - '0';
		num[i][res]++;
		rep(j, 10) {
			num[i + 1][j] += num[i][j];
		}
	}
	map<ll, ll>mp;
	for (ll i = 1;i < n - 1;++i) {
		rep(j, 10) {
			rep(k, 10) {
				ll res = s[i] - '0';
				res *= 10;
				if (num[i - 1][j] >= 1 && num[n - 1][k] - num[i][k] >= 1) {
					res += j * 100 + k;
					mp[res]++;
				}
			}
		}
	}
	ll ans = 0;
	for (auto p : mp) {
		ans++;
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;
#define taskname "TEST"
#define pb	push_back
typedef long double ld;
typedef long long ll;
const int maxn = 2e5 + 5;
int n , h[maxn];
ll c;
const int HullType = 0;//0 -> min 1 -> max
const ll inf = 1e18;
struct line
{
    ll a , b;
    bool is_query;
    mutable double line_x;
    line() {a = 0; b = 0; line_x = 0; is_query = 0;}
    line(ll _a, ll _b) {a = _a; b = _b; line_x = 0; is_query = 0; }
    line(ll _a, ll _b , bool _is_query , double _line_x ){a = _a; b = _b ; is_query = _is_query ; line_x = _line_x;};
    bool operator < (const line &l2) const
    {
        if(!is_query && !l2.is_query)return HullType == 0 ? (a > l2.a) : (a < l2.a);
        return line_x < l2.line_x;
    }
    ll value_at(ll x) const {return a * x + b;}
};
struct DynamicHull : set <line>
{
	double intersect_x(const line &l1, const line &l2){return (double)(l1.b - l2.b) / (double)(l2.a - l1.a);}
	bool has_next(iterator it) { return it != end() && next(it) != end();}
	bool has_prev(iterator it) { return it != end() && it != begin(); }
	bool irrelevant(const line & l1 , const line &l2, const line &l3) {return intersect_x(l1, l3) <= intersect_x(l1, l2);}
	bool irrelevant(iterator it) { return has_prev(it) && has_next(it) && irrelevant(*prev(it), *it, *next(it)); }
	void update_border(iterator it)
	{
		if(has_next(it))it->line_x = intersect_x(*it, *next(it));
		else it->line_x = inf;
	}
	void add(ll a, ll b)
	{
		line curr_line = line(a, b);
		iterator it = lower_bound(curr_line);
		if(it != end() && it->a == a)
		{
			if((HullType == 0 && it->b > b) || (HullType == 1 && it->b < b)) it = erase(it);
			else return;
		}
		it = insert(it, curr_line);
		if(irrelevant(it))
		{
			erase(it);
			return;
		}
		while(has_prev(it) && irrelevant(prev(it))) erase(prev(it));
		while(has_next(it) && irrelevant(next(it))) erase(next(it));
		update_border(it);
		if(has_prev(it)) update_border(prev(it));
		if(has_next(it)) update_border(next(it));
	}
	ll query(ll x)
	{
	    //assert(!empty());
        if(empty())return HullType == 0 ? inf : -inf;
		return lower_bound(line(0,0,1,x))->value_at(x);
	}
};
DynamicHull s;
ll dp[maxn];
int main()
{
    ios_base::sync_with_stdio(0);
	cin.tie(0);
	if(fopen(taskname".INP","r"))
        freopen(taskname".INP", "r",stdin) ,
        freopen(taskname".OUT", "w",stdout);
    cin >> n >> c;
    for(int i = 1 ; i <= n ; ++i)
        cin >> h[i];
    for(int i = 2 ; i <= n ; ++i)
    {
        s.add(2 * -h[i - 1] , (ll)h[i - 1] * h[i - 1] + dp[i - 1]);
        dp[i] = s.query(h[i]) + (ll)h[i] * h[i] + c;
    }
    cout << dp[n];
}


Measured memory_bytes: 18176
d, d2 = [list(map(int, input().split())) for i in range(2)]  
from collections import OrderedDict
def make_p(d):
    p = OrderedDict()
    for k, v in zip(["T", "N", "S", "E", "W", "B"], [d[0], d[4], d[1], d[2], d[3], d[5]]):
        p[k] = v
    return p

p, p2 = make_p(d), make_p(d2)

for c in "SSSWNNNWNNNESSSWNNNESSSX":       
    t, n, s, e, w, b = p["T"], p["N"], p["S"], p["E"], p["W"], p["B"]
    if p == p2:
        print("Yes")
        break
    if c == "X":
        print("No")
    if c == "N":
        p["N"], p["T"], p["S"], p["B"]= t, s, b, n
    if c == "S":
        p["N"], p["T"], p["S"], p["B"]= b, n, t, s
    if c == "E":
        p["E"], p["T"], p["W"], p["B"]= t, w, b, e
    if c == "W":
        p["E"], p["T"], p["W"], p["B"]= b, e, t, w     


Measured memory_bytes: 6012
import java.util.*;
import java.awt.geom.Point2D;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
//Loopで使う文字列の長さは固定！
//intで大丈夫？オーバーフローしない？
//Loop回数は本当に10⁹以内になってる？Loopは回る？？
public class Main {
    public static void main(String[]$){
        Scanner sc = new Scanner(in);
        int n=sc.nextInt();
        int[] t=new int[n];
        int sumt=0;
        for (int i = 0; i < n; i++) {
            t[i]=sc.nextInt();
            sumt+=t[i];
        }
        int m=sc.nextInt();
        int[] p=new int[m];
        int[] x=new int[m];
        for (int i = 0; i < m; i++) {
            p[i]=sc.nextInt();
            x[i]=sc.nextInt();
        }
        for (int i = 0; i < m; i++) {
            out.println(sumt-t[p[i]-1]+x[i]);
        }
    }
}

Measured memory_bytes: 21716
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#include<deque>
#define rep(i,rept)	for(int i = 0; i<(ll)rept;++i)
typedef long long ll;
using namespace std;


int main() {

	ll n = 0, m = 0;
	cin >> n >> m;

	if (n == 1) {
		cout << m << endl;
		return 0;
	}

	if (m%n == 0) {
		cout << m / n << endl;
		return 0;
	}

	for (ll i = 100000000; i >= 1; i--) {
		if (m % i == 0 && m / i >= n) {
			cout << i << endl;
			return 0;
		}
	}

}

Measured memory_bytes: 256
//2018-1-28
//miaomiao
//
#include <bits/stdc++.h>
using namespace std;

#define LL long long
#define pb push_back
#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define Forr(i, a, b) for(int i = (a); i >= (int)(b); --i)

#define N (100000+5)

struct node{
	int v, d;
};

vector<node> G[N];

LL val[N];
bool vis[N];

bool Dfs(int now){
	vis[now] = true;

	For(i, 0, G[now].size() - 1){
		int v = G[now][i].v, d = G[now][i].d;
		if(vis[v]){
			if(d + val[now] != val[v]) return false;
			continue;
		}

		val[v] = val[now] + 1ll * d;
		if(!Dfs(v)) return false;
	}

	return true;
}

int main(){
	int n, m, u, v, d;
	scanf("%d%d", &n, &m);

	For(i, 1, m){
		scanf("%d%d%d", &u, &v, &d);
		G[u].pb((node){v, d}); G[v].pb((node){u, -d});
	}

	For(i, 1, n) if(!vis[i]){
		val[i] = 0;
		if(!Dfs(i)){
			puts("No"); return 0;
		}
	}
	puts("Yes");

	return 0;
}

Measured memory_bytes: 12416
from math import gcd
k = int(input())+1
n = 0
for i in range(1,k):
  for j in range(i,k):
    for l in range(j, k):
      if i == j == l:
        n += gcd(i,gcd(j,l))
      elif i == j or j == l or l == i:
        n += gcd(i,gcd(j,l))*3
      else:
        n += gcd(i,gcd(j,l))*6
print(n)

Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int n,m,ans=0,father[N],sum[N];
int Findfather(int x){
    return father[x]==x?x:father[x]=Findfather(father[x]);
}

void Union(int x,int y){
    x=Findfather(x),y=Findfather(y);
    if(x!=y) father[y]=x,sum[x]+=sum[y];
}

void init(){
    for(int i=0;i<=n;i++)
        father[i]=i,sum[i]=1;
}

int main(){
    cin>>n>>m;
    init();
    while(m--){
        int u,v;
        cin>>u>>v;
        Union(u,v);
    }
    for(int i=1;i<=n;i++) if(Findfather(i)==i) ans=max(ans,sum[i]);
    cout<<ans;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
#define int long long
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define INF (1ll<<60)
typedef pair<int, int> pii;
#define FI first
#define SE second
#define all(s) s.begin(),s.end()
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define pb push_back

int N, C, K;
priority_queue<int, vector<int>, greater<int>> que;
signed main() {
	cin >> N >> C >> K;
	rep(i,N)
	{
		int t;
		cin >> t;
		que.push(t);
	}
	int ans = 0;
	while (!que.empty()) {
		int ti = que.top();
		int ti_k = ti + K;
		ans++;
		for (int i = 0; i < C && que.top() <= ti_k; ++i) {
			que.pop();
			if (que.empty())
				break;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1400
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Maximize the Formula
            var line = ReadLine();

            var numbers = line.OrderByDescending(n => n).ToList();

            string s = numbers[0].ToString() + numbers[1].ToString();
            int x = int.Parse(s);
            int y = numbers[2];

            Console.WriteLine(x + y);
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine().TrimEnd();
            var array = line.Split(' ');
            var numbers = new List<int>();

            foreach (var s in array)
            {
                int num = int.Parse(s);
                numbers.Add(num);
            }

            return numbers;
        }
    }
}

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

int main(){
  string a[3];
  cin >> a[0] >> a[1] >> a[2];
  string small="abcdefghijklmnopqrstuvwxyz";
  string big="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  for(int i=0;i<3;i++){
    for(int j=0;j<26;j++){
      if(a[i][0]==small[j]){
        cout << big[j];
      }
    }
  }
}

Measured memory_bytes: 256
N = int(input())

max_a = 100 // 4
max_b = 100 // 7
A = False

for a in range(max_a+1):
    if A == True:
        break
    for b in range(max_b+1):
        total = a*4 + b*7
        if total == N:
            A = True
            break
        if total != N:
            A = False
            continue
            
if A == True:
    print('Yes')
if A == False:
    print('No')

Measured memory_bytes: 9100
#include<bits/stdc++.h>
#define ll long long int
#define mod 1e9+7
using namespace std;
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   int t;
   t=1;
   while(t--)
   {
     double d,t,s;
     cin>>d>>t>>s;
     if((d/s)<=t)
        cout<<"Yes\n";
            else
            cout<<"No\n";
   }
}


Measured memory_bytes: 3716
#include<stdio.h>
#include<stdlib.h>

int main(){
int n, a, b, c;

scanf("%d", &n);

a = n/100;
b = (n%100)/10;
c = (n-(a*100)-(b*10));

if (a==7||b==7||c==7){
	printf("Yes");
}
else{
	printf("No");	
}
}

Measured memory_bytes: 1704
r,c = map(int,input().split())
a = []
row_sum = []
for i in range(r):
    a.append(list(map(int,input().split())))
    print(*a[i],sum(a[i]))
for i in range(c):
    row_sum.append(sum(a[j][i] for j in range(r)))
print(*row_sum,sum(row_sum))


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

int main()
{
	int d,g;
	cin >> d >> g;
	int p[d], c[d];
	for(int i = 0; i < d; i++)
		cin >> p[i] >> c[i];

	long long ans = 100000000000000;	//INFINITY
	for(int t = 0; t < (1 << d); t++){
		long long score = 0;
		long long solved = 0;
		int maxUnSolvedD = -1;
		for(int i = 0; i < d; i++){
			if(t & (1 << i)){
				score += 100 * (i+1) * p[i] + c[i];
				solved += p[i];
			}else{
				maxUnSolvedD = i;
			}
		}
		//cout << t << " " << score << " " << solved << " " << ans << endl;
		if(score >= g){
			ans = min(ans, solved);
			continue;
		}
		if(maxUnSolvedD != -1){
			int add = (g - score + ((maxUnSolvedD+1) * 100) - 1) / ((maxUnSolvedD+1) * 100);
			if(add < p[maxUnSolvedD])
				ans = min(ans, solved + add);
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout << fixed << setprecision(n)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

bool exists_Euler(const vector<vector<int>>&g) {
	for (int i = 2; i < g.size(); ++i)if (g[i].size() % 2 == 1) return false;
	return g[0].size() % 2 == 1 && g[1].size() % 2 == 1;
}
signed main()
{
	int a, b;
	while (cin >> a >> b) {
		vector<pair<int, int>>inp;
		int max_idx = -1;
		do {
			inp.push_back(make_pair(a - 1, b - 1));
			max_idx = max(max_idx, max(a, b));
		} while (cin >> a >> b, a != 0 || b != 0);
		vector<vector<int>>g(max_idx + 1);
		REPC(i, inp) {
			g[i.first].push_back(i.second);
			g[i.second].push_back(i.first);
		}
		cout << (exists_Euler(g) ? "OK" : "NG") << endl;
	}
}


Measured memory_bytes: 3064
#pragma GCC optimize("O2")
#pragma GCC optimize("Ofast")
#include<map>
#include<cmath>
#include<ctime>
#include<bitset>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define maxn 105
const int mod=998244353;

int n;
char s[maxn];
bitset<100> pps,all;
map<pair<int,string>,int> h;

inline int read(){
	int x=0,f=1; char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int dp(bitset<100> pps,int len){
	if (!len) return 1;
	pair<int,string> pp=make_pair(len,pps.to_string());
	if (h.find(pp)!=h.end()) return h[pp];
	int ret=dp(pps>>1,len-1)*(pps[0]+1); ret>=mod?ret-=mod:0;
    for (int i=1;i<=(len>>1);i++){
		bitset<100> x=pps,y,all; all.reset();
		for (int j=0;j<i;j++) all[j]=1;
		y=x&all,x>>=i;
		for (int j=2;i*j<=len;j++)
			y&=x&all,x>>=i,ret=(ret+1ll*dp(y,i)*dp(x,len-i*j))%mod;
	}
	return h[pp]=ret;
}

int main(){
    scanf("%s",s),n=strlen(s);
	for (int i=0;i<n;i++) pps[i]=s[i]-'0';
	cout<<dp(pps,n)<<endl;
	return 0;
}


Measured memory_bytes: 9728
#include <iostream>
#include <vector>
#include <bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < n; ++i)

// https://atcoder.jp/contests/s8pc-4/tasks/s8pc_4_b

int main() {
  int n, k;
  cin >> n >> k;
  vector<ll> a(n, 0); 
  rep(i, n) cin >> a[i];

  ll ans = 1e15;
  rep (bit, (1 << n)) {
    if (bitset<32>(bit).count() != k) continue;

    ll cost = 0;
    ll maxH = a[0] + 1;
    rep (i, n) {
      if (bit & (1 << i)) {
        // 一番目のビルはコストがかからないからスキップ
        if (i == 0) continue;
        if (a[i] < maxH) {
          cost += (maxH - a[i]);
          ++maxH;
        } else {
          maxH = a[i] + 1;
        }
      } else {
        maxH = max(maxH, a[i]);
      }
    }
    ans = min(ans, cost);
  }
  cout << ans << endl;
  return 0;
}

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

typedef long long int ll;
using ii= pair<ll,ll>;
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define all(o) (o).begin(),(o).end()
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ld long double
#define eps 0.00000000001
#define mod 1000000007

class prioritize{
    public: bool operator() (ii &p1,ii &p2){
        return p1.F<p2.F;
    }
};


int main()
{
    
    #ifndef ONLINE_JUDGE
        freopen("input1.txt","r", stdin);
        freopen("output1.txt","w",stdout);
        auto start= high_resolution_clock::now();
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    int x;
    cin>>x;

    if(x==0) cout<<1<<"\n";
    else cout<<0<<"\n";
    
    #ifndef ONLINE_JUDGE
        auto stop= high_resolution_clock::now();
        auto duration= duration_cast<milliseconds>(stop-start);
        cout<<"run time: "<<duration.count()<<" ms"<<"\n";
    #endif
}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int t[7],n,a;
int main(void){
    while(cin>>n&&n){
    for(int i=0;i<7;i++)t[i]=0;
    for(int i=0;i<n;i++){
        cin>>a;
        for(int j=0;j<7;j++){
            if(j*10<=a&&a<=j*10+9){
                t[j]++;
                break;
            }
            if(j==6)t[6]++;
        }
    }
    for(int i=0;i<7;i++){
        cout<<t[i]<<endl;
    }
  }
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0 ; i < (int)(n) ; i++)
typedef long long ll;
typedef long double Double;
void solve(ll N, ll A, ll B){
	if( (B - A) % 2 == 1 ) cout << "Borys" << endl;
	else cout << "Alice" << endl;
}

int main(){	
	ll A;
	ll N;
	ll B;
	scanf("%lld",&N);
	scanf("%lld",&A);
	scanf("%lld",&B);
	solve(N, A, B);
	return 0;
}



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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll X, A, B;
    ll temp;
    cin >> X >> A >> B;
    temp = A - B;
    if(temp >= 0) cout << "delicious" << endl;
    else if(X >= -temp) cout << "safe" << endl;
    else cout << "dangerous" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

 int main()
{
    char S[3],a='R',b='S';

    scanf("%s",&S);

    if(S[0]=='R' && S[1]=='S' && S[2]=='R'){

        printf("1");
    }

    else if(S[0]=='S' && S[1]=='R' && S[2]=='S'){

        printf("1");
    }

    else if(S[0]=='S' && S[1]=='S' && S[2]=='R'){

        printf("1");
    }

    else if(S[0]=='R' && S[1]=='S' && S[2]=='S'){

        printf("1");
    }

    else if(S[0]=='R' && S[1]=='R' && S[2]=='S'){

        printf("2");
    }

    else if(S[0]=='S' && S[1]=='R' && S[2]=='R'){

        printf("2");
    }

    else if(S[0]=='R' && S[1]=='R' && S[2]=='R'){

        printf("3");
    }

    else{
        printf("0");
    }


  return 0;

}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 85;
const int OFFSET = 15000;

int n, m;
bitset<30000> dp[maxn][maxn];
int a[maxn][maxn];

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

  cin>>n>>m;
  for (int i=0; i<n; i++) {
    for (int j=0; j<m; j++) {
      cin>>a[i][j];
    }
  }
  for (int i=0; i<n; i++) {
    for (int j=0; j<m; j++) {
      int x; cin>>x;
      a[i][j] = abs(a[i][j] - x);
    }
  }

  dp[0][0][OFFSET] = 1;
  
  for (int i=0; i<n; i++) {
    for (int j=0; j<m; j++) {
      if (i) {
	dp[i][j] |= dp[i-1][j];
      }
      if (j) {
	dp[i][j] |= dp[i][j-1];
      }

      dp[i][j] = (dp[i][j] << a[i][j]) | (dp[i][j] >> a[i][j]);
    }
  }


  for (int i=0; ; i++) {
    if (dp[n-1][m-1][OFFSET+i] || dp[n-1][m-1][OFFSET-i]) out(i);
  }
  
  

  return 0;
}


Measured memory_bytes: 25088
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

using Facts = map<ll, int>; 
void factrize(ll n, Facts& mp) {
  if(n < 2) return;
  ll m = sqrt(n);
  REP(i, 2, m+1) {
    int cnt = 0;
    while(n%i == 0) {
      n /= i;
      ++cnt;
    }
    if(cnt > 0) mp[i] += cnt;
  }
  if(n != 1) mp[n]++;
}


int main(){
    ll a, b;
    cin >> a >> b;
    ll g = __gcd(a,b);
    Facts f;
    factrize(g, f);
    cout << f.size()+1 << endl;
    return 0;
}

Measured memory_bytes: 256
//  Created by Sengxian on 2017/7/1.
//  Copyright (c) 2017年 Sengxian. All rights reserved.
//  
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
inline int readInt() {
	int n = 0, ch = getchar();
	while (!isdigit(ch)) ch = getchar();
	while (isdigit(ch)) n = n * 10 + ch - '0', ch = getchar();
	return n;
}

const int MAX_N = 100000 + 3, MOD = 1000000007;
int n, a[MAX_N], lastPos[MAX_N];
ll inv[MAX_N], fact[MAX_N], factInv[MAX_N];

inline ll C(int n, int k) {
	if (k > n) return 0;
	if (k < 0) return 0;
	return fact[n] * factInv[k] % MOD * factInv[n - k] % MOD;
}

int main() {
	n = readInt();
	int x = 0, y = 0;
	memset(lastPos, -1, sizeof lastPos);
	for (int i = 0; i <= n; ++i) {
		a[i] = readInt() - 1;
		if (lastPos[a[i]] != -1) x = lastPos[a[i]], y = n - i;
		else lastPos[a[i]] = i;
	}
	
	inv[1] = 1;
	for (int i = 2; i < MAX_N; ++i) inv[i] = ((-(MOD / i) * inv[MOD % i] % MOD) + MOD) % MOD;
	fact[0] = factInv[0] = 1;
	for (int i = 1; i < MAX_N; ++i) {
		fact[i] = fact[i - 1] * i % MOD;
		factInv[i] = factInv[i - 1] * inv[i] % MOD;
	}
	
	for (int i = 1; i <= n + 1; ++i) printf("%lld\n", (C(n + 1, i) - C(x + y, i - 1) + MOD) % MOD);
	
	return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repr(i, a, b) for (int i = a; i >= b; i--)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) (a).size()
#define pb(a) push_back(a)
#define eb(...) emplace_back(__VA_ARGS__)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr double EPS = 1e-10;

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
}

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

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int N, M;
  string S, T;
  cin >> N >> M >> S >> T;
  int L = lcm(N, M);
  int g = gcd(N, M);
  int n = N/g, m = M/g;
  rep(i, 0, g) {
    if (S[i*n] == T[i*m]) continue;
    cout << -1 << endl;
    return 0;
  }
  cout << L << endl;

  return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC095
{
    class ProblemB
    {
        static void Main(string[] args)
        {
            string[] NX = Console.ReadLine().Split(' ');
            int N = int.Parse(NX[0]);
            int X = int.Parse(NX[1]);

            int[] m = new int[N];
            for(int i = 0; i < N; i++)
            {
                m[i] = int.Parse(Console.ReadLine());
                X -= m[i];
            }

            int result = N + X / m.Min();

            Console.WriteLine(result);            
        }
    }
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define MAX(a, b) ((a) < (b) ? (b) : (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main()
{
    int n;
    cin >> n;
    vector<int> surplus(n, 0);
    int a[n + 1];
    rep(i, n) cin >> a[i];
    a[n] = 0;
    ll cnt_sum = 0;
    int npos = 0;
    rep(i, n)
    {
        cnt_sum += abs(a[i] - npos);
        if (a[i] < npos && a[i] < a[i + 1])
        {
            surplus[i] = (min(npos, a[i + 1]) - a[i]) * 2;
        }
        if (a[i] > npos && a[i] > a[i + 1])
        {
            surplus[i] = (a[i] - max(npos, a[i + 1])) * 2;
        }
        npos = a[i];
    }
    cnt_sum += abs(a[n - 1]);
    rep(i, n)
    {
        cout << cnt_sum - surplus[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4028
M, D = map(int, input().split())

count = 0

if M < 4 or D < 22:
  print(0)
else:
  for i in range(4,M+1):
    for j in range(22,D+1):
      d = list(str(j))
      if int(d[0]) < 2 or int(d[1]) < 2:
        continue
      if i == int(d[0])*int(d[1]):
        count += 1
      
    
  
  print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1<<18,INF=1<<30;
vector<int> dx={-1,0,1,0},dy={0,-1,0,1};

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N;cin>>N;
        if(N==0) break;
        int ans=N;
        
        for(int i=0;i<=1000;i++){
            for(int j=0;j<=100;j++){
                if(i*i+j*j*j>N) continue;
                
                ans=min(ans,i+j+(N-i*i-j*j*j));
            }
        }
        
        cout<<ans<<endl;
    }
    
}



Measured memory_bytes: 3092
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int sumA = 0, sumB = 0;
		
		for (int i = 0; i < 4; i++) {
			sumA += scanner.nextInt();
		}
		for (int i = 0; i < 4; i++) {
			sumB += scanner.nextInt();
		}
		if (sumA < sumB) {
			System.out.println(sumB);
		} else {
			System.out.println(sumA);
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

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

using namespace std;

int main() {
  while(1){
    vector<pair<int,int>> v;
    int n;
    cin>>n;
    if(!n)break;
    REP(i,n){
      int c,m1,s1,m2,s2,m3,s3,m4,s4;
      cin>>c>>m1>>s1>>m2>>s2>>m3>>s3>>m4>>s4;
      v.push_back(make_pair(m1*60+s1+m2*60+s2+m3*60+s3+m4*60+s4,c));
    }
    sort(begin(v),end(v));
    cout<<v[0].second<<endl;
    cout<<v[1].second<<endl;
    cout<<v[v.size()-2].second<<endl;
  }
  return 0;
}

Measured memory_bytes: 1304