akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
void ABC140(void);
void ABC141(void);
void ABC142(void);
void ABC143(void);
void ABC144(void);
void ABC145(void);
void ABC146(void);
void ABC147(void);
void ABC148(void);
void ABC149(void);

int main(void){
    ABC147();
}

void ABC147(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22)cout<<"bust"<<endl;
    else cout<<"win"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define For(i,a,b) for (int i=a;i<=b;i++)
#define Rep(i,a,b) for (int i=b;i>=a;i--)
using namespace std;
inline int read(){
	int k=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}
	return k*f;
}
bool f[20010];
int main()
{
	int n=read();f[0]=1;
	For(i,1,n)
	{
		int x=read();
		for(int j=10000;j>=0;j--)f[j+x]|=f[j];
	}
	int ans=0;
	for(int i=10000;i>=0;i--)if(i%10!=0&&f[i]){ans=i;break;}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
    #define chmin(a, b) a = min(a, b)
    #define chmax(a, b) a = max(a, b)
    #define pb push_back
    #define sz size()
     
    using namespace std;
    using ll = long long int;
    using Graph = vector<vector<int>>;
    using P = pair<ll, ll>;
     
const int MOD = 1e9 + 7;
const ll ZER = 0;


int main(){
    string s;
    cin >> s;
    bool f = false;
    rep(i, s.sz){
        if(s[i] == 'C')f = true;
        if(s[i] == 'F' && f){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}



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

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

	vector<int> v(n);
	for (int i = 0; i < n; i++)
		cin >> v[i];

	int ans = 0;
	for (int i = 1; i < n - 1; i++) {
		if (v[i - 1] < v[i] && v[i] < v[i + 1] || v[i + 1] < v[i] && v[i] < v[i - 1]) 
			ans++;
	}

	cout << ans << endl;
	
	return 0;
}



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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, a[200];

int main() {
	cin >> n;
	rep(i,n) cin >> a[i];
	
	int ans = inf;
	rep(i,n) {
		int l = 0;
		while(a[i]%2==0) {
			a[i] /= 2;
			l++;
		}
		chmin(ans, l);
	}
	cout << ans << ln;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;


int main(){
    int a,b;
    double t=3.305785; 
    scanf("%d %d",&a,&b);
    printf("%.10lf\n",a*b/t);
    return 0;
}

Measured memory_bytes: 1208
import std.stdio;
import std.string;
import std.algorithm;
import std.conv;

void selectionSortWithCount(ref int[] arr, out int cnt)
{
  for (auto i = 0; i < arr.length; i++) {
    int min = i;
    for (auto j = i; j < arr.length; j++) {
      if (arr[j] < arr[min]) {
        min = j;
      }
    }
    swap(arr[i], arr[min]);
    if (i != min) cnt++;
  }
}


void main(string[] args)
{
  int n = to!int(strip(readln()));
  int[] arr = to!(int[])(split(readln()));
  int cnt;
  selectionSortWithCount(arr, cnt);
  writeln(join(arr.map!(text), " "));
  writeln(cnt);
}

Measured memory_bytes: 2468
import java.util.*;

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

        int N = sc.nextInt();
        int[] V = new int[20];
        int[] C = new int[20];
        

        for (int i = 0; i < N; i++){
            V[i] = sc.nextInt();
        }
        for (int i = 0; i < N; i++){
            C[i] = sc.nextInt();
        }

        int answer = 0;
        for(int i=0; i<N; i++){
            if (V[i] > C[i]){
                answer += V[i]-C[i];
            }
        }

        System.out.println(answer);
    }
}



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

int main(void) {
    int n,m;cin>>n>>m;
    int a[n][m],b[m];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            int tmp;cin>>tmp;
            a[i][j] = tmp;
        }
    }
    for (int i = 0; i < m; i++) {
        cin>>b[i];
    }
    for (int i = 0; i < n; i++) {
        int sum = 0;
        for (int j = 0; j < m; j++) {
            sum += a[i][j] * b[j];
        }
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
#include <stdio.h>

int a[25];
int main(void)
{
	int i, j, n, len, sub;
	
	while (scanf("%d", &len), len != 0){
		for (i = 0; i < len; i++){
			scanf("%d", &a[i]);
		}
		
		n = i = 32;
		j = 0;
		while (n > 0){
			n -= (n - 1) % 5;
			printf("%d\n", n);
			
			if (a[j] == 0) j = 0;
			n -= a[j];
			if (n > 0) printf("%d\n", n);
			
			j++;
		}
		printf("0\n");
	}
	
	return 0;
}

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

#define st first
#define nd second
typedef long long LL;
typedef long double LLD;
typedef pair <int, int> PII;
typedef pair <LL, LL> PLL;

int main()
{   
    int r;
    scanf("%d", &r);

    if (r < 1200)
        printf("ABC");
    else if (r < 2800)
        printf("ARC");
    else
        printf("AGC");

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N, K, S;

int main() {

	cin >> N >> K >> S;

	if (S < 1000000000) {
		rep(i, K) cout << S << " ";
		rep(i, N - K) cout << 1000000000 << " ";
		return 0;
	}
	else {
		rep(i, K) cout << S << " ";
		rep(i, N - K) cout << 999999999 << " ";
		return 0;
	}


	return 0;
}


Measured memory_bytes: 1280
k = int(input())
even = [i for i in range(1, k+1) if i%2==0]
odd = [i for i in range(1, k+1) if i%2!=0]
ans_lst = []
for i in even:    
    for j in odd:
        even_odd = []
        even_odd.append(i)
        even_odd.append(j)
        ans_lst.append(even_odd)
print(len(ans_lst))

Measured memory_bytes: 3188
/*input
4
1 1 1 1
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
map<int,int> mp;
map<int,int> mp2;

set<pii> st;

int main()
{
	IOS;
	int n;
	cin>>n;
	REP(i,n){
		int tmp;cin>>tmp;
		if(i%2){
			mp[tmp]++;
		}
		else mp2[tmp]++;
	}
	for(pii i:mp2){
		st.insert(MP(i.S,i.F));
	}
	st.insert(MP(0,0));
	int ans=0;

	for(pii i:mp){
		if(mp2.count(i.F)){
			pii tmp=MP(mp2[i.F],i.F);

			st.erase(tmp);
			ans=max(ans,i.S+prev(st.end())->F);
			st.insert(tmp);
		}
		else{
			ans=max(ans,i.S+prev(st.end())->F);
		}
	}
	cout<<n-ans<<'\n';
	return 0;
}


Measured memory_bytes: 7296
#include<iostream>
#include<string>
#define num 26
using namespace std;

int main(){
	int i;
	string str;
	string strcp;
	string::iterator si;
	while(getline(cin, str)){
		strcp = str;
		for(i=0;i<num;i++){
			if(  strcp.find("this") != string::npos
			  || strcp.find("that") != string::npos
			  || strcp.find("the" ) != string::npos){
				cout << strcp << endl;
			}
			si = strcp.begin();
			while(si != strcp.end()){
				if('a' <= *si && *si <= 'y'){
					*si = *si + 1;
				}else if(*si == 'z'){
					*si = 'a';
				}
				si++;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int mod = 1e9 + 7;
const int inf = 2e18;

signed main() {
    int N, R;
    cin >> N >> R;
    cout << R + (100 * max(10 - N, 0LL)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

signed main(){
	int a, b;
	while(cin >> a >> b){
		a = a + b;
		int ans = 0;
		while(a){
			a /= 10;
			ans++;
		}
		cout << ans << endl;
	}
}

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

int main() {
	string S;
	cin >>S;
	int n,c;
	n=S.length();
	c=0;
	for(int i=0;i<n/2;i++){
		if(S.at(i)!=S.at(n-i-1)){
			c++;
		}
	}
	cout <<c;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            int cntAC = 0;
            int cntWA = 0;
            int cntTLE = 0;
            int cntRE = 0;
            for (int i = 0; i < N; i++)
            {
                string S = Console.ReadLine();
                if (S == "AC")
                {
                    cntAC++;
                }
                else if (S == "WA")
                {
                    cntWA++;
                }
                else if (S == "TLE")
                {
                    cntTLE++;
                }
                else if (S == "RE")
                {
                    cntRE++;
                }
            }
            Console.WriteLine("AC" + " " + "x" + " " + cntAC.ToString());
            Console.WriteLine("WA" + " " + "x" + " " + cntWA.ToString());
            Console.WriteLine("TLE" + " " + "x" + " " + cntTLE.ToString());
            Console.WriteLine("RE" + " " + "x" + " " + cntRE.ToString());
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


//Console.WriteLine(ans);


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

int main(){
  int64_t K,A,B;
  cin >> K >> A >> B;
  if(B<=A+2){
    cout << 1+K << endl;
  }else{
    if(K<A+1){
      cout << 1+K << endl;
    }else{
      int64_t ans=B;
      K-=(A+1);
      int64_t count=K/2;
      ans+=(B-A)*count+(K%2);
      cout << ans << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define rep(i,j,k) for(int i=j;i<k;i++)
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
const int  COMMAX = 510000;

long long fac[COMMAX], finv[COMMAX], inv[COMMAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < COMMAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

struct UnionFind {
  vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
  vector<int> rank;
  int num;
  UnionFind(int N) : par(N) , rank(N) { //最初は全てが根であるとして初期化
    num = N;
    for(int i = 0; i < N; i++){
      par[i] = i;
      rank[i] = 0;
    }
  }

  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); //xの根をrx
    int ry = root(y); //yの根をry
    if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
    if(rank[rx] < rank[ry]){
      par[rx] = ry;  
    }else{
      par[ry] = rx;
      if(rank[rx] == rank[ry])rank[rx]++;
    }
    num--;
  }

  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    return root(x) == root(y);
  }
};

const int MS = 2;
const long long mod[] = {999999937LL, 1000000007LL}, base = 9973;
struct rolling_hash {
    int n;
    vector<long long> hs[MS], pw[MS];
    rolling_hash(){}
    rolling_hash(const string &s) {
        n = s.size();
        for (int i = 0; i < MS; i++) {
            hs[i].assign(n+1,0);
            pw[i].assign(n+1,0);
            hs[i][0] = 0;
            pw[i][0] = 1;
            for (int j = 0; j < n; j++) {
                pw[i][j+1] = pw[i][j]*base%mod[i];
                hs[i][j+1] = (hs[i][j]*base+s[j])%mod[i];
            }
        }
    }

    long long hash(int l, int r, int i) { return ((hs[i][r]-hs[i][l]*pw[i][r-l])%mod[i]+mod[i])%mod[i]; }

    bool match(int l1, int r1, int l2, int r2) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l1,r1,i)==hash(l2,r2,i);
        return ret;
    }

    bool match(int l, int r, long long h[]) {
        bool ret = 1;
        for (int i = 0; i < MS; i++) ret &= hash(l,r,i)==h[i];
        return ret;
    }
};
double xhako[8];
double yhako[8];
vector<int> vec;
int main(){
  int n;
  cin >> n;
  rep(i,0,n){
    cin >> xhako[i] >> yhako[i];
    vec.push_back(i);
  }
  double sumup = 0;
  int count = 0;
      do {
        count += 1;
          for(int i=0;i<n-1;i++){
            double xp = xhako[vec[i]] - xhako[vec[i+1]];
            double yp = yhako[vec[i]] - yhako[vec[i+1]];
            sumup += sqrt(xp*xp + yp*yp);
          }
    } while( next_permutation(vec.begin(), vec.end()) ); 
      sumup /= count;
      cout.precision(17);
      cout << (sumup) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  string S;
  cin >> S;
  int N = S.size();
  rep(i,N)
  {
    if(i%2==0)
    {
      if(S[i]=='L')
      {
        cout << "No" << endl;
        return 0;
      }
    }
    else
    {
      if(S[i]=='R')
      {
        cout << "No" << endl;
        return 0;
      }
    }
    
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)

int main(){
	
	long N;
	vector<long> As;
	cin>>N;
	REP(i,N){
		long input;
		cin>>input;
		As.push_back(input);
	}

	long kekka = 0;
	for(long i = 0; i < N-1; i++){
		kekka += As[i]/2;
		As[i] = (As[i] % 2);

		if( As[i] <= As[i+1]){
			kekka += As[i];
			As[i+1] -= As[i];
			As[i] = 0;
		}

	}
	
	kekka += (As[N-1]/2);

	cout<<kekka<<endl;
	return 0;
}


Measured memory_bytes: 1400
#include <stdio.h>

int main(void)
{
	int i, j;
	int num[5];
	int tmp;
	
	for (i = 0; i < 5; i++) {
		scanf("%d", &num[i]);
	}
	for (i = 0; i < 5; i++) {
		for (j = i; j < 5; j++) {
			if (num[j] > num[i]) {
				tmp = num[i];
				num[i] = num[j];
				num[j] = tmp;
			}
		}
	}
	for (i = 0; i < 5; i++) {
		printf("%d", num[i]);
		printf("%c", (i != 4) ? ' ' : '\n');
	}
	return (0);
}

Measured memory_bytes: 600
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    if(S == "SUN"){
        print(7);
    }else if(S == "MON"){
        print(6);
    }else if(S == "TUE"){
        print(5);
    }else if(S == "WED"){
        print(4);
    }else if(S == "THU"){
        print(3);
    }else if(S == "FRI"){
        print(2);
    }else{
        print(1);
    }


    

}

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

int main(){
  string S; cin >> S;
  ll N = S.size();
  vector<ll> alp(26, 0);
  for(ll i = 0; i < N; i++){
    alp[S[i] - 'a']++;
  }
  
  ll ans = (N * (N-1)) / 2;
  for(ll e : alp){
    ans -= (e * (e - 1)) / 2;
  }
  
  cout << ++ans << endl;
}

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

int main(){
  int n;
  string s;
  cin >> n;
  
  for(int i = 0; n > i; i++){
    cin >>s;
    if(s == "Y"){
      cout << "Four"<<endl;
      break;
    }
    
    if(i == n - 1){
      cout << "Three"<<endl;
    }
  }



}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
inline long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }

vector<int> prime_table(int n) {
    vector<int> is_prime(n + 1);
    if (n) iota(is_prime.begin() + 2, is_prime.end(), 2);
    for (int i = 2; i * i <= n; i++) if (is_prime[i]) {
        for (int j = i + i; j <= n; j += i) is_prime[j] = 0;
    }
    return is_prime;
}
vector<int> make_primes(int ma) {
    vector<int> ps = prime_table(ma);
    ps.erase(remove(ps.begin(), ps.end(), 0), ps.end());
    return ps;
}

int main() {
    auto ps = make_primes(10000);
    int n; cin >> n;
    vector<long long> pos, neg;
    int sz = n + 2;
    pos.insert(pos.end(), ps.begin(), ps.begin() + sz);
    neg.insert(neg.end(), ps.begin() + sz, ps.begin() + sz * 2);
    vector<vector<long long>> a(sz, vector<long long>(sz, 1));
    for (int i = 0; i < sz; i++) for (int j = 0; j < sz; j++) {
        int wa = i + j, sa = i - j + n + 1;
        if ((i + j) & 1) a[i][j] = pos[wa / 2] * neg[sa / 2];
    }
    for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) {
        if ((i + j) & 1) continue;
        a[i][j] = lcm(a[i-1][j], lcm(a[i][j-1], lcm(a[i][j+1], a[i+1][j]))) + 1;
    }
    for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) {
        cout << a[i][j] << " \n"[j == n];
    }
    return 0;
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
#define int long long
const int inf=1145141919;
const int dd[]={0,-1,0,1,0};
using namespace std;
int p[50];
int ct[51][51];
int combi(int n,int m){
	if(ct[n][m]==-1)
		ct[n][m]=combi(n-1,m)+combi(n-1,m-1);
	return ct[n][m];
}
signed main(){
	fill((int*)ct,(int*)ct+51*51,-1);
	for(int i=0;i<51;i++){
		ct[i][0]=1;
		ct[i][i]=1;
	}
	int n,a,b;
	int i;
	cin>>n>>a>>b;
	for(i=0;i<n;i++)
		cin>>p[i];
	sort(p,p+n);
	reverse(p,p+n);
	int u,v;
	for(i=a-1;i>=0;i--)
		if(p[i]!=p[a-1])
			break;
	u=i+1;
	for(i=a;i<n;i++)
		if(p[i]!=p[a-1])
			break;
	v=i;
	int x=0;
	for(i=0;i<a;i++)
		x+=p[i];
	cout<<fixed<<setprecision(15)<<(double)x/a<<endl;
	if(u==0){
		x=0;
		for(i=a;i<=min(v,b);i++)
			x+=combi(v,i);
		cout<<x<<endl;
	}else
		cout<<combi(v-u,a-u)<<endl;
}


Measured memory_bytes: 256
'''
参考
https://qiita.com/tanakh/items/a312a9bd684658ab1e7b
'''
N = int(input())
C = list(map(str, input()))

left = 0
right = N - 1
ans = 0

while True:
    while left < N and C[left] != 'W':      # 左側から「白」が見つかるまでポインタをずらしていく
        left += 1
    while right >= 0 and C[right] != 'R':   # 右側から「赤」が見つかるまでポインタをずらしていく
        right -= 1
    if left >= right:                       # 停止条件
        break
    ans += 1                                # 見つかったら解をカウントアップ（赤白入れ替え）
    left += 1
    right -= 1

print(ans)


Measured memory_bytes: 10692
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void maxNoOfString(TreeMap<String, Integer> trr, Object[] keys) {
		int max = trr.get(keys[0]);
		for (int count = 1; count < keys.length; count++) {
			if(trr.get(keys[count]) > max) max = trr.get(keys[count]);
		}
		getKey(trr, max);
	}
	
	public static void getKey(TreeMap<String, Integer> trr, Integer value) {
		for (String key : trr.keySet()) {
			if(value.equals(trr.get(key))) System.out.println(key);
		}
	}
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int t = scan.nextInt(); scan.nextLine();
		TreeMap<String, Integer> trr = new TreeMap<>();
		for (int count = 0; count < t; count++) {
			String str = scan.nextLine();
			if(trr.containsKey(str)) trr.put(str, trr.get(str) + 1);
			else trr.put(str, 1);
		}
		maxNoOfString(trr, trr.keySet().toArray());
		scan.close();
	}
}

Measured memory_bytes: 83460
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<unordered_map>
#include<queue>
#include<stack>
#include<vector>

using namespace std;

int main(){
    int n;
    cin>>n;
    while(n > 0){
        if(n%10 == 7){
            cout<<"Yes"<<endl;
            return 0;
        }
        n /= 10;
    }

    cout<<"No"<<endl;
}


Measured memory_bytes: 3128
#include <iostream>
#include <vector>
#include <cassert>
#include <string>
#include <map>
#include <algorithm>
#include <queue>
using namespace std;
constexpr long long MOD = 998244353;

int main() {
	int n, s; cin >> n >> s;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];

	vector<vector<long long>> dp(s + 3030, vector<long long>(3));
	dp[0][0] = 1;
	for (int i = 0; i < n; ++i) {
		vector<vector<long long>> next(s + 3030, vector<long long>(3));
		for (int j = 0; j <= s; ++j) {
			// 状態維持
			next[j][0] += dp[j][0];
			next[j][1] += dp[j][1]; // 足さない
			next[j + a[i]][1] += dp[j][1]; // 足す
			next[j][2] += dp[j][2];
			// 区間を始める
			next[j][1] += dp[j][0]; // 加算なし
			next[j + a[i]][1] += dp[j][0]; // 加算あり
			// 区間を終える
			next[j][2] += dp[j][0] + dp[j][1]; // 加算なし
			next[j + a[i]][2] += dp[j][0] + dp[j][1]; // 加算あり

			next[j][0] %= MOD;
			next[j][1] %= MOD;
			next[j][2] %= MOD;
			next[j + a[i]][1] %= MOD;
			next[j + a[i]][2] %= MOD;
		}
		dp = next;
	}
	cout << dp[s][2];
	return 0;
}

Measured memory_bytes: 976
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n,m;

ll f(ll w,ll id){
	ll ans = (w-id-1)*(id+1);
	return ans%Mod;
}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	std::cout<<std::fixed<<std::setprecision(30);
	cin>>n>>m;
	Vi x,y;
	x.resize(n);
	y.resize(m);
	rep(i,n){
		cin>>x[i];
	}
	rep(i,m){
		cin>>y[i];
	}
	sort(all(x));
	sort(all(y));
	ll yy =0;
	rep(i,m-1){
		ll idd = y[i+1]-y[i];
		idd *= f(m,i);
		yy += idd;
		yy %= Mod;
	}
	ll ans = 0;
	rep(i,n-1){
		ll idd = x[i+1]-x[i];
		idd *= f(n,i);
		idd %= Mod;
		ans += idd * yy;
		ans %= Mod;
	}
	print(ans);
	return 0;
}

Measured memory_bytes: 1792
// ALDS_1_2_D Shell Sort

#include <iostream>
#define NMAX 	1000000
#define MMAX	100

int A[NMAX];

int insertionSort(int array[], int n, int g){
	int cnt = 0;

	for(int init=0 ; init<g ; init++){
		for(int i=g+init ; i<n ; i+=g){
			int target = array[i];
			int j = i;
			while( (j >= g) && (target < array[j-g]) ){
				array[j] = array[j-g]; // Shift right
				j -= g;
				cnt++;
			}
			array[j] = target;
		}
	}

	return cnt;
}

int main(int argc, char *argv[]){
	int n, m = 1;
	int G[MMAX];
	int cnt_all = 0;
	int cnt_g;

	std::cin >> n;
	for(int i=0 ; i<n ; i++){
		std::cin >> A[i];
	}

	// 全然わからなかった…以下解説見ながら

	// Generate gap
	G[0] = 1;
	int G_n1 = 3*G[0] + 1;
	while((G_n1 < n) && (m < MMAX-1)){
		G[m] = G_n1;
		G_n1 = 3*G[m] + 1;
		m++;
	}
	
	for(int i=m-1 ; i>=0 ; i--){
		cnt_g = insertionSort(A, n, G[i]);
		cnt_all += cnt_g;
	}

	// Output gap value
	std::cout << m << std::endl;
	for(int i=m-1 ; i>0 ; i--){
		std::cout << G[i] << " ";
	}
	std::cout << G[0] << std::endl;

	// Output swap count
	std::cout << cnt_all << std::endl;

	// Output sorted array
	for(int i=0 ; i<n ; i++){
		std::cout << A[i] << std::endl;
	}

	return 0;
}



Measured memory_bytes: 7000
import java.util.*;

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

        int N = scan.nextInt();
        int M = scan.nextInt();
        int day = 0;
        for (int i = 0; i < M; i++) {
                day += scan.nextInt();
        }
        if(day>N){
            System.out.println(-1);
        }
        else{
            System.out.println(N-day);
        }
    }
}



Measured memory_bytes: 45936
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N,M,a;
  cin>>N>>M;
  if(N==1){
    cout<<M<<endl;
    return 0;
  }
  vector<ll> A(0,0);
  //Mの約数列挙してlower_bound
  for(int i=1; i*i<=M; i++){
    if(M%i==0){
      A.push_back(i);
      A.push_back(M/i);
    }
  }
  sort(A.begin(), A.end());
  auto IT=lower_bound(A.begin(), A.end(), N);
  ll pos=IT-A.begin();
  //Nをすれすれで上回る組み合わせの相方が答え    
  ll ans=M/A[pos];
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if(!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if(t & 1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
mint fact(int n) {
  if(n == 1 || n == 0) return 1;
  mint res = n;
  return res * fact(n - 1);
}

int main() {
  ll n;
  cin >> n;
  string s0, s1;
  cin >> s0 >> s1;
  mint ans = 1;
  bool h = false;
  ll i = 1;
  if(s0[0] == s1[0]) {
    h = true;
    ans *= 3;
  } else {
    ans *= 6;
    i++;
  }
  for(; i < n; i++) {
    bool now = (s0[i] == s1[i]);
    if(h)
      ans *= 2;
    else if(!now)
      ans *= 3;
    h = now;
    if(!now) i++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define per(i,a,n) for(int i=n-1;i>=a;i--)
#define VI vector<int>
#define PII pair<int,int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define db double
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
mt19937 mrand(random_device{}());
const ll mod = 1000000007;
int rnd(int x){return mrand()%x;}
clock_t ac; double TLE(){return (double)(clock()-ac)/CLOCKS_PER_SEC;}
void DBG() {cerr << "]" << endl;}
template<class H, class... T> void DBG(H h, T... t) {
cerr << to_string(h);
if(sizeof...(t)) cerr << ", ";
DBG(t...);}
#ifdef _DEBUG
#define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

int main(){
 ios::sync_with_stdio(0);
 cin.tie(0);
 int n;
 cin>>n;
 ll a[n];
 map<ll,ll>m;
 ll sum=0;
 rep(i,0,n){
   cin>>a[i];
   sum+=a[i];
   m[a[i]]++;
 }
 int q;
 cin>>q;
 while(q--){
  ll b,c;
  cin>>b>>c;
  sum-=b*m[b];
  sum+=c*m[b];
  m[c]+=m[b];
  m[b]=0;
 cout<<sum<<"\n";  
 }
}




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

int n;

int main(){
    cin>>n;
    int maxv=INT32_MIN;
    int minv=INT32_MAX;
    for(int i=0; i<n; ++i){
        int x;
        cin>>x;
        maxv=max(maxv, x-minv);
        minv=min(minv, x);
    }
    cout<<maxv<<endl;
    return 0;
}


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

int main(){
  int N,mod=1000000007;
  cin >> N;
  long long sum=0;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
    sum+=A.at(i);
  }
  long long ans=0;
  for(int i=0;i<N;i++){
    sum-=A.at(i);
    long long subsum=sum%mod;
    long long B=(A.at(i)*subsum)%mod;
    ans=(ans+B)%mod;
  }
  cout << ans << endl;
}
    
  

Measured memory_bytes: 4044
n = int(input())
r_min = int(input())
r_ji = - float('inf')
for t in range(n - 1):
    r_t = float(input())
    if r_ji < r_t - r_min:
        r_ji = r_t - r_min
    if r_t < r_min:
        r_min = r_t
print(int(r_ji))


Measured memory_bytes: 5628
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        int[] road = new int[2 * M];
        int[] count = new int[N];

        for (int i = 0; i < 2 * M; i++) {
            road[i] = Integer.parseInt(sc.next());
        }

        for (int i = 0; i < 2 * M; i++) {
            for (int j = 1; j <= N; j++) {
                if (road[i] == j) {
                    count[j - 1]++;
                }
            }
        }

        PrintWriter out = new PrintWriter(System.out);
        for (int i = 0; i < N; i++) {
            out.println(count[i]);
            out.flush();
        }
        sc.close();
    }
}

Measured memory_bytes: 35724
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
using namespace std;
typedef pair<string, string> P;

int f;
map<P, int> cnts;

void input() {
	int n;
	
	cin >> n >> f;
	for (int i = 0; i < n; i++) {
		int m;
		cin >> m;
		
		string s[10];
		for (int j = 0; j < m; j++) {
			cin >> s[j];
		}
		sort(s, s + m);
		
		for (int j = 0; j < m; j++) {
			for (int k = j + 1; k < m; k++) {
				if (cnts.find(P(s[j], s[k])) == cnts.end()) {
					cnts[P(s[j], s[k])] = 0;
				}
				cnts[P(s[j], s[k])]++;
			}
		}
	}
}

int main() {
	input();
	
	int ans = 0;
	for (map<P, int>::iterator it = cnts.begin(); it != cnts.end(); it++) {
		if (it->second < f) { continue; }
		ans++;
	}
	cout << ans << endl;
	
	for (map<P, int>::iterator it = cnts.begin(); it != cnts.end(); it++) {
		if (it->second < f) { continue; }
		P str = it->first;
		
		cout << str.first << " " << str.second << endl;
	}
	return 0;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,a,b;cin >> n >> a >> b;
	if(n==1){
		if(a==b) cout << 1 << endl;
		else cout << 0 << endl;
	}
	else if(a>b) cout << 0 << endl;
	else cout << max((n-2)*b-(n-2)*a+1,(ll)0) << endl;
}

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

typedef long long ll;

int const N = 100 * 1000 + 16;
int const M = 1000 * 1000 * 1000 + 7;

int n;
int a[N];
ll v[2][N];
ll dp[2][N];

int sign(ll x) {
  return x >= 0 ? 1 : -1;
}

int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);

  cin >> n;
  for(int i = 0; i < n; ++i)
    cin >> a[i];

  if(n == 1) {
    cout << 0 << endl;
    return 0;
  }

  if(a[0] < 0) {
    v[0][0] = 1;
    dp[0][0] = 1 - a[0];

    v[1][0] = a[0];
    dp[1][0] = 0;
  } else if(a[0] > 0) {
    v[0][0] = a[0];
    dp[0][0] = 0;

    v[1][0] = -1;
    dp[1][0] = 1 + a[0];
  } else {
    v[0][0] = 1;
    dp[0][0] = 1;

    v[1][0] = -1;
    dp[1][0] = 1;
  }

  for(int i = 1; i < n; ++i) {
    ll x = a[i];

    v[0][i] = v[1][i-1] + x;
    v[1][i] = v[0][i-1] + x;

    dp[0][i] = dp[1][i-1];
    dp[1][i] = dp[0][i-1];

    if(v[0][i] <= 0) {
      auto d = 1 - v[0][i];
      v[0][i] += d;
      dp[0][i] += d;
    }

    if(v[1][i] >= 0) {
      auto d = 1 + v[1][i];
      v[1][i] -= d;
      dp[1][i] += d;
    }
  }

  cout << min(dp[0][n-1], dp[1][n-1]) << endl;
}

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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define _P(...) (void)fprintf(stderr, __VA_ARGS__)

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



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

	string s;
	cin >>s;
	
	VI a(4);
	rep(i,4) a[i] = s[i]-'0';
	
	rep(i,1<<3){
		int w = a[0];
		rep(j,3){
			if((i >> j) & 1) w += a[j+1];
			else w -= a[j+1];
		}
		if(w==7){
			cout <<a[0];
			rep(j,3){
				cout <<(i>>j &1? "+": "-");
				cout <<a[j+1];
			}
			cout <<"=7\n";
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int d[N],n,m,x,y,q[N],f,r,has[N],ans;
vector<int> v[N];
int main()
{
	scanf("%d%d",&n,&m);
	while(m--)
	{
		scanf("%d%d",&x,&y);
		x--;y--;
		v[x].push_back(y);
		has[y]++;
	}
	for(int i=0;i<n;i++)
	if(!has[i])
	q[r++]=i;
	while(f<r)
	{
		x=q[f++];
		for(int i=0;i<v[x].size();i++)
		{
			y=v[x][i];
			if(d[x]+1>d[y])d[y]=d[x]+1;
			if(ans<d[y])ans=d[y];
			has[y]--;
			if(!has[y])q[r++]=y;
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 6912
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0; }
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
ll nod(ll F) { return log10(F) + 1; }
//**定義場所**//
//gcd, isPrime, eratos, modinv, bitSearch, dfs, bfs, dijkstra, UnionFind//
ll i, j, k, l, m, n; ll N, M, K, H, W, L; string S;
ll MOD = 1000000007; ll ans = 0; ll INF = 9999999999999;
vl flag, color; vll path; vl A, T;
//***********//
int main() {
	cin >> N;
	vl P(N), Q(N);
	ll p = 0, q = 0;
	for (i = 0; i < N; i++) {
		cin >> P[i];
		//p += 10 * pow(10, N - i - 1);
	}
	for (i = 0; i < N; i++) {
		cin >> Q[i];
		//q += 10 * pow(10, N - i - 1);
	}
	vl test(N);
	for (i = 0; i < N; i++) {
		test[i] = i + 1;
	}
	ll now = 1;
	while (next_permutation(test.begin(),test.end())) {
		if (test == P) {
			p = now;
		}
		if (test == Q) {
			q = now;
		}
		now++;
	}
	cout << abs(p - q);
}

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

using ll = long long;
using P = pair<int, int>;

const int MAX = 1e5;
const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

vector<int> graph[MAX];
int fennec[MAX], snuke[MAX];
bool used[MAX];

void dfs1(int v, int d) {
  fennec[v] = d;
  used[v] = true;
  for (int i = 0; i < graph[v].size(); i++) {
    int to = graph[v][i];
    if (used[to]) continue;

    dfs1(to, d + 1);
  }
}

void dfsN(int v, int d) {
  snuke[v] = d;
  used[v] = true;
  for (int i = 0; i < graph[v].size(); i++) {
    int to = graph[v][i];
    if (used[to]) continue;

    dfsN(to, d + 1);
  }
}

int main() {
  // 入力
  int N;
  cin >> N;
  int a[N-1], b[N-1];
  for (int i = 0; i < N - 1; i++) cin >> a[i] >> b[i];

  for (int i = 0; i < N - 1; i++) {
    a[i]--, b[i]--;
    graph[a[i]].push_back(b[i]);
    graph[b[i]].push_back(a[i]);
  }

  // 頂点0、N-1からのDFSで各頂点までの最短距離を求める
  dfs1(0, 0);
  fill(used, used + MAX, false);
  dfsN(N-1, 0);

  int f = 0, s = 0;
  for (int i = 1; i < N - 1; i++) {
    if (fennec[i] <= snuke[i]) f++;
    else s++;
  }

  // 解答
  cout << (f > s ? "Fennec" : "Snuke") << endl;

  return 0;
}


Measured memory_bytes: 12032
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String args[]){//double 处理果盘
		Scanner in = new Scanner(System.in);
		long n = in.nextLong();
		long[] num = new long[(int) n];
		for (int i=0;i<n;i++){
			num[i] = in.nextLong();
		}
		Arrays.sort(num);
//		System.out.println(num.length);
		int count = 0;
		for (int i=0;i<n-2;i++){
			for (int j=i+1;j<n-1;j++){
				long su = num[i]+num[j];
				for(int k=j+1;k<n;k++){
					if (num[k] < su){
						++count;
					}else{
						break;
					}
				}
			}
		}
		System.out.println(count);
	}
}	

Measured memory_bytes: 28608
#include <iostream>
#include <vector>
#include<map>
#include<string>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<typeinfo>
#include<queue>
#include<iomanip>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> h(N);
	for (int i = 0; i < N; i++) {
		cin >> h[i];
	}
	
	vector<int> dp(N,0);
	dp[0] = 0;
	dp[1] = abs(h[0] - h[1]);
	for (int i = 1; i < N-1; i++) {
		dp[i + 1] = min(dp[i - 1] + abs(h[i - 1] - h[i + 1]), dp[i] + abs(h[i] - h[i + 1]));
	}
	cout << dp[N-1]<<endl;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    string s;
    cin >> s;
    if( s == "BBB" || s == "AAA" ) cout << "No";
    else cout << "Yes";
    cout << endl;

    return 0;
}



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

const int N = 16;
const long long IMPOSSIBLE = 4e18;

long long dp[1 << N];
long long sum[1 << N];
int n;
int arr[N][N];

void read() {
  cin >> n;
  for (int i = 0 ; i < n ; i++)
    for (int j = 0 ; j < n ; j++)
      cin >> arr[i][j];
}

long long solve(int bm) {
  if (bm == 0) return 0;

  long long &ret = dp[bm];
  if (ret != IMPOSSIBLE) return ret;

  ret = -IMPOSSIBLE;
  for (int mask = bm ; mask > 0 ; mask = bm & (mask-1)) {
    ret = max(ret, sum[mask] + solve(bm ^ mask));
  }

  return ret;
}

long long work() {
  for (int bm = 0 ; bm < (1 << n ) ; bm++) {
    vector<int> v;
    for (int i = 0 ; i < n ; i++)
      if (bm & (1 << i)) {
        v.push_back(i);
      }
    
    for (int i = 0 ; i < v.size() ; i++)
      for (int j = i+1 ; j < v.size() ; j++)
        sum[bm] += arr[v[i]][v[j]];
    
    dp[bm] = IMPOSSIBLE;
  }

  return solve((1 << n) - 1);
}

int main() {
  read();
  cout << work() << endl;
  return 0;
}

Measured memory_bytes: 1280
#include "cstdio"
#include "algorithm"
#include "cstring"
using namespace std;
char a[105],b[105];
bool cmp(char x,char y){
	return x>y;
}
int main(){
	scanf("%s%s",a,b);
	sort(a,a+strlen(a));sort(b,b+strlen(b),cmp);
	if(strcmp(a,b)<0)printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, n) for (int i = 1; i <= (n); i++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
using ll = long long;
template <class T>
using Grid = vector<vector<T>>;
vector<vector<pair<int, int>>> g;
vector<int> ans;
void dfs(int i) {
    for (auto x : g[i]) {
        if (ans[x.first] != -1)
            continue;
        if (x.second % 2 == 0)
            ans[x.first] = ans[i];
        else
            ans[x.first] = !ans[i];
        dfs(x.first);
    }
}
int main() {
    int N;
    cin >> N;
    g.resize(N + 1);
    rep(i, N - 1) {
        int a, b, c;
        cin >> a >> b >> c;
        g[a].emplace_back(b, c);
        g[b].emplace_back(a, c);
    }
    ans.assign(N + 1, -1);
    ans[1] = 0;
    dfs(1);
    rep2(i, N) printf("%d\n", ans[i]);
}

Measured memory_bytes: 11096
n = int(input())
a = list(map(int, input().split()))

a.sort()

M = 1000005
cnt = [0] * M

for i in range(n):
    if cnt[a[i]] != 0:
        cnt[a[i]] = 2
        continue
    for j in range(a[i], M, a[i]):
        cnt[j] += 1

ans = 0

for i in range(n):
    if cnt[a[i]] == 1:
        ans += 1

print(ans)

Measured memory_bytes: 32160
import java.nio.charset.IllegalCharsetNameException;
import java.util.*;
import java.lang.*;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String o = sc.next();
		String e = sc.next();
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < e.length(); i++) {
			sb.append(o.charAt(i));
			sb.append(e.charAt(i));
		}
		if (o.length() > e.length()) {
			sb.append(o.charAt(o.length() - 1));
		}
		System.out.println(sb);
	}
}

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

#define ll long long

template<typename T> void drop(const T &x){cout<<x<<'\n';exit(0);}

void solve() {
  int n, T; cin >> n >> T;

  int t, ans=0, x=0;
  for(int i=0; i<n; ++i) {
    cin >> t;
    ans += t+T;
    ans -= max(t,x);
    x = t+T;
  }
  cout << ans << '\n';
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) solve();

  return 0;
}


Measured memory_bytes: 3624