akhauriyash/Code-Regression huggingface dataset:
s = input()
w = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" ]

ans = 0
if s == w[0]:
    ans += 7
if s == w[1]:
    ans += 6
if s == w[2]:
    ans += 5
if s == w[3]:
    ans += 4
if s == w[4]:
    ans += 3
if s == w[5]:
    ans += 2
if s == w[6]:
    ans += 1


print(ans)

Measured memory_bytes: 38512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author amotoma3
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.nextString();
            int n = s.length();
            int ans = n;
            for (int i = 0; i < n - 1; i++) {
                if (s.charAt(i) != s.charAt(i + 1)) {
                    ans = Math.min(ans, Math.max(i + 1, n - 1 - i));
                }
            }

            out.println(ans);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 25044
import sys
S = input().rstrip()
S = S[::-1]
S1 = "dream"
S2 = "dreamer"
S3 = "erase"
S4 = "eraser"
S1 = S1[::-1]
S2 = S2[::-1]
S3 = S3[::-1]
S4 = S4[::-1]
while len(S) > 0:
  if S[0:len(S1)] == S1:
    S = S[len(S1):]
  elif S[0:len(S2)] == S2:
    S = S[len(S2):]
  elif S[0:len(S3)] == S3:
    S = S[len(S3):]
  elif S[0:len(S4)] == S4:
    S = S[len(S4):]
  else:
    print("NO")
    sys.exit()
print("YES")
 

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();
		String s = sc.next();
		char[] sArray = s.toCharArray();
		int[] numOfW = new int[n];
		int[] numOfE = new int[n];
		//wの数配列作る
		numOfW[0] = 0;
		for(int i=1;i<n;i++) {
			if(sArray[i-1] == 'W') {
				numOfW[i] = numOfW[i-1]+1;
			} else {
				numOfW[i] = numOfW[i-1];
			}
		}

		//Eの数配列作る
		numOfE[n-1] = 0;
		for(int i= n-2;i>=0;i--) {
			if(sArray[i+1]=='E') {
				numOfE[i] = numOfE[i+1]+1;
			} else {
				numOfE[i] = numOfE[i+1];
			}
		}
		int min = n;
		for(int i=0;i<sArray.length;i++) {
			if(min > numOfW[i]+numOfE[i]) {
				min = numOfW[i]+numOfE[i];
			}
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 33024
#include <iostream>
using namespace std;
int main(void){
    int R,G,B,N;
    cin >> R >> G >> B >> N;
    
    int res=0,b;
    for(int r=0;r<=N/R;r++){
        for(int g=0;g<=N/G;g++){
            b = N - r*R - g*G;
            if(b>=0 && b%B==0){
                res++;
            }
        }
    }
    
    cout << res << endl;
    
}


Measured memory_bytes: 256
#if __cplusplus >= 201103L
#pragma comment(linker, "/STACK:64000000")
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <valarray>
#include <utility>
#include <cctype>
#include <numeric>
#include <memory>
#if __cplusplus >= 201103L
#include <cwchar>
#include <cwctype>
#include <array>
#include <forward_list>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<min(min(a+b,a+c),b+c)<<endl;
	#ifdef home
	eprintf("time = %d ms\n", (int)(clock() * 1000. / CLOCKS_PER_SEC));
	#endif
	return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

// あるノードを選び、根として、葉を全て削除する
// 最後の1つを選んだ人の勝ちt

int N;
vector<int>path[202020];
int flg[202020];
int mxx = 0;
void dfs(int x, int val){
    flg[x] = val;
    if(flg[mxx] < flg[x])mxx = x;
    for(int i = 0; i < path[x].size(); i++){
        int nxt = path[x][i];
        if(flg[nxt])continue;
        dfs(nxt, val + 1);
    }
}

int dp[202020];

int main(){

    cin >> N;
    for(int i = 1; i < N; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        path[a].push_back(b);
        path[b].push_back(a);
    }
    for(int i = 0; i < N; i++)flg[i] = 0;
    dfs(0, 1);
    for(int i = 0; i < N; i++)flg[i] = 0;
    dfs(mxx, 1);
    int depth = flg[mxx];
    dp[0] = 1;
    dp[1] = 1;
    dp[2] = 2;
    for(int i = 1; i <= depth; i++){
        if(dp[i] == 0){
            if(dp[i - 1] == 1 && dp[i - 2] == 1){
                dp[i] = 2;
            }
            else{
                dp[i] = 1;
            }
        }
    }    
    if(dp[depth] == 1)cout << "First" << endl;
    else cout << "Second" << endl;

    return 0;
}

Measured memory_bytes: 22144
#include <bits/stdc++.h>
#define int long long
using namespace std;

string a,b;
int ans;
signed main() {
	cin>>a;
	cin>>b;
	for(int i=0; i<a.length(); i++) {
		if(a[i]==b[i]) {
			ans++;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    set<string>answer;
    int index;
    int ans=0;
    REP(i,10){
        REP(j,10){
            REP(k,10){
                index=0;
                bool iok=false,jok=false,kok=false;
                while(index<n){
                    if(s[index] == (char)('0'+i)){
                        iok=true;
                        break;
                    }
                    index++;
                }
                index++;
                while(index<n){
                    if(s[index] == (char)('0'+j)){
                        jok=true;
                        break;
                    }
                    index++;
                }
                index++;
                while(index<n){
                    if(s[index] == (char)('0'+k)){
                        kok=true;
                        break;
                    }
                    index++;
                }
                index++;
                if(iok and jok and kok)ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
	array<int, 10> x;
	x.fill(0);
	for (int i = 0; i < 3; ++i) {
		int a;
		cin >> a;
		++x[a - 1];
	}

	if (x[4] == 2 && x[6] == 1) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


N = int(input())
A = int(input())

print("%d"%(N*N-A))


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,e,k,m,n,o,p,q,r,s,t,u,v;

    cin>>a>>b>>c>>d>>e>>k;
    m=b-a;
    n=c-a;
    o=d-a;
    p=e-a;

    q=c-b;
    r=d-b;
    s=e-b;

    t=d-c;
    u=e-c;

    v=e-d;

    if(k>=m && k>=n && k>=o && k>=p && k>=q  && k>=r && k>=s && k>=t && k>=u && k>=v){
        cout<<"Yay!"<<endl;
    }
    else{
        cout<<":("<<endl;
    }
    return 0;

}


Measured memory_bytes: 384
N = int(input())
ans = 0
_A = 0
B_ = 0
B_A = 0

for _ in range(N):
    s = input()
    ans += s.count('AB')

    if s[-1] == 'A':
        _A += 1

    if s[0] == 'B':
        B_ += 1

    if s[0] == 'B' and s[-1] == 'A':
        B_A += 1

ans += min(_A, B_)
if _A == B_ == B_A != 0:
    ans -= 1
print(ans)


Measured memory_bytes: 3064
from collections import defaultdict

class LCM_mod:
    """
    最小公倍数の計算を行う
    オーバーフローが発生しないように素因数分解し,
    因数の積を逐次余りに置き換えて最小公倍数を導出する.
    """
    def __init__(self, max_num, p=10**9+7):
        self.max_num = max_num + 1
        self.p = p
        self.prime = [0 for _ in range(self.max_num)]
        self.max_map = defaultdict(int)
        self.sieve()

    def rep_sqr(self, base, k):
        # 繰り返し二乗法
        if k == 0:
            return 1
        elif k % 2 == 0:
            return (self.rep_sqr(base, k / 2) ** 2) % self.p
        else:
            return (self.rep_sqr(base, k - 1) * base) % self.p

    def sieve(self):
        """
        エラトステネスの篩　O(n)
        nまでに含まれる素数を導出
        """
        self.prime[0], self.prime[1] = 1, 1
        for i in range(2, self.max_num):
            if self.prime[i] == 0:
                for j in range(i * 2, self.max_num, i):
                    if self.prime[j] == 0:
                        self.prime[j] = i
                self.prime[i] = i

    def lcm_list_mod(self, arr):
        """
        listのそれぞれの要素について、素因数分解する
        それぞれの因数について最大であれば更新する
        """
        for i in range(len(arr)):
            num = arr[i]
            d = defaultdict(int)

            while num > 1:
                fact = self.prime[num]
                d[fact] += 1
                num //= fact

            for i in d.keys():
                self.max_map[i] = max(self.max_map[i], d[i])

        ans = 1
        for i in self.max_map.keys():
            ans = (ans * self.rep_sqr(i, self.max_map[i])) % self.p
        return ans


class FLT:
    def __init__(self, mod=10**9+7):
        self.mod = mod

    def rep_sqr(self, base, k):
        if k == 0:
            return 1
        elif k % 2 == 0:
            return (self.rep_sqr(base, k // 2) ** 2) % self.mod
        else:
            return (self.rep_sqr(base, k - 1) * base) % self.mod

    def inv(self, a):
        """ 逆元を取る """
        return self.rep_sqr(a, self.mod-2)

n = int(input())
a = list(map(int, input().split()))
MOD = 10**9+7

lcm_mod = LCM_mod(max(a), MOD)
lcm_all = lcm_mod.lcm_list_mod(a)
flt = FLT(MOD)

b = list(map(lambda x: lcm_all * flt.inv(x), a))
ans = 0
for i in range(len(b)):
    ans += b[i]
    ans %= MOD
print(ans)


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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i=0; i<n; ++i) cin >> a[i];
	vector<int> dp(n,INT_MAX);
	dp[0] = 0;
	for (int i=0; i<n; ++i){
		for (int j=i+1; j<min(n,i+k+1); ++j){
			dp[j] = min(dp[j],dp[i]+abs(a[i]-a[j]));
		}
	}
	cout << dp[n-1];
	return 0;
}

Measured memory_bytes: 3836
import math
import itertools
def length(X,Y,c):
    sum_=0
    for i in range(len(c)-1):
        sum_+=math.sqrt((X[c[i]]-X[c[i+1]])**2 + (Y[c[i]]-Y[c[i+1]])**2)
    #print(sum_)
    return sum_
N=int(input())
X=[0]*N
Y=[0]*N
for i in range(N):
    X[i], Y[i] = map(int,input().split())
C = list(itertools.permutations(range(0,N)))
sum_=0
for c in C:
    sum_+=length(X,Y,c)
print(sum_/len(C))

Measured memory_bytes: 8052
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)


int main() {
  int n;
  cin >> n;
  string s=to_string(n);
  int co=0;
  rep(i,s.size()){
    co+=s.at(i)-'0';
  }
  if(n%co==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int c[]={0,2,5,5,4,5,6,3,7,6};
string stmax(string a, string b)
{
  if(a.size() > b.size())
  {
    return a;
  }
  else if(a.size() < b.size())
  {
      return b;
  }
  else{
  	if(a>=b)return a;
    else return b;
  }
}
    
int main(){
  int n,m;
  cin>>n>>m;
  vector<int>a(m);
  for(int i=0; i<m; i++){
    cin>>a[i];
  }
  vector<string>dp(10101,"");
  for(int i=0; i<=n; i++){
    for(int j=0; j<a.size(); j++){
      if(i==0||dp[i]!=""){
      	if(i+c[a[j]]>n)continue;
        dp[i+c[a[j]]]=stmax(dp[i]+to_string(a[j]),dp[i+c[a[j]]]);
      }
    }
  }
  cout<<dp[n]<<endl;
}
    
  
   

Measured memory_bytes: 33024
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>
#include <set>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x)
#define PUT(x) printf("%d\n",x)
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = { 0,1,0 };

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };


int main(void)
{
	int N, M, X,left = 0,right = 0;
	cin >> N >> M >> X;
	
	for(int i = 0; i < M; i++){
		int a;
		cin >> a;
		if (a < X)
			left++;
		if (a > X)
			right++;
	}


	cout << min(left, right) << endl;

	return 0;
}


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

int idx, ans, len;
string s;

int level(){
  int cntJ = 0;
  while(idx < len && s[idx] == 'J'){
    idx++;
    cntJ++;
  }

  int cntO = 0;
  while(idx < len && s[idx] == 'O'){
    idx++;
    cntO++;
  }

  int cntI = 0;
  while(idx < len && s[idx] == 'I'){
    idx++;
    cntI++;
  }

  if(cntJ >= cntO && cntO <= cntI) return cntO;
  return 0;
}

int main(){
  while(cin >> s){
    ans = idx = 0;
    len = s.length();

    while(idx < len){
      if(s[idx] == 'J'){
        int tmp = level();
        ans = max(ans, tmp);
      }
      else{
        idx++;
      }
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 1984
cards = [
'S 1', 'S 2', 'S 3', 'S 4', 'S 5', 'S 6', 'S 7', 'S 8', 'S 9', 'S 10', 'S 11', 'S 12', 'S 13',
'H 1', 'H 2', 'H 3', 'H 4', 'H 5', 'H 6', 'H 7', 'H 8', 'H 9', 'H 10', 'H 11', 'H 12', 'H 13',
'C 1', 'C 2', 'C 3', 'C 4', 'C 5', 'C 6', 'C 7', 'C 8', 'C 9', 'C 10', 'C 11', 'C 12', 'C 13',
'D 1', 'D 2', 'D 3', 'D 4', 'D 5', 'D 6', 'D 7', 'D 8', 'D 9', 'D 10', 'D 11', 'D 12', 'D 13'
]

n = int(input())
for i in range(n):
    card = input()
    cards.remove(card)

for i in cards:
    print(i)

Measured memory_bytes: 7740
#include <bits/stdc++.h>
#define int long long
#define m_k make_pair
using namespace std;
const int N=2*1e5+100;
int n,a[N],b[N],vi[N],ans;
queue <pair<int,int> > q;
inline int pre(int x){return((x==1)?n:x-1);}
inline int suc(int x){return((x==n)?1:x+1);}
inline bool check(int x){return(b[x]>=b[pre(x)]+b[suc(x)]&&b[x]>a[x]);}
signed main()
{
	scanf("%lld",&n);
	for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for (int i=1;i<=n;i++) scanf("%lld",&b[i]);
	bool bl=1;
	for (int i=1;i<=n;i++) if (b[i]<a[i]) bl=0;
	if (!bl)
	{
		printf("-1\n");
		return 0;
	}
	for (int i=1;i<=n;i++)
	{
		if (check(i))
		{
			vi[i]=1;
			q.push(m_k(b[i],i));
		}
	}
	bl=1;
	while (!q.empty())
	{
		int x=q.front().second;
		q.pop();
		vi[x]=0;
		int delta=b[x]-a[x];
		delta/=b[pre(x)]+b[suc(x)];
		ans+=delta;
		b[x]-=(b[pre(x)]+b[suc(x)])*delta;
		if (delta==0)
		{
			bl=0;
			break;
		}
		if (check(pre(x)) && !vi[pre(x)]) vi[pre(x)]=1,q.push(m_k(b[pre(x)],pre(x)));
		if (check(suc(x)) && !vi[suc(x)]) vi[suc(x)]=1,q.push(m_k(b[suc(x)],suc(x)));
	}
	if (!bl)
	{
		printf("-1\n");
		return 0;
	}
	for (int i=1;i<=n;i++) if (a[i]!=b[i]) bl=0;
	if (!bl)
	{
		printf("-1\n");
		return 0;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 9636
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define bit(i,k)(((i)>>(k))&1)

typedef struct tnode{
	struct tnode*oya;
	struct tnode*ko[26];
	int a[26];
} trienode;

trienode*maketrienode(trienode*vv){
	trienode*v=malloc(sizeof(trienode));
	v->oya=vv;
	rep(i,0,26)v->ko[i]=0;
	rep(i,0,26)v->a[i]=0;
	return v;
}

int trieins(trienode*v,char*s){
	if(s[0]==0)return 0;
	if(! v->ko[s[0]-'a'])v->ko[s[0]-'a']=maketrienode(v);
	int ret=trieins(v->ko[s[0]-'a'],s+1);
	ret|=1<<(s[0]-'a');
	rep(i,0,26)if(bit(ret,i))v->a[i]++;
	return ret;
}

trienode*triesearch(trienode*v,char*s){
	if(s[0]==0)return v;
	if(! v->ko[s[0]-'a'])return 0;
	return triesearch(v->ko[s[0]-'a'],s+1);
}

trienode*root;
char s[2000010];
int idx[200010];
int main(){
	root=maketrienode(0);
	int n;
	scanf("%d",&n);
	rep(i,0,n){
		scanf("%s",s+idx[i]);
		int len=strlen(s+idx[i]);
		rep(j,0,len/2){char t=s[idx[i]+j];s[idx[i]+j]=s[idx[i]+len-1-j];s[idx[i]+len-1-j]=t;}
		trieins(root,s+idx[i]);
		idx[i+1]=idx[i]+strlen(s+idx[i])+1;
	}
	
	ll ans=0;
	rep(i,0,n){
		trienode*v=triesearch(root,s+idx[i]);
		ans+=v->oya->a[s[idx[i+1]-2]-'a'];
	}
	printf("%lld\n",ans-n);
}

Measured memory_bytes: 357112
# E
X, Y, NA, NB, NC = map(int, input().split())
*A, = map(int, input().split())
*B, = map(int, input().split())
*C, = map(int, input().split())

A = sorted(A)[-X:]
B = sorted(B)[-Y:]
C = sorted(C)[::-1]

ans = sum(A) + sum(B)


i = 0
j = 0
num_A = len(A)
num_B = len(B)
for c in C:
    if i < num_A and j < num_B:
        if A[i] < B[j] and A[i] < c:

            ans += c - A[i]
            i += 1
        elif A[i] >= B[j] and B[j] < c:

            ans += c - B[j]
            j += 1

    elif i < num_A:
        if A[i] < c:
            ans += c - A[i]
            i += 1

    elif j < num_B:
        if B[j] < c:
            ans += c - B[j]
            j += 1

    else:
        break

print(ans)


Measured memory_bytes: 112884
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
#ifdef zerol
#define dbg(x...) do { cout << "\033[32;1m" << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

int n;

int main() {
    // int t;

    string s;
    cin >> s;
    auto it = find(s.begin(), s.end(), '7');

    if (it != s.end()) {
        puts("Yes");
    } else {
        puts("No");
    }

    return 0;
}

Measured memory_bytes: 3624
import sys
from bisect import bisect_left as bl
from bisect import bisect_right as br
input = sys.stdin.readline
N = int(input())
table = [[] for _ in range(2 * pow(10, 5) + 1)]
a = []
t = 0
mod = 10 ** 9 + 7
for i in range(N):
  x = int(input())
  if t != x:
    table[x].append(i)
    t = x
  a.append(x)
#print(table[4], table[3])
dp = [0] * N
dp[0] = 1
for i in range(N):
  j = br(table[a[i]], i)
  k = bl(table[a[i]], i)
  if j < len(table[a[i]]) and (table[a[i]][k] == i):
    dp[table[a[i]][j]] += dp[i]
    dp[table[a[i]][j]] %= mod
  if i + 1 < N: 
    dp[i + 1] += dp[i]
    dp[i + 1] %= mod
  #print(dp)
print(dp[-1])

Measured memory_bytes: 74700
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
//#include<cstdio>
//#include<algorithm>
//#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int N, M;
int K[100001];
int to[200001], ne[200001], he[100001], num[200001];
vector<int> S1[100001], S2[100001];
int dame[100001];

int dfs(int v, int prev) {
	if (dame[v]) {
		ll ret = 1;
		if (prev >= 2) {
			int k = K[v] - num[prev];
			if (k >= 2) ret *= S1[v][k - 2];
			if (k < K[v]) ret *= S2[v][k];
			ret %= M;
		}
		else ret = S1[v][K[v] - 1];
		if (dame[v] >= 2 && dame[v] != prev) {
			ll tmp = dfs(to[dame[v]], dame[v] ^ 1);
			int k = K[v] - num[dame[v]];
			for (int i = k - 1; i < K[v]; i++) {
				S1[v][i] = S1[v][i] * tmp % M;
			}
			for (int i = k - 1; i >= 0; i--) {
				S2[v][i] = S2[v][i] * tmp % M;
			}
			ret *= tmp;
			dame[v] = -1;
		}
		return (ret + 1) % M;
	}
	dame[v] = prev;
	ll ret = 1;
	int k = 0;
	for (int i = he[v]; i; i = ne[i]) {
		int tmp = 1;
		if (i != prev) {
			tmp = dfs(to[i], i ^ 1);
			ret = ret * tmp % M;
		}
		S1[v][k] = ret;
		S2[v][k++] = tmp;
	}
	for (int i = k - 2; i >= 0; i--) {
		S2[v][i] = ((ll)S2[v][i] * S2[v][i + 1]) % M;
	}
	return ret + 1;
}

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


	cin >> N >> M;

	int k = 2;
	rep1(i, N - 1) {
		int x, y;
		cin >> x >> y;

		num[k] = K[x]++;
		to[k] = y;
		ne[k] = he[x];
		he[x] = k++;
		num[k] = K[y]++;
		to[k] = x;
		ne[k] = he[y];
		he[y] = k++;
	}
	rep1(i, N) {
		S1[i].resize(K[i]);
		S2[i].resize(K[i]);
	}

	rep1(j, N) {
		ll kotae = (dfs(j, -1) - 1 + M) % M;
		co(kotae);
	}


	Would you please return 0;
}

Measured memory_bytes: 21248
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
  int X, Y, Z, K;
  std::cin >> X >> Y >> Z >> K;

  std::vector<long long> A(X);
  std::vector<long long> B(Y);
  std::vector<long long> C(Z);

  for (int i=0; i<X; i++) std::cin >> A[i];
  for (int i=0; i<Y; i++) std::cin >> B[i];
  for (int i=0; i<Z; i++) std::cin >> C[i];

  std::sort(A.begin(), A.end(), std::greater<long long>());
  std::sort(B.begin(), B.end(), std::greater<long long>());
  std::sort(C.begin(), C.end(), std::greater<long long>());

  std::vector<long long> vec;

  for (int i=0; i<X; i++)
    for (int j=0; j<Y; j++)
      for (int k=0; k<Z; k++)
        if ((i+1)*(j+1)*(k+1) <= K)
          vec.push_back(A[i]+B[j]+C[k]);
        else
          break;

  std::sort(vec.begin(), vec.end(), std::greater<long long>());

  for (int i=0; i<K; i++)
    std::cout << vec[i] << '\n';

  return 0;
}


Measured memory_bytes: 1404
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(p,a,b)    for(int p=a;i<b;i++)
#define INF 0x3f3f3f3f


int main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("o2.txt", "w", stdout);
    #endif

    int n,i;
    string s;
    set<string> se;
    cin>>n;
    while(n--)
    {
        cin>>s;
        se.insert(s);
    }
    cout<<se.size();
    return 0;
}

Measured memory_bytes: 19164
#include<bits/stdc++.h>
#define int long long

using namespace std;

int n;
int dp[100001];
bool v[100001];
vector<int> h;

int s1(int i)
{
    if(i==n)
        return 0;
    if(i==n-1)
        return abs(h[i]-h[i+1]);
    if(v[i])
        return dp[i];
    v[i] = 1;
    return dp[i] = min(abs(h[i]-h[i+1])+s1(i+1),abs(h[i]-h[i+2])+s1(i+2));
}

void solve()
{
    cin >> n;
    h.resize(n+1);
    for(int i=1; i<n+1; i++){
    	cin>>h[i];
    }

    cout << s1(1) << endl;
}
 
signed main()
{
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	string n;
	cin>>n;
	cout<<(n.at(0)==n.at(2)?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


int main() {
    int n,m;
 
   cin >> n >> m;
  
   int a[n];
  
   for(int i = 0;i<n;i++){
     cin >> a[i];
   }
  
   int ans = 0;
  
   int sum = 1;
  
   for(int i = 0;i<n;i++){
     
      
      ans = ans+a[i];
      
     
      if(ans<=m){
        sum++;
      }
      
   }
  
   cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	long long h;
	cin >> h;

	long long attacks = 0;
	long long monsters = 1;
	while (h > 1) {
		h >>= 1;
		attacks += monsters;
		monsters <<= 1;
	}

	cout << attacks + monsters << "\n";

	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

template<typename T> bool InRange(T t, T l, T r){ return l <= t && t < r; }

int main(){
	
	int N, M;
	cin >> N >> M;
	vector<ll> A(N);
	for(int i=0;i<N;i++) cin >> A[i];
	
	unordered_map<ll, ll> d;
	ll tot = 0;
	for(int i=0;i<N;i++){
		tot += A[i]; tot %= M;
		d[tot]++;
	}
	
	ll ans = 0;
	tot = 0;
	for(int i=0;i<N;i++){
		ans += d[tot];
		tot += A[i]; tot %= M;
		d[tot]--;
	}
	
	cout << ans << endl;
	
	
	
	
	
    return 0;
}

Measured memory_bytes: 4492
loop do
  n,k = gets.chomp.split(' ').map(&:to_i)
  break if (n|k) == 0
  stocks = gets.chomp.split(' ').map(&:to_i)
  family_total = Array.new(k, 0)
  n.times do
    member = gets.chomp.split(' ').map(&:to_i)
    family_total = member.zip(family_total).map{|x, y|x + y}
  end

  result = true
  stocks.zip(family_total).each do |stock, total|
    if stock < total
      result = false
      break
    end
  end
  puts result ? 'Yes' : 'No'
end

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

using namespace std;

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

#define INF (1<<(4*4-1))
#define MOD 1000000007

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

   int s;
   cin>>s;

   vector<bool>used(10000001,false);
   vector<int>dp(10000001);
   dp[0] = s;
   used[s]=true;
   for(int i=1;i<=10000000;i++){
      if(dp[i-1]%2)dp[i]=3*dp[i-1]+1;
      else dp[i]=dp[i-1]/2;
      if(used[dp[i]]){
         cout<<i+1<<endl;
         return 0;
      }
      used[dp[i]]=true;
   }

   return 0;
}


Measured memory_bytes: 40576
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    Set<Integer> set = new HashSet<>();
    for (int i = 0; i < N; i++) {
      int a = scanner.nextInt();
      if (set.contains(a)) set.remove(a);
      else set.add(a);
    }
    System.out.println(set.size());
  }
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

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

    int n = S.size();
    vector<int> ans(n);

    rep(ri, 2) {
        { // solve R
            int cnt = 0;
            rep(i, n) {
                if (S[i] == 'R') cnt++;
                else {
                    ans[i] += cnt / 2; // RRRRR の偶数番目の個数がLに行く
                    ans[i - 1] += (cnt + 1) / 2; // RRRRR の奇数番目の個数がRに行く
                    cnt = 0;
                }
            }
        }

        // RとLを交換
        reverse(ans.begin(), ans.end());
        reverse(S.begin(), S.end());
        rep(i,n) {
            if (S[i] == 'L') S[i] = 'R';
            else S[i] = 'L';
        }
    }

    rep(i, n) {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 1024
import sys
import itertools
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    N = in_n()
    ans = []

    def dfs(s):

        if len(s) == N:
            ans.append(s)
            return

        maxs = max(map(ord, s))
        for i in range(ord('a'), maxs + 2):
            dfs(s + chr(i))

    dfs('a')
    print('\n'.join(sorted(ans)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 19428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1000000;
ll dp[N];
ll h[N];
const int mx=1e9+5;
int main(){
    ll n,k;cin>>n>>k;
   
     for(int i=0;i<n;i++){
        cin>>h[i];dp[i]=mx;
    }dp[0]=0;
     for(int i=0;i<n;i++){
     for(int j=1;j<=k&&(i+j)<n;j++){
         dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
     }
    }cout<<dp[n-1];
}

Measured memory_bytes: 5156
n,m=map(int,input().split())
h=list(map(int,input().split()))
ab=[list(map(int,input().split())) for _ in range(m)]
list=[0]*n
for a,b in ab:
  list[a-1]=max(list[a-1],h[b-1])
  list[b-1]=max(list[b-1],h[a-1])
count=0
for i in range(n):
  if list[i]<h[i]:
    count+=1
print(count)

Measured memory_bytes: 32024
q=int(input())
lr=[]
for i in range(q):
  lr.append(list(map(int,input().split())))

p=[]
for i in range(2,100001):
  f=1
  for j in p:
    if j>i**0.5:
      break
    if i%j==0:
      f=0
      break
  if f:
    p.append(i)
p.append(10000000000)
s=[0]
j=0
k=0
for i in range(1,100001,2):
  if p[j]<i:
    j+=1
  if p[k]<(i+1)//2:
    k+=1
  if (i==p[j])and((i+1)//2==p[k]):
    s.append(s[-1]+1)
  else:
    s.append(s[-1])
  s.append(s[-1])

for i in lr:
  print(s[i[1]]-s[i[0]-1])

Measured memory_bytes: 29048
#include<bits/stdc++.h>
using namespace std;
#define lop(i,n) for(ll i=0;i<n;i++)
#define lop1(i,n) for(ll i=1;i<=n;i++)
#define lopr(i,n) for(ll i=n-1;i>=0;i--)
#define ll long long int
#define pb push_back
#define all(v) v.begin(),v.end()
#define IOS  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl '\n'
#define F first
#define S second	
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define LCM(a,b) (a*b)/__gcd(a,b)
#define mii map<int,int>
#define mll map<ll,ll>
#define ub upper_bound
#define lb lower_bound
#define sz(x) (ll)x.size()
#define ld long double
#define pcnt(x) __builtin_popcountll(x)
const long long I1=1e9;
const long long I2=1e18;
const int32_t M1=1e9+7;
const int32_t M2=998244353;
template<typename T,typename T1>T maxn(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T minn(T &a,T1 b){if(b<a)a=b;return a;}
ll dp[3001][3001];
 ll n;
void solve()
{
  //code begins from here//
 cin>>n;
 ll a[n+1];
 lop1(i,n) cin>>a[i];
 lop1(j,n)
 {
     for (ll i=j;i>0;i--)
     {
         if(i==j) {if(n%2) dp[i][j]=a[i];
         else dp[i][j]=-a[i];
         continue;}
         if((j-i+1)%2==n%2)
         {
              dp[i][j]=max(dp[i+1][j]+a[i],dp[i][j-1]+a[j]);
         }
         else
         {
             dp[i][j]=min(dp[i+1][j]-a[i],dp[i][j-1]-a[j]);
         }
         
     }
 }
 cout<<dp[1][n]<<endl;
}

signed main()
{
    IOS;
    #ifdef MODULO
        initialize();
    #endif
    #ifdef SIEVE
        sieve();
    #endif
    int testcase=1;
    //cin>>testcase;
    while(testcase--) solve();
    return 0;
}

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



 class Program
{


	public static void Main()
	{
		
		int n;
		n = int.Parse(Console.ReadLine());
		int[] a = new int[n];
		//int[] tmp = new int[n];
		int[] input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
		Array.Sort(input);
		int count = 0;
		count = input.Where((item,index) => index % 2 == 0).Sum();
		Console.Write(count);
	}
}	
	
	
	

Measured memory_bytes: 2904
#include<iostream>
#include<algorithm>
#include<map>
#include<math.h>
#include<set>
#include<unordered_map>
#include<string>
#include<vector>
using namespace std;

#define int long long

void fastio()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
	fastio();
	int k, a, b;
	cin >> k;
	cin >> a >> b;
	bool ans = false;
	for (int i = a; i <= b; ++i)
	{
		if (i % k == 0)
			ans = true;

	}
	if (ans)
		cout << "OK" << endl;
	else
		cout << "NG" << endl;
	return 0;
}


Measured memory_bytes: 3036
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>

using namespace std;

const int MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;
#define rep(i, m, n) for(int i=m;i<n;i++)
#define rrep(i, n, m) for(int i=n;i>=m;i--)

int main() {
    int N;
    cin >> N;
    if (N % 2 == 0) {
        cout << N << endl;
    }else{
        cout << 2 * N << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

int main() {
  ll a,b,c,d; cin >> a >> b >> c >> d;
  ll ans = -1000000000000000000;
  chmax(ans, a*c);
  chmax(ans, a*d);
  chmax(ans, b*c);
  chmax(ans, b*d);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	VS s(8); rep(i, 8)cin >> s[i];

	puts("90");
	rep(i, 8) {
		for (int j = 7; j >= 0; j--)cout << s[j][i];
		puts("");
	}

	puts("180");
	for (int i = 7; i >= 0; i--) {
		for (int j = 7; j >= 0; j--)cout << s[i][j];
		puts("");
	}

	puts("270");
	for (int i = 7; i >= 0; i--) {
		rep(j, 8)cout << s[j][i];
		puts("");
	}
}


Measured memory_bytes: 2964
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>
using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))
#define DEBUGM(d,n,m,i,j) printf("DEBUGM :\n"); rep(i,n){ rep(j,m) if(inf==d[i][j]) printf("inf "); else printf("%d ", d[i][j]); printf("\n");} printf("DEBUGM END LINE\n")

typedef long long ll;

const ll INF =1LL << 62;
const int inf =1 << 29;

int cost[45][405][405];

int main(){
    int n,ma,mb;
    cin >> n >> ma >> mb;
    vector<tuple<int,int,int> > v(n);
    rep(i,n){
        int a,b,c;
        cin >> a >> b >> c;
        v[i] = mt(a,b,c);
    }

    rep(k,45) rep(i,405) rep(j,405) cost[k][i][j] = inf;
    cost[0][0][0] = 0;
    rep(i,n+1){
        if(i!=0){
            int a = get<0>(v[i-1]),b = get<1>(v[i-1]),c = get<2>(v[i-1]);
            rep(k,405) rep(j,405){
                if(cost[i-1][k][j]!=inf){
                    cost[i][k][j] = min(cost[i][k][j], cost[i-1][k][j]);
                    cost[i][k+a][j+b] = min(cost[i-1][k+a][j+b], cost[i-1][k][j] + c);
                }  
            }
        }
    }
    //DEBUGM(cost[n],7,7,i,j);
    int aa = ma, bb = mb, ans=inf;
    while(aa<401&& bb < 401){
        ans = cost[n][aa][bb] < ans ? cost[n][aa][bb] : ans;
        aa += ma; bb += mb; 
    }
    if(536870912==ans) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

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

int digitsum(int n){
  int s = 0;
  while (n){
    s += n % 10;
    n /= 10;
  }
  return s;
}

int main() {
  int N;
  cin >> N;
  int min_s = 1000000;
  for (int i = 1; i < N/2 + 1; i++){
    int a = digitsum(i) + digitsum(N - i);
    min_s = min(min_s, a);
  }
  cout << min_s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
int main()
{
   int N;
   cin >> N;
   vector<int> P(N);
   REP(i, N) cin >> P[i];
   vector<int> Q(N);
   REP(i, N) cin >> Q[i];
   vector<int> V(N);
   REP(i, N) {
       V[i] = i+1;
   }
   int t = 1;
   int a = -1;
   int b = -1;
   do {
       bool flg = true;
       REP(i, N) {
           if(P[i] != V[i]) {
               flg = false;
               break;
           }
       }
       if(flg) a = t;
       flg = true;
       REP(i, N) {
           if(Q[i] != V[i]) {
               flg = false;
               break;
           }
       }
       if(flg) b = t;
       t++;
   } while( next_permutation(V.begin(), V.end()) );
   cout << abs(a-b) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int ans, num[101], i;
  char roman[101];

  while(scanf("%s", roman) != EOF){

    for(i = 0;roman[i] != 0;i++){
      switch(roman[i]){
      case 'I': num[i] = 1; break;
      case 'V': num[i] = 5; break;
      case 'X': num[i] = 10; break;
      case 'L': num[i] = 50; break;
      case 'C': num[i] = 100; break;
      case 'D': num[i] = 500; break;
      case 'M': num[i] = 1000; break;
      default: num[i] = 0;
      }
    }
    ans = num[--i];
    for(--i;i >= 0;i--)
      if(num[i] >= num[i + 1]) ans += num[i]; else ans -= num[i];
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 540
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int a,b;
    string x;
    
    cin >> a >> b;
    
    if(a>=b){
  //      x = to_string(b);
        for(int i=0;i<a;i++) cout << b;
    }
    
    if(a<b){
//        x = to_string(a);
        for(int i=0;i<b;i++) cout << a;
    }
    return 0;
 
}



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

int main(){
    ll D;
    cin >> D;
    vector<ll> vec(26);
    rep(i,26){
        cin >> vec[i];
    }
    vector<vector<ll> > happiness(D, vector<ll>(26));
    rep(i,D){
        rep(j,26){
            cin >> happiness[i][j];
        }
    }
    rep(i,D){
        ll intmax = happiness[i][0];
        ll t = 0;
        rep(j,26){
            if (intmax <= happiness[i][j]){
                t = j + 1;
            }
        }
        cout << t << endl;
    }
}



Measured memory_bytes: 3716
mod = 10 ** 9 + 7

N = int(input())
C = list(map(int, input().split()))
C.sort(reverse=True)

if N == 1:
    print(2 * C[0] % mod)
    exit()

ans = 0
coef = pow(2, N-1, mod)
for c in C:
    ans += c * coef
    ans %= mod
    coef = (coef + pow(2, N - 2, mod)) % mod

ans *= pow(2, N, mod)
ans %= mod
print(ans)

Measured memory_bytes: 26016
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  int n, cnt0 = 0, cnt2 = 0, cnt4 = 0;
  cin >> n;
  ll a;
  string ans = "No";
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a % 4 == 0) cnt4++;
    else if (a % 2 == 0) cnt2++;
    else cnt0++;
  }
  if (cnt0 == 0) {
    if (cnt2 > 1 || cnt4 > 0) ans = "Yes";
  } else {
    if (cnt2 % 2 == 0 && (cnt4 >= cnt0 - 1)) ans = "Yes";
    else if (cnt2 % 2 == 1 && (cnt4 >= cnt0)) ans = "Yes";
  }
  cout << ans << endl;
}


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

#define INF INT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef std::pair<int,int> pii;

using namespace std;

int main() {
    int n;
    cin >> n;
    vector< deque<int> > a(n);
    REP(i,n){
        REP(j,n-1){
            int aa;
            cin >> aa;
            a[i].push_back(aa-1);   
        }
    }

    int ans = 0;
    int aaaaa = n*(n-1)/2;
    bool fffff = true;
    for(;;){
        vector<bool> f(n,false);
        bool comp = true;
        bool all_f = true;
        REP(j,n){
            if(a[j].empty())continue;
            comp = false;

            int enemy = a[j].front();
            int enemy_to_enemy = a[enemy].front();
            if(f[enemy])continue;
            if(j != enemy_to_enemy)continue;
            f[j] = true;
            f[enemy] = true;
            all_f = false;
            // cout << enemy << " " << enemy_to_enemy << endl;
        }
        if(comp)break;
        
        if(all_f){
            ans = -1;
            break;
        }
        ans++;
        int c = 0;
        REP(i,n){
            if(f[i]){a[i].pop_front();
                c++;
            }
        }
        if(ans > 100000){
            cout << aaaaa << endl;
            return 0;
        }
        // cout << ans << endl;
    }
 
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4736
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import static java.util.Arrays.sort;



public class Main {
    public static void main(String[] args) {
        FastScanner fsc = new FastScanner();
        int w = fsc.nextInt();
        int h = fsc.nextInt();
        long[][] pq = new long[w + h][2];
        long ans = 0;
        for (int i = 0; i < w + h; i++) {
            pq[i][0] = fsc.nextLong();
            pq[i][1] = i < w ? 0 : 1;
            ans += pq[i][0];
        }
        sort(pq, (u, v) -> Long.compare(u[0], v[0]));
        int x = w, y = h;
        long cnt = h + w;
        for (int i = 0; i < h + w; i++) {
            if (cnt == (long) (h + 1) * (w + 1) - 1) {
                break;
            }
            if (pq[i][1] == 0) {
                ans += pq[i][0] * y;
                cnt += y;
                x--;
            } else {
                ans += pq[i][0] * x;
                cnt += x;
                y--;
            }
        }
        System.out.println(ans);
    }
}


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: 35012