akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) if (cond) break
#define ctif(cond) if (cond) continue
#define retif(cond) if (cond) return
void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}
template<typename T> T extgcd(T a, T b, T &x, T &y)
{
    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b) {
        T q = a/b; a %= b; swap(a, b);
        x0 -= q*x1; swap(x0, x1);
        y0 -= q*y1; swap(y0, y1);
    }
    x = x0; y = y0; return a;
}
int ctz(uint x) {return __builtin_ctz(x);}
int ctzll(ull x) {return __builtin_ctzll(x);}
int clz(uint x) {return __builtin_clz(x);}
int clzll(ull x) {return __builtin_clzll(x);}
int popcnt(uint x) {return __builtin_popcount(x);}
int popcntll(ull x) {return __builtin_popcountll(x);}
int bsr(uint x) {return 31^clz(x);}
int bsrll(ull x) {return 63^clzll(x);}

int main()
{
    canhazfast();

    int x;

    cin >> x;
    cout << 8-(x-400)/200 << '\n';

    return 0;
}


Measured memory_bytes: 3648
d=3;a=[]
n=int(input());s=n**.5
while n%2==0 and n>3:a+=[2];n//=2
while s>d and n>d:
 if n%d>0:d+=2
 else:a+=[d];n//=d

a+=[n];p=1
for f in set(a):
 p*=f**a.count(f)*(1-1/f)
print(int(p))


Measured memory_bytes: 5636
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

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

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, n) for (ll i = n; i >= 0; --i)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define pb push_back
#define ist insert
#define fst first
#define snd second



int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    ll N, T;
    cin >> N >> T;
    vector<pair<ll, ll>> X;
    rep (i, N) {
        ll t;
        cin >> t;
        X.pb({t + T, t});
    }
    sort(all(X));
    if (N == 1) {
        cout << X[0].fst - X[0].snd << endl;
    } else {
        ll ans = X[0].fst - X[0].snd;
        rep(i, N - 1) {
            ans += X[i + 1].fst - max(X[i].fst, X[i + 1].snd);
        }
        cout << ans << endl;
    }
}


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

// 9*9 ÌpYÌóÔð\·
int m[81];
// (x,y)ªÔá¦Ä¢éÌÆ« d[y*9+x] = 1
int d[81];

void solve(){
	// ú»
	for(int i=0 ; i < 81 ; i++ ){
		d[i] = 0;
	}
	
	for(int y=0 ; y < 9 ; y++ ){
		// f[i] :=  i ªo»µ½ñ
		int f[10] = {0};
		for(int x=0 ; x < 9 ; x++ ){
			int i = y * 9 + x;
			f[ m[i] ]++;
		}
		for(int x=0 ; x < 9 ; x++ ){
			int i = y * 9 + x;
			if( f[ m[i] ] >= 2 ){
				d[i] = 1;
			}
		}
	}
	for(int x=0 ; x < 9 ; x++ ){
		// f[i] :=  i ªo»µ½ñ
		int f[10] = {0};
		for(int y=0 ; y < 9 ; y++ ){
			int i = y * 9 + x;
			f[ m[i] ]++;
		}
		for(int y=0 ; y < 9 ; y++ ){
			int i = y * 9 + x;
			if( f[ m[i] ] >= 2 ){
				d[i] = 1;
			}
		}
	}
	for(int i=0 ; i < 9 ; i++ ){
		// f[i] :=  i ªo»µ½ñ
		int f[10] = {0};
		int a[9] = {0,3,6,27,30,33,54,57,60};
		int b[9] = {0,1,2,9,10,11,18,19,20};
		for(int j=0 ; j < 9 ; j++ ){
			int k = a[i] + b[j];
			f[ m[k] ]++;
		}
		for(int j=0 ; j < 9 ; j++ ){
			int k = a[i] + b[j];
			if( f[ m[k] ] >= 2 ){
				d[k] = 1;
			}
		}
	}
}

int main(){
	int n;
	cin >> n;
	for(int t=0 ; t < n  ; t++ ){
		for(int i=0 ; i < 81 ; i++ ){
			cin >> m[i];
		}
		
		if( t != 0 ){
			cout << endl;
		}
		solve();
		for(int y=0 ; y < 9 ; y++ ){
			for(int x=0 ; x < 9 ; x++ ){
				int i = y * 9 + x;
				char c;
				c = (d[i])? '*' : ' ';
				cout << c << m[i];
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 0
#include <stdio.h>

int main(){
	int i,j;
	int a[101][101]={{0}};
	int x,y;
	scanf("%d %d",&x,&y);
	for(j=0;j<x;j++){
		for(i=0;i<y;i++){
			scanf("%d",&a[j][i]);
			a[j][y]+=a[j][i];
			a[x][i]+=a[j][i];
		}
		a[x][y]+=a[j][y];
	}
	for(j=0;j<=x;j++){
		for(i=0;i<=y;i++){
			printf("%d",a[j][i]);
			if(i!=y){
				printf(" ");
			}
		}
		
			printf("\n");
		
	}
	return 0;
}

Measured memory_bytes: 652
n,m=(int(x) for x in input().split())
a=[int(y) for y in input().split()]
z=0
for i in range(0,len(a)):
  if a[i]>=sum(a)/(4*m):
    z=z+1
  else:
    z=z
if m<=z<=n:
  print('Yes')
else:
  print('No')

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

int main() {
  string S;
  cin >> S;
  
  if(S.at(1) == 'S'){
    if(S.at(0) == 'S' && S.at(2) == 'S'){
      cout << 0 <<endl;
    }
    else{
      cout << 1 <<endl;
    }
  }
  else if(S.at(0) == 'R' && S.at(2) == 'R'){
    cout << 3 <<endl;
  }
  else if(S.at(0) == 'S' && S.at(2) == 'S'){
    cout << 1 <<endl;
  }
  else{
    cout << 2 <<endl;
  } 
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;
int main(){
  int n; cin >> n;
  vector<int> d(n);
  ll ans =0;

  rep(i,n) cin >> d.at(i);

  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      ans += d.at(i)*d.at(j);
    }
  }

  cout << ans << endl;

}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
const int MAX = 510000;
const ll MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//a^n%mod
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int main(){
  string s;
  cin >> s;
  ll n=s.size();
  ll a[n+1];
  a[0]=0;
  ll c[n+1];
  ll b[n+1];
  b[0]=0;
  ll bb[n+1];
  bb[n]=0;
  c[n]=0;
  rep(i,n){
    if(s[i]=='A')a[i+1]=a[i]+1;
    else a[i+1]=a[i];
    if(s[i]=='?')b[i+1]=b[i]+1;
    else b[i+1]=b[i];
    if(s[n-1-i]=='C')c[n-1-i]=c[n-i]+1;
    else c[n-1-i]=c[n-i];
    if(s[n-1-i]=='?')bb[n-1-i]=bb[n-i]+1;
    else bb[n-1-i]=bb[n-i];
  }
  ll q[n];
  q[0]=1;
  rep(i,n-1)q[i+1]=q[i]*3%MOD;
  ll ans=0;
  //cout << s << n << endl;
  rep(i,n){
    if(s[i]=='B'||s[i]=='?'){
      //cout << 111 << endl;
      ans=(ans+(a[i]*q[b[i]]+(b[i]*q[max((ll)0,b[i]-1)])%MOD)%MOD*((c[i+1]*q[bb[i+1]]+(bb[i+1]*q[max(bb[1+i]-1,(ll)0)])%MOD)%MOD)%MOD)%MOD;
    }
    //cout << a[i] << " " << b[i] << " " << c[i+1] << " " << bb[i+1] << " " << q[b[i]] << " " << q[max((ll)0,b[i]-1)] << endl;
    //cout << ans << " " << -1<< endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <utility>
#define llint long long
#define mod 1000000007
#define inf 1e18

using namespace std;
typedef pair<llint, pair<llint, llint> > T;

llint a, b, c, n;
llint dx[] = {0, 0, -1, 1, 0, 0}, dy[] = {-1, 1, 0, 0, 0, 0}, dz[] = {0, 0, 0, 0, -1, 1};
set<T> S;

int main(void)
{

    cin >> a >> b >> c >> n;
    llint ans = a*b+b*c+c*a;
    ans *= 2;
    llint x, y, z;
    for(int i = 1; i <= n; i++){
      cin >> x >> y >> z;
      for(int j = 0; j < 6; j++){
        llint nx = x + dx[j], ny = y + dy[j], nz = z + dz[j];
        if(nx < 0 || nx >= a || ny < 0 || ny >= b || nz < 0 || nz >= c || S.count(T(nx, make_pair(ny, nz)))) ans--;
        else ans++;
        S.insert(T(x, make_pair(y, z)));
      }
    }
    cout << ans << endl;

  return 0;
}



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

int main() {
  int n; cin >> n;
  int h[n];
  for (auto &v : h) cin >> v;
  int hmax = 0;
  int ans = 0;
  for (auto &v : h) if (hmax <= v) { ++ans; hmax = v; }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <string>
#include <iostream>
using namespace std;
 
int main(){
    string s;
    cin >> s;
    long long int x=0;
    for(long long int i=0; i<s.length(); i++){
        x += (s[i] - '0');
    }
    if(x%9==0)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 3712
num = int(raw_input())
line = raw_input()
 
item_str = line.strip().split(" ")
print " ".join(item_str)
A = map(int, item_str)
 
for i in range(1, num):
    v = A[i]
    j = i - 1
    for j in range(j, -1, -1):
        if A[j] > v:
            A[j+1] = A[j]
            j -= 1
        else:
            break
    A[j+1] = v
    str_A = map(str, A)
    print " ".join(str_A)

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


Measured memory_bytes: 3084
#include <cstdio>
#include <map>
using namespace std;
typedef long long ll;
ll h, w, n, a, b, c[15];
map<pair<ll,ll>,ll> mp;
int main() {
	ll i, j;
	scanf("%d%d%d", &h, &w, &n);
	c[0] = (h-2) * (w-2);
	while(n--) {
		scanf("%d%d", &a, &b);
		for(i=a; i<a+3; i++) for(j=b; j<b+3; j++) {
			if(i>2 && j>2 && i<=h && j<=w) {
				c[mp[{i,j}]]--;
				c[++mp[{i,j}]]++;
			}
		}
	}
	for(i=0; i<=9; i++) printf("%lld\n", c[i]);
	return 0;
}

Measured memory_bytes: 56448
#include <stdio.h>

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

    scanf("%d %d %d\n", &a, &b, &c);

    if((a != b && b != c && c != a) || (a == b && b == c)){
        printf("No\n");
    }else{
        printf("Yes\n");
    }
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
int main()
{
    std::string str,a;
    std::cin >> str;
    int c = 0;
    bool result = false;
    for(char b : str){
        if(b == 'A'){
            if(str[c + 1] == 'C'){
                result = true;
            }
        }
        c++;
        if(c == str.size())break;
    }
    if(result){
        std::cout <<"Yes"<<std::endl;
    }else{
        std::cout <<"No"<<std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, greater<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 100'000;
const int LOGN = 19;

int n, m, k;

pair<int, int> d[300][300];
int was[300];

void solve(int test) {
  cin >> n >> m >> k;
  vector<vector<int>> g(n, vector<int>(n));
  for (int i = 0; i < m; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    --a; --b;
    g[a][b] = c;
    g[b][a] = c;
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      d[i][j].first = inf;
      d[i][j].second = 0;
    }
    d[i][i].first = 0;
    d[i][i].second = k;
    memset(was, 0, sizeof(was));
    for (int j = 0; j < n - 1; ++j) {
      int v = -1;
      for (int q = 0; q < n; ++q) {
        if (was[q]) {
          continue;
        }
        if (v == -1 || d[i][v].first > d[i][q].first) {
          v = q;
        } else if (d[i][v].first == d[i][q].first && d[i][v].second < d[i][q].second) {
          v = q;
        }
      }
      was[v] = 1;
      for (int q = 0; q < n; ++q) {
        if (g[v][q] && g[v][q] <= k) {
          int refil = d[i][v].first;
          int cap = d[i][v].second;
          if (g[v][q] > cap) {
            ++refil;
            cap = k;
          }
          cap -= g[v][q];
          if (d[i][q].first > refil) {
            d[i][q] = make_pair(refil, cap);
          } else if (d[i][q].first == refil && d[i][q].second < cap) {
            d[i][q] = make_pair(refil, cap);
          }
        }
      }
    }
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    if (d[a][b].first == inf) {
      d[a][b].first = -1;
    }
    cout << d[a][b].first << '\n';
  }
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}




Measured memory_bytes: 1664
import sys
input = sys.stdin.readline

K, S = map(int, input().split())

# X + Y = A
# Z = S - A
ans = 0
for A in range(2*K+1):
    Z = S - A
    if 0 <= Z and Z <= K:
        for X in range(K+1):
            Y = A - X
            if 0 <= Y and Y <= K:
                ans += 1
print(ans)

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define bitget(a, b) (((a) >> (b)) & 1)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vsort(x) sort(x.begin(), x.end())

using int32 = int_fast32_t;
using int64 = int_fast64_t;
using uint32 = uint_fast32_t;
using uint64 = uint_fast64_t;

using namespace std;

int main() {
	int x, y, z;
	scanf("%d %d %d", &x, &y, &z);
	int64 ans;
	x -= z;
	ans = x / (y + z);
	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from math import ceil

t1, t2 = li()
a1, a2 = li()
b1, b2 = li()

# 交互になる
if (b1 - a1) * t1 + (b2 - a2) * t2 == 0:
    print('infinity')

# 高橋君が先を行く
elif (b1 - a1) * t1 + (b2 - a2) * t2 < 0:
    # ずっと高橋君の方が速い
    if (b1 - a1) * t1 < 0 and (b2 - a2) * t2 < 0:
        print(0)
    # T2分間は追いつかれる
    elif (b1 - a1) * t1 < 0 and (b2 - a2) * t2 > 0:
        print(0)
    # T1分間は追いつかれる
    else:
        cross = ceil((b1-a1)*t1 / ((a1-b1)*t1 + (a2-b2)*t2)) - 1
        #print(((b1-a1)*t1 + (b2-a2)*t2) * (cross+1) + (a1-b1)*t1)
        if ((a1-b1)*t1 + (a2-b2)*t2) * (cross+1) + (a1-b1)*t1 == 0:
            print(2* (cross+ 1))
        else:
            print(2 * cross + 1)

# 高橋君が遅れる
else:
    # ずっと高橋君のほうが遅い
    if (b1 - a1) * t1 > 0 and (b2 - a2) * t2 > 0:
        print(0)
    # T2分間は追い上げる
    elif (b1 - a1) * t1 > 0 and (b2 - a2) * t2 < 0:
        print(0)
    # T1分間は追い上げる
    else:
        cross = ceil((b1-a1)*t1 / ((a1-b1)*t1 + (a2-b2)*t2)) - 1
        #print(((a1-b1)*t1 + (a2-b2)*t2) * (cross+1) + (a1-b1)*t1)
        if ((a1-b1)*t1 + (a2-b2)*t2) * (cross+1) + (a1-b1)*t1 == 0:
            print(2 * (cross + 1))
        else:
            print(2 * cross + 1)


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int h, w;
string s[101];
int main(void){
    cin >> h >> w;
    s[0] = string(w+1, '#');
    for(int i=1;i<=h;i++){
        string t;
        cin >> t;
        s[i] = "#" + t;
    }

    vector< vector< int > > mem(h+1, vector<int>(w+1, 1e5));
    s[0][1] = s[1][0] = '.';
    mem[0][1] = mem[1][0] = 0;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            int x = mem[i][j-1];
            if(s[i][j-1] == '.' && s[i][j] == '#') x++;
            int y = mem[i-1][j];
            if(s[i-1][j] == '.' && s[i][j] == '#') y++;
            mem[i][j] = min(x, y);
        }
    }
    cout << mem[h][w] << endl;
}


Measured memory_bytes: 256
from itertools import combinations


def get_primes(N):
    primes = []
    for num in range(2, N + 1):
        for prime in primes:
            if num % prime == 0:
                break
        else:
            primes.append(num)
    return primes


N = int(input())

primes = get_primes(55555)

# 列挙した素数のうち、5で割った余りが1であるものだけ抽出
primes_5 = []
for prime in primes:
    if prime % 5 == 1:
        primes_5.append(prime)

primes_5 = primes_5[:N]
print(*primes_5)


Measured memory_bytes: 71744
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int main()
{
    LL x;
    cin >> x;
    LL a = x / 11;
    LL ans = a * 2;
    x -= a * 11;
    int i = 0;
    while (x > 0)
    {
        x -= (i % 2 == 0) ? 6 : 5;
        ++ans;
        ++i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i=0;i<n;i++) a[i] = sc.nextInt();
		sc.close();

		int count = 0;
		for(int i=0;i<n;i++){
			if(a[a[i]-1]==i+1) count ++;
		}
		System.out.println(count/2);
	}

}

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

struct Point{double x,y;};

void koch(int n, Point a, Point b){
	if(n==0) return;
	Point s, t, u;
	double th = M_PI * 60.0 / 180.0;

	s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
	s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
	t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
	t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
	u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
	u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

	koch(n-1,a,s);
	printf("%.8f %.8f\n",s.x,s.y);
	koch(n-1,s,u);
	printf("%.8f %.8f\n",u.x,u.y);
	koch(n-1,u,t);
	printf("%.8f %.8f\n",t.x,t.y);
	koch(n-1,t,b);
}

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

	scanf("%d",&n);

	a.x = 0;
	a.y = 0;
	b.x = 100;
	b.y = 0;

	printf("%.8f %.8f\n",a.x,a.y);
	koch(n,a,b);
	printf("%.8f %.8f\n",b.x,b.y);
	
	return 0;
}

Measured memory_bytes: 2696
#include<bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define N 200005

#define fast ios_base::sync_with_stdio(false)
#define itt cin.tie(0)
#define now cout.tie(0)

using namespace std;

ll n,m,a[N];

int main()
{
	cin>>n;
	memset(a,0,sizeof(a));
	for(ll i=0;i<n-1;i++)
	{
		cin>>m;
		a[m]++;
	}
	for(ll i=1;i<=n;i++)
	{
		cout<<a[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 5152
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

int W_Length(char *str){
	int length = 0;
	while(*str++ != '\0')
		length++;
	return length;
}

void swap(int *a, int *b){
  int temp;
  temp=*a;
  *a=*b;
  *b=temp;
}
//swap(&a, &b)

double deg(double theta){//deg to theta
return theta*(2*3.14159265359)/360;
}

int cmp( const void *p, const void *q ) {
    return *(int*)p - *(int*)q;
}//ちいさい順
//qsort(a,n,sizeof(int),cmp);
//char s[n][11]

int cmp_s(const void * left, const void * right)
{
	char *left_char = (char *)left;
  char *right_char = (char *)right;
  return strcmp(left_char, right_char);
}
//qsort(s,n,sizeof(s[0]),cmp_s);


int main (void)
{
	int a[210000],b,c,n,i,cou[4]={0};
  char s[210000][5];

scanf("%d",&n);
	for(i=0;i<n;i++){
scanf("%s",s[i]);
	}
  
  for(i=0;i<n;i++){
    
if(strcmp(s[i],"AC")==0){
cou[0]++;
}
    
    else if(strcmp(s[i],"WA")==0){
    cou[1]++;
    }
    
    else if(strcmp(s[i],"TLE")==0){
    cou[2]++;
    }
    
    else{
    cou[3]++;
    }
    
	}
  printf("AC x %d\n",cou[0]);
  printf("WA x %d\n",cou[1]);
  printf("TLE x %d\n",cou[2]);
  printf("RE x %d\n",cou[3]);
  
return 0;
}


Measured memory_bytes: 2224
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n;
	cin >> n;
	if (n%2==1) {
		cout << (n+1)/2*((n-1)/2) << endl;
	} else {
		cout << (n/2)*(n/2) << endl;
	}
}

Measured memory_bytes: 256
N = int(input())
W = [input() for _ in range(N)]
exist = []
for i, w in enumerate(W):
    if w in exist:
        print("No")
        exit()
    if i != 0 and W[i - 1][-1] != w[0]:
        print("No")
        exit()
    exist.append(w)
print("Yes")


Measured memory_bytes: 3064
import heapq
import copy
import numpy as np

N=int(input())
A=[]
for n in range(N):
    A.append( int(input()) )
A_ = copy.deepcopy(A)
A_ = np.array(A_)
A_ *= -1
A_ = list(A_)
heapq.heapify( A_ )
max_val = heapq.heappop(A_)*(-1)
second_max_val = heapq.heappop(A_)*(-1)

is_max = []
for n in range(N):
    if A[n]==max_val:
        is_max.append(True)
    else:
        is_max.append(False)
max_val_num = np.sum( np.array(is_max) )

for n in range(N):
    if max_val_num > 1:
        print(max_val)
    else:
        if is_max[n]:
            print(second_max_val)
        else:
            print(max_val)


Measured memory_bytes: 30980
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

using ull = unsigned long long;

int main() {
	int n, x=0;
	cin >> n;
	vector<int> a = vector<int>(n);
	for (int i = 0; i < n; ++i){
		cin >> a[i];
		x ^= a[i];
	}
	for (int i = 0; i < n; ++i){
		cout << (x^a[i]) << " ";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3940
//??????????SM??????????

//  -------------Sourav Mondal----------   
//        _____________________________________"GUN IS ON FIRE~SM"
//..._|.._|___________________, ,) ----)           "KILL YOUR headache Shoot iT"
//....../ `---___________----_____|]_____)     ********* 2eZ4@SM
//...../_==o;;;;;;;;_______.:/ 
//.....), ---.(_(__) /                                   ask2sm*********
//....// (.||_.) ), ----" 
//...//___//
//../|___/|                              
//.||___||
//----------------------------------------------------------------------------


#include<bits/stdc++.h>
using namespace std;
#define llt long long int
int main(){
    int n,a,b;
  cin>>n>>a>>b;
  cout<<min(n*a,b)<<endl;
return 0;
}
//-------------------------------------IND------------------------------------

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	long long int x,y,a,i;
	scanf("%lld%lld",&x,&y);
	if(x%y==0){
		puts("-1");
	}else{
		for(i=1;;i++){
			a=x*i;
			if(a%y!=0){
				printf("%lld\n",a);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 128
N=int(input())
xy = [map(int, input().split()) for _ in range(N)]
x, y = [list(i) for i in zip(*xy)]
cnt=0
result="No"
# 出力して確認
#for n in range(N-1):
for i in range(N):
    cnt=cnt+1 if x[i]==y[i] else 0
    if cnt>2:
        result="Yes"
print(result)

Measured memory_bytes: 9196
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		String s = sc.next();
		int[][] a = new int[7][n];
		
		int[] J = new int[]{0,3,5,6};
		int[] O = new int[]{1,3,4,6};
		int[] I = new int[]{2,4,5,6};
		int[] p = new int[]{0,1,3,4,5,6};
		int[] q = new int[]{1,2,3,4,5,6};
		int[] r = new int[]{0,2,3,4,5,6};
		
		a[3][0] = 1;
		a[5][0] = 1;
		a[6][0] = 1;
		char c = s.charAt(0);
		if(c=='J') a[0][0] = 1;
		else if(c=='O') a[5][0] = 0;
		else if(c=='I') a[3][0] = 0;
		
		for(int i=1;i<n;i++){
			c = s.charAt(i);
			
			if(c=='J') for(int j=0;j<4;j++) a[0][i] += a[J[j]][i-1];
			else if(c=='O') for(int j=0;j<4;j++) a[1][i] += a[O[j]][i-1];
			else if(c=='I') for(int j=0;j<4;j++) a[2][i] += a[I[j]][i-1];
			if(c!='I') for(int j=0;j<6;j++) a[3][i] += a[p[j]][i-1];
			if(c!='J') for(int j=0;j<6;j++) a[4][i] += a[q[j]][i-1];
			if(c!='O') for(int j=0;j<6;j++) a[5][i] += a[r[j]][i-1];
			for(int j=0;j<7;j++) a[6][i] += a[j][i-1];
			
			for(int j=0;j<7;j++) a[j][i] %= 10007;
		}
		
		for(int i=1;i<7;i++) a[0][n-1] += a[i][n-1];
		System.out.println(a[0][n-1]%10007);
	}

}

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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define _sort(a) sort(a.begin(), a.end())
#define _sort_d(a) sort(a.rbegin(), a.rend())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

int main() {
  string s, t;
  cin >> s >> t;

  _sort(s); _sort_d(t);
  if (s < t) {
    py();
  } else {
    pn();
  }
}

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

int main() {
  string a, b;
  cin >> a >> b;
  if (a.size() == b.size()) {
    if (a == b) {
      cout << "EQUAL" << endl;
      return 0;
    }
    cout << (a > b ? "GREATER" : "LESS") << endl;
    return 0;
  }
  cout << (a.size() > b.size() ? "GREATER" : "LESS") << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

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

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(n)-1,i##_len=(int)(s);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 2019

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};
//今回の変数

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
ll Minl(ll a, ll b) {
	return (a)<(b) ? (a) : (b);
}
ll Maxl(ll a, ll b) {
	return (a)>(b) ? (a) : (b);
}
void hSwap(int x[], int i, int j)
{
	int temp;

	temp = x[i];
	x[i] = x[j];
	x[j] = temp;
}
void ShowData(int x[], int left, int right)
{
	int i;
	for (i = left; i <= right; i++)printf("%d  ", x[i]);
	printf("\n");
}
void QSort(int x[], int left, int right, int n) {
	int i, j;	//左端,右端
	int pivot;	//軸

	i = left;
	j = right;
	pivot = x[(left + right) / 2];

	while (1) {
		if (n > 0) {				//n>0なら昇順、n<=0なら降順
			while ((x[i] < pivot) && (i <= right))i++;	//軸値より大きい要素
			while ((pivot < x[j]) && (i <= right))j--;	//軸値より小さい要素
		}
		else {
			while ((x[i] > pivot) && (i <= right))i++;	//軸値より小さい要素
			while ((pivot > x[j]) && (i <= right))j--;	//軸値より大きい要素
		}
		if (i >= j)	break;
		hSwap(x, i, j);
		i++; j--;
	}
	//ShowData(x, left, right);

	if (left < i - 1)QSort(x, left, i - 1, n);
	if (j + 1 <  right)QSort(x, j + 1, right, n);
}


int main() {
	int n;
	scanf("%d", &n);
	int a[100000];
	REP(i, n) {
		scanf("%d", &a[i]);
	}
	QSort(a, 0, n - 1, 1);
	//ShowData(a, 0, n-1);

	if ((a[0] ^ a[n/3]) != a[n/3*2]) {
		puts("No");
		return 0;
	}
	FOR(i, 1, n/3) {
		//printf("%d %d", a[i], a[0]);
		if (a[i] != a[0]) {
			puts("No");
			return 0;
		}
	}
	FOR(i, n/3+1, n / 3 * 2) {
		//printf("%d %d", a[i], a[n/3]);
		if (a[i] != a[n/3]) {
			puts("No");
			return 0;
		}
	}
	FOR(i, n / 3 * 2 + 1, n) {
		//printf("%d %d", a[i], a[n/3*2]);
		if (a[i] != a[n/3*2]) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String args[]) {
		while(true) {
			int a = sc.nextInt(), b = sc.nextInt();
			if(a == 0 && b == 0) break;
			int[][] ary = new int[a][b];
			ary[0][0] = 1;
			int N = sc.nextInt();
			for(int i = 0; i < N; i++) {
				ary[sc.nextInt() - 1][sc.nextInt() - 1] = -1;
			}
			
			for(int y = 0; y < b; y++) {
				for(int x = 0; x < a; x++) {
					if(x == 0 && y == 0) continue;
					if(ary[x][y] == -1) continue;

					if(y == 0 && ary[x - 1][y] != -1) {
						ary[x][y] = ary[x - 1][y];
					}
					else if(x == 0 && ary[x][y - 1] != -1) {
						ary[x][y] = ary[x][y - 1];
					} else {
						if(y != 0 && ary[x][y - 1] != -1) ary[x][y] += ary[x][y - 1];
						if(x != 0 && ary[x - 1][y] != -1) ary[x][y] += ary[x - 1][y];
					}
				}
			}
			System.out.println(ary[a - 1][b - 1]);
		}
	}
}

Measured memory_bytes: 12000
//#define NDEBUG

#include <bits/stdc++.h>
#include <bits/extc++.h>

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define mt make_tuple
#define gt(t, i) get<i>(t)
#define iceil(a, b) (((a) + (b) - 1) / (b))
#define tomax(a, b) ((a) = max((a), (b)))
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}

//#define TEST

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;
using tiii = tuple<int, int, int>;

const ll MOD = 1000000007;
const ll MAX = 2147483647;

template<typename A, typename B>
ostream& operator<<(ostream& o, pair<A, B> p){
    return o << '(' << p.F << ',' << p.S << ')';
}

int main(){
    StarBurstStream

    int k, s;
    cin >> k >> s;

    int ans = 0;
    for(int x = 0; x <= k; x++){
        for(int y = 0; y <= k; y++){
            int z = s - x - y;
            if(z >= 0 && z <= k) ans++;
        }
    }
    cout << ans << "\n";

    return 0;
}

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

#define all(p) p.begin(), p.end()
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define ll long long
#define llu unsigned long long
#define ld long double
#define vll vector<long long int>
#define vi vector<int>
#define pii pair <int, int>
#define pll pair <long long int, long long int>
#define vpii vector<pair<int,int> >
#define nl cout<<"\n"
#define sp cout<<" "
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)

const  int  INF = 0x7f7f7f7f;
char grid[205][205];
int  main ()
{
	ios_base::sync_with_stdio(false);
    //freopen ("input.txt", "r", stdin);
    //freopen ("output.txt", "w", stdout);
    int h,w;
    char c[105][105];
    cin>>h>>w;
    rep(i,1,h) rep(j,1,w) cin>>c[i][j];

    for(int i=1; i<=2*h; i++)
    {
        for(int j=1; j<=w; j++)
        {
            grid[i][j] = c[(i+1)/2][j];
        }
    }

    for(int i=1; i<=2*h; i++)
    {
        for(int j=1; j<=w; j++)
            cout<<grid[i][j];
        nl;
    }
    return  0;
}


Measured memory_bytes: 384
package main

import "fmt"

func fizzBuzz(i int) bool {
	if i%3 == 0 {
		return true
	} else if i%5 == 0 {
		return true
	}
	return false
}

func main() {
	var n int
	fmt.Scan(&n)

	var res int
	for i := 1; i < n+1; i++ {
		if !fizzBuzz(i) {
			res += i
		}
	}

	fmt.Println(res)
}


Measured memory_bytes: 1756
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define faster ios_base::sync_with_stdio(0);
#define faster_tie cin.tie(0);
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define NL cout<<'\n'

ll n,k,x;
vector<ll>height;
vector <ll> sol(110000,-1);

ll solve(ll x)
{
    if(x==1)
    {
        sol[x]=0;
        return 0;
    }
    if(sol[x]!=-1)return sol[x];
    ll a=INT_MAX;

    for(ll i=x-1;i>x-1-k;i--)
    {
        if(i==0)break;
        a=min(a,solve(i)+abs(height[i]-height[x]));
    }
    sol[x]=a;
    return a;

}


int main()
{
    cin>>n>>k;
    height.push_back(-1);
    for(ll i=0;i<=n;i++)
    {
        sol[i]=-1;
    }
    for(int i=0;i<n;i++)
    {
        cin>>x;
        height.push_back(x);
    }

    ll ans=solve(n);
    cout<<ans;



    return 0;
}


Measured memory_bytes: 6644
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <math.h>

int main (void)
{
    char S[4], T[4];
    intmax_t ans = 0;

    gets(S);
    gets(T);

    if (S[0] == T[0]) ans++;
    if (S[1] == T[1]) ans++;
    if (S[2] == T[2]) ans++;

    printf("%jd\n", ans);

    return 0;
}


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

int main(){
	string a,b,c;
  	cin >> a >> b >> c;
  	int an=0,bn=0,cn=0,colo=1;
  	while(true){
    	if (colo==1){
          if (an==a.size()){cout <<"A"<<endl; break;}
          if (a[an]=='a')colo=1;
          if (a[an]=='b')colo=2;
          if (a[an]=='c')colo=3;
          an+=1;}
    	if (colo==2){
          if (bn==b.size()){cout <<"B"<<endl; break;}
          if (b[bn]=='a')colo=1;
          if (b[bn]=='b')colo=2;
          if (b[bn]=='c')colo=3;
          bn+=1;}
      	if (colo==3){ 
          if (cn==c.size()){cout <<"C"<<endl; break;}
          if (c[cn]=='a')colo=1;
          if (c[cn]=='b')colo=2;
          if (c[cn]=='c')colo=3;
          cn+=1;}
      	 }
}

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

int main() {
  int n, m;
  cin >> n >> m;

  int sum = 0;

  for (int i = n - 1; i > 0; i --) {
    sum += i;
  }
  for (int i = m - 1; i > 0; i --) {
    sum += i;
  }

  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr ll INF = (1LL << 55);
int main(){
  int n;
  ll k;
  cin >> n >> k;
  vector<ll> a(n), f(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> f[i];
  sort(a.begin(), a.end());
  sort(f.begin(), f.end(), greater<ll>());
  auto ok = [&](ll m){
    ll cnt = 0;
    for (int i = 0; i < n; i++) {
      cnt += max(0LL, a[i] - m /f[i]);
    }
    return cnt <= k;
  };
  ll l = -1, r = INF;
  while (r - l > 1) {
    ll m = (r + l) / 2;
    if (ok(m)) r = m;
    else l = m;
  }
  cout << r << endl;
  return 0;
}

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

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

	string s = string( 3, 'S' );
	int ans = 0;
	if( S[0] == 'S' && S[1] == 'S' && S[2] == 'S' ) ;
	else if( S[0] == 'R' && S[1] == 'R' && S[2] == 'R' ) ans = 3;
	else if( S[0] == 'R' && S[1] == 'R' && S[2] == 'S' ) ans = 2;
	else if( S[0] == 'S' && S[1] == 'R' && S[2] == 'R' ) ans = 2;
	else ans = 1;

	cout << ans << endl;
}


Measured memory_bytes: 3620
<?php
fscanf(STDIN, "%d %d", $process_count, $quantum);
$queue = [];
$head=0;
$tail=0;

for($i = 0; $i < $process_count; $i++) $queue[$tail++] = explode(" ",trim(fgets(STDIN)));
$total_time = 0;

while ($head!=$tail) {
    $tmp = $queue[$head++];
    if ($tmp[1] <= $quantum) {
        $total_time += $tmp[1];
        $tmp[1] = $total_time;
        echo ("$tmp[0] $tmp[1]\n"); 
        continue;
    }
    $tmp[1] -= $quantum;
    $queue[$tail++] = $tmp;
    $total_time += $quantum;
}



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

using i64 = long long int;

i64 gcd(i64 m, i64 n) {
    return (n == 0 ? m : gcd(n, m % n));
}

i64 lcm(i64 m, i64 n) {
    return m / gcd(m, n) * n;
}

int main(){
    int n;
    cin >> n;
    i64 ans;
    for(int i=0;i<n;++i){
        i64 t;
        cin >> t;
        if(i == 0)ans = t;
        else ans = lcm(ans, t);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const string keyword[] = {"that", "this" };

int affine (int a, int b, int x )
{
	return ((a*x + b ) % 26 );
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.AC", "r", stdin );
	int n;
	string sn = "";
	getline (cin, sn );
	stringstream ssn (sn );
	ssn >> n;
//	scanf ("%d", &n );
	rep (i, n ){
		string str = "";
		getline (cin, str );
		int m = str.length();
		string res = "";
		for (int a = 1; a <= 26; a++ ){
			if (__gcd (a, 26 ) != 1 ) continue;
			for (int b = 0; b <= 26; b++ ){
				string s = str;
				rep (i, m ){
					if (isalpha(s[i] ) ){
						char c = (char)(affine (a, b, (int)(s[i] - 'a') ) + 'a' );
						if (isalpha (c ) ){
							s[i] = c;
						} // end if
					} // end if
				} // end rep
//				cerr << "s: " << s << endl;
				rep (i, 2 ){
					if (s.find (keyword[i] ) != string::npos ){
						res = s;
						break;
					} // end if
				} // end rep
				if (!res.empty() ) break;
			} // end for
			if (!res.empty() ) break;
		} // end for
		cout << res << endl;
	} // end loop
		
	return 0;
}

Measured memory_bytes: 1232
import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
  [n, m] <- f
  unless (n == 0 && m == 0) $ do
    solve n m <$> f >>= print
    main
  where
    f = map read <$> words <$> getLine

solve :: Int -> Int -> [Int] -> Int
solve n m xs = h . head . groupBy g . sort . map f $ zip xs [1..]
  where
    f (x, i) = (m `div` x * x, x, i)
    g (t1, x1, _) (t2, x2, _) = t1 == t2 && x1 == x2
    h ys
      | length ys > 1 = n
      | otherwise = let (_, _, i) = head ys in i



Measured memory_bytes: 5028
<?php
// Your code here!
$input = explode(" ",trim(fgets(STDIN)));
$a = $input[0];
$b = $input[1];
$c = $input[2];
$x = $input[3];
$y = $input[4];

$case1 = $a * $x + $b * $y;

if($x <= $y){
    $case2 = $b*($y-$x)+$c * 2 *$x;
}else{
    $case2 = $a*($x-$y)+$c*2*$y;
}

if($x <= $y){
   $case3 = $c * 2 *$y; 
}else{
    $case3 = $c * 2 *$x;
}

echo min($case1,$case2,$case3);



?>


Measured memory_bytes: 4728
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
//typedef __int128_t lll;
using namespace std;

ll P;
vvl G = vv(100001, 0, 0, ll);
vll num(100001, 1);
vll rev(100001, 1);
vvl t = vv(100001, 0, 0, ll);

ll f_bottom(ll now, ll from){
  ll ret = 1;
  for(int i=0;i<G[now].size();i++){
    if(G[now][i] == from) continue;
    ll tmp = (f_bottom(G[now][i], now) + 1)%P;
    t[now].push_back(tmp);
    ret = (ret * tmp)%P;
  }
  return num[now] = ret;
}

void f_down(ll now, ll from){
  vll l(t[now].size(), 1), r(t[now].size(), 1);
  for(int i=0;i<t[now].size();i++) l[i] = ((i==0?1:l[i-1]) * t[now][i])%P;
  for(int i=0;i<t[now].size();i++) r[i] = ((i==0?1:r[i-1]) * t[now][t[now].size()-1-i])%P;

  ll c = 0;
  for(int i=0;i<G[now].size();i++){
    if(G[now][i]==from) continue;
    ll tmp = ((c==0?1:l[c-1])*(c==t[now].size()-1?1:r[t[now].size()-2-c]))%P;
    c++;
    tmp = (rev[now] * tmp)%P;
    rev[G[now][i]] = (tmp + 1)%P;
  }
  for(int i=0;i<G[now].size();i++){
    if(G[now][i]==from) continue;
    f_down(G[now][i], now);
  }
}

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n >> P;

  re(i, n-1){
    ll a, b;scanf("%lld %lld", &a, &b);
    G[a].push_back(b), G[b].push_back(a);
  }
  f_bottom(1, -1);
  f_down(1, -1);
  for(int i=1;i<=n;i++){
    std::cout << (num[i] * rev[i])%P << '\n';
  }
  return 0;
}


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

int main(void) {
    string S;
    int len,pos;
    cin >> S;

    len = S.size();
       
    if(len < 5){
        goto error_route;
    }
    for(pos=len;pos > 0;) {
        if(pos < 2) goto error_route;
        pos -= 2;
        if(strncmp((char*)&S[pos],"er",2) == 0) {
            if((pos >= 4) && (strncmp((char*)&S[pos-4],"eras",4) == 0)){
                pos -= 4;
            } else if((pos >= 5) && (strncmp((char*)&S[pos-5],"dream",5) == 0)) {
                pos -= 5;
            } else {
                goto error_route;
            }
        } else {
            if(pos < 3) {
                goto error_route;
            }
            pos -= 3;
            if((strncmp((char*)&S[pos],"erase",5) != 0) && (strncmp((char*)&S[pos],"dream",5) != 0)) {
                goto error_route;
            }
        }
    }

    cout << "YES\n";

    return 0;

error_route:
    cout << "NO\n";    
    return 0;
}


Measured memory_bytes: 512
package main

import "fmt"

const mod = 1e9 + 7

func main() {
	var (
		n int
		s string
	)
	fmt.Scan(&n, &s)

	runes := make([]int, 26)
	for i := 0; i < n; i++ {
		runes[s[i]-'a']++
	}

	result := 1
	for i := 0; i < 26; i++ {
		result = result * (runes[i] + 1) % mod
	}
	fmt.Println(result - 1)
}


Measured memory_bytes: 1280
import java.util.*;
import static java.lang.System.*;
public class Main {
  public static void main(String args[]){
    Scanner sc = new Scanner(in);
    int A = sc.nextInt(), B = sc.nextInt();
    int[] array = {A+B,A-B,A*B};
    Arrays.sort(array);
    out.println(array[2]);
  }
}

Measured memory_bytes: 35552
#include<iostream>
#include<map>
#include<cmath>

using namespace std;

int main() {
	map<int, int> card;

	int n;
	cin >> n;

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

	int ans = card.size() - 1 + card.size() % 2;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
using namespace std;
const int inf = 1e18 + 7;
const int N = 1e6 + 7;
const int md = 1e9 + 7;
void sol() {
  int h[N], n, ans = 0, k;
  cin >> n >> k;
  for(int i=0; i<n; i++) {
    cin >> h[i];
  }
  sort(h, h+n);
  reverse(h, h+n);
  for(int i=k; i<n; i++) {
    ans += h[i];
  }
  cout << ans;
}

int32_t main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T = 1;
  //cin >> T; while(T--) 
  sol();
  return 0;
}


Measured memory_bytes: 3584
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
using namespace std; 
map<string,int>	sta;
int direct[4]={1,-1,4,-4};

void BFS()
{
	queue<string> q;
	q.push("01234567");
	sta["01234567"]=0;
	while(!q.empty())
	{
		string now=q.front();
		q.pop();
		
		int p;
		for(int i=0;i<8;++i)
			if(now[i]=='0')	
			{
				p=i;
				break;
			}
			
		for(int i=0;i<4;++i)
		{
			int n=p+direct[i];
			
			if(n<8&&n>=0&&!(p==3&&i==0)&&!(p==4&&i==1))
			{
				string next=now;
				swap(next[p],next[n]);
				if(sta.find(next)==sta.end())//判断该元素是否存在 
				{
					sta[next]=sta[now]+1;
					q.push(next); 
				}				
			}	
		}	
	}
}

int main()
{
	char a;
	string b;
	BFS();
	while(cin>>a)
	{
		b+=a;
		cin.get();
		for(int i=0;i<7;++i)
		{
			cin>>a;
			b+=a;
			cin.get();
		}
		cout<<sta[b]<<endl;
		b.erase(b.begin(),b.end());
	}
	
	return 0;
}


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

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

    vector<int> v(7);
    
    for(int i=0; i<7; i++)
        cin >> v[i];
    
    long long ans1 = 0, ans2 = 0;
    ans1 += v[3] / 2 * 2 + v[4] / 2 * 2;

    if(v[3] % 2 + v[4] % 2 == 2 && v[0])
        ans1 += 3LL + (v[0] - 1) / 2 * 2;
    else
        ans1 += v[0] / 2 * 2;

    if(v[0] && v[3] && v[4])
        ans2 += 3LL + (v[0] - 1) / 2 * 2 + (v[3] - 1) / 2 * 2 + (v[4] - 1) / 2 * 2;
    else
        ans2 += v[0] / 2 * 2LL + v[3] / 2 * 2 + v[4] / 2 * 2;

    cout << max(ans1, ans2) + v[1] << "\n";
    return 0;
}


Measured memory_bytes: 256