akhauriyash/Code-Regression huggingface dataset:
let S = readLine()!.characters.map{String($0)}
let K = Int(readLine()!)! - 1
for (i, c) in S.enumerate() {
  if c == "1" {
    if K == i {
      print(c)
      break
    }
  } else {
    print(c)
    break
  }
}  

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

int main() {
    int n, W; cin >> n >> W;
    vector<long long> v(n);
    vector<long long> w(n);
    for (int i = 0; i < n; ++i) {
        cin >> w[i] >> v[i];
    }
    vector<vector<long long>> dp(n+1, vector<long long>(W+1));
    for (int i = n-1; i >= 0; --i) {
        for (int j = 0; j <= W; ++j) {
            int nw = j + w[i];
            if (nw <= W) {
                dp[i][j] = max(dp[i+1][j], dp[i+1][nw] + v[i]);
            } else {
                dp[i][j] = dp[i+1][j];
            }
        }
    }
    long long ans = 0;
    for (int i = 0; i <= W; ++i) {
        ans = max(ans, dp[0][i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 80256
n,m= map(int,input().split())
maxl = 0
minr = n
for i in range(m):
    templ,tempr = map(int,input().split())
    maxl = max(maxl,templ)
    minr = min(minr,tempr)
if minr - maxl >= 0:
    print(minr - maxl + 1)
else:
    print(0)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

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;
}
// 法mでのaの逆元を計算
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;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    string S; cin >> S;
    bool f=true;
    for(int i=0;i<26;i++){
        int cnt=0;
        for(int j=0;j<S.size();j++){
            if('a'+i==S[j])cnt++;
        }
        if(cnt>=2){
            f=false;
            break;
        }
    }
    if(f) cout << "yes" << endl;
    else cout << "no" << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
const int MOD = 1000000007;
int64 N;
int dp[65][2][2];
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
    return 1LL * a * b % MOD;
}
void update(int &x,int y) {
    x = inc(x,y);
}
void Solve() {
    read(N);
    dp[61][1][0] = 1;
    for(int i = 60 ; i >= 0 ; --i) {
	for(int j = 0 ; j < 2 ; ++j) {
	    for(int k = 0 ; k < 2 ; ++k) {
		int t = (N >> i) & 1,u;
		u = t;
		if(j == 0) u = 1;
		
		for(int h = 0 ; h <= u ; ++h) {
		    int p = j && (h == t);
		    if(k) {
			if(h == 0){
			    update(dp[i][p][1],dp[i + 1][j][k]);
			    update(dp[i][p][0],dp[i + 1][j][k]);
			}
			else {
			    update(dp[i][p][1],dp[i + 1][j][k]);
			}
		    }
		    else {
			if(h == 0) {
			    update(dp[i][p][0],dp[i + 1][j][k]);
			}
			else {
			    update(dp[i][p][1],dp[i + 1][j][k]);
			    update(dp[i][p][0],dp[i + 1][j][k]);
			}
		    }
		}
	    }
	}
    }
    int ans = 0;
    for(int j = 0 ; j < 2 ; ++j) {
	update(ans,dp[0][j][0]);
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N,M;
    int count = 0;
    cin >> N >> M;
    vector<int> a(M);
    vector<int> b(M);
    for(int i=0; i<M; i++){
      cin >> a.at(i) >> b.at(i);
    }
    for(int j=0; j<N; j++){
          count=0;
      for(int i=0; i<M; i++){
        if(a.at(i) == j+1){
          count++;
        }
        if(b.at(i) == j+1){
          count++;
        }
      }
      cout << count << endl;
    }
}

Measured memory_bytes: 256
#-- define function ---#
def init_box(n):
	b = []
	for i in range(n):
		b.append([False, 1])

	b[0][0] = True

	return b

def move(a, b, lst):
	if lst[a][1] == 1:
		if lst[a][0]:
			lst[a][0] = False
			lst[b][0] = True
		else:
			lst[a][0] = False
	else:
		if lst[a][0]:
			lst[b][0] = True

	lst[a][1] -= 1
	lst[b][1] += 1

def count_red(lst):
	c = 0
	for i in lst:
		if i[0]:
			c += 1

	return c

#--- main ---#
N, M = input().split()
N, M = int(N), int(M)
box = init_box(N)
act = []
for i in range(M):
	x, y = input().split()
	x, y = int(x), int(y)
	act.append([x - 1, y - 1])

for i in act:
	move(i[0], i[1], box)
print(count_red(box))


Measured memory_bytes: 29812
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define ulli unsigned lli
#define ld long double
#define pb push_back
#define mp make_pair
#define bp pop_back
#define vi vector<int>
#define vvi vector< vector<int> >
#define vli vector<lli>
#define vvli vector< vector<lli> >
#define pii pair <int, int>
#define pli pair <lli, lli>
#define forn(i,n) for(i=0;i<n;i++)
#define FORN(i,k,n) for(i=k;i<n;i++)
#define rof(i,k,n) for(i=k;i>=n;i--)
#define wh(k) while(k--)
#define mod 1000000007
#define set(a,s) memset(a,s,sizeof(a))

int main()
{
	fast;
	int n,i;
	cin>>n;
	int b[n-1];
	forn(i,n-1)
	cin>>b[i];
	int count=0;
	count+=b[0];
	count+=b[n-2];
	forn(i,n-2)
	{
		count+=min(b[i],b[i+1]);
	}
	cout<<count<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
using namespace std;


int main(){    
    int n ;
    cin >> n ;
    int64_t ans = 0 ;
    for (int64_t i = 0; i < n; i++)
    {
        int ii = i+1 ;
        if (ii % 3 != 0 && ii % 5 != 0)
        {
            ans += ii ;
        }
        
    }
    cout << ans << endl ;
}

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

using i64 = int64_t;

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

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

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

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

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

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

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

void solve() {
    //const i64 mod = 1'000'000'007;

    i64 N,ga,sa,ba,gb,sb,bb;
    cin >> N;
    cin >> ga >> sa >> ba;
    cin >> gb >> sb >> bb;

    set<i64> st;
    rep(i,0,N+1){
        rep(j,0,N+1){
            i64 r=N-i*ga-j*sa;
            if(r<0) break;
            i64 k=0;
            if(-ba+bb>0){
                k=r/ba;
                r-=k*ba;
            }

            i64 x=r+i*max(ga,gb)+j*max(sa,sb)+k*bb;
            st.insert(x);
        }
    }

    i64 x=*st.rbegin();

    i64 ans=0;
    vector<i64> dp(x+1);
    dp[x]=x;
    for(i64 i=x; i>=0; --i){
        chmax(ans,dp[i]);
        if(i-gb>=0) chmax(dp[i-gb],dp[i]-gb+ga);
        if(i-sb>=0) chmax(dp[i-sb],dp[i]-sb+sa);
        if(i-bb>=0) chmax(dp[i-bb],dp[i]-bb+ba);
    }

    cout << ans << endl;
}

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


Measured memory_bytes: 200704
// May this submission get accepted
#pragma GCC optimize ("O3")
#pragma GCC target("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
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 (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// 標準入出力
struct inp {
    size_t sz;
    inp(size_t _sz = 1) : sz(_sz) {}
    template <typename T> operator T () const { T a; cin >> a; return a; }
    template <typename T> operator vector<T> () const { vector<T> a(sz); for (size_t i = 0; i < sz; i++) cin >> a[i]; return a; }
    template <typename T, typename U> operator pair<T, U> () const { T f; U s; cin >> f >> s; return pair<T, U>(f, s); }
};
inp inp1; // input one
template <typename T> void say(T &x, char end = '\n') { cout << x << end; }
template <typename T> void say(vector<T> &x, char sep = ' ', char end = '\n') { for (size_t i = 0, sz = x.size(); i < sz; i++) { cout << x[i] << (i == sz-1 ? end : sep); } }

// モジュール


// 処理内容
int main() {
    
    ios::sync_with_stdio(false); // stdioを使うときはコメントアウトすること
    cin.tie(nullptr);            // インタラクティブ問題ではコメントアウトすること
    
    ll n = inp1;
    ll k = inp1;
    vector<ll> h = inp(n);

    sort(ALL_OF(h));
    ll ans = accumulate(h.begin(), h.end() - min(n, k), 0LL);
    say(ans);
    
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll n;
graph t;
ll ans[e5];

void dfs(ll x,ll prev,ll d){
  ans[x] = d%2;
  for(auto y : t[x]){
    if(y.first == prev) continue;
    dfs(y.first, x, d+y.second);
  }
}

int main(){
  cin >> n;
  for(ll i = 0;i < n-1;i++){
    ll u,v,w;
    cin >> u >> v >> w;
    t[u][v] = w;
    t[v][u] = w;

  }
  dfs(1,0,0);
  for(ll i = 1;i <= n;i++) cout << ans[i] << endl;

}


Measured memory_bytes: 21924
#include <cstdio>
#include <algorithm>

using std::max;
using std::min;

typedef long long ll;

int main() {
    ll a, b, c, k, ans = 0;
    scanf("%lld%lld%lld%lld", &a, &b, &c, &k);
    
    ans += min(a, k);
    k -= min(a, k);
    
    k -= min(b, k);

    ans -= min(c, k);
    k -= min(c, k);
    
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3252
import java.util.Scanner;
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int k;
    k = sc.nextInt();
    long sum = 0;
    for(int a = 1; a <= k ; a++){
      for(int b = 1; b <=k; b++){
        for(int c = 1; c<=k; c++){
          sum += gcd(c,gcd(a,b));
        }
      }
    }
    System.out.println(sum);
  }

  public static int gcd(int x, int y){ //最大公約数
    if(x<y){
      return gcd(y,x);
    }
    if(y == 0){
      return x;
    }
    return gcd(y,x%y);
  }
}


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

int main(){
  int n;
  cin >> n;
  priority_queue<int> a;
  rep(i,n){
    int b;
    cin >> b;
    a.push(b);
  }
  ll t=0;
  t += a.top();
  a.pop();
  rep(i,n-2){
    t += a.top();
    if(i%2) a.pop();
  }
  cout << t << endl;
}

Measured memory_bytes: 4288
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
	    Scanner std = new Scanner(System.in);
	    int num = 1;
	    while(true){
	    	int n = Integer.parseInt(std.next());
	    	if(n!=0){
	    		System.out.println("Case "+num+": "+n);
	    		num++;
	    	}else{
	    		break;
	    	}
	    }
	}
}

Measured memory_bytes: 40204
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;


int main(){  
  int n;
  cin >> n;
  vector<ll> x(n);
  rep(i,n){ cin>>x[i]; }
  sort(x.rbegin(),x.rend());
  ll ans=x[0];
  ll cmb1=x[1];
  ll cmb2=x[n-1];
  for(int i=1; i<n; i++){
    if(x[i]>ans/2){cmb1=x[i];}else{cmb2=x[i];break;}    
  }
  if(ans-cmb1>=cmb2){ cout<<ans<<" "<<cmb1<<endl; }else{ cout<<ans<<" "<<cmb2<<endl; }
  return 0;
}

Measured memory_bytes: 1024
a = [0 for i in range(51)]
for i in range(10):
  for j in range(10):
    for k in range(10):
      for l in range(10):
        a[i + j + k + l] += 1
while True:
  try:
    n = int(input())
    print(a[n])
   
  except EOFError:
    break
  
  


Measured memory_bytes: 5596
#include <stdio.h>
#include <string.h>

char a[100][101];
int n, l;

void swap(int x, int y) {
    char t;
    for(int i=0; i<l; i++) {
        t=a[x][i];
        a[x][i]=a[y][i];
        a[y][i]=t;
    }
}


int main(void) {
    scanf("%d%d", &n, &l);
    
    for(int i=0; i<n; i++)
        scanf("%s", a[i]);
    
    for(int i=0; i<n-1; i++) {
        for(int j=i+1; j<n; j++) {
            if(strcmp(a[i], a[j])>0) {
                swap(i, j);
            }
        }
    }
    
    for(int i=0; i<n; i++)
        printf("%s", a[i]);
    
    return 0;
}

Measured memory_bytes: 128
def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)
      
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        if isCLKWISE(phU) : continue
        while(True):
            del phU[-2]
            if len(phU) == 2 : break
            else :
                if isCLKWISE(phU) : break

    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        if isCLKWISE(phL) : continue
        while(True):
            del phL[-2]
            if len(phL) == 2 : break
            else :
                if isCLKWISE(phL) : break

                
                
    ph = phU + phL[1:-1]
    return ph
  
n = range(int(input()))
P = [[int(x) for x in input().split()] for _ in n]
Q = ConvexHullScan(P)
Q.reverse()
print(len(Q))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]
R = Q[idx:] + Q[:idx]
for r in R : print(r[0],r[1])

Measured memory_bytes: 33916
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>

using namespace std;

#define INF (100000)

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

int main(){
    int N;
    cin >> N;

    vector<long long> dp(N+1, 1); 

    /* 1円 */
    for(int i=0; i<N+1; i++){
        dp[i] = i;
    }

    /* 6円 */
    for(int j=1; j<=6; j++){
        for(int i=0; i<N+1; i++){
            long long a = i + pow(6.0, float(j));
            if(a > N){
                break;
            }
            else{
                chmin(dp[a], dp[i]+1);
            }
        }
    }


    /* 9円 */
    for(int j=1; j<=5; j++){
        for(int i=0; i<N+1; i++){
            long long a = i + pow(9.0, float(j));
            if(a > N){
                break;
            }
            else{
                chmin(dp[a], dp[i]+1);
            }
        }
    }

    cout << dp[N] << endl;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    string s;
    cin >> s;

    rep(i, 1<<3) {
        string t = "";
        int temp = 0, a = 1;
        for(int j=3; j>=1; j--) {
            t += s[j];
            if(i&a) {
                temp += s[j]-'0';
                t += '+';
            } else {
                temp -= s[j]-'0';
                t += '-';
            }
            a <<= 1;
        }
        temp += s[0]-'0';
        t += s[0];
        if(temp == 7) {
            rep(j, t.size()) cout << t[t.size()-1-j];
            cout << "=7" << endl;
            return 0;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(){
  string s;
  cin >> s;
  if(s == "SUN") {
    cout << 7 << endl;
  } else if (s == "MON"){
    cout << 6 << endl;
  } else if (s == "TUE"){
    cout << 5 << endl;
  } else if (s == "WED"){
    cout << 4 << endl;
  } else if (s == "THU"){
    cout << 3 << endl;
  } else if (s == "FRI"){
    cout << 2 << endl;
  } else if (s == "SAT"){
    cout << 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 3556
#include <iostream>
#include <string>

using namespace std;

int main() {
	string s, t, u;
	int a, b;
	cin >> s >> t >> a >> b >> u;
	if (s == u) cout << a - 1 << " " << b << endl;
	else if (t == u)cout << a << " " << b - 1 << endl;

}

Measured memory_bytes: 256
unittest
{
	assert( [ "15" ].parse.expand.solve == "23" );
	assert( [ "1" ].parse.expand.solve == "1" );
	assert( [ "13" ].parse.expand.solve == "21" );
	assert( [ "100000" ].parse.expand.solve == "3234566667" );
}



import std.algorithm;
import std.conv;
import std.functional;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto k = input.front.to!( long );
	return tuple( k );
}

auto solve( long k )
{
	long[] anss;
	auto p = 0L;
	LOOP: for( auto d = 1L;; d++ )
	{
		foreach( i; 1 .. 10 )
		{
			auto pp = memoize!solve2( i, d );
			if( k <= p + pp )
			{
				anss.length = d;
				anss[ 0 ] = i;
				break LOOP;
			}
			p += pp;
		}
	}
	foreach( i, ref ans; anss )
	{
		if( i == 0 ) continue;
		foreach( j; max( 0, anss[ i - 1 ] - 1 ) .. min( 10, anss[ i - 1 ] + 2 ) )
		{
			auto pp = memoize!solve2( j, anss.length.signed - i );
			if( k <= p + pp )
			{
				ans = j;
				break;
			}
			p += pp;
		}
	}
	return anss.to!( string[] ).join( "" );
}

long solve2( long i, long d )
{
	if( d <= 1 ) return 1L;
	if( i == 0 ) return memoize!solve2( i, d - 1 ) + memoize!solve2( i + 1, d - 1 );
	if( i == 9 ) return memoize!solve2( i - 1, d - 1 ) + memoize!solve2( i, d - 1 );
	return memoize!solve2( i - 1, d - 1 ) + memoize!solve2( i, d - 1 ) + memoize!solve2( i + 1, d - 1 );
}


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

using namespace std;

using i64 = long long;
#define forn(a, e) for (i64 a = 0; a < (i64)(e); a++)
#define forr(a, s, e) for (i64 a = s; a < (i64)(e); a++)
#define fore(e, a) for (auto& e : a)

#ifdef LOCAL
#define logv(a) {cerr << #a << " = "; fore(e, a) {cerr << e << " ";} cerr << "\n";}
#define logvp(a) {cerr << #a << " = "; fore(e, a) {cerr << "(" << e.first << ", " << e.second << ") ";} cerr << "\n";}
#define logvv(a) {cerr << #a << " = \n"; fore(r, a) { fore(e, r) {cerr << e << " ";} cerr << "\n";} }
#define logvf(a, field) {cerr << #a"."#field << " = \n"; fore(e, a) { cerr << e.field << " ";} cerr << "\n"; }
#define logvff(a, f1, f2) {cerr << #a".{"#f1 << ", "#f2 << "} = \n"; fore(e, a) { cerr << "(" << e.f1 <<", " << e.f2 << ") ";} cerr << "\n"; }
#define logs(a) cerr << #a << " = " << (a) << "\n";
#define logss(a, b) cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << "\n";
#define logp(a) cerr << #a << " = " << "(" << a.first << ", " << a.second << ")" << "\n";
#define cond(pred, stmt) if (pred) { stmt }
#else
#define logv(a)
#define logvp(a)
#define logvv(a)
#define logvf(a, field)
#define logvff(a, f1, f2)
#define logs(a)
#define logss(a, b)
#define logp(a)
#define cond(pred, stmt)
#endif

using iip = pair<int, int>;
using llp = pair<i64, i64>;
using ivec = vector<int>;
using llvec = vector<i64>;
using svec = vector<string>;
template<typename T> using vec = vector<T>;

template<typename T, typename Dim>
auto make_vec(T value, Dim dim) { return vector<T>(dim, value); }
template<typename T, typename Dim1, typename... Dim>
auto make_vec(T value, Dim1 dim1, Dim... dims) { return make_vec(make_vec(value, dims...), dim1); }

template<typename T>
bool uax(T& v, const T& newv) { if (v < newv) { v = newv; return true; } else return false; }
template<typename T>
bool uin(T& v, const T& newv) { if (v > newv) { v = newv; return true; } else return false; }

template<typename T>
istream& operator>>(istream& is, vector<T>& c) { for (auto& e : c) is >> e; return is; }
template<typename T, size_t N>
istream& operator>>(istream& is, array<T, N>& c) { for (auto& e : c) is >> e; return is; }

template<typename ...T>
istream& read(T&... args) { return (cin >> ... >> args); }

static mt19937 rande(123123);
template<typename T>
T rand_int(T from, T to) { uniform_int_distribution<T> distr(from, to); return distr(rande); }

// const i64 INF = 1e18;
const int INF = 2e9;
const i64 M = 1e9 + 7;
const int MXB = 20;
using bin = bitset<MXB + 1>;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    rande.seed(chrono::steady_clock::now().time_since_epoch().count());

    string s;
    while (read(s)) {
        if (s.back() == 's') {
            s += "es";
        } else {
            s += "s";
        }
        cout << s << endl;
    }
}

Measured memory_bytes: 3624
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main() {
	// your code goes here
	long long int a,b,c,d;
	cin>>a>>b>>c>>d;
    long long int x,y,z,w;
    x=a*c;
    y=a*d;
    z=b*c;
    w=b*d;
    long long int max1=max(x,y);
    max1=max(max1,z);
    max1=max(max1,w);
    cout<<max1<<endl;
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll r; cin>>r;
	cout << 3*r*r << "\n";
	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 t = sc.nextInt();
		int[] x = new int[n];
		long[][][] dp = new long[n + 1][n + 1][2501];
		for(int i = 0 ; i < n ; i++) x[i] = sc.nextInt();
		dp[0][0][0] = 1;
		for(int i = 0 ; i < n ; i++) {
			for(int j = 0 ; j < n ; j++) {
				for(int k = 0 ; k <= 2500 ; k++) {
//					if(x[i] + k <= 2500) dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
//					else dp[i + 1][j][k] += dp[i][j][k];
					if(x[i] + k <= 2500) {
						dp[i+1][j + 1][k + x[i]] += dp[i][j][k];
					}
					dp[i+1][j][k] += dp[i][j][k];
				}
			}
		}
		long ans = 0;
		for(int i = 1 ; i <= n ; i++) {
			ans += dp[n][i][i * t];
		}
		System.out.println(ans);
	}

}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n;
string s;
ll cnt[30];
ll r[30];

int main(){
    cin >> n >> s;
    rep(i,n)cnt[s[i] - 'a']++;
    ll ans = 0;
    rep(i,n){
        ll sum = 0;
        r[s[i] - 'a']++;
        rep(j,26)if(r[j] > 0 && cnt[j] - r[j] > 0)sum++;
        ans = max(ans,sum);
    }
    cout << ans << endl;
}

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

using namespace std;
int main(void){
   int A,B,C,K;
   cin >> A >> B >> C >> K;
   int sum = 0;
   
   if(A>K){
       sum+=K;
   }else{
       sum+=A;
   }
   
  for(int i = 0; i < K-A-B; i++){
      sum--;
  }
  cout << sum << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <cstdlib>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {

	ll N;
	cin >> N;
	string an = "";
	while (N > 0) {
		char k = ((N-1) % 26) + 'a';
		an = k+an;
		N = (N-1)/26;
	}
	cout << an << endl;
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 1e9
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n;cin>>n;
  pair<int,int>now=mp(0,0);
  int mae=0;
  bool flag=true;
  for(int i=0;i<n;i++){
    int t,x,y;cin>>t>>x>>y;
    int cnt=abs(now.F-x)+abs(now.S-y);
    if(((t-mae)-cnt)>=0&&((t-mae)-cnt)%2==0){
      now.F=x;now.S=y;
    }else{
      flag=false;
    }
    mae=t;
  }
  if(flag)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}


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

typedef struct {
	char word[ 31 ];
	int cnt, page[ 100 ];
} Data;

Data data[ 100 ];

int compare1( const void *a, const void *b ) {
	return *(int *)a - *(int *)b;
}

int compare2( const void *a, const void *b ) {
	return strcmp( (*(Data *)a).word, (*(Data *)b).word );
}

int main( void ) {
	int i, j;
	char word[ 31 ];
	int page, cnt;

	cnt = 0;
	while ( scanf( "%s %d", word, &page ) != EOF ) {
		for ( i = 0; i < cnt && strcmp( word, data[ i ].word ); i++ ) ;
		if ( i == cnt )
			strcpy( data[ cnt++ ].word, word );
		data[ i ].page[ data[ i ].cnt++ ] = page;
	}

	for ( i = 0; i < cnt; i++ )
		qsort( data[ i ].page, data[ i ].cnt, sizeof(int), &compare1 );
	qsort( data, cnt, sizeof(Data), &compare2 );

	for ( i = 0; i < cnt; i++ ) {
		puts( data[ i ].word );
		for ( j = 0; j < data[ i ].cnt; j++ )
			printf( "%d%c", data[ i ].page[ j ], j == data[ i ].cnt - 1 ? '\n' : ' ' );
	}

	return 0;
}

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

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main() {
    ll A,B;cin >> A >> B;
    ll N = min(A,B);
    auto pf = prime_factorize(N);
    ll res = 1;
    for (ll i = 0;i < pf.size();i++){
        if (A % pf[i].first == 0 && B % pf[i].first == 0) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
<?php
$n = trim(fgets(STDIN));
$a = explode(" ", trim(fgets(STDIN)));
$q = $d = $s = 0;
foreach($a as $num){
    if($num % 4 == 0){
        $q++;
    }elseif($num % 2 == 0){
        $d++;
    }else{
        $s++;
    }
}
if($d)$s++;
if($q + 1 >= $s){
    echo "Yes";
}else{
    echo "No";
}


Measured memory_bytes: 12792
(r, c) = [int(i) for i in input().split()]
src = []
for _ in range(r):
    row = [int(i) for i in input().split()]
    row.append(sum(row))
    src.append(row)
last_row = [0 for _ in range(c + 1)]
for rc in range(r):
    for cc in range(c+1):
        last_row[cc] += src[rc][cc]
src.append(last_row)
 
for rc in range(r+1):
    print(' '.join([str(a) for a in src[rc]]))

Measured memory_bytes: 7724
import itertools
import math
N=int(input())
l=[]
mem=[]
P=list(itertools.permutations(range(1,N+1)))
for i in range(N):
    l.append(list(map(int,input().split())))
for i in range(len(P)):
    mem.append(0)
    for j in range(len(P[i])-1):
        pos1 = P[i][j]-1
        pos2 = P[i][j+1]-1
        mem[i] += math.sqrt(((l[pos1][0]-l[pos2][0])**2) + ((l[pos1][1]-l[pos2][1])**2))
print(sum(mem)/len(mem))

Measured memory_bytes: 9252
package main

import (
	"fmt"
	"sort"
)

func main() {
	var in = make([]int, 3)
	fmt.Scanf("%d %d %d ", &in[0], &in[1], &in[2])
	sort.Ints(in)
	fmt.Println(in[0] + in[1] + 10 * in[2])
}


Measured memory_bytes: 512
// In the name of God 
#include <bits/stdc++.h>

using namespace std ;
 
#define int long long
#define all(v) v.begin() , v.end()

template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}
template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}

const int N = ( int )1e5 + 10 ; 

string s , t ;

int ss [ N ] , tt [ N ] ; 

int32_t main()                     
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> s >> t ;
	for ( int j = 0 ; j < ( int )s.size ( ) ; ++j ) {
		if ( j )
			ss [ j ] = ss [ j - 1 ] ;
		ss [ j ] += ( s [ j ] == 'A' ) + 1 ; 
	}
	for ( int j = 0 ; j < ( int )t.size ( ) ; ++j ) {
		if ( j )
		       tt [ j ] = tt [ j - 1 ] ;
		tt [ j ] += ( t [ j ] == 'A' ) + 1 ; 
	}
	int m ;
	cin >> m ;
	while ( m -- ) {
		int a , b , c , d ;
		cin >> a >> b >> c >> d ;
		a -- , b -- , c -- , d -- ;
		int vals = ss [ b ] - ( !a ? 0 : ss [ a - 1 ] ) ; 
		int valt = tt [ d ] - ( !c ? 0 : tt [ c - 1 ] ) ; 
		if ( vals % 3 == valt % 3 )
			cout << "YES\n" ;
		else
			cout << "NO\n" ; 
	}
}


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

long long dp[52][52][3000],ans;
int n,s,ar[300];

long long recursion(int node,int level,long long sum) {

    if(dp[node][level][sum]!=-1) {
        return dp[node][level][sum];
    }

    long long& x=dp[node][level][sum];

    if(level>0 && sum==1LL*s*level) {
        x=1;
    }
    else
        x=0;

    for(int i=node+1; i<=n; i++)
        x+=recursion(i,level+1,sum+ar[i]);

    return x;
}

int main() {

    while(cin>>n>>s) {
        ans=0;

        memset(dp,-1,sizeof(dp));

        for(int i=1; i<=n; i++)
            scanf("%d",ar+i);

        long long ans=recursion(0,0,0);
        cout<<ans<<endl;

    }

    return 0;
}


Measured memory_bytes: 63616
import java.util.*;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        boolean ok = true;
        if (s.charAt(0) != 'A')
            ok = false;
        boolean check = false;
        int idx = 0;
        for (int i = 2; i < s.length() - 1; i++) {
            if (s.charAt(i) == 'C') {
                check = true;
                idx = i;
                break;
            }
        }
        ok &= check;
        for (int i = 1; i < s.length(); i++) {
            if (i == idx)
                continue;
            if (s.charAt(i) >= 'A' && s.charAt(i) <= 'Z')
                ok = false;
        }
        System.out.println(ok ? "AC" : "WA");

    }

}


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


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

  if(a<10 && 0<a && 0<b && b<10 ){
    int ans = a*b;
    cout << ans << endl;
  }else{
    cout << "-1" << endl;
  }
  return 0;
}


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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;

int N;
ll K;
vector<ll> A;

ll counting(ll x){
  ll cnt = 0;
  REP(i, N){
    int ok, ng;
    if(A[i] > 0){
      ok = -1, ng = N;
    }
    else{
      ok = N, ng = -1;
    }
    while(abs(ok-ng) > 1){
      int mid = (ok+ng) / 2;
      if(A[i]*A[mid] <= x){
        ok = mid;
      }
      else{
        ng = mid;
      }
    }
    int add;
    if(A[i] > 0){
      add = ok+1;
      if(add >= i+1) add--;
    }
    else{
      add = N-ok;
      if(add >= N-i) add--;
    }
    cnt+= add;
  }
  return cnt / 2;
}

int main(){
  cin >> N >> K;
  A.resize(N);
  REP(i, N){
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  ll ng = -1e18, ok = 1e18;
  while(abs(ok-ng) > 1){
    ll mid = (ok+ng) / 2;
    if(counting(mid) >= K){
      ok = mid;
    }
    else{
      ng = mid;
    }
  }
  cout << ok << endl;
  return 0;
}


Measured memory_bytes: 1792
//include
//------------------------------------------
#include <bits/stdc++.h> // only for GCC

using namespace std;

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

//container util
//------------------------------------------
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

//repetition
//------------------------------------------
#define loop(i,a,b) for(ull i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)

//constant
//--------------------------------------------
const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

// output vector
// ------------------------------------------
namespace std {
    template<typename T>ostream&operator<<(ostream&os, vector<T>const&v){
        iter(it,v) os<<*it<<(it+1==v.end()?"":",");
        return os;
    }
    template<typename T, typename U>ostream&operator<<(ostream&os,const pair<T,U>&p){
        return os << "[" << p.dirst << "," << p.second << "]";
    }
}

//clear memory
// ------------------------------------------
#define clr(a,i) memset((a), (i) ,sizeof(a))

int main(){
   int h,m,s;
   int ha,ma,sa;
   while(cin >> h >> m >> s){
      if(h+m+s==-3) break;
      int ha=0,ma=0,sa=0;
      ha=2-h;
      if(m>0){
         ha--; ma=60-m;
      }
      if(s>0){
         if(ma==0){
            ha--; ma=60-m;
         }
         ma--; sa=60-s;
      }
      if(ha<10)cout << '0' ;
      cout << ha << ":"; 
      if(ma<10)cout << '0' ;
      cout << ma << ":" ;
      if(sa<10) cout << '0';
      cout << sa << endl;
      sa*=3;ma*=3;ha*=3;
      if(sa>=60){
         ma+=(sa/60); sa-=(sa/60)*60;
      }
      if(ma>=60){
         ha+=(ma/60); ma-=(ma/60)*60;
      }
      if(ha<10)cout << '0' ;
      cout << ha << ":"; 
      if(ma<10)cout << '0' ;
      cout << ma << ":" ;
      if(sa<10) cout << '0';
      cout << sa << endl;
   }
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
 
ll Pmod(ll n,ll k){
	ll r=k,ret=1;
	while(true){
		if(n==0)break;
		if(n%2==1){
			ret=ret*r%mod;
		}
		n/=2;
		r=r*r%mod;
	}
	return ret;
}
 
vector<pair<ll,ll> > v;
int main(){
	ll n,k;
	cin>>n>>k;
	for(ll i=1;i*i<=n;i++){
		if(n%i==0){
			v.push_back(make_pair(i,-1));
			if(i!=n/i)v.push_back(make_pair(n/i,-1));
		}
	}
	sort(v.begin(),v.end());
	ll ans[2]={0,0};
	for(int i=0;i<v.size();i++){
		ll x=v[i].first;
		ll tmp=Pmod((x+1)/2,k);
		for(int j=0;j<i;j++){
			if(x%v[j].first==0){
				tmp=(mod+tmp-v[j].second)%mod;
			}
		}
		v[i].second=tmp;
		ans[x%2]+=tmp*x%(mod*(ll)10);
	}
	//cout<<ans[0]<<" "<<ans[1]<<endl;
	cout<<(ans[0]/2+ans[1])%mod<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

const ll mod = 1e9+7;
// dp[i][j] : i人の男性まで考えた時、jで表される女性とマッチする組み合わせ
ll dp[25][1<<22];

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

    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;

    rep(m,n) rep(bit, 1<<n) {
        // dp[i][i個のbitが立っている]のみ有効
        int cnt = 0;
        rep(w,n) {
            if (bit & (1<<w)) cnt++;
        }
        if (cnt != m) continue;

        rep(w,n) {
            if (a[m][w] && !(bit & (1<<w))) {
                (dp[m+1][bit|(1<<w)] += dp[m][bit]) %= mod;
            }
        }
    }

    cout << dp[n][(1<<n)-1] << endl;

    return 0;
}

Measured memory_bytes: 819584
input = input()

acgt = ['A', 'G', 'C', 'T']

count_list = []
count = 0
for letter in input:
    if letter in acgt:
        count += 1
        count_list.append(count)
    else:
        count = 0
        count_list.append(count)
print(max(count_list))

Measured memory_bytes: 2940
def main():
    n = input()
    sum = 1
    l = list(map(int, input().split()))
    if 0 in l:
        print(0)
        return
    for i in l:
        sum *= int(i)
        if sum > 10**18:
            print(-1)
            exit()
    print(sum)


if __name__ == '__main__':
    main()


Measured memory_bytes: 21596
#include <iostream>
using namespace std;
int main() {
    int n;
    std::cin >> n;
    for (int i = 1; i <= n; i++) {
        if (i % 3 == 0) {
            cout << " " << i;
            continue;
        }
        int x = i;
        do {
            if (x % 10 == 3) {
                cout << " " << i;
                break;
            }
        } while (x /= 10);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3096
#include "stdio.h"
#include "stdlib.h"
#include "iostream"
#include "math.h"
#include <string.h>


using namespace std;
#define fori0(G) for(int i=0;i<G;i++)
#define fori1(G) for(int i=1;i<=G;i++)
#define forj0(G) for(int j=0;j<G;j++)
#define forj1(G) for(int j=1;j<=G;j++)
#define fork0(G) for(int k=0;k<G;k++)
#define fork1(G) for(int k=1;k<=G;k++)

int h, w;
char ch[200][200];
int fl[200][200];

void dfs(int x, int y) {
	fl[x][y] = 0;
	int dx[] = { -1,0,1,0 };
	int dy[] = { 0,1,0,-1 };
	int nx, ny;
	//printf("(%d,%d)", x, y);
	fori0(4) {
		
		nx = x + dx[i];
		ny = y + dy[i];
		if (0 <= nx && nx < h && 0 <= ny && ny < w&&fl[nx][ny]&&ch[x][y]==ch[nx][ny]) { dfs(nx, ny); }
	}
	return;

}

int main() {
	int co;
	


	while (1) {
		co = 0;
		cin >> h >> w;
		if (h == 0 && w == 0)break;
		fori0(h)forj0(w) {
			cin >> ch[i][j];
			fl[i][j] = 1;
		}
		fori0(h)forj0(w) {
			if (fl[i][j]) {
				//fl[i][j] = 0;
				co++;
				dfs(i, j);
			}
		}
		printf("%d\n", co);
	}
	//system("pause");
	return 0;
}



Measured memory_bytes: 4264
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<fstream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

    // input
    ll N, x;
    cin >> N >> x;

    if(x==1 || x==2*N-1){
        p_no();
    }else{
        p_yes();
        vector<ll> A(2*N-1);
        A[N-2] = x-1;
        A[N-1] = x;
        A[N] = x+1;
        
        queue<ll> que;
        FOR(i, 1, 2*N){
            if(i==x || i==x-1 || i==x+1){
                //
            }else{
                que.push(i);
            }
        }
        FOR(i, 0, N-2){
            A[i] = que.front();
            que.pop();
        }
        FOR(i, N+1, 2*N-1){
            A[i] = que.front();
            que.pop();
        }
        for(ll a : A){
            p(a);
        }
    }
    
    return 0;
}

Measured memory_bytes: 4736
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<cmath>
#include<string>

#define ls (t<<1)
#define rs ((t<<1)+1)
#define mid ((l+r)>>1)
#define fi first
#define se second
#define mk make_pair
#define pb push_back

#define N 100005
#define M 200005
#define seed 23333
#define Mo 1000000007

using namespace std;
int i,j,m,n,p,k,a,b,c,ans,fac[N],inv[N];
int C(int x,int y)
{
		if (y==0) return 1; 
		if (x<y) return 0;
		return 1ll*fac[x]*inv[y]%Mo*inv[x-y]%Mo;
}
int power(int x,int y)
{
		int s=1;
		for (;y;y>>=1)
		{
				if (y&1) s=1ll*s*x%Mo;
				x=1ll*x*x%Mo;
		}
		return s;
}
void jia(int &x,int y)
{
		x+=y; if (x>=Mo) x-=Mo;
}
int main()
{
	scanf("%d%d%d%d",&n,&a,&b,&c);
	fac[0]=inv[0]=1;
	for (i=1;i<N;++i) fac[i]=1ll*fac[i-1]*i%Mo,inv[i]=power(fac[i],Mo-2);
	if (b&1) puts("0");
	else 
	{
		  b/=2;
		  for (i=0;i<=a;++i)
		  	for (j=0;i+j<=c;++j)
		  		if ((c-i-j)%3==0)
		  		{
		  				jia(ans,1ll*C(a+b,a)*C(a,i)%Mo*C(b+j-1,j)%Mo*C(a+b+1+(c-i-j)/3-1,(c-i-j)/3)%Mo); 
		  		}
		printf("%d\n",ans);
	}
}


Measured memory_bytes: 1152