akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
template <typename T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const vector<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
void ce(void){cerr << '\n';}
template <typename T>
void ce(const T n){cerr << n << '\n';}
template <typename T>
void cesp(const T n){cerr << n << ' ';}
template <typename T>
void ce(initializer_list<T> v){for(T i : v) cesp(i); ce();}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18L+1;
constexpr ll MOD = 1e9L+7;
// constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

int main(void){
	ll n, x, y;
	cin >> n >> x >> y;
	--x, --y;

	Vec ans(n + 1);
	rep(i, n){
		REP(j, i + 1, n){
			ll d = j - i;
			chmin(d, abs(i - x) + abs(j - y) + 1);
			ans[d]++;
			// cerr << i << " " << j << " " << d << endl;
		}
	}

	repn(i, n - 1) co(ans[i]);

	return 0;
}


Measured memory_bytes: 3624
from collections import defaultdict


N, M = map(int, input().split())
PY = [list(map(int, input().split())) for _ in range(M)]

di = defaultdict(list)

for i, py in enumerate(PY):
    di[py[0]].append([py[1], i])

ans = ["" for _ in range(M)]

for k, v in di.items():
    v.sort()

    for j, yi in enumerate(v):
        s = str(k).zfill(6)
        t = str(j + 1).zfill(6)
        ans[yi[1]] = s + t

print("\n".join(ans))


Measured memory_bytes: 62588
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define rep(i,n) for(long long  i = 0; i < n; i++)
#define rep2(i,a,n) for(long long  i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> PLL;

template <class T> vector<T> solve(T n) {
    vector<T> ret;
    for(T i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

int main() 
{
    int n;
    cin >> n;
    int ans = 0;
    
    for(int i = 1; i <= n; i=i+2) {
        vector<int> d = solve(i);
        if(d.size() == 8) { ans++; }    
    }
    cout << ans << endl;
    return 0;
}



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


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

void solve(long long N, std::string S) {
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    if (i + 2 < N && S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') {
      cnt++;
    }
  }
  cout << cnt << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::string S;
  std::cin >> S;
  solve(N, S);
  return 0;
}


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

int A[100][100];

void Main()
{
  int N, K;
  cin >> N >> K;
  vector<int> d(K);
  set<int> se;
  rep(i,K) {
    cin >> d[i];
    rep(j,d[i]) {
      cin >> A[i][j];
      if (se.find(A[i][j]) == se.end()) se.insert(A[i][j]);
    }
  }
  
  int cnt = 0;
  for (int i = 1; i <= N; i++) {
    if (se.find(i) == se.end()) cnt++;
  }
  cout << cnt << endl;
  
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}


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

int main()
{    
    int a,b,ans;
    cin >> a >> b;

    if(!a || !b)ans = 0;
    else{
        while(a != b){
            if(a > b)a -= b;
            else b -= a;
        }
        ans = a;
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

int N, M;
queue<int> GasStationLane[10];

int findLessCarsLane() {
	unsigned int minNum, laneNo;

	minNum = GasStationLane[0].size();
	laneNo = 0;
	for (int i = 1; i < N; ++i) {
		if (GasStationLane[i].size() < minNum) {
			minNum = GasStationLane[i].size();
			laneNo = i;
		}
	}

	return laneNo;
}

int main() {
	int cmd, val, laneNo;

	cin >> N >> M;
	for (int i = 0; i < M; ++i) {
		cin >> cmd >> val;
		if (cmd == 0) {
			--val;
			cout << GasStationLane[val].front() << endl;
			GasStationLane[val].pop();
			continue;
		}
		laneNo = findLessCarsLane();
		GasStationLane[laneNo].push(val);
	}

	return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

int N, M;
vector<vector<int> > G;

int dp[100100];
int rec(int v){
  if(dp[v] != -1) return dp[v];

  int res = 0;
  for(auto nv : G[v]){
    chmax(res, rec(nv)+1);
  }
  return dp[v] = res;
}

int main(){
  cin >> N >> M;
  G.assign(N, vector<int>());
  rep(i, M){
    int x, y;
    cin >> x >> y;
    x--, y--;
    G[x].push_back(y);
  }

  rep(v, N) dp[v] = -1;

  int res = 0;
  rep(v, N) chmax(res, rec(v));
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 8192
import numpy as np
mod=10**9+7
def solve():
    n,k = map(int,input().split())
    a = np.array([list(map(int,input().split())) for i in range(n)],dtype=np.int64)
    print(modpow(a,k).sum()%mod)
def mult(A,B):
    N=len(A)
    C = np.zeros((N,N),np.int64)
    for n in range(N):
        C[n] = (A[n,:][:,None] * B % mod).sum(axis=0) % mod
    return C
def modpow(A,k):
    n=len(A)
    res=np.eye(n,dtype=np.int64)
    for i in range(k.bit_length()):
        if k>>i&1:
            res=mult(A,res)
        A=mult(A,A)
    return res
solve()

Measured memory_bytes: 12516
n = int(input())
li = list(map(int, input().split()))

def calc(a,x):
    return(a-x)**2

res = []
for j in range(100):
    for i in range(len(li)):
        tmp = sum(map(calc, [j+1 for x in range(len(li))],li))
        res.append(tmp)

print(min(res))


Measured memory_bytes: 3408
#include<stdio.h>
int main(void){
   double a, b, c, d, e, f, L, M, N, O,  X, Y; 
   while ( scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF ) {
      L = f - e * c / b;
      M = d - a * e / b;
      N = f - d * c / a;
      O = e - d * b / a;
      X = L / M;
      Y = N / O;
      if ( X > -0.0005 && X <= 0 ) X = X - X;
      printf("%.3lf %.3lf\n",  X, Y);
   }
   return 0;
}

Measured memory_bytes: 1736
def main():
    N, K = map(int, input().split())
    D = set(map(int, input().split()))
    numset = set(range(0,10))
    d = numset.difference(D)

    for n in range(N, pow(10, 6) + 10):
        check = set(list(str(n)))
        ngflag = False
        for i in check:
            if int(i) in D:
                ngflag = True
                break
        if not ngflag:
            break
    print(n)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9144
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vll t(n);
    ll sum = 0;
    REP(i,n){
        cin >> t[i];
        sum += t[i];
    }
    ll m;
    cin >> m;
    REP(i,m){
        ll p,x;
        cin >> p >> x;
        p--;
        ll ret = sum - t[p] + x;
        cout << ret << "\n";
    }

    return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		String[] W = new String[N];
		for (int i = 0; i < N; i++) {
			W[i] = sc.next();

			for (int j = 0; j < i; j++) {
				if (W[i].equals(W[j])) {
					System.out.println("No");
					return;
				}
			}
		}

		for (int i = 1; i < N; i++) {
			if (W[i - 1].charAt(W[i - 1].length() - 1) != W[i].charAt(0)) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}

Measured memory_bytes: 21844
#include <cstdio>
#include <algorithm>
using namespace std;

#define INF 0x33433433

int n;
int m;
int c[20];
int dp[50001];

int main() {
    scanf("%d%d", &n, &m);
    for (int i=0; i<m; i++) {
        scanf("%d", &c[i]);
    }

    fill(dp, dp+50001, INF);
    dp[0] = 0;
    for (int i=0; i<n; i++) {
        for (int j=0; j<m; j++) {
            if (i+c[j] <= n) {
                dp[i+c[j]] = min(dp[i+c[j]], dp[i]+1);
            }
        }
    }

    printf("%d\n", dp[n]);
}

Measured memory_bytes: 1224
n=int(input())
b=list(map(int,input().split()))
a=[1000000 for _ in range(n)]

for i in range(n-1):
  a[i]=min(a[i],b[i])
  a[i+1]=min(a[i+1],b[i])
ans=0
for i in range(n):
  ans+=a[i]
print(ans)

Measured memory_bytes: 38384
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
#include<assert.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")
#define charsize 100005 //10^5+5

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a= c;}
// void fill(ll n, ll a[n], ll value){ rep(i,0,n) a[i] = value; }
void cin(ll *n){ scanf("%lld",&(*n)); }
void cin2(ll *a, ll *b){ scanf("%lld%lld",&(*a),&(*b)); }
void cin3(ll *a, ll *b, ll *c){ scanf("%lld%lld%lld",&(*a),&(*b),&(*c)); }
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod_MOD1(ll n){n+= n<0?((-n)/MOD1+1)*MOD1:0; return n%=MOD1;}
ll mod_p(ll n ,ll p){n+= n<0?((-n)/p+1)*p:0; return n%=p;}
ll change_into_num(char s[] , ll len, ll p){ return !p ? 0 : POW(10,p-1)*(s[len-p]-'0') + change_into_num(s,len,p-1); }

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
// int int_sort( const void * a , const void * b ) {
//   return strcmp(( char * )a , ( char * )b );
// }
//     qsort((void*)s,n,sizeof(s[0]),int_sort );

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

int main(void){
    // char ;
    ll a,b,k;
    // ll ans=0;
    // cin(&n);
    // cin2(&,&);
    cin3(&k,&a,&b);
    // ll [n];
    // rep(i,0,n){
    //     cin(&[i]);
    // }
    rep(i,a,b+1){
        if(i%k==0){
            printf("OK\n");
            return 0;
        }
    }
    

    
    printf("NG\n");
    return 0;
}


Measured memory_bytes: 1664
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int ans = (a+b)/2;
    System.out.println((a+b)%2==0 ? ans : ans+1);
  }
}


Measured memory_bytes: 35848
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <cstring>
#include <utility>
#include <map>
#include <queue>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;


int main()
{
    ios::sync_with_stdio(false);
ll     n,m;
    cin>>n>>m;
    priority_queue<ll>a;
    for(int i=0;i<n;i++)
        {
            ll x;
            cin>>x;
            a.push(x);
        }
    while(m--)
    {
        ll y=a.top();
        y/=2;
        a.pop();
        a.push(y);
    }
    ll ans=0;
    for(int i=0;i<n;i++)
    {   ll y=a.top();
        ans+=y;
        a.pop();}
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    vector<ll> cnt(200005);
    ll sum=0;
    for(int i=0;i<N;i++){
        int a;cin>>a;
        cnt[a]++;
        sum+=a;
    }
    int Q;cin>>Q;
    while(Q--){
        int a,b;cin>>a>>b;
        sum+=cnt[a]*(b-a);
        cnt[b]+=cnt[a];
        //sum+=cnt[a]*b;
        cnt[a]=0;
        
        cout<<sum<<"\n";
    }
}



Measured memory_bytes: 4768
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        scan.close();
        String tmp = "";
        for (String c : s.split(""))
        {
            if (tmp.contains(c) == false)
                tmp += c;
        }
        System.out.println(s.length() == tmp.length() ? "yes" : "no");
    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T& a,T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if (a < b) {a = b; return true;} return false;}

using Graph = vector<vector<int>>;

int main(){
  int n, m; cin >> n >> m;
  Graph G(n);
  rep(i, m){
    int a, b;
    cin >> a >> b;
    --a; --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  vector<int> vec(n);
  rep(i, n) vec[i] = i;
  vector<int> seen(n);
  rep(i, n) seen[i] = 0;
  int n_seen = 0;
  do{
    if (vec[0] != 0) continue;
    seen.assign(n, 0);
    seen[0] = 1;
    rep(i, n){
      if (vec[i] == 0) continue;
      if (find(G[vec[i]].begin(), G[vec[i]].end(), vec[i-1]) != G[vec[i]].end()){ //前回のものと繋がっている場合
        seen[vec[i]] = 1;
      }
    }
    if (count(seen.begin(), seen.end(),1) == n) n_seen++;
    
  }while (next_permutation(vec.begin(), vec.end()));
  cout << n_seen << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long h,w;
  cin >> h >> w;
  if(h==1 || w==1){
    cout << 1 << endl;
  }
  else if(h*w%2==0){
    cout << h*w/2 << endl;
  }
  else{
    cout << h*w/2+1 << endl;
  }
}

Measured memory_bytes: 3568
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0
inf = float("inf")

n = k()
s,t = map(str,input().split())
a = []
for i in range(n):
    a.append(s[i]+t[i])

print("".join(a))


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

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

void solve(){
    int n;
    cin >> n;
    vector<int> a(n);
    int mini=inf,maxi=-inf;
    rep(i,0,n){
        cin >> a[i];
        mini=min(mini,a[i]);
        maxi=max(maxi,a[i]);
    }
    int ans=inf;
    rep(i,mini,maxi+1){
        int tmp=0;
        rep(j,0,n) tmp+=(i-a[j])*(i-a[j]);
        ans=min(ans,tmp);
    }
    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 256
#20131027

gets.to_i.times{
	array=[]
	trains=gets.chomp
	array.push trains
	array.push trains.reverse if trains != trains.reverse
	(trains.length-1).times{|t|
		str1,str2 = trains[0..t],trains[t+1..trains.length-1]
		array.push str1+str2.reverse if array.index(str1+str2.reverse) == nil
		array.push str1.reverse+str2 if array.index(str1.reverse+str2) == nil
		array.push str1.reverse+str2.reverse if array.index(str1.reverse+str2.reverse) == nil
		array.push str2+str1 if array.index(str2+str1) == nil
		array.push str2+str1.reverse if array.index(str2+str1.reverse) == nil
		array.push str2.reverse+str1 if array.index(str2.reverse+str1) == nil
		array.push str2.reverse+str1.reverse if array.index(str2.reverse+str1.reverse) == nil
	
	}
	p array.length
}

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

int maxPointsMemo(int **arr, int m, int lastN,int **dp){
    if(m==0) return 0;
    if(lastN!=-1 && dp[m][lastN]!=-1) return dp[m][lastN];
    int first=lastN==1?INT_MIN:arr[m-1][0] + maxPointsMemo(arr,m-1,1,dp);
    int second=lastN==2?INT_MIN:arr[m-1][1] + maxPointsMemo(arr,m-1,2,dp);
    int third=lastN==3?INT_MIN:arr[m-1][2] + maxPointsMemo(arr,m-1,3,dp);
    dp[m][lastN]= max(first,max(second,third));
    return dp[m][lastN];
}

int main()
{
   int m,n=3;
   cin>>m;
   
   int **arr=new int*[m];
   for(int i=0;i<m;i++){
       arr[i]=new int[n];
       for(int j=0;j<n;j++){
            cin>>arr[i][j];
       }
   }
   
   int **dp=new int*[m+1];
   for(int i=0;i<=m;i++){
       dp[i]=new int[n+1];
       for(int j=0;j<=n;j++){
           dp[i][j]=-1;
       }
   }
    cout<<maxPointsMemo(arr,m,-1,dp);
   
   
   return 0;
}

Measured memory_bytes: 17408
import sys
input = sys.stdin.buffer.readline

N = int(input())
a = list(map(int, input().split()))

# dp[i][j] 区間a[i,j)だけ残った時点で互いの点数を一旦0とし、ゲームを最後まで続けた場合のX-Yの値
dp = [[float("inf")]*(N+1) for _ in range(N+1)]
for i in range(N+1):
    dp[i][i] = 0

# こちらもメモ化再帰ではpypy3でも間に合わない
# j==i+1, i+2, ...とループしてdpテーブルの上三角部分を対角線と平行に埋めていく。jをshift_iと書き換えてループ
for shift_i in range(1, N+1):
    for i in range(N+1):
        if i+shift_i >= N+1:
            continue
        elif ((i+shift_i)-i)%2 == N%2: # 先手番
            dp[i][(i+shift_i)] = max(a[i] + dp[i+1][(i+shift_i)], a[(i+shift_i)-1] + dp[i][(i+shift_i)-1])
        else:
            dp[i][(i+shift_i)] = min(-a[i] + dp[i+1][(i+shift_i)], -a[(i+shift_i)-1] + dp[i][(i+shift_i)-1])

print(dp[0][N])

Measured memory_bytes: 308360
--  N
--W   E
--  S
data Dir = N | E | W | S deriving Eq
data Sp  = In | Out deriving Eq

next d c =
  case c of
    'R' -> case d of
             N -> E
             E -> S
             S -> W
             W -> N
    'L' -> case d of
             N -> W
             W -> S
             S -> E
             E -> N

ans :: Dir -> Sp -> Int -> String -> Int
ans _ _ n [] = n

ans d s n (c:cs) =
  let d' = next d c
      s' = if (d == N)
           then if (c == 'R') then In else Out
           else s
      n' = if (d == W) && (c == 'R') && (s == In) then (n + 1) else n
  in
    ans d' s' n' cs

main = do
  l <- getLine
  let o = ans N In 0 l
  print o



Measured memory_bytes: 3876
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, [ $t:tt ]) => {{
    let len = read_value!($iter, usize);
    (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  }};

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    n: chars,
  }
  let n: Vec<_> = n.into_iter().map(|d| d as i32 - '0' as i32).collect();
  let l = n.len();
  let mut same = vec![0; l+1];
  let mut more = vec![0; l+1];
  same[0] = 0;
  more[0] = 1;
  for i in 1 .. l + 1 {
    same[i] = cmp::min(
      same[i-1] + n[i-1],
      more[i-1] + 10 - n[i-1]
    );
    more[i] = cmp::min(
      same[i-1] + n[i-1] + 1,
      more[i-1] + 9 - n[i-1]
    );
  }
  // dbg!(&same);
  // dbg!(&more);

  puts!("{}\n", same[l]);
}


Measured memory_bytes: 17400
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int[] data = new int[3];
		data[0] = in.nextInt();//a
		data[1] = in.nextInt();//b
		data[2] = in.nextInt();//c
		
		int tmp;
		for(int i=0; i<data.length; i++) {
			for(int j=i+1; j< data.length; j++) {
				if(data[i]>data[j]) {
					tmp = data[i];
					data[i] = data[j];
					data[j] = tmp;
				}
			}
		}
		
		System.out.printf("%d %d %d\n", data[0], data[1], data[2]);
	}

}

Measured memory_bytes: 26164
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;
//?????§??¬?´???°
int gcd(int x, int y) { return y ? gcd(y, x%y) : x; }
//????°???¬?????°
int lcm(int x, int y) { return x*y / gcd(x, y); }
signed main() {
	while (true) {
		int a[3], m[3];
		rep(i, 0, 3)cin >> a[i] >> m[i];
		if (a[0] == 0)break;
		int x = 1, y = 1, z = 1;
		x = (a[0] * x) % m[0];
		y = (a[1] * y) % m[1];
		z = (a[2] * z) % m[2];
		int cnt[3] = { 1,1,1 };
		while (x != 1) {
			cnt[0]++;
			x = (a[0] * x)%m[0];
		}
		while (y != 1) {
			cnt[1]++;
			y = (a[1] * y)%m[1];
		}
		while (z != 1) {
			cnt[2]++;
			z = (a[2] * z)%m[2];
		}
		int ans = lcm(lcm(cnt[0], cnt[1]), lcm(cnt[1], cnt[2]));
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3092
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<double, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size
#define EPS (1e-10)

void add_mod(ll &a, ll b){
	a += b;
	a %= MOD;
}

void mul_mod(ll &a, ll b){
	a *= b;
	a %= MOD;
}

int main(void){
	int n,i,a[123],cnt=1,ans=0;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> a[i];
	}
	for(i=1; i<n; ++i){
		if(a[i] == a[i-1]){
			++cnt;
		}else{
			ans += cnt/2;
			cnt = 1;
		}
	}
	ans += cnt/2;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n, k = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)

memo = {}
i = a[0] - 1
memo[a[0]] = 1
count = 2

while !memo.has_key?(a[i]) do
    memo[a[i]] = count
    i = a[i]-1
    count += 1
end

before_cycle_count = memo[a[i]]
ans = memo.to_a

if before_cycle_count >= k then
    puts ans[k-1][0]
else
    tmp = (k-before_cycle_count) % (ans.size-before_cycle_count+1) + before_cycle_count
    puts ans[tmp-1][0]
end

Measured memory_bytes: 45284
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int cnt = 0;
		for (int a = 1; a < n; a++) {
			for (int b = 1; a * b < n; b++) {
				cnt++;
			}
		}
		
		System.out.println(cnt);
		
		sc.close();
	}
}



Measured memory_bytes: 27104
program main
implicit None
	integer(8)::a,b,k,i
	
	read *,a,b,k
	
	do i = 1,k
		if(mod(i,2) == 1)then
			a = a/2
			b = b + a
			else
			b = b/2
			a = a + b
		endif
	enddo
	
	print 101,a,b
	
101 format(i0,1x,i0)
end program main


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

#define int long long
#define ar array 
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,a,b) for(int i = a; i < b; i++)
 
using namespace std;

typedef long long ll; 
typedef vector<int> vi;
typedef pair<int,int> pii;
 
 
const  int mxN = 1e5+5;
const  long long INF= 1e18;
const long long mod= 1e9+7;
 	
signed main(){
	int n, x;
	cin >> n >> x;
	int sum = 0;
	while(x--) {
		int a; cin >> a;
		sum += a;
	}
	if(sum > n) cout << -1;
	else cout << n - sum;
}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	



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



int main() {
    float x1 = 0;
    float y1 = 0;
    float r1 = 7;

    float x2 = 0;
    float y2 = 0;
    float r2 = 1;

    std::cin >> x1 >> y1 >> r1;
    std::cin >> x2 >> y2 >> r2;

    float d = sqrt(pow((x1 - x2),2) + pow((y1 - y2),2)); // TODO: provide type safety

    if((r1 + r2) < d){
        std::cout << 4 << std::endl;
    }
    else if((r1 + r2) > d){
        if(abs(r1 - r2) == d){
            std::cout << 1 << std::endl;
            return 0;
        }else if(abs(r1 - r2) > d){
            std::cout << 0 << std::endl;
            return 0;
        }
        std::cout << 2 << std::endl;
    }
    else std::cout << 3 << std::endl;

    return 0;
}


Measured memory_bytes: 3228
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int s[10]={111,222,333,444,555,666,777,888,999};
  for(int i=0;i<9;i++){
    if(s[i] >= n){
    cout << s[i] << endl;
    break;
    }
  }


}


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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;



void solve()
{
	int x; cin >> x;

	int val = 8;
	int rt = 400;
	while (rt + 199 < x) rt += 200, val--;

	cout << val << endl;

}

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

	int test = 1;
	// cin >> test;
	while (test--)solve();


}





















Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
ll a,b,ans;
ll gcd(ll x,ll y) {
	if (!x||!y) return x+y;
	return gcd(y,x%y);
}
int main() {
	//freopen("1.txt","r",stdin);
	read(a); read(b); a=gcd(a,b);
	for (b=2;b*b<=a;b++)
		if (a%b==0) {
			ans++;
			while (a%b==0) a/=b;
		}
	if (a>1) ans++;
	printf("%lld\n",ans+1);
	return 0;
}

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

const long long mod=1000000007LL;

long long dp[105][5][5][5]={};

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	dp[0][0][0][0]=1;
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < 5; ++j)
		{
			for (int k = 0; k < 5; ++k)
			{
				for (int l = 0; l < 5; ++l)
				{
					for (int m = 1; m < 5; ++m)
					{
						if ((k==1&&l==3&&m==2)||(k==3&&l==1&&m==2)||(k==1&&l==2&&m==3)||(j==1&&k==3&&m==2)||(j==1&&l==3&&m==2))
						{
							continue;
						}
						dp[i+1][k][l][m]+=dp[i][j][k][l];
						dp[i+1][k][l][m]%=mod;
					}
				}
			}
		}
	}
	long long ans=0LL;
	for (int i = 0; i < 5; ++i)
	{
		for (int j = 0; j < 5; ++j)
		{
			for (int k = 0; k < 5; ++k)
			{
				ans+=dp[n][i][j][k];
				ans%=mod;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


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


using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;


int main() {

	int a, b;
	cin >> a >> b;

	REP(i, 100000) {
		if (i * 8 / 100 == a && i / 10 == b) {
			cout << i << endl;
			return 0;
		}
	}

	cout << -1 << 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 D = sc.nextInt();
    int T = sc.nextInt();
    int S = sc.nextInt();
    float R = (float)D / (float)S;
    if(R <= T)
      System.out.println("Yes");
    else
      System.out.println("No");
  }
}


Measured memory_bytes: 35792
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int yard = A*B;
		int res = A*B-(A+B-1);
		System.out.println(res);
	}

}


Measured memory_bytes: 21460
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner io = new Scanner(System.in);
		int N = io.nextInt();
		int a_min = Integer.MAX_VALUE;
		int a_max = Integer.MIN_VALUE;
		
		for(int i=0;i<N;i++){
			int a = io.nextInt();
			a_min = Math.min(a_min,a);
			a_max = Math.max(a_max,a);
		}
		
		System.out.println(a_max-a_min);
		
	}	
}

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

using namespace std; 

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	
	long long n, a, b;
	cin >> n >> a >> b;
	long long q = n / (a + b);
	long long r = n % (a + b);
	long long ans = q*a + min(r, a);
	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define loop(i, a, b) for(li i=a; i<=b; i++)
#define stuff ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
typedef long long li;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<li, li> lii;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<ii> vii;
typedef vector<lii> vlii;
li mod = 1e9+7;
li expo(li base, li exponent)
{
	li ans=1;
	while(exponent)
	{
		if(exponent&1) ans = (ans*base)%mod;
		base = (base*base)%mod;
		exponent >>= 1;
	}
	return ans;
}
li gcd(li x, li y)
{
	if(y==0) return x;
	return gcd(y, x%y);
}


typedef tree<li, null_type, less<li>,
rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main()
{
	stuff;
	// #ifndef ONLINE_JUDGE 
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// freopen("error.txt", "w", stderr);
	// #endif

	li k, a,b;
	cin >> k >> a >> b;
	if(a%k==0)
	{
		cout << "OK";
		return 0;
	}
	li num = a/k;
	if(num*k+k<=b)
	{
		cout << "OK";
		return 0;
	}
	cout << "NG";
	return 0;
}


Measured memory_bytes: 3652
#include <utility>
#include <iostream>
#include <cmath>
#include <deque>
#include <string>
#include <time.h>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <sstream>
#include <algorithm>
#include <bitset>

#define pii pair<ll,ll>
#define X first
#define Y second
#define mp make_pair

typedef long long ll;
using namespace std;
#define MAXN 10000007
#define MOD 998244353
#define N 1048576
ll n, x, k, z, m, pos, q, ans_v;
ll x1, p1, x2;
vector<ll> g[300500], f;

ll fac[MAXN], invfac[MAXN];

ll binpow(ll x, ll y) {
    if (y == 0) {
        return 1;
    }
    ll tmp = binpow(x, y / 2);
    tmp = tmp * tmp % MOD;
    if (y % 2) {
        return x * tmp % MOD;
    }
    return tmp;
}

ll inv(ll x) {
    return binpow(x, MOD-2);
}

ll C(ll n, ll m) {
    if (n < m) {
        return 0;
    }
    return fac[n] * invfac[m] % MOD * invfac[n-m] % MOD;
}

void precalc_facs() {
    fac[0] = invfac[0] = 1;
    for (int i = 1; i < MAXN; i++) {
        fac[i] = fac[i-1] * i % MOD;
        invfac[i] = inv(fac[i]);
    }
}

ll a[MAXN], pa[MAXN], p3[2 * MAXN], p2[2 * MAXN], sp[MAXN], spp[MAXN];

int main() {
    precalc_facs();
    cin >> n;
    n /= 2;
    p3[0] = 1;
    p2[0] = 1;
    for (int i = 0; i <= 2 * n; i++) {

        p3[i+1] = p3[i] * 3 % MOD;
        p2[i+1] = p2[i] * 2 % MOD;
    }

    for (int i = 0; i <= n; i++) {
        sp[i] = p2[n-i] * C(n, i) % MOD;
        spp[i+1] = (spp[i] + sp[i]) % MOD;
    }

    for (int i = 0; i <= n; i++) {
    }

    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        ll sum = sp[i] * (p3[n] - (spp[n - i + 1] - spp[0])) % MOD;
        ans = (ans + sum) % MOD;
        //cout << ans << endl;
    }
    cout << (p3[n*2] - ans * 2 + MOD * 2) % MOD << endl;


    return 0;
}

Measured memory_bytes: 405504
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
N = int(input())
a = list(map(int, input().split()))
a = sorted(a)

a1 = a.pop(0)
a2 = a.pop(0)
res = Decimal((a1 + a2) / 2)

for i in range(N - 2):
    res = Decimal((a[i] + res) / 2)

print(res)

Measured memory_bytes: 5076
# 2019-11-12 16:33:33(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n = int(sys.stdin.readline().rstrip())

    otoshidamas = []
    for _ in range(n):
        x, u = sys.stdin.readline().split()
        x = float(x)
        otoshidamas.append([x, u])
    
    total = 0
    for i in range(n):
        if otoshidamas[i][1] == 'JPY':
            total += otoshidamas[i][0]
        else:
            total += otoshidamas[i][0] * 38e4
    
    print(total)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<string>
using namespace std;
int main()
{
  string s;
  cin>>s;
  if(s=="SUN") cout<<"7";
  if(s=="MON") cout<<"6";
  if(s=="TUE") cout<<"5";
  if(s=="WED") cout<<"4";
  if(s=="THU") cout<<"3";
  if(s=="FRI") cout<<"2";
  if(s=="SAT") cout<<"1";
}


Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;
const lli inf = 1e18;

bool is_digit(string &s){
    if(s.length()>=2u and s[0]=='0') return false;
    for(char c: s){
        if(!('0'<=c and c<='9')) return false;
    }
    return true;
}

int main(){
    lli n;
    string s;
    cin >> n >> s;
    s += "+";
    int m = s.length();
    // dp[i][j][k] = (s[i::i+j]をk文字置換して"xxxx+"の形式にしたときの最小の評価値)
    vector<vector<vector<lli>>> dp_pre(m, vector<vector<lli>>(12, vector<lli>(12, inf)));
    for(int i=0; i<m; i++){
        for(int j=1; j<=10; j++){
            if(i+j >= m) break;
            string sub = s.substr(i, j);
            int count = (s[i+j]=='+')? 0: 1;
            for(int k=0; k<j; k++){
                if(sub[k]=='+'){
                    if(k==0 and j!=1) sub[k] = '1';
                    else sub[k] = '0';
                    count++;
                }
            }
            for(int nrep=0; nrep<=j; nrep++){
                if(is_digit(sub)){
                    dp_pre[i][j+1][count] = min(dp_pre[i][j+1][count], stoll(sub));
                }
                if(nrep == j) break;
                char repc = (nrep==0 and j!=1)? '1': '0';
                if(sub[nrep] != repc){
                    sub[nrep] = repc;
                    count++;
                }
                
            }
        }
    }
    vector<vector<lli>> dp(m+1, vector<lli>(m+1, inf));
    dp[0][0] = 0;
    for(int i=0; i<m; i++){
        for(int j=0; j<m+1; j++){
            if(dp[i][j] == inf) continue;
            for(int k=0; k<12; k++){
                for(int l=0; l<12; l++){
                    if(i+k>m or j+l>m) continue;
                    dp[i+k][j+l] = min(dp[i+k][j+l], dp[i][j]+dp_pre[i][k][l]);
                }
            }
        }
    }
    int ans = -1;
    for(int i=0; i<m+1; i++){
        if(dp[m][i] <= n){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 12336
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

int main() {
	long long L, R; cin >> L >> R;
	if (R < 2019)cout << L * (L + 1)%2019 << endl;
	else {
		if (L % 2019 == 0 || R % 2019 == 0)cout << 0 << endl;
		else if (L / 2019 != R / 2019)cout << 0 << endl;
		
		else {
			long long ans = 1e12;
			for (long long i = L; i <= R; i++) {
				for (long long j = i + 1; j <= R; j++) {
					ans = min(ans, (i % 2019)*(j % 2019)%2019);
				}
			}
			cout << ans << endl;
		}
		

	}


}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a) for(int i = 0; i < a; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    int k; cin>>k;
    int e,o;
    e=k/2;
    o=(k+1)/2;
    cout<<e*o<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll =  long long;
const ll INTF = 1e9 + 7;

vector<ll> tr;
int n;

void update(int p, ll val)
{
    for (; p <= n; p = p | (p + 1))
        tr[p] = max(tr[p], val);
}

ll query(int p)
{
    ll ret = 0;
    for (; p >= 0; p = (p & (p + 1)) - 1)
        ret = max(ret, tr[p]);
    return ret;
}

int main() {

    cin >> n;

    tr = vector<ll>(n+1, 0);

    vector<pair<int,int>> fl(n);
    for(int i=0; i<n; i++)
        cin >> fl[i].first;
    for(int i=0; i<n; i++)
        cin >> fl[i].second;

    vector<ll> dp(n+1, 0);
    for(int i=0; i<n; i++)
    {
        dp[fl[i].first] = query(fl[i].first-1) + fl[i].second;
        update(fl[i].first , dp[fl[i].first]);
    }

    ll ans =0;
    for(int i=0; i<=n ;i++)
        ans = max(ans, dp[i]);
   
   cout<<ans;
    
    return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>
int main() {
    int a, b, c;
    
    scanf("%d%d%d", &a, &b, &c);
    
    if (a < b) {
        if (b < c) printf("Yes\n");
        
        else printf("No\n");
    }
    
    else printf("No\n");
    
    return 0;
}


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

using P = pair<int,int>;

signed main(){
	int n,x[3010],y[3010],ans = 0;
	char d[3010];
	map<int,set<P>> xy,yx;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> x[i] >> y[i] >> d[i];
	}
	for(int i = 0;i < n;i++){
		xy.clear();
		yx.clear();
		for(int j = 0;j < n;j++){
			xy[x[j]].emplace(y[j],j);
			yx[y[j]].emplace(x[j],j);
		}
		int v = i,cnt = 0;
		while(1){
			int nv;
			cnt++;
			if(d[v] == '^'){
				auto it = xy[x[v]].find(P(y[v],v));
				if(it == xy[x[v]].begin()) break;
				nv = (*(--it)).second;
			}else if(d[v] == 'v'){
				auto it = xy[x[v]].find(P(y[v],v));
				if(++it == xy[x[v]].end()) break;
				nv = (*it).second;
			}else if(d[v] == '<'){
				auto it = yx[y[v]].find(P(x[v],v));
				if(it == yx[y[v]].begin()) break;
				nv = (*(--it)).second;
			}else{
				auto it = yx[y[v]].find(P(x[v],v));
				if(++it == yx[y[v]].end()) break;
				nv = (*it).second;
			}
			xy[x[v]].erase(P(y[v],v));
			yx[y[v]].erase(P(x[v],v));
			v = nv;
		}
		ans = max(ans,cnt);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3676
N,X = map(int,input().split())
u = list(map(int,input().split()))
def gcd_list(numbers):
    gct = numbers[0]
    for i in range(len(numbers)-1):
        r = numbers[i+1] % gct
        while r != 0:
            ka = r
            r = gct
            gct = ka
            r = r % gct
    return gct
u.append(X)
u.sort()
sa = []
for i in range(len(u)-1):
    sa.append(u[i+1]-u[i])
if len(sa) > 1:
    print(gcd_list(sa))
else:
    print(sa[0])

Measured memory_bytes: 14252
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include <fstream>
using namespace std;
typedef long long ll;
const ll INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int mod = 1e9+7;
const int maxn = 200005;
ll T,n,m;
int main() {
	cin>>n>>m;
	cout<<max(n+m,max(n-m,n*m))<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int v[100001];
int s[100001];
bool M(int p) {
  if (p == 1) return false;
  for (int i = 2;i <= sqrt(p);i++) {
    if (p % i == 0) return false;
  }
  return true;
}
void S() {
  for (int i = 2;i <= 100000;i++) {
    if (M(i) && M((i + 1) / 2)) s[i] = s[i - 1] + 1;
    else s[i] = s[i - 1];
  }
} 
int main() {
  int q;
  int a,b;
  cin >> q;
  S();
  while (q--) {
    cin >> a >> b;
    cout << s[b] - s[a - 1] << endl;
  }
  return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;

const lld N = 200043;
const lld MOD = 1000000007;

lld add(lld x, lld y)
{
    x += y;
    while(x >= MOD) x -= MOD;
    while(x < 0) x += MOD;
    return x;
}

lld mul(lld x, lld y)
{
    return (x * 1ll * y) % MOD;
}

lld binpow(lld x, lld y)
{
    lld z = 1;
    while(y)
    {
        if(y & 1) z = mul(z, x);
        x = mul(x, x);
        y >>= 1;
    }
    return z;
}

lld inv(lld x)
{
    return binpow(x, MOD - 2);
}

lld divide(lld x, lld y)
{
    return mul(x, inv(y));
}

// Combinations

/*
lld fact[N];

void precalc()
{
    fact[0] = 1;
    for(lld i = 1; i < N; i++)
        fact[i] = mul(fact[i - 1], i);
}

lld C(lld n, lld k)
{
    return divide(fact[n], mul(fact[k], fact[n - k]));
}
*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t,i,j;
    //cin>>t;
    t=1;
    while(t--)
    {
        lld n,a ,b;
        cin>>n>>a>>b;
        string str;
        cin>>str;
        lld ctr=0,ctr2=0;
        for(i=0;i<str.length();i++)
        {
            if(str[i]=='a' && ctr+ctr2<(a+b))
            {
                cout<<"Yes"<<endl;
                ctr++;
            }
            else
            if(str[i]=='b' && ctr+ctr2<(a+b) && ctr2<b)
            {
                cout<<"Yes"<<endl;
                ctr2++;
            }
            else
                cout<<"No"<<endl;
        }
    }
}



Measured memory_bytes: 848