akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author IncubatorMan
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define long long long
typedef pair < long , long > pii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
class ERedAndGreenApples {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int xx,y,a,b,c;
	    in>>xx>>y>>a>>b>>c;
	    vector<long> dataA(a),dataB(b),dataC(c);
	    for(long& x: dataA) in>>x;
	    for(long& x: dataB) in>>x;
	    for(long& x: dataC) in>>x;
	    sort(dataA.begin(),dataA.end(),greater<long>());
	    sort(dataB.begin(),dataB.end(),greater<long>());
	    sort(dataC.begin(),dataC.end(),greater<long>());
	    vector<long>ans;
	    for(int i=0;i<xx;i++){
	        ans.push_back(dataA[i]);
	    }
        for(int i=0;i<y;i++){
            ans.push_back(dataB[i]);
        }
        sort(ans.begin(),ans.end());
        for(int i=0;i<c && i<(xx+y);i++){
            if(dataC[i]>ans[i]){
                ans[i]= dataC[i];
            }
            else break;
        }
        out<<accumulate(ans.begin(),ans.end(),0LL)<<endl;
	}
};


int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);
	ERedAndGreenApples solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 4852
#標準入力
N, M, Q = map(int, input().split())
abcd = []
for _ in range(Q):
    tmp = list(map(int, input().split()))
    abcd.append(tmp)

#実装
import itertools as it
A_candidate = list(it.combinations_with_replacement(range(1, M + 1), N))
ans = 0
for i in range(len(A_candidate)):
    tmp = 0
    for j in range(Q):
        ABCD = abcd[j]
        if A_candidate[i][ABCD[1] - 1] - A_candidate[i][ABCD[0] - 1] == ABCD[2] :
            tmp += ABCD[3]
    if ans < tmp:
        ans = tmp
print(ans)
                   

Measured memory_bytes: 21580
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if(b - a == c - b) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
		
	}
}


Measured memory_bytes: 21844
n=int(input())
*h,=map(int,input().split())
ans=0

while any(h):
  l,r=0,0
  while l<n and not h[l]:
    l+=1
  r=l
  while r<n and h[r]:
    r+=1
  v=min(h[l:r])
  for i in range(l,r):
    h[i]-=v
  ans+=v

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
//2^0+2^1+2^2+…+2^n<2^(n+1)よりsum>=2^(n+1)のとき2^(n+1)が絶対に使われる？
int main(void)
{
	int sum=0;
	while(scanf("%d",&sum)!=EOF){
		int data[10]={0},i=0;
		if(sum>=512){
			sum-=512;
			data[i]=512;
			i++;
		}
		if(sum>=256){
			sum-=256;
			data[i]=256;
			i++;
		}
		if(sum>=128){
			sum-=128;
			data[i]=128;
			i++;
        }
		if(sum>=64){
			sum-=64;
			data[i]=64;
			i++;
		}
		if(sum>=32){
			sum-=32;
			data[i]=32;
			i++;
		}
		if(sum>=16){
			sum-=16;
			data[i]=16;
			i++;
		}
		if(sum>=8){
			sum-=8;
			data[i]=8;
			i++;
		}
		if(sum>=4){
			sum-=4;
			data[i]=4;
			i++;
		}
		if(sum>=2){
			sum-=2;
			data[i]=2;
			i++;
		}
		if(sum>=1){
			sum-=1;
			data[i]=1;
			i++;
		}
		for(i--;i>=0;i--){
			printf("%d",data[i]);
			if(i!=0) printf(" ");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;

int N,K,Q;
ll A[2020];
const ll INF=LLONG_MAX/2;

int main(){
  cin>>N>>K>>Q;
  rep(i,N) cin>>A[i];
  ll ans=INF;
  rep(i,N){
    int l=0;
    vector<ll> v,tmp;
    rep(j,N){
      if(A[j]<A[i]){
        if(tmp.size()>=K){
          sort(tmp.begin(),tmp.end());
          rep(k,tmp.size()-K+1) v.push_back(tmp[k]);
        }
        tmp.clear();
      }else{
        tmp.push_back(A[j]);
      }
    }
    if(tmp.size()>=K){
      sort(tmp.begin(),tmp.end());
      rep(k,tmp.size()-K+1) v.push_back(tmp[k]);
    }
    sort(v.begin(),v.end());
    if(v.size()<Q) continue;
    else ans=min(ans,v[Q-1]-v[0]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
                                        #include<iostream>
                                        #include<cstdio>
                                        #include<vector>
                                        #include<queue>
                                        #include<map>
                                        #include<cstring>
                                        #include<string>
                                        #include <math.h>
                                        #include<algorithm>
                                    //    #include <boost/multiprecision/cpp_int.hpp>
                                        #include<functional>
                                #define int long long
                                        #define inf  1000000007
                                        #define pa pair<int,int>
                                        #define ll long long
                                        #define pal pair<double,pa>
                                        #define ppa pair<int,int>
                                        #define ppap pair<pa,pa>
                                        #define ssa pair<string,int>
                                        #define  mp make_pair
                                        #define  pb push_back
                                        #define EPS (1e-10)
                                        #define equals(a,b) (fabs((a)-(b))<EPS)
                                  #define VI vector<int>
                                        using namespace std;


int gcd(int a,int b){
	if(a<b) return gcd(b,a);
	if(b==0) return a;
	if(a%b==0) return b;
	return gcd(b,a%b);
}
map<int,int>ma;
           signed main(){
               int n;
 // cin>>n;
         int f[100];
           	f[0]=1;
           	f[1]=1;
           	for(int  i=2;i<50;i++)f[i]=f[i-1]+f[i-2];
           	int u;
           	cin>>u;
           	
           	cout<<f[u]<<endl;
           }
             

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
string a, b;

int main() {
    cin.tie(0); ios::sync_with_stdio(0);
    cin >> a >> b;
    if (b.length() == a.length() + 1) {
        bool ok = true;
        for (int i = 0; i < a.length(); i++)
            if (a[i] != b[i])
                ok = false;
        if (ok)
            cout << "Yes";
        else
            cout << "No";
    } else
        cout << "No";
    return 0;
}


Measured memory_bytes: 3640
N = int(input())
A = list(map(int,input().split()))
from collections import Counter
from bisect import bisect
vs = list(Counter(A).values())
vs.sort()
cums = [0]
for v in vs:
    cums.append(cums[-1] + v)

def is_ok(k,m):
    j = bisect(vs,m)
    z = cums[j] + m*(len(vs)-j)
    return z >= m*k

ans = []
for k in range(1,N+1):
    if k > len(vs):
        ans.append(0)
    else:
        ok = 0
        ng = N//k + 1
        while ng-ok > 1:
            m = (ok+ng)//2
            if is_ok(k,m):
                ok = m
            else:
                ng = m
        ans.append(ok)

print(*ans, sep='\n')

Measured memory_bytes: 39116
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;

    vector<int64_t> p(a), q(b), r(c);
    for (auto&& pp : p) {
        cin >> pp;
    }
    for (auto&& qq : q) {
        cin >> qq;
    }
    for (auto&& rr : r) {
        cin >> rr;
    }

    constexpr auto INF = numeric_limits<int64_t>::max();
    p.push_back(INF);
    q.push_back(INF);
    sort(p.rbegin(), p.rend());
    sort(q.rbegin(), q.rend());
    sort(r.rbegin(), r.rend());
    p.resize(x + 1);
    q.resize(y + 1);
    int64_t s = 0;
    for (auto i : irange(0L, c)) {
        if (p.back() < q.back()) {
            if (p.back() >= r[i]) {
                break;
            }
            p.pop_back();
        } else {
            if (q.back() >= r[i]) {
                break;
            }
            q.pop_back();
        }
        s += r[i];
    }

    s += accumulate(p.begin() + 1, p.end(), 0L);
    s += accumulate(q.begin() + 1, q.end(), 0L);

    cout << s << endl;
}

Measured memory_bytes: 3328
n=int(input())
a=list(map(int,input().split()))
ans=0
a.sort()
cnt=[0 for i in range(a[-1]+1)]
for i in a:
  cnt[i]+=1

dp=[True for i in range(a[-1]+1)]

for i in range(n):
  if dp[a[i]]==False:
    #print(dp)
    continue
  if a[i]*2<=a[-1]+1:
    for j in range(a[i]*2,a[-1]+1,a[i]):
      dp[j]=False
      #print(dp)
for i in range(len(cnt)):
  if cnt[i]>=2:
    dp[i]=False
    
for i in range(n):
  if dp[a[i]]:
    ans+=1
print(ans)




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

int main() {
	
	int W, H, x, y, r;
	
	cin >> W >> H >> x >> y >> r;
	
	// xについて
	if ( (x - r >= 0) && (x + r <= W) )
	{
		// yについて
		if ( (y - r >= 0) && (y + r <= H) ) 
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	
	cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;

int main(){
    int x,a,b;	cin >> x >> a >> b;
    if(b-a<=0){
	cout << "delicious" << endl;
    }else if(b-a>0 && b-a<=x){
	cout << "safe" << endl;
    }else{
	cout << "dangerous" << endl;
    }
}


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

int h, w, a, b;
long long rv = 0;

//mod
const int mod = 1e9 + 7;
int pow(int x, int y) { //x^y
	int rv = 1;
	for (; y > 0; y >>= 1, x = (long long) x * x % mod)
		if (y & 1)
			rv = (long long) rv * x % mod;
	return rv;
}
int inverce(int x) {
	return pow(x, mod - 2);
}

//comb
const int factMax = 2e5;
int fact[factMax + 1];
void initializeFact() {
	fact[0] = 1;
	for (int i = 1; i <= factMax; i++)
		fact[i] = (long long) fact[i - 1] * i % mod;
}
int comb(int n, int k) {
	if (k < 0 || n - k < 0)
		return 0;
	int denom = (long long) fact[k] * fact[n - k] % mod;
	return (long long) fact[n] * inverce(denom) % mod;
}

int main() {
	initializeFact();
	cin >> h >> w >> a >> b;
	for (int i = 0; i < h - a; i++) {
		rv += (long long) comb(b - 1 + i, i)
				* comb(w - 1 - b + h - 1 - i, h - 1 - i);
		rv %= mod;
	}
	cout << rv << endl;
}


Measured memory_bytes: 1024
input_line = input()
input_line = input_line.split()
N = int(input_line[0])
K = int(input_line[1])
data = [0] * N

for i in range(K):
  temp = int(input())
  person = input()
  person = person.split()
  for j in range(len(person)):
    data[int(person[j]) - 1] += 1

count = 0
for i in range(N):
  if data[i] == 0:
    count += 1

print(count)

Measured memory_bytes: 9208
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

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

  if(n*a < b)
  {
    cout << n*a << endl;
  }
  else
  {
    cout << b << endl;
  }
}

Measured memory_bytes: 256
/*-In the name of God-
 
Author : Syed Mujtaba
Seek knowledge from the Cradle to the Grave !!
https://www.linkedin.com/in/syed-mujtaba
*/

#include <bits/stdc++.h>
using namespace std;
#define int             long long
#define ld              long double
#define ll              long long
#define pb              push_back
#define fi              first
#define se              second
#define MAXN            200064
#define mod             1000000007  //998244353 // 1e9 + 7
#define MAX             8000000000000000064LL
#define MIN            -8000000000000000064LL
#define mt              make_tuple
#define eps             1e-6
#define endl            '\n'
#define test            int T_T; cin>>T_T; while(T_T--)
#define fast_io         ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

signed main()
{
   fast_io
   int l, r, d;
   cin >> l >> r >> d;
   cout << r / d - (l-1)/d << endl;

}

Measured memory_bytes: 3608
#include<stdio.h>
int main(void)
{
int a,b,c,d,e,ans;
scanf("%d %d",&a,&b);
c=a+b;
d=a-b;
e=a*b;
if(c>d) ans=c;else ans=d;
if(ans<e) ans=e;
printf("%d",ans);
return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace atcorder_BeginnerContest_124
{
    class Program
    {

        static void Main(string[] args)
        {

            int cnt = int.Parse(Console.ReadLine());
            int[] dataRow = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            int ret = 0;

            for (int i = 0; i < cnt; i++)
            {
                bool noCntFlg = false;
                for (int j = 0; j < i; j++)
                {
                    if (dataRow[i] < dataRow[j])
                    {
                        noCntFlg = true;
                        break;
                    }
                }
                if (!noCntFlg) ret++;
            }

            Console.WriteLine(ret);

        }

    }
}



Measured memory_bytes: 11092
import java.util.*;

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

    while(true){
      int n = sc.nextInt();
      if(n == 0){
        break;
      }

      int s[] = new int[n];
      for(int i=0;i<n;i++){
        s[i] = sc.nextInt();
      }

      Arrays.sort(s);
      s[0] = 0;
      s[n-1] = 0;

      int ans = 0;
      for(int i=0;i<n;i++){
        ans += s[i];
      }
      ans = ans / (n-2);

      System.out.println(ans);
    }
  }
}


Measured memory_bytes: 29384
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
using namespace std;

long long mod = 1e9+7;

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

    set<long long> broken;
    for(long long i = 0; i < m; i++){
        long long a;
        cin >> a;
        broken.insert(a);
    }

    if(n == 1 and m == 1 and broken.find(1) != broken.end()){
        printf("0\n");
        return 0;
    }

    vector<long long> v(n+1);
    v[0] = 1;
    v[1] = 1;

    bool possible = true;
    for(long long i = 2; i <= n; i++){
        if(broken.find(i-1) != broken.end() and broken.find(i-2) != broken.end()){
            possible = false;
        }
        else if(broken.find(i-1) != broken.end()){
            v[i] = v[i-2]%mod;
        }
        else if(broken.find(i-2) != broken.end()){
            v[i] = v[i-1]%mod;
        }
        else{
            v[i] = (v[i-1]%mod + v[i-2]%mod)%mod;
        }
        
    }

    if(possible == false){
        printf("0\n");
    }
    else{
        printf("%lld\n", v[n]);
    }
    return 0;
}

Measured memory_bytes: 5760
k=int(input())
s=len(input())
mod=10**9+7
fact=[1]*(k+s+1)
inv=[1]*(k+s+1)
for i in range(2,k+s+1):
    fact[i]=i*fact[i-1]%mod
inv[-1]=pow(fact[-1],mod-2,mod)
for i in range(k+s,1,-1):
    inv[i-1]=inv[i]*i%mod
def comb(x,y):return fact[x]*inv[y]%mod*inv[x-y]%mod if x>=y>=0 else 0
ans=pow(26,k+s,mod)
for i in range(s):
    ans=(ans-pow(25,k+s-i,mod)*comb(k+s,i)%mod)%mod
print(ans)

Measured memory_bytes: 133168
import java.util.*;

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

        long a = sc.nextInt();
        long b = sc.nextInt();
        long c = sc.nextInt();
        long d = sc.nextInt();
        long max = 0;

        max = a * c;

        if (a*d >= max) {
            max = a*d;
        }
        if (b*c>=max) {
                max = b*c;
        }
        if (b*d>=max) {
            max = b*d;
        }
            
        System.out.println(max);
        sc.close();
    }
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int dest[200010][60];

void solve() {
    ll N, K;
    cin >> N >> K;
    for (ll i = 0; i < N; i++) {
        int a;
        cin >> a;
        --a;
        dest[i][0] = a;
    }

    for (ll j = 0; j < 59; j++) {
        for (ll i = 0; i < N; i++) {
            dest[i][j + 1] = dest[dest[i][j]][j];
        }
    }

    ll cur = 0;
    for (ll i = 0; i <= 60; i++) {
        if (K & 1) cur = dest[cur][i];
        K >>= 1;
    }

    cout << cur + 1 << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;

  if(A >= 13){
    cout << B << endl;
  }else if (A >= 6){
    cout << B / 2 << endl;
  }else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int masj[1001][1001];
int maso[1001][1001];
int masi[1001][1001];
int main(){
  int m,n;
  int k;
  memset(masj,0,sizeof(masj));
  memset(maso,0,sizeof(maso));
  memset(masi,0,sizeof(masi));
  cin>>m>>n;
  cin>>k;
  for(int i=1;i<=m;i++){
    for(int j=1;j<=n;j++){
      char c;
      cin>>c;
      masj[i][j]=masj[i-1][j]+masj[i][j-1]-masj[i-1][j-1];
      maso[i][j]=maso[i-1][j]+maso[i][j-1]-maso[i-1][j-1];
      masi[i][j]=masi[i-1][j]+masi[i][j-1]-masi[i-1][j-1];
      if(c=='J') masj[i][j]++;
      else if(c=='O') maso[i][j]++;
      else if(c=='I') masi[i][j]++;
    }
  }
  for(int i=0;i<k;i++){
    int a,b,c,d;
    cin>>a>>b>>c>>d;

    cout<<masj[c][d]+masj[a-1][b-1]-masj[a-1][d]-masj[c][b-1]<<' ';
    cout<<maso[c][d]+maso[a-1][b-1]-maso[a-1][d]-maso[c][b-1]<<' ';
    cout<<masi[c][d]+masi[a-1][b-1]-masi[a-1][d]-masi[c][b-1]<<endl;
  }
}

Measured memory_bytes: 12908
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define all(x) x.begin(),x.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
 




int main()
{
    fastio
    ll t,i,j,x;
    
    
    ll a;
    cin>>a;
    cout<<a+a*a+a*a*a;
    
    
    
}


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

typedef unsigned long long ll;
#define mod 1000000007
#define all(x) (x).begin(),(x).end()

void solve(){
	int n;
	cin>>n;
	vector<int> vec(n);
	for(int &i:vec)
		cin>>i;

	sort(all(vec));
 
    int ans = 0;
 
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < i; ++j) {
            for (int k = 0; k < j; ++k) {
                if (vec[k] != vec[j] and vec[i] != vec[j] and
                    vec[k] + vec[j] > vec[i]) {
                    ans++;
                }
            }
        }
    }
  cout << ans << endl;
}


int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
  return 0;
}

Measured memory_bytes: 3608
n=int(input());a=[0]*n;l=[list(map(int,input().split()))for i in a];d=1;k=n*~-n
while sum(a)<k and d<1e4:
 L=[1]*n;y=0;d+=1
 for i in range(n):
  if-~a[i]-n:
   x=l[i][a[i]]-1
   if l[x][a[x]]*L[x]*L[i]==i+1:a[i]+=1;a[x]+=1;L[i]=L[x]=0;y=1
print([k//2,d*y-1][d*y<1e4])

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

int main(void){
    int n, m, a[20][20], b[20], c, sum = 0, count = 0;
    cin >> n >> m >> c;
    for(int i = 0; i < m; ++i) cin >> b[i]; 
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < m; ++j){
            cin >> a[i][j];
        }
    }

    for(int i = 0; i < n; ++i){
        for(int j = 0; j < m; ++j){
            sum += a[i][j] * b[j];
        }
        if(sum > -c) count++;
        sum = 0;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;

typedef long long ll;

const ll inf=1e18;

ll n,a[50];

inline ll dfs(int l,int r,ll x,ll y)
{
	if(r-l<=1)return 0;
	ll ans=inf;
	for(register int i=l+1;i<r;++i)
		ans=min(ans,dfs(l,i,x,x+y)+dfs(i,r,x+y,y)+(ll)a[i]*(x+y));
	return ans;
}

int main()
{
	scanf("%lld",&n);
	for(register int i=1;i<=n;++i)scanf("%lld",&a[i]);
	printf("%lld\n",(ll)a[1]+a[n]+dfs(1,n,1,1));
	return 0;
}

Measured memory_bytes: 256
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            switch (S)
            {
                case "SUN":
                    Console.WriteLine(7);
                    break;
                case "MON":
                    Console.WriteLine(6);
                    break;
                case "TUE":
                    Console.WriteLine(5);
                    break;
                case "WED":
                    Console.WriteLine(4);
                    break;
                case "THU":
                    Console.WriteLine(3);
                    break;
                case "FRI":
                    Console.WriteLine(2);
                    break;
                case "SAT":
                    Console.WriteLine(1);
                    break;
                default:
                    break;
            }
        }
    }
}


Measured memory_bytes: 13152
#include <bits/stdc++.h>
#define vvi vector<vector<long long> > 
using namespace std;
void dfs(int u,vvi &e,vector<int> &p,vector<int> &sz){
	sz[u]=1;
	for(int j=0;j<e[u].size();j++){
		int v=e[u][j];
		if(p[u]!=v){
			p[v]=u;
			dfs(v,e,p,sz);
			sz[u]+=sz[v];
		}
	}
} 
int main(){
	int n;
	cin>>n;
	vvi e(n);
	for(int i=0;i+1<n;i++){
		int a,b;
		cin>>a>>b;
		--a;
		--b;
		e[a].push_back(b);
		e[b].push_back(a);
	}
	vector<int> p(n,-1),sz(n,0);
	dfs(0,e,p,sz);
	vector<int> path ;
	int c=n-1,psz=0;
	while(c>=0){
		path.push_back(sz[c]-psz);
		psz=sz[c];
		c=p[c];
	}
	reverse(path.begin(),path.end());
	long long ls=0LL,rs=0LL;
	int i=0,j=path.size()-1;
	while(i<=j){
		ls+=path[i++];
		if(i<=j)rs+=path[j--];
	}
	cout<<(ls>rs?"Fennec":"Snuke")<<endl;
	return 0;
}

Measured memory_bytes: 15100
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793
 
   
int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    VI t(n);
    string x;
    rep(i,n)cin >> s.at(i) >> t.at(i);
    cin >> x;
    int m=mm;
    ll ans=0;
    rep(i,n){
        if(x==s.at(i))m=i;
        if(i>m)ans+=t.at(i);
    }
    cout << ans << endl;
} 
    

Measured memory_bytes: 3608
#include <iostream>

using namespace std;

int main() {
    string a,b;
    cin >> a >> b;
    int x,y;
    cin >> x >> y;
    string u;
    cin >> u;
    if(u == a)
      --x;
    else
      --y;
      cout << x << ' ' << y << '\n';

}

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

int main(){
  int N;
  string S;

  cin >> N >> S;
  int count =0;

  for(int i=0; i<=N-3; i++){
    
    if(S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') count++;
  }

  cout << count << endl;
    

} 


Measured memory_bytes: 256
//set many funcs
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define inf 1145141919
#define llinf 1145141919810364364
#define mod 1000000007

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    long long n,t[128],i,r;
    scanf("%lld",&n);
    for(i=1;i<=n;i++){
        scanf("%lld",&t[i]);
        if(i==1){r=t[i];}else{r=lllcm(r,t[i]);}
    }
    printf("%lld\n",r);
    return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    s = input()
    t = input()
    ans = 0
    for i in range(3):
        if s[i] == t[i]:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


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

// input
int N;


void input() {
    cin >> N;
}


int main() {
    input();
    vector<ll> w(N + 1);
    w[0] = 2;
    w[1] = 1;
    for (int i = 2; i <= N; i++) w[i] = w[i - 1] + w[i - 2];
    ll ans = w[N];
    cout << ans << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define int llint
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define PI (acos(-1))
#define EPS (1e-10)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using Complex = std::complex<double>;
using namespace std;


int N, M;


int solve(){
	if(N > M) swap(N, M);
	if(M-N > 1) return 0;
	int ans = 1;
	repe(i, 1, N) ans = MUL(ans, i);
	repe(i, 1, M) ans = MUL(ans, i);
	if(N == M) ans = MUL(ans, 2);
	return ans;
}


signed main(){
	cin >> N >> M;

	cout << solve() << endl;

	return 0;
}

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

Measured memory_bytes: 2584
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n;
    cin >> n;
    long long ans = 0;
    REP(i, n)
    {
        int a;
        cin >> a;
        while (a % 2 == 0)
        {
            a /= 2;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// Let's bring the sky down :)
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 4e2 + 10;
ll a[N];
int n;
ll dp[N][N];
ll solve(int l, int r){
    if(l == r)
        return 0;
    if(dp[l][r] != -1)
        return dp[l][r];
    ll ans = 1e15;
    for(int i = l + 1; i <= r; i++){
        ans = min(ans, a[i - 1] - a[l - 1] + solve(l, i - 1) + a[r] - a[i - 1] + solve(i, r));
    }
    return dp[l][r] = ans;
}
int main()
{
    ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> a[i], a[i] += a[i - 1];
    memset(dp, -1, sizeof(dp));
    cout << solve(1, n);
return 0;
}


Measured memory_bytes: 1664
# /user/bin/python
# -*- coding: utf-8 -*-
import sys 


def fact(n):
  ret = 0
  for i in range(1, n+1):
    if n % i == 0:
      ret += 1
  return ret


n = int(input())
ans = 0
for i in range(1,n+1,2):
  if fact(i) == 8:
    ans += 1
print(ans)  

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC154B
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int L = S.Length;
            string[] ans = new string[L];
            for (int i = 0; i < L; i++)
            {
                ans[i] = "x";
            }
            Console.WriteLine(string.Join("", ans));
        }
    }
}


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

int main() {
  int n,m;
  cin>>n>>m;
  int a,b;
  cin>>a>>b;
  for(int i=0;i<m-1;i++){
    int c;
    cin>>c;
    a=max(a,c);
    int d;
    cin>>d;
    b=min(b,d);
  }
  cout<<max(0,b-a+1)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iomanip>
#include<sstream>
#include<map>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1;i <=n;i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
typedef long double ld;
const ll MOD =  1000000007;
const ll INF =  1LL << 60;
int n, m, x, y,z,w,h, sum, ans;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
struct edge {
    int to;
    ll cost;
    edge(int to, ll cost) : to(to), cost(cost) {}
};
vector<vector<edge>> G(100000);
using  p = pair<ll, int>;
vector<ll> d(100000,INF);
void dijkstra(int s) {
    priority_queue<p, vector<p>, greater<p> >pq;
    d[s] = 0;
    pq.push({ 0,s });
    while (!pq.empty()) {
        p now = pq.top(); pq.pop();
        int v = now.second;
        if (d[v] < now.first) continue;
        for (edge e : G[v]) {
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                pq.push(p(d[e.to], e.to));
            }
        }
    }
}
int main(void) {
    cin >> n >> m >> w;
    rep(i, m) {
        cin >> x >> y >> z;
        G[x].push_back({ y,z });
    }
    dijkstra(w);
    rep(i, n) {
        if (d[i] == INF) cout << "INF" << endl;
        else cout << d[i] << endl;
    }
}


Measured memory_bytes: 19404
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;

int main(){
    queue<int> Qt;
    queue<string> Qn;
    
    int n,q,t=0;
    cin >> n >> q;
    for(int i=0;i<n;i++){
        string s;
        cin >> s;
        Qn.push(s);
        int x;
        cin >> x;
        Qt.push(x);
    }
    while(!Qn.empty()){
        string cur_n=Qn.front();
        int cur_t=Qt.front();
        Qn.pop();
        Qt.pop();
        if(cur_t > q){
            Qn.push(cur_n);
            Qt.push(cur_t - q);
            t += q;
        }
        else{
            t += cur_t;
            cout << cur_n << ' ' << t << endl;
        }
    }
}


Measured memory_bytes: 5600
N = int(input())
S = input()
min = S[1:N].count('E')
now = S[1:N].count('E')

for i in range(1,N):
  if S[i-1] == 'E' and S[i] == 'E':
    now -= 1
  if S[i-1] == 'W' and S[i] == 'W':
    now += 1
  if now < min:
    min = now

print(min)

Measured memory_bytes: 3700
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn print_result(result: bool) {
    if !result {
        println!(":(");
    } else {
        println!("Yay!")
    }
}

fn can_comm(list: Vec<i32>, k: i32) -> bool {
    for x1 in 0..(list.len() - 1) {
        for x2 in (x1 + 1)..list.len() {
            if (list[x2] - list[x1]).abs() > k {
                return false;
            }
        }
    }

    true
}

fn main() {
    let mut array = Vec::<i32>::new();
    for _ in 0..5 {
        let line = read_vec::<i32>();
        array.push(line[0]);
    }

    let line = read_vec::<i32>();
    print_result(can_comm(array, line[0]));
}


Measured memory_bytes: 4352
X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
st = set(p)
diff = 0
while True:
    if X - diff not in st:
        print(X - diff)
        break
    if X + diff not in st:
        print(X + diff)
        break
    diff += 1

Measured memory_bytes: 61664
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>


using namespace std;

typedef long long LL;

bool gezi[50][105];

int main()
{
    int a,b;
    while (cin >>a >>b)
    {
        memset(gezi,false,sizeof(gezi));
        int point =1;
        int h1 =0;
        for (int i=0; i<a-1; i++)
        {
            gezi[h1][point] = true;
            gezi[h1+1][point] = true;
            gezi[h1+1][point-1] = true;
            point+=2;
            if (point>100)
            {
                point=1;
                h1 +=2;
            }
        }
        h1 = 44;
        point =1;
        if (a == 1)
            b++;
        for (int i=0; i<b-1; i++)
        {
            gezi[h1][point] = true;
            point+=2;
            if (point>100)
            {
                point=1;
                h1 -=2;
            }
        }
        printf("45 100\n");
        for (int i=0; i<45; i++)
        {
            for (int j=0; j<100; j++)
            {
                if (gezi[i][j] == true)
                    printf("#");
                else
                    printf(".");
            }
            printf("\n");
        }
    }




#ifdef VSCode
    system("pause");
#endif
    return 0;
}

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

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	int cnt=0;

	for (int i = 0; i < N; i++) cin >> A.at(i);

	sort(A.begin(), A.end());

	while (1) {
		if (cnt == 0) N -= K;
		else N -= K - 1;

		cnt++;
		if (N == 0) {
			break;
		}
		else if (N < K - 1) {
			cnt++;
			break;
		}
	}

	cout << cnt << endl;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(void){
   int x[5];
   scanf("%d %d %d %d %d", &x[0], &x[1], &x[2], &x[3], &x[4]);
      
   if(x[0] == 0){
      printf("%d\n", 1);
   }else if(x[1] == 0){
      printf("%d\n", 2);
   }else if(x[2] == 0){
      printf("%d\n", 3);
   }else if(x[3] == 0){
      printf("%d\n", 4);
   }else if(x[4] == 0){
      printf("%d\n", 5);
   }
}

Measured memory_bytes: 1684
S = input()

if S == 'RRR':
    print(3)
elif S[:2] == 'RR' or S[1:] == 'RR':
    print(2)
elif S[0] == 'R' or S[1] == 'R' or S[2] == 'R':
    print(1)
else:
    print(0)

Measured memory_bytes: 8944
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

class Program
{
    void solve()
    {
        int k = int.Parse(Console.ReadLine());
        int[] a = new int[k];
        int idx = 0;
        long max = 2, min = 2;
        bool f_invalid = false;
        string[] buff = Console.ReadLine().Split(' ');
        for (int i = 0; i < k; ++i)
        {
            int p = int.Parse(buff[i]);
            if (idx == 0 || a[idx - 1] != p)
            {
                a[idx++] = p;
            }
        }

        for (int i = idx - 1; i >= 0; --i)
        {
            int g = a[i];
            min = ((min - 1) / g) * g + g;
            max = (max / g) * g + g - 1;
            if (min > max)
            {
                f_invalid = true;
                break;
            }
        }
        if (f_invalid)
        {
            Console.WriteLine("-1");
        }
        else
        {
            Console.WriteLine(min + " " + max);
        }
    }

    public static int Main()
    {
        bool loop = false;
#if ES_DEBUG
        loop = true;
#endif
        do
        {
            new Program().solve();
        } while (loop);
        return 0;
    }
}


Measured memory_bytes: 26848
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdarg.h>
#include<malloc.h>

int main()
{
	int i;
	double a, s;

	while(scanf("%lf", &a) != EOF){
		s = 0;
		for(i=1; i<=10; i++){
			if(i == 1)
				s += a;
			else if(i % 2 == 0){
				a = a * 2;
				s += a;
			} else {
				a = a / 3;
				s += a;
			}
		}
		printf("%f\n", s);
	}
	return 0;
}

Measured memory_bytes: 648
import sys
sys.setrecursionlimit(10**6)

s = input()

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

ans = 0
tmp = 0

for ch in s:
    if ch in l:
        tmp += 1
    else:
        ans = max(ans, tmp)
        tmp = 0
ans = max(ans, tmp)
        
print(ans)

Measured memory_bytes: 9000
//Author : Sukarna Paul

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/detail/standard_policies.hpp>
#define pi acos(-1)
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define MAX 300005
#define INF 0x3f3f3f3f
template <class T> inline T bigmod(T p,T e,T M){ll ret = 1LL;for(; e > 0LL; e >>= 1LL){if(e & 1LL) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}

using namespace std;
using namespace __gnu_pbds;

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update>pref_trie;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;




int main(){
    IOS
    //freopen("output.txt","w",stdout);
    int h,w;
    cin>>h>>w;

    char arr[h+1][w+1];
    memset(arr,'x',sizeof arr);
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>arr[i][j];
        }
    }
    int ans[h+1][w+1];
    memset(ans,0,sizeof ans);

    for(int i=1;i<=h;i++){

        for(int j=1;j<=w;j++){

            int upor=ans[i-1][j];
            int left=ans[i][j-1];

            if(arr[i][j]=='.'){
                if(!(i==1 && j==1)){
                    if(arr[i-1][j]=='x')upor+=1000000;
                    if(arr[i][j-1]=='x')left+=1000000;
                }
                ans[i][j]=min(upor,left);
            }
            else{
                if(arr[i-1][j]=='.')upor+=1;
                if(arr[i][j-1]=='.')left+=1;
                if(arr[i-1][j]=='x')upor+=1000000;
                if(arr[i][j-1]=='x')left+=1000000;
                if(i==1 && j==1){
                    ans[i][j]=1;
                    continue;
                }
                ans[i][j]=min(upor,left);
            }
            //cout<<ans[i][j]<<" ";
            //cout<<arr[i][j]<<" ";
        }
        //cout<<"\n";

    }
    cout<<ans[h][w]<<"\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;cin>>s;
    if((s=="abc")||(s=="acb")||(s=="bac")||(s=="bca")||(s=="cab")||(s=="cba")){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    getchar();
    getchar();
    return 0;
}

Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N=gets.to_i
a=get_i
ans=0
(N-1).times do|i|
    min_i=i
    (i+1).upto(N-1) do|j|
        if a[min_i]>a[j]
            min_i=j
        end
    end
    a[min_i],a[i]=a[i],a[min_i]
    ans+=1 if min_i!=i
end
puts a.join(" ")
puts ans


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

int main()
{
	int S;

	cin >> S;

	// ??????????¨????
	int h = S / 3600;

	// ???????¨????
	int m = (S - (3600 * h)) / 60;

	// ?§?????¨????
	int s = (S - (3600 * h) - (60 * m));

	// ??????
	cout << h << ":" << m << ":" << s << endl;

	return 0;
}

Measured memory_bytes: 1164
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

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);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int N = in.nextInt();
			String L = in.next();
			List<String> list = new ArrayList<>();
			for(int i = 0; i < N; i++) {
				list.add(in.next());
			}
			Collections.sort(list);
			for(int i = 0; i < N; i++) {
				out.print(list.get(i));
			}
		}
	}
	
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}


Measured memory_bytes: 21460
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define MAX 100100
#define ll long long
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
struct Line{int v,next;}e[MAX];
int h[MAX],cnt=1;
inline void Add(int u,int v){e[cnt]=(Line){v,h[u]};h[u]=cnt++;}
int n,K,ans,fa[MAX],dep[MAX];
int dfs(int u,int dep)
{
	int ret=dep;
	for(int i=h[u];i;i=e[i].next)
		ret=max(ret,dfs(e[i].v,dep+1));
	if(fa[u]!=1&&ret-dep==K-1){++ans;return 0;}
	return ret;
}
int main()
{
	n=read();K=read();
	for(int i=1;i<=n;++i)fa[i]=read();
	for(int i=2;i<=n;++i)Add(fa[i],i);
	if(fa[1]!=1)++ans;fa[1]=1;
	dfs(1,0);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 6528
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	int sktr(int n,int a[]){
		int result = 0;
		int max = 0;
		for(int i = 0;i < n;i++){
			if(a[i] + result >= 0){
				result = result + a[i];
				if(max < result)max = result;
			}else{
				result = 0;
			}
		}
		if(max == 0){
			max = a[0];
			for(int i = 1;i < n;i++){
				if(max < a[i])max = a[i];
			}
		}
		return max;
	}
	void doIt() {
		while(true){
			int n = sc.nextInt();
			if(n == 0)break;
			int a[] = new int [n];
			for(int i = 0;i < n;i++){
				a[i] = sc.nextInt();
			}
			System.out.println(sktr(n,a));
		}
	}
	public static void main(String[] args) {
    	// TODO Auto-generated method stub
    	new Main().doIt();
    }
}

Measured memory_bytes: 26464
#include<iostream>

int main(void){
    int h, n, a;
    std::cin >> h >> n;
    int sum = 0;
    for(int i = 0; i < n; i++){
	std::cin >> a;
	sum += a;
    }
    if(h <= sum) std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;
    return 0;
}



Measured memory_bytes: 3632
#include <iostream>

using namespace std;

const int kMax = 100000;
int H[kMax];
int A[kMax];
int B[kMax];

bool bad[kMax];

int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < N; ++i) {
    cin >> H[i];
  }
  for (int i = 0; i < M; ++i) {
    cin >> A[i] >> B[i];
  }
  for (int i = 0; i < M; ++i) {
    int a = A[i] - 1;
    int b = B[i] - 1;
    if (H[a] <= H[b]) {
      bad[a] = true;
    }
    if (H[b] <= H[a]) {
      bad[b] = true;
    }
  }
  int good = 0;
  for (int i = 0; i < N; ++i) {
    if (!bad[i]) {
      ++good;
    }
  }
  cout << good << endl;
}

Measured memory_bytes: 4904
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s,t;
  cin>>s>>t;
  int ans=0;
  for(int i=0;i<3;i++)
  {
    if(s[i]==t[i]) ans++;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define FASTIO ios::sync_with_stdio(0); cin.tie(0);
#define REP(i,a,b) for(int i=a;i<b;i++)
const int inf=2e3;
#define maxx 1005
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;

int main(){
    FASTIO;
    int n,m,cnt,mn=inf;
    string s,t;
    cin>>s>>t;
    n=s.size();
    m=t.size();
    REP(i,0,n-m+1){
      cnt=0;
      REP(j,0,m){
        if(t[j]!=s[i+j]) cnt++;
      }
      mn=min(mn,cnt);
    }
    cout<<mn<<endl;
    return 0;
}


Measured memory_bytes: 3652
def main():
    n, *s = map(str, open(0).read().split())

    a = [[t.count(chr(x)) for x in range(97, 97 + 26)] for t in s]
    b = []
    for i, t in enumerate(zip(*a)):
        m = min(t)
        if m > 0:
            c = chr(i + 97) * m
            b.append(c)
    ans = "".join(b)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9084