akhauriyash/Code-Regression huggingface dataset:
/**
 * Author: AcFunction
 * Date:   2019-09-04 21:48:14
 * Email:  3486942970@qq.com
**/

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ull unsigned long long
#define db double
#define ldb long double 

#define fi first
#define se second
#define MP make_pair
#define pii pair <int, int>
#define pil pair <int, ll> 
#define pli pair <ll, int>
#define pll pair <ll, ll>  

#define All(x) x.begin(), x.end()
#define pb push_back
#define pf push_front

#define ms0(x) memset(x, 0, sizeof(x))
#define ms1(x) memset(x, -1, sizeof(x))

#define oiu cerr << "Yes!" << endl; 
#define O(x) cerr << #x << ": " << x << endl;  

template <typename T> void printarr(T a[], int b, int e) {
  if(b > e) return ; 
  for(int i = b; i < e; i++) cout << a[i] << " "; 
  cout << a[e] << " " << endl; 
} 

template <typename T> int chkmax(T &x, const T &y) {
  return x < y ? x = y, 1 : 0; 
}

template <typename T> int chkmin(T &x, const T &y) {
  return x > y ? x = y, 1 : 0; 
}

const int N = 200200; 

ll n, a[N], b[N]; 

priority_queue <pli> Q; 

int main() {
  scanf("%lld", &n); ll ans = 0; 
  for(int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]); 
  }
  for(int i = 1; i <= n; i++) {
    scanf("%lld", &b[i]); 
    Q.push({b[i], i}); 
    if(b[i] < a[i]) {
      puts("-1"); 
      return 0; 
    }
  }
  while(!Q.empty()) {
    pli tmp = Q.top(); Q.pop(); 
    if(tmp.fi == a[tmp.se]) continue ; 
    if(tmp.fi < a[tmp.se]) {
      puts("-1"); 
      return 0; 
    }
    int id = tmp.se; 
    int id1 = id + 1; 
    int id2 = id - 1; 
    if(id1 > n) id1 -= n; 
    if(id2 < 1) id2 += n; 
    if(b[id] < b[id1] + b[id2] + a[id]) {
      puts("-1");
      return 0; 
    }
    ll t = b[id1] + b[id2]; 
    ll x = b[id] - a[id]; 
    ans += x / t; b[id] -= x / t * t; 
    if(a[id] != b[id])
      Q.push({b[id], id}); 
  }
  for(int i = 1; i <= n; i++) {
    if(a[i] != b[i]) {
      puts("-1"); 
      return 0; 
    }
  }
  printf("%lld\n", ans);
  return 0; 
}

//

Measured memory_bytes: 8944
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

int64 mod = pow(10, 9) + 7;
int64 ans;

void P(int64 n, int64 m) {
    rep(i, m) ans = (ans * (n - i)) % mod;
}

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

    int64 n, k;
    scanf("%lld %lld", &n, &k);
    vector<vector<int>> adj(n);
    rep(i, n - 1) {
        int a, b;
        scanf("%d %d", &a, &b);
        a--; b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    ans = k;
    stack<int> dfs;
    vector<bool> visited(n, false);
    dfs.push(0);
    int depth = 0;
    while(!dfs.empty()) {
        int x = dfs.top();
        dfs.pop();
        visited[x] = true;
        int cdepth = depth;

        int64 m = 0;
        for (auto v : adj[x]) {
            if (!visited[v]) {
                m++;
                dfs.push(v);
                depth++;
            } else {
                depth--;
            }
        }
        P(k - 1 - (cdepth == 0 ? 0 : 1), m);
        cerr << '\n';
    }


    cout << ans << '\n';

    return 0;
}



Measured memory_bytes: 6520
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    
    int n, a, b; cin >> n >> a >> b;
    cout << min(n * a, b) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;(i)>=0;(i)--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())

typedef long long ll;


bool used[100010];
int amount[100010];

int main(){
    
    REP(i,100010)used[i]=false;
    REP(i,100010)amount[i]=0;
    used[1]=true;
    
    int N,M;
    cin>>N>>M;
    
    REP(i,N)amount[i+1]=1;
    
    REP(i,M){
        int x,y;
        cin>>x>>y;
        
        if(used[x]&&amount[x]>0){
            if(amount[x]==1)used[x]=false;
            amount[x]--;
            amount[y]++;
            used[y]=true;
        }else if(amount[x]>0){
            amount[x]--;
            amount[y]++;
        }
        
    }
    
    int ans=0;
    REP(i,N)if(used[i+1])ans++;
    
 //   REP(i,N)cout<<used[i+1]<<" ";
 //   cout<<endl;
    
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;

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

Measured memory_bytes: 3640
#一桁　９個
#三桁　９００個
#五桁　９００００個
N =int(input())
number =0
if N>=100000:
  number=90909
elif N>=10000:
  number=909+N-10000+1
elif N>=1000:
  number=909
elif N>=100:
  number=9+N-100+1
elif N>=10:
  number=9
else:
  number=N
print(number)



Measured memory_bytes: 2940
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) throws ClassNotFoundException, IOException {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int L = sc.nextInt();
		int sum = 0;
		int preAbs = 300;
		int pre = 300;
		for(int i = 1; i <= N; i++) {
			int aji = L + i - 1;
			if(preAbs > Math.abs(aji)) {
				preAbs = Math.abs(aji);
				pre = aji;
			}
			sum = sum + aji;
		}

		if(pre < 0) {
			System.out.println(sum + preAbs);
		}else {
			System.out.println(sum - preAbs);
		}
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 22996
/////////////////////////////////////////////////////////
//
//  c/temp.cpp file
//  Last Updated: 2018-10-23 ...Maybe
//
//    I hope you adding this code to the setting file
//    alias g++='g++ -std=c++1y -DDEBUG_LOCAL'
//
/////////////////////////////////////////////////////////

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

//#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _REP(i,n) REAP(i,0,n)
#define REAP(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,REAP,_REP,)(__VA_ARGS__)

#define _REPR(i,n) REAPR(i,n,0)
#define REAPR(i,a,b) for(int i=int(a-1);i>=int(b);--i)
#define REPR(...) _overload3(__VA_ARGS__,REAPR,_REPR,)(__VA_ARGS__)

#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()

#define coutALL(a) {int loop_coutALL=0;for(auto e:a) cout<<(loop_coutALL++?" ":"")<<e; cout<<endl;}

#define coutYN(a) cout<<((a)?"YES":"NO")<<endl;
#define coutYn(a) cout<<((a)?"Yes":"No")<<endl;
#define coutyn(a) cout<<((a)?"yes":"no")<<endl;

#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)

const int INF=1145141919;
//const long long INF=114514191911451419;
const int MOD=(int)1e9+7;
const double EPS=1e-12;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
//const int dx[]={-1,-1,-1,0,1,1,1,0},dy[]={-1,0,1,1,1,0,-1,-1};

using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;

typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef pair<string,int> psi;
typedef pair<string,string> pss;

typedef long long ll;

template<typename T> istream &operator >> (istream &is, vector<T> &v){for(T &x:v) is>>x;return is;}
template<typename T> ostream &operator << (ostream &os, vector<T> &v){int i=0;for(T &x:v) os<<(i++?" ":"")<<x;return os;}

ll rev(ll n){ll x=0;for(;n>0;){x=x*10+n%10;n/=10;}return x;}

template<class T> ll upper(T n,T m){return (n+m-1)/m;};
template<class T> ll rounding(T n){return (long double)n+0.5;};

template<class T> bool inG(T x,T n){return 0<=x && 0<n;}
template<class T> bool outG(T x,T n){return x<0 || n<=x;}

inline int qp(int a,ll b){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
inline int qp(int a,ll b,int mo){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

inline ll fac(ll k,ll n){ll a=1;for(int i=0;i<n;i++)a*=k--;return a;}
inline ll fac(ll k,ll n,int mo){ll a=1;for(int i=0;i<n;i++)a*=k--,a%=mo;return a;}

inline int dsum(ll n){int a=0;for(;n;n/=10)a+=n%10;return a;}

struct Arithmetic{Arithmetic(){cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);}};

//#define DEBUG_LOCAL

#ifdef DEBUG_LOCAL
template<typename T> void deb(T a){cerr<<"deb: "<<a<<"です"<<endl;}
#define debl {cerr<<"debug: "<<__LINE__<<"行目だ"<<endl;}
void what_cr(){cout<<__GCC_ATOMIC_CHAR16_T_LOCK_FREE<<" ←？"<<endl;}
//ori_func S

//ori_func E
#else
template<typename T>void deb(T a){}
#define debl
void what_cr(){}void t_t(){}
#endif

signed main(){

  Arithmetic Exception;

  string s;
  cin>>s;

  REP(i,s.size()) cout<<s[i++];

  return 0;

}


Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
#define ran 111111
int e[ran];
int m;
int chk(int x){
	int res = 0;
	for(int i=x; i<ran; i+=m)
		res += e[i];
//	printf("%d\n",res);
	return res/2;
}
int chk2(int x){
	int A = 0, B = 0, C = 0, D = 0;
	for(int i=x; i<ran; i+=m){
		A += e[i]/2;
		C += e[i];
	}
	for(int i=m-x; i<ran; i+=m){
		B += e[i]/2;
		D += e[i];
	}
	int tmp1 = min(D-B*2,C);
	int tmp2 = min(C-A*2,D);
//	printf("%d %d %d %d\n",A,B,C,D);
	return max(tmp1+B+min((C-tmp1)/2,A), tmp2+A+min((D-tmp2)/2,B));
}
int main(){
	int x,y;
	for(scanf("%d%d",&x,&m); x--;){
		scanf("%d",&y);
		e[y] ++;
	}
	int res = chk(0);
	if(m % 2 == 0)res += chk(m/2);
	for(int i=1; i+i<m; i++)
		res += chk2(i);
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

#define debug(x) (#x " : " + to_string(x))
#define debug_cout(x) (cout << #x << " : " <<  to_string(x) << endl)
//#define debug_cout(x) ( )
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair((a), (b));
using namespace std;
using ll = long long;
//#define int long long
template<class T> bool chmax(T& a, T& b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T& b) { if (a > b) { a = b; return true; } return false; }
constexpr int INF = 2e9;

/*****/

string S;

void out(vector<int> op)
{
	for (int i = 0; i < 4 - 1; i++)
	{
		cout << S.at(i);
		cout << (op.at(i+1) == 1 ? '+' : '-');
	}
	cout << S.at(3) << "=7" << endl;
}

bool ret(int begin, int sum, vector<int> op)
{
	int num = S.at(begin) - '0';

	if (begin == 3)
	{
		if (sum + num == 7)
		{
			op.push_back(1);
			out(op);
			return true;
		}
		if (sum - num == 7)
		{
			op.push_back(-1);
			out(op);
			return true;
		}

		return false;
	}

	bool isOK = false;

	vector<int> op1(op);
	op1.push_back(1);
	isOK = ret(begin + 1, sum + num, op1);

	if (!isOK)
	{
		vector<int> op2(op);
		op2.push_back(-1);
		isOK = ret(begin + 1, sum - num, op2);
	}

	return isOK;
}

int main()
{
	cin >> S;

	ret(0, 0, vector<int>(0));

	return 0;
}


Measured memory_bytes: 256
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    Sd = input()
    T = input()
    rp = len(Sd)-len(T)
    ret = []
    for i in range(rp+1):
        Td = ('?'*i) + T + ('?' * (rp-i))
        Tr = ''
        for i, c in enumerate(Sd):
            d = Td[i]
            if c == '?' and d=='?':
                Tr+='a'
            elif c == '?' and d!='?':
                Tr+=d
            elif c != '?' and d=='?':
                Tr+=c
            elif c == d:
                Tr+=d
            else:
                break
        if len(Tr)==len(Sd):
            ret.append(Tr)
    if len(ret)==0:
        print('UNRESTORABLE')
    else:
        ret.sort()
        print(ret[0])

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  const int dx = tx - sx,dy = ty - sy;
  //path1
  cout << string(dy,'U') << string(dx,'R'); 
  // Path 2
  cout << string(dy,'D') << string(dx,'L'); 
  // Path 3
  cout << 'L' << string(dy+1,'U') << string(dx+1,'R') << 'D';
  // Path 4
  cout << 'R' << string(dy+1,'D') << string(dx+1,'L') << 'U';

  // EndLine
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
//long long ccw(const Point& A, const Point& B, const Point& C) {
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}

int main() {
	// 최대유량, 앳코더, (종만북(?) 생각) - 기하 잘하고 싶다!
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	string s; cin >> s;
	int len = s.size();
	int ans = 0;
	rep(i, len) {
		if (s[i] == '+')ans += 1;
		else ans -= 1;
	}
	cout << ans << '\n';






}


Measured memory_bytes: 256
n = int(input())
a = n % 10
if a == 2 or a == 4 or a == 5 or a == 7 or a == 9:
    print('hon')
elif a == 0 or a == 1 or a == 6 or a == 8:
    print('pon')
else:
    print('bon')

Measured memory_bytes: 9172
#include "bits/stdc++.h" 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n;
    cin >> n;
    vi d(3, 0);
    for(int i = 0; i < n; i++) {
        vi c(3);
        vi cur(3, 0);
        for(int j = 0; j < 3; j++) cin >> c[j];
        for(int k = 0; k < 3; k++){
            for(int j = 0; j < 3; j++){
                if(k != j){
                    cur[j] = max(cur[j], d[k] + c[j]);
                }
            }
        }
        d = cur;
    }
    cout << max({d[0], d[1], d[2]});
}

Measured memory_bytes: 256
#include <iostream>

int main() {
    
    int a, b, c;
    std::cin >> a >> b >> c;
    
    if (a > b) std::swap(a, b);
    if (a > c) std::swap(a, c);
    if (b > c) std::swap(b, c);
    
    std::cout << a << " "  << b << " " << c << std::endl;
    
    return 0;
}


Measured memory_bytes: 3092
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>

using namespace std;

#define SIZE 10000
#define INF 1000000000

vector<int> G[SIZE];

vector<pair<int,int> > dijkstra(int n, int start) {
  priority_queue<pair<pair<int,int>, int>> pq;
  bool visited[SIZE] = {};
  vector<pair<int,int> > res(n, {INF, INF});

  pq.push({{0, -start}, start});

  while(pq.size()) {
    auto p = pq.top();
    pq.pop();

    int now = p.second;
    int len = -p.first.first;
    int minV = -p.first.second;

    if (visited[now]) continue;
    visited[now] = true;
    res[now] = {len, minV};

    for (int to : G[now]) {
      pq.push({{-len-1, -min(minV, to)}, to});
    }
  }

  return res;
}

int main() {
  int N, M, A, B, C, x;
  vector<int> a, b, c;
  int root[SIZE];

  scanf("%d%d%d%d", &N, &A, &B, &C);

  for (int i=0; i<A; i++) {
    scanf("%d", &x);
    a.push_back(x-1);
  }

  for (int i=0; i<B; i++) {
    scanf("%d", &x);
    b.push_back(x-1);
  }

  for (int i=0; i<C; i++) {
    scanf("%d", &x);
    c.push_back(x-1);
  }

  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());

  for (int i=0; i<N; i++) root[i] = i;
  for (int x : a) root[x] = a[0];
  for (int x : b) root[x] = b[0];
  for (int x : c) root[x] = c[0];

  scanf("%d", &M);

  for (int i=0; i<M; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--; y--;

    G[root[x]].push_back(root[y]);
    G[root[y]].push_back(root[x]);
  }

  auto vecA = dijkstra(N, root[a[0]]);
  auto vecB = dijkstra(N, root[b[0]]);
  auto vecC = dijkstra(N, root[c[0]]);

  pair<int,int> ans = {INF, -1};

  for(int i=0; i<N; i++) {
    if (i != root[i]) continue;

    int len = vecA[i].first + vecB[i].first + vecC[i].first;
    int minV = min({vecA[i].second, vecB[i].second, vecC[i].second});

    ans = min(ans, {len, minV});
  }

  cout << ans.first << " " << ans.second + 1 << endl;

  return 0;
}



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

#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MAX (int)1e9 + 99
#define maxof(a,b,c) max(a,max(b,c))
#define minof(a,b,c) min(a,min(b,c))
#define vi vector<int>
#define vb vector<bool>
#define ll long long
#define ull unsigned long long
#define vll vector<ll>
#define pa pair<int, int>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define MOD 1000000007
#define bitcnt(x) __builtin_popcount(x)
#define gcd(a,b) __gcd(a,b)
#define all(x) (x).begin(),(x).end()
#define ts(x) to_string(x)
#define set0(x) memset(x, 0, sizeof(x))
const double pi = 3.14159265358979323846;
ll binpow(ll, ll);
ll mult(ll, ll);
ll add(ll , ll);
ll division(ll, ll);
ll nCr(ll, ll);
ll inv(ll);
void calc();
template<class T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is;}
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) {if (!v.empty()) {os << v.front();for (int i = 1; i < v.size(); ++i) os << ' ' << v[i];} return os;}
const int N=50010;
//ll fact[N];

ll dp[402][402];
const ll INF = 1e18L + 9;

/*ll sum(int l, int r, vll a)
{
    ll s = 0;
    for(int i=l; i<=r; i++)
        s+=a[i];

    return s;
}*/

void solve()
{
    int n;
    cin>>n;
    vll a(n);
    rep(i,n) cin>>a[i];

    auto sum = [&](int l, int r)
    {
        ll s = 0;
        for(int i=l; i<=r; i++)
            s+=a[i];

        return s;
    };

    for(int l = n-1; l>=0 ; l--)
    {
        for(int r = l; r<n; r++)
        {
            if (l==r)
            {
                dp[l][r] = 0;
            }
            else
            {
                dp[l][r] = INF;
                ll s = sum(l,r);
                for(int i = l; i<=r-1; i++)
                {
                    dp[l][r] = min(dp[l][r], dp[l][i] + dp[i+1][r] + s);
                }
            }
        }
    }

    cout<<dp[0][n-1];
}

int main()
{
    fastio;
    
    int t=1;
    //cin>>t;
    
    rep(i,t)
    {
        solve();
        cout<<"\n";
    }
    return 0;
}

ll add(ll a, ll b){
    a+=b;
    while(a>=MOD) a-=MOD;
    while(a<0) a+=MOD;
    return a;
}

ll mult(ll a, ll b){
    return (a * 1ll * b) % MOD;
}


ll binpow(ll a, ll b){
    ll c = 1;
    while(b > 0)
    {
        if(b % 2 == 1)
            c = mult(c, a);
        a = mult(a, a);
        b /= 2;
    }
    return c;   
}

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

ll division(ll a, ll b){
    return mult(a, inv(b));
}

/*ll nCr(ll n, ll r){
    if(r > n) return 0;
    return division(fact[n], mult(fact[n-r], fact[r]));
}

void calc(){
    fact[0] = 1;
    srep(i,1,N-1)
        fact[i] = (i*1ll*fac[i-1])%MOD;

}*/

Measured memory_bytes: 4904
n, k = map(int, input().split())
d = list(map(int, input().split()))

d = set([str(_d) for _d in d])

ans = n
while True:
    f = True
    a = str(ans)
    for _a in a:
        if _a in d:
            f = False
    if f:
        print(ans)
        break
    else:
        ans += 1


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
using ll = long long;

ll div2_count(ll num) {
  ll count = 0;
  while(num % 2 == 0) {
    count++;
    num /= 2;
  }
  return count;
}

int main() {
  int N;
  cin >> N;
  ll a;
  ll ans = 0;
  for(int i = 0; i < N; ++i) {
    cin >> a;
    ans += div2_count(a);
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  std::string str;
  std::cin >> str;
  
  int first = std::stoi(str.substr(0, 2));
  int second = std::stoi(str.substr(2, 2));
  if (12 < first || first == 0) {
    if (second <= 12 && 0 < second) {
      std::cout << "YYMM" << std::endl;
    } else {
      std::cout << "NA" << std::endl;
    }
  } else {
    if ((0 < first && second == 0) || 12 < second) {
      std::cout << "MMYY" << std::endl;
    } else if (first == 0) {
      std::cout << "NA" << std::endl;
    } else {
      std::cout << "AMBIGUOUS" << std::endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const ll M=2e5+5;
ll a[M],ct[M];
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n;
	ll res = 0;
	cin>>n;
	for(ll i=1;i<=n;i++)
	{
		cin>>a[i];
		res = res + ct[a[i]];
		ct[a[i]]++;
	}
	for(ll i=1;i<=n;i++)
	{
		cout<<res-ct[a[i]]+1<<"\n";
	}
	return 0;
}

Measured memory_bytes: 4736
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scanf("%2d%2d", &a, &b)

	var ans string
	if (1 <= a && a <= 12) && (1 <= b && b <= 12) {
		ans = "AMBIGUOUS"
	} else if 1 <= a && a <= 12 {
		ans = "MMYY"
	} else if 1 <= b && b <= 12 {
		ans = "YYMM"
	} else {
		ans = "NA"
	}

	fmt.Println(ans)
}


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

struct Lowlink{
    int n,time;
    vector<int> ord,low;
    vector<vector<int>> G;
    vector<int> articulation;
    vector<pair<int,int>> bridge;
    Lowlink(int n):n(n),time(0),ord(n,-1),low(n),G(n){}
    void add_edge(int u,int v){
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }
    void dfs(int v,int p){
        ord[v]=low[v]=time++;
        bool is_articulation=false;
        int cnt=0;
        for (int u:G[v]){
            if (u==p) continue;
            if (~ord[u]){
                low[v]=min(low[v],ord[u]);
                continue;
            }
            ++cnt;
            dfs(u,v);
            low[v]=min(low[v],low[u]);
            is_articulation|=(~p&&ord[v]<=low[u]);
            if (ord[v]<low[u]) bridge.emplace_back(v,u);
        }
        is_articulation|=(p<0&&cnt>1);
        if (is_articulation) articulation.emplace_back(v);
    }
    void build(){
        for (int v=0;v<n;++v){
            if (ord[v]<0) dfs(v,-1);
        }
    }
};

// https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/3/GRL_3_A

void GRL_3_A(){
    int V,E; cin >> V >> E;
    Lowlink L(V);
    for (int i=0;i<E;++i){
        int s,t; cin >> s >> t;
        L.add_edge(s,t);
    }
    L.build();
    vector<int> ans=L.articulation;
    sort(ans.begin(),ans.end());
    for (int v:ans) cout << v << '\n';
}

// https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/3/GRL_3_B

void GRL_3_B(){
    int V,E; cin >> V >> E;
    Lowlink L(V);
    for (int i=0;i<E;++i){
        int s,t; cin >> s >> t;
        L.add_edge(s,t);
    }
    L.build();
    vector<pair<int,int>> ans=L.bridge;
    for (auto &e:ans) if (e.second<e.first)
        swap(e.first,e.second);
    sort(ans.begin(),ans.end());
    for (auto e:ans) cout << e.first << ' ' << e.second << '\n';
}

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


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

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    string s,t;
    int r=INT_MAX,n,n1,br=0;
    cin >> s >> t;
    n=s.size(); n1=t.size();
    for (int i=0;i<n-(n1-1);i++)
    {
        br=0;
        for (int j=0;j<n1;j++)
            if(s[i+j]!=t[j])
                br++;
        r=min(r,br);
    }
    cout << r;
}


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

struct uf{
    vector<int> t;
    uf(int n):t(n,-1){}
    int r(int x){
        while(t[x] >= 0)x = t[t[x]] >= 0 ? t[x] = t[t[x]] : t[x];
        return x;
    }
    int f(int x,int y){return r(x)==r(y);}
    int u(int x,int y){x=r(x);y=r(y);if(t[x]>t[y])swap(x,y);t[x]+=t[y];t[y]=x;}
    template<class F,class... R>
    int u(F f,R... r){for(auto i:initializer_list<int>{r...})u(f,i);}
};

int main(){
    uf uf1(13);
    uf1.u(1,3,5,7,8,10,12);
    uf1.u(4,6,9,11);
    int a, b;
    cin >> a >> b;
    puts(uf1.f(a, b) ? "Yes" : "No");
}


Measured memory_bytes: 256
/// wa ^3^

#pragma GCC optimize("O3")

#include<bits/stdc++.h>
                           
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;                                   

const int INF32 = 1e9 + 1e2;

void stndrtn() {
#ifdef accepted    
    freopen(".in", "r", stdin);
#endif
}

int MOD;

int mult(int x, int y) {
    return (ll)(x * 1ll * y) % MOD;
}

int binpow(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1)
            res = mult(res, a);
        a = mult(a, a);
        b >>= 1;         
    }    
    return res;
}                                    

int dv(int a, int b) {
    int x = mult(a, binpow(b, MOD-2));
    return x + (-x+MOD-1)/MOD * MOD;
}

const int MAX = 1e5+10;

int cnt[MAX];

vector<int> a;

ll solve(int l, int r) {
    if (r-l == 1) 
        return a[l] % MOD == 0;
    int m = l+r >> 1;
    int ten = 1, pv = 0;
    for (int i = m-1; i >= l; --i) {
        pv = ((a[i]*ten + pv) % MOD);
        cnt[pv]++, ten = mult(ten, 10);        
    }
    ten = 1;
    ll sum = 0, rd = 0;
    for (int i = m; i < r; ++i) {
        rd = (rd * 10 + a[i]) % MOD;
        sum += cnt[dv(-rd, ten = mult(ten, 10))];    
    }
    ten = 1, pv = 0;
    for (int i = m-1; i >= l; --i) {
        pv = ((a[i]*ten + pv) % MOD);
        cnt[pv]--, ten = mult(ten, 10);        
    }
    return sum + solve(l, m) + solve(m, r);
}

int main() {
    ios_base::sync_with_stdio(0);                               
    cin.tie(nullptr), stndrtn();
    int n;
    cin >> n >> MOD;
    string s;
    cin >> s;
    for (char c : s)
        a.pb(c-'0');
    ll ans = 0;
    if (MOD == 2) {
        for (int i = 0; i < n; ++i) 
            ans += (a[i] % 2 == 0) * (i+1);
    } else if (MOD == 5) {
        for (int i = 0; i < n; ++i)
            ans += (a[i] % 5 == 0) * (i+1);
    } else ans = solve(0, n);
    return cout << ans, 0;
}



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

int main() {
  int N;
  cin >> N;
  vector<int> A(N + 1);
  vector<int> B(N + 1);
  B[1] = 0;
  
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
    if (i % 2 == 1) B[1] += A[i];
    else B[1] -= A[i];
  }
  
  cout << B[1] << " ";
  
  for (int i = 2; i <= N; i++) {
    B[i] = 2 * A[i - 1] - B[i - 1];
    cout << B[i] << " ";
  }
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;
void f(int n){
  vector<int> in(n);
  int ans = 0;
  for(int i = 0; i < n; i++){
  	cin >> in.at(i);
  }
  sort(in.begin(), in.end());
  for(int i = 0; i < n-2; i++){
  	for(int j = i+1; j < n-1; j++){
      	if(in.at(i) == in.at(j))
          continue;
    	for(int k = j+1; k < n; k++){
          if(in.at(i) == in.at(k) || in.at(j) == in.at(k))
            continue;
          //cout << in.at(i) << in.at(j) << in.at(k) << endl;
          if(in.at(i) + in.at(j) > in.at(k))
            ans++;
        }
    }
  }
  cout << ans << endl;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  if(n < 3){
  	cout << 0 << endl;
    return 0;
  }
    
  f(n);
 return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif

const int X = 1000010;
int nxt[X][26];
int par[X], cp[X];
bool is[X];
int num[X][26];
int Num[X];

int I = 1;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	rep(i,X) rep(j,26) nxt[i][j] = -1;
	rep(i,X) par[i] = -1;

	int N; cin >> N;
	V<string> s(N); rep(i,N) cin >> s[i];
	rep(i,N){
		string t = s[i]; reverse(all(t));
		int v = 0;
		for(char c_: t){
			int c = c_-'a';
			if(nxt[v][c] == -1){
				nxt[v][c] = I;
				par[I] = v;
				cp[I] = c;
				I++;
			}
			v = nxt[v][c];
		}
		is[v] = true;
	}
	per(v,I){
		rep(c,26) if(nxt[v][c] != -1){
			int u = nxt[v][c];
			rep(d,26){
				num[v][d] += (c == d ? Num[u] : num[u][d]);
			}
			Num[v] += Num[u];
		}
		if(is[v]) Num[v]++;
	}
	ll ans = 0;
	per(v,I) if(is[v]){
		int p = par[v];
		int c = cp[v];
		ans += num[p][c]-1;
	}
	cout << ans << endl;
}


Measured memory_bytes: 220392
h,w = map(int,input().strip().split())
arr = []
for i in range(h):
    temp = list(input().strip())
    arr.append(temp)

dp = [[0 for _ in range(w)] for _ in range(h)] 
for i in range(h):
    for j in range(w):
        if i==0 and j==0:
            if arr[i][j]=='#':
                dp[i][j] = 1            
        elif arr[i][j]=='#':
            if i==0:
                if arr[i][j-1]=='#':
                    dp[i][j] = dp[i][j-1]
                else:
                    dp[i][j] = dp[i][j-1]+1
            elif j==0:
                if arr[i-1][j]=='#':
                    dp[i][j] = dp[i-1][j]
                else:
                    dp[i][j] = dp[i-1][j]+1
            else:
                if arr[i][j-1]=='#':
                    ans1 = dp[i][j-1]
                else:
                    ans1 = dp[i][j-1]+1
                if arr[i-1][j]=='#':
                    ans2 = dp[i-1][j]
                else:
                    ans2 = dp[i-1][j]+1
                dp[i][j] = min(ans1,ans2)
        else:
            if i==0:
                dp[i][j] = dp[i][j-1]
            elif j==0:
                dp[i][j] = dp[i-1][j]
            else:
                dp[i][j] = min(dp[i][j-1],dp[i-1][j])
print(dp[-1][-1])

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

public class Solution
{
    public static void Main()
    {
        var s = Console.ReadLine();
        var c = s[0];
        if ('a' <= c && c <= 'z')
        {
            Console.WriteLine('a');
        }
        else
        {
            Console.WriteLine('A');
        }
    }
}

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

int strength[14] = {
    0, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
};

int main(){
    ios_base::sync_with_stdio(false);
    int A, B; cin >> A >> B;
    if (strength[A] > strength[B]){
        cout << "Alice";
    }
    else if (strength[B] > strength[A]){
        cout << "Bob";
    }
    else{
        cout << "Draw";
    }
    return 0;
}

Measured memory_bytes: 256
/* Coached by rainboy */
#include <stdio.h>
#include <string.h>

#define N 100000

int main() {
	static char s[N + 1];
	int n, i;

	scanf("%s", s);
	n = strlen(s);
	for (i = 0; i < n; )
		if (s[i] == 'd') {
			if (i + 5 > n || strncmp(s + i, "dream", 5) != 0) {
				printf("NO\n");
				return 0;
			}
			if (i + 7 <= n && strncmp(s + i, "dreamer", 7) == 0 && (i + 7 == n || s[i + 7] != 'a'))
				i += 7;
			else
				i += 5;
		} else if (s[i] == 'e') {
			if (i + 5 > n || strncmp(s + i, "erase", 5) != 0) {
				printf("NO\n");
				return 0;
			}
			if (i + 6 <= n && strncmp(s + i, "eraser", 6) == 0)
				i += 6;
			else
				i += 5;
		} else {
			printf("NO\n");
			return 0;
		}
	printf("YES\n");
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Collections;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var ir = new Resolver(new ConsoleReader());
            Console.WriteLine(ir.Resolve());
        }
    }

    public class Resolver
    {
        IInputReader InputReader { get; }
        public List<string> Messages { get; set; } = new List<string>();

        int n;
        List<long[]> ls = new List<long[]>();

        public void ParseLines() {
            n = int.Parse(InputReader.ReadLine());
            foreach (var i in Enumerable.Range(0, n))
            {
                ls.Add(InputReader.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray());
            }

        }

        public class Table
        {
            public long PointA { get; set; } = 0;
            Person A { get; }
            Person B { get; }
            int[] _dishes;

            public Table(Person a, Person b, int ndish)
            {
                this.A = a;
                this.B = b;
                this._dishes = Enumerable.Range(0, ndish).ToArray();
            }

            public long CalculatePoint()
            {
                _dishes
                .Select(x => A.Taste[x] + B.Taste[x])
                .OrderBy(x => -x)
                .Where((x, i)=> i % 2 == 0 ).ToList().ForEach(x => {
                    PointA += x;
                });

                PointA -= B.Taste.Values.Sum(x => x);
                return PointA;
            }


        }


    public class Person{
            public Dictionary<int, long> Taste { get; }
            public long HappyScore { get; set; } = 0;

            public Person(Dictionary<int, long> taste)
            {
                Taste = taste;
            }

        }


        public string Resolve()
        {
            var range = Enumerable.Range(0, n);

            var a = new Person(range.ToDictionary(i => i, i => ls[i][0]));
            var b = new Person(range.ToDictionary(i => i, i => ls[i][1]));

            var table = new Table(a, b, n);

            return table.CalculatePoint().ToString();
        }


        public Resolver(IInputReader inputReader)
        {
            InputReader = inputReader;
            ParseLines();
        }

    }

    public interface IInputReader
    {
        string ReadLine();
    }

    class ConsoleReader : IInputReader
    {
        string IInputReader.ReadLine()
        {
            return Console.ReadLine();
        }
    }
}


Measured memory_bytes: 40012
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;

int main(){
  int N, M;
  cin >> N >>M;
  vector<pair<long long, long long>> AB(N);
  for(int i = 0; i < N; i++){
    cin >> AB[i].first >> AB[i].second;
  }
  sort(AB.begin(), AB.end());
  
  long long ans = 0LL;
  long long now = 0LL;
  for(int i = 0; i < N; i++){
    if(now + AB[i].second < M){
      ans += AB[i].first * AB[i].second;
      now += AB[i].second;
    }else{
      ans += (M - now) * AB[i].first;
      break;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1792
import itertools

N = int(input())
l = sorted(list(map(int, input().split())))

cnt = 0
for v in itertools.combinations(l, 3):
  if int(v[0]) != int(v[1]) and int(v[1]) != int(v[2]) and int(v[2]) != int(v[0]):
    if int(v[1]) - int(v[0]) < int(v[2]) < int(v[0]) + int(v[1]):
      cnt += 1
    
print(cnt)   
  

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

using namespace std;

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

string s;

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

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N;
  cin>>N;
  vector<ll> P(N);
  ll point[N+1];
  for(ll i=0;i<N;++i) {
    cin>>P[i];
    point[P[i]] = i;
  }
  set<ll> st;
  st.insert(-1);
  st.insert(N);
  ll ans = 0;
  auto l1=st.begin(), l2=st.begin(), r1=st.end(), r2=st.end(), index=st.end();
  for(ll i=N;i>=1;--i) {
    st.insert(point[i]);
    index = st.find(point[i]);
    r1 = next(index);
    l1 = prev(index);
    if(*r1==N) {
      if(*l1==-1) {
        continue;
      }
      else {
        l2 = prev(l1);
        ans += i*(*r1-*index)*(*l1-*l2);
      }
    }
    else {
      r2 = next(r1);
      if(*l1==-1) {
        ans += i*(*index-*l1)*(*r2-*r1);
      }
      else {
        l2 = prev(l1);
        ans += i*(*index-*l1)*(*r2-*r1)+i*(*l1-*l2)*(*r1-*index);
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 9444
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;


void solve(){
    int n, m;
    cin >> n >> m;
    char a[55][55];
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++) {
            cin >> a[i][j];
        }
    }
    
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++) {
            if(a[i][j] == '#'){
                if(a[i + 1][j] != '#')a[i + 1][j]++;
                if(a[i - 1][j] != '#')a[i - 1][j]++;
                if(a[i + 1][j + 1] != '#')a[i + 1][j + 1]++;
                if(a[i + 1][j - 1] != '#')a[i + 1][j - 1]++;
                if(a[i][j + 1] != '#')a[i][j + 1]++;
                if(a[i][j - 1] != '#')a[i][j - 1]++;
                if(a[i - 1][j + 1] != '#')a[i - 1][j + 1]++;
                if(a[i - 1][j - 1] != '#')a[i - 1][j - 1]++;
            }
        }
    }
    
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++) {
            if(a[i][j] == '#') cout << a[i][j];
            else cout << a[i][j] - '.';
        }
        cout << endl;
    }
    
}
int main(){
    int q = 1;
    //cin >> q;}
    while(q--) solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#define INF 1000000
#define MAX_V 2010
using namespace std;

struct edge{int to,cost; };
vector<edge> G[MAX_V];

bool used[MAX_V];
bool c[MAX_V][MAX_V];
int d[MAX_V],h[MAX_V],f[MAX_V][MAX_V];
int V;

void dfs(int s){
	used[s] = true;
	int i = 0;
	while(true){
		edge e = G[s][i];
		if(e.to==-1){
			break;
		}
		if(!used[e.to]){
			i++;
			used[e.to] = true;
			d[e.to] = d[s] + e.cost;
			dfs(e.to);
		}else{
			i++;
		}
	}
}

int main(){
	int i,j,k,mx,l,ans=0;
	cin >> V >> k;
	for(i=0;i<V-1;i++){
		int s,t;
		cin >> s >> t;
		s--; t--;
		edge e;
		e.to = t;
		e.cost = 1;
		G[s].push_back(e);
		e.to = s;
		e.cost = 1;
		G[t].push_back(e);
	}
	for(i=0;i<V;i++){
		edge e;
		e.to = -1; e.cost = 0;
		G[i].push_back(e);
	}
	for(i=0;i<V;i++){
		h[i] = 0;
		for(j=0;j<V;j++){
			c[i][j] = true;
			used[j] = false;
		}
		d[i] = 0;
		dfs(i);
		for(j=0;j<V;j++){
			f[i][j] = d[j];
		}
	}
	
	for(i=0;i<V;i++){
		for(j=0;j<V;j++){
			if(f[i][j]>k){
				c[i][j] = false;
				h[i]++;
				h[j]++;
			}
		}
	}
	
	for(i=0;i<V;i++){
		mx = 0;
		for(j=0;j<V;j++){
			if(h[j]>mx){
				mx = h[j];
				l = j;
			}
		}
		if(mx==0){
			break;
		}
		for(j=0;j<V;j++){
			if(!c[j][l]){
				c[j][l] = true;
				h[l]--;
				h[j]--;
			}
			if(!c[l][j]){
				c[l][j] = true;
				h[l]--;
				h[j]--;
			}
		}
		ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 20224
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, m;
  
  cin >> n >> m;
  
  double answer = (n + m) / 2.0;
  
  if ((answer - (int)answer) != 0) {
    answer += 1;
  }
  
  cout << (int)answer << endl;
  
  return 0;
}

Measured memory_bytes: 256
/******************************************************************************

                            Online C Compiler.
                Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

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

int top,S[1000];

void push(int x){
    S[++top] = x;
}

int pop(){
    top--;
    return S[top+1];
}

int main(){
    int a,b;
    top = 0;
    char s[100];
    
    while(scanf("%s",s) != EOF){
       if (s[0] == '+'){
           a = pop();
           b = pop();
           push(a+b);
        }else if (s[0] == '-'){
        b = pop();
        a = pop();
        push (a-b);
        }else if (s[0] == '*' ){
        b = pop();
        a = pop();
        push (a*b);
        } else {
            push(atoi(s));
        }    
    }
    
    printf("%d\n",pop());
    return 0;
}


Measured memory_bytes: 2140