akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            int a = cin.ReadInt;
            int b = cin.ReadInt;
            int c = a * b;
            if (c % 2 == 0)
            {
                WriteLine("Even");
            }
            else
            {
                WriteLine("Odd");
            }
        }
    }
       
    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

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

int main() {
    int n, i, max, sum;
    vector<int> p;

    cin >> n;
    p.resize(n);

    for (i = 0; i < n; i++) {
        cin >> p.at(i);
    }

    max = p.at(0);
    sum = p.at(0);
    for (i = 1; i < n; i++) {
        sum += p.at(i);
        if( max < p.at(i)) {
            max = p.at(i);
        }
    }

    cout << sum - max / 2 << endl;

    return 0;
}

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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define mp make_pair
#define ll long long
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2097162
#define inf 1e9
#define MOD 1000000007

int main()
{

    string ss;
    cin >> ss;
    stack< char > s;
    s.push('a');
    for(ll i = 0; i < ss.size(); i++)
    {

        char c = s.top();
        if(c != ss[i] && c != 'a') s.pop();
        else s.push(ss[i]);
    }
    ll z = s.size()-1;
    ll m = ss.size();
    cout << m-z;
}


Measured memory_bytes: 512
using System;
using System.Linq;

namespace T1PBC
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            char[] s = Console.ReadLine().ToCharArray();
            int k = int.Parse(Console.ReadLine());

            int count = 0;
            foreach (char c in s)
            {
                if (c != s[k - 1])
                    s[count] = '*';
                count++;
            }
            Console.WriteLine(s);
        }
    }
}

Measured memory_bytes: 11092
#include <stdio.h>

int main(void){
    int l,k,m,ks,ms,sn;
    scanf ("%d%d%d%d%d",&l,&ks,&ms,&k,&m);
    if (ks / k > ms / m){
        sn = ks / k;
        if (ks % k){
            sn++;
        }
    }
    else{
        sn = ms / m;
        if (ms % m){
            sn++;
        }
    }
    printf ("%d\n",l - sn);
    return 0;
}

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


using namespace std;
using ll = long long;
const int N = 1e6 + 600;



int n ,b[205],a[206];
int ans = 0;
int main() {
    cin >> n;
    for(int i = 0;i < n -1;++i)
            cin >> b[i];
    a[0] = b[0];
    for(int i = 1; i < n ; ++i){
            a[i] = min(b[i],b[i - 1]);
    }
    a[n - 1] = b[n - 2];
    for(int i  = 0; i < n; ++i)
           ans += a[i];
    cout << ans << "\n";
//    0 0   10 10 10 23
//    0 153   10  10 23

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main
{
	public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    String t=sc.next();
    int ans=0;
    char c1[]=s.toCharArray();
    char c2[]=t.toCharArray();
    for(int i=0;i<c1.length;i++)
        {
            if(c1[i]==c2[i]){
                
            }
            else{
                ans++;
            }
        }
    System.out.println(ans);
	}
}


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

typedef long long ll;
const ll MOD = 924844033;
const int MAXN = 200010;

inline int read() {
	int x = 0, f = 1;
	char ch = getchar();
	for(; !isdigit(ch); ch = getchar()) if(ch=='-') f=-1;
	for(; isdigit(ch); ch = getchar()) x = (x*10)+(ch^48);
	return x * f;
}

inline ll qpow(ll a, ll b) {
	ll res = 1;
	while(b) {
		if(b & 1LL) res = res * a % MOD;
		b >>= 1, a = a * a % MOD;
	}
	return res;
}

int len, d, r[550000];
ll invlen, w[550000][2];

inline void NTT_init() {
	int i;
	invlen = qpow(len, MOD-2);
	for(i = 0; i < len; i++) r[i] = (r[i>>1]>>1)|((i&1)<<(d-1));
	ll g = qpow(5, (MOD-1)>>d);
	w[0][0] = w[len][0] = 1;
	for(i = 1; i < len; i++) w[i][0] = w[i-1][0]*g%MOD;
	for(i = 0; i <= len; i++) w[i][1] = w[len-i][0];
}

inline void NTT(ll a[], int t) {
	int i, j, k;
	for(i = 0; i < len; i++) if(i < r[i]) swap(a[i], a[r[i]]);
	for(i = 2; i <= len; i<<=1) 
		for(j = 0; j < len; j += i) 
			for(k = 0; k < (i>>1); k++) {
				ll val = a[j+k+(i>>1)]*w[(len/i)*k][t]%MOD;
				a[j+k+(i>>1)] = ((a[j+k]-val)%MOD+MOD)%MOD;
				a[j+k] = (a[j+k]+val)%MOD;
			}
}

ll a[550000], b[550000], fac[MAXN], ifac[MAXN];
int e, st[MAXN], to[MAXN<<1];
int nxt[MAXN<<1];
inline void Add(int u, int v) {
	to[++e] = v, nxt[e] = st[u];
	st[u] = e;
}

int n, c[MAXN];
ll pre[MAXN], ans[MAXN];

int dfs(int u, int fa) {
	int i, sz = 1;
	for(i = st[u]; i; i = nxt[i]) {
		int v = to[i];
		if(v == fa) continue;
		sz += dfs(v, u);
	}
	if(u != 1) c[sz]++;
	return sz;
}

inline ll C(int x, int y) {
	return fac[x]*ifac[y]%MOD*ifac[x-y]%MOD;
}

int main() {

	int i;
	n = read();
	fac[0] = 1;
	for(i = 1; i <= n; i++) fac[i] = fac[i-1]*i%MOD;
	ifac[n] = qpow(fac[n], MOD-2);
	for(i = n; i >= 1; i--) ifac[i-1] = ifac[i]*i%MOD;

	for(i = 1; i < n; i++) {
		int u = read(), v = read();
		Add(u, v), Add(v, u);
	}
	dfs(1, 0);
	for(i = 1; i <= n; i++) pre[i] = pre[i-1]+c[i];
	for(i = 1; i <= n; i++) 
		ans[i] = C(n, i)*(1+pre[n])%MOD;
	for(len = 1; len <= (n<<1); len<<=1) d++;
	NTT_init();
	for(i = 0; i <= n; i++) a[i] = c[i]*fac[i]%MOD, b[i] = ifac[n-i];
	/*for(i = 0; i <= n; i++) printf("%lld ", a[i]);
	printf("\n");
	for(i = 0; i <= n; i++) printf("%lld ", b[i]);
	printf("\n");*/
	NTT(a, 0), NTT(b, 0);
	for(i = 0; i < len; i++) a[i] = a[i]*b[i]%MOD;
	NTT(a, 1);
	for(i = n+1; i < len; i++) 
		ans[i-n] = ((ans[i-n]-a[i]*invlen%MOD*ifac[i-n]%MOD)%MOD+MOD)%MOD;
	/*for(i = 0; i < len; i++) printf("%lld ", a[i]*invlen%MOD);
	printf("\n");
	printf(":%lld\n", len*invlen%MOD);*/

	for(i = 0; i < len; i++) a[i] = b[i] = 0;
	for(i = 0; i <= n; i++) a[i] = c[n-i]*fac[i]%MOD, b[i] = ifac[n-i];
	NTT(a, 0), NTT(b, 0);
	for(i = 0; i < len; i++) a[i] = a[i]*b[i]%MOD;
	NTT(a, 1);
	for(i = n+1; i < len; i++)
		ans[i-n] = ((ans[i-n]-a[i]*invlen%MOD*ifac[i-n]%MOD)%MOD+MOD)%MOD;

	for(i = 1; i <= n; i++) printf("%lld\n", ans[i]);
	return 0;
}


Measured memory_bytes: 40320
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
 
mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000
 
d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))
 
A, B = LI()
ans = mod
for i in range(1251):
    if math.floor(i * 0.08) == A and math.floor(i * 0.1) == B:
        ans = i
        break
    else:
        pass
else:
    ans = -1
 
print(ans)


Measured memory_bytes: 66740
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int ans;
	if (a == b) ans = c;
	else if (a == c) ans = b;
	else ans = a;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
#define cmin(a,b) a = min(a,b);
int ans[11][11];
int trans[10][10];
int n = 10;
void Floyd() {
    for (int k = 0; k < n; k++)
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                cmin(ans[i][j], ans[i][k] + ans[k][j]);


}
int main() {
    int h, w;
    while (scanf("%d%d", &h, &w) != EOF) // H * M
    {
        for (int i = 0; i <= 9; i++)
            for (int j = 0; j <= 9; j++)
                scanf("%d", &ans[i][j]);
        Floyd();
        int tot = 0;
        for (int i = 1; i <= h; i++)
            for (int j = 1; j <= w; j++) {
                int x;
                scanf("%d", &x);
                if (x == -1) continue;
                else tot += ans[x][1];
            }
        return !printf("%d\n", tot);
    }
}

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

int main()
{
    size_t N;
    cin >> N;
    int all = 0;
    vector<int> a(N);
    for (int &aa : a)
    {
        cin >> aa;
        all ^= aa;
    }
    for (int aa : a)
    {
        cout << (all ^ aa) << " ";
    }
    cout << endl;
}


Measured memory_bytes: 4044
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const ll Inf = 1e14;

ll Rec(ll i,ll Last);

ll n;
ll a[100100];
ll b[100100];
ll c[100100];

ll Dp[100100][5];

int main()
{
    memset(Dp,-1,sizeof(Dp));

    cin>>n;

    for(ll i=0;i<n;i++)    scanf("%I64d%I64d%I64d",a+i,b+i,c+i);

    cout<<Rec(0,0);
}

ll Rec(ll i,ll Last)
{
    if(i==n)    return 0;

    ll Res = -Inf;

    if(Dp[i][Last]+1)   return Dp[i][Last];

    if(Last!=1) Res = max( Res , a[i] + Rec(i+1,1) );
    if(Last!=2) Res = max( Res , b[i] + Rec(i+1,2) );
    if(Last!=3) Res = max( Res , c[i] + Rec(i+1,3) );

    return Dp[i][Last] = Res;
}


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

using namespace std;

typedef pair<int,int> pii;

vector<pair<int,pii>> arr;

int H = 0;

bool check(int x, int y){
  pair<int,pii> start = arr[0];
  int dis = abs(arr[0].first - x) + abs(arr[0].second.first - y);
  H = dis + arr[0].second.second;
  bool pos = true;
  for(int i=1;i<arr.size();++i){
    int val = max(H - abs(arr[i].first - x) - abs(arr[i].second.first - y),0);
    if(val!=arr[i].second.second) return false;
  }
  return true;
}

bool fun(pair<int,pii> a, pair<int,pii> b){
  return a.second.second > b.second.second;
}

main(){
  int n; cin >> n;
  int x,y,h;
  for(int i=0;i<n;++i){
    cin >> x >> y >> h;
    arr.push_back(pair<int,pii>(x,pii(y,h)));
  }
  sort(arr.begin(),arr.end(),fun);
  for(int i=0;i<=100;++i) for(int j=0;j<=100;++j){
      if(check(i,j)){
	cout << i << " " << j << " " << H << endl;
	return 0;
      }
    }
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import qualified Data.List
import qualified Data.Char
import Debug.Trace
import qualified Data.Sequence as Seq

main ::IO()
main = do
  [n,m] <- map read . words <$> getLine :: IO [Int]
  as <- replicateM m $ read <$> getLine :: IO [Int]
  putStrLn $ show $ solve n as

solve :: Int -> [Int] -> Int
solve n as =
  -- traceShow (take n cands) $
  ans
  where
    isBrokenL = brokenListToBool as [0..]
    cands =  dp f $ tail isBrokenL
    ans = cands !! (n+1)

f isBroken prevCombo prevPrevCombo =
  -- traceShow cand $
  cand
  where
    cand =
      if isBroken then 0
      else (prevCombo + prevPrevCombo)  `mod` 1000000007

-- brokenListToBool [] [] = []
brokenListToBool [] _ = repeat False -- False : brokenListToBool [] bs' 
brokenListToBool as@(a:as') (b:bs') 
  | a==b =  True : brokenListToBool as' bs'
  | otherwise = False : brokenListToBool as bs'
  

-- functions --

dp f l =
  combos
  where
    combos = 0 : 1 : zipWith3 f l combos (tail combos)



Measured memory_bytes: 43388
n = gets.to_i
a = gets.chomp.split.map(&:to_i)

min = 200 ** 2 * 100

for i in -100..100 do
  temp = 0
  a.each do |an|
    temp += (an - i) ** 2
  end
  min = temp if temp < min
end

puts min

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
using ll = long long;
using P = pair<int, int>;
/* ------------------------------------------------ */
ll fact(int i) {       //階乗(i <= 20 まで)
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ------------------------------------------------ */

int main() {
    ll x;
    cin >> x;
    for(ll i = -1000;i<=1000;i++) {
        for(ll j = -1000;j<=1000;j++) {
            if(i*i*i*i*i-j*j*j*j*j==x){
                cout << i << ' ' << j << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3540
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())

X=[A,B,C,D,E]
ans=0

Y=10

for i in range(len(X)):
    if X[i]%10 == 0:
        ans+=X[i]
    else:
        Y=min(Y,X[i]%10)
        ans+=(X[i]//10)*10+10

ans +=-10+Y
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;
#define endl '\n'

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

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

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

	ll N, K; cin >> N >> K;
	vector<int> A(N, -1), B(N, -1);

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

	int t = 0;
	ll p0, p;
	for (int i = 0; i <= K; i++) {
		if (i == K) {
			cout << t + 1 << endl; return 0;
		}
		if (B[t] != -1) {
			p0 = B[t];
			p = i - B[t];
			break;
		}
		B[t] = i;
		t = A[t] - 1;
	}

	K -= p0;
	K %= p;

	for (int i = 0; i <= K; i++) {
		if (i == K) {
			cout << t + 1 << endl; return 0;
		}
		t = A[t] - 1;
	}

	return 0;
}

Measured memory_bytes: 4424
object Main extends App {

  import scala.io.StdIn.{readInt, readLine}
  val n = readInt()
  val arr = readLine().trim.split(" ").map(_.toInt)
  val sorted = arr.toList.sorted
  var ans = 0
  for (i <- 0 to (sorted.length - 1)) {
    if (i % 2 == 0) ans += sorted(i)
  }
  println(ans)

}

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

int main() {
  int N, M;
  cin >> N >> M;
  cout << (N == M ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace AtCoder
{
    internal class Program
    {
        private static void Main()
        {
            var s = Console.ReadLine() ?? "";
            var t = Console.ReadLine() ?? "";
            var c = s.Where((t1, i) => t1 != t[i]).Count();
            Console.WriteLine(c);
        }
    }
}


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

using namespace std;

int n;
string s;

int main() {
	cin >> n >> s;
	for(int i = 0; i < int(s.size()); i++)
		s[i] = ((s[i]-'A')+n)%26 + 'A';
	cout << s << endl;
	
    return 0;
}


Measured memory_bytes: 256
/* 
chirag11032000
Chirag Thakur
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std::endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

void test_case();

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	test_case();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void test_case() {
	int ctr = 1;
	int s;
	cin >> s;
	set < int > seen;
	while (!seen.count(s)) {
		seen.insert(s);
		if (s & 1) {
			s = 3 * s + 1;
		} else {
			s /= 2;
		}
		++ctr;
	}
	cout << ctr << "\n";
}

Measured memory_bytes: 256
function Main(input) {
 
    var N = new Number(input.split('\n')[0]);
    var a = input.split('\n');
    var f = true;
    for (var i = 1; i <= N; i++){
        var tmp = a[i].split(' ');
        var t = tmp[0] - 0;
        var x = tmp[1] - 0;
        var y = tmp[2] - 0;

        t -= (Math.abs(x) + Math.abs(y));
        if (t < 0) {
            f = false;
            break;
        }
        else if (t % 2 != 0) {
            f = false;
            break;
        }
    }
 
    console.log(f ? "Yes" : "No");
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 49868
def main():
    buf = input()
    N = int(buf)
    a = []
    for i in range(N):
        buf = input()
        a.append(int(buf))
    for i in a:
        if i % 2 == 0:
            continue
        else:
            print("first")
            return
    print("second")

if __name__ == '__main__':
    main()


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

int main() {
    int N, cnt = 0;
    cin >> N;
    vector<string> gift(N);
    string copy;
    for (int i = 0; i < N; i++) cin >> gift.at(i);
    sort(gift.begin(), gift.end());
    for (int i = 0; i < N; i++) {
        if (i == 0) {
            copy = gift.at(0);
            cnt++;
        } else if (copy != gift.at(i)) {
            copy = gift.at(i);
            cnt++;
        }
    }
    
    cout << cnt << endl;
}

Measured memory_bytes: 9592
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

void Main()
{
  int a, b, c, d;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> d;
  
  while(a > 0 && c > 0){
    c = c - b;
    if(c <= 0)
      break;
    
    a = a - d;
  }
  
  if(a <= 0)
    printf("No");
  else if(c <= 0)
    printf("Yes");
}

int main()
{
  std::cout << std::fixed << std::setprecision(15);
  Main();
}

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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define INF 10000000000000009
#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl



signed main(){
    int P[25]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
    int N;
    cin >> N;
    map<int,int> G;
    REP(i,25){
        G[P[i]]=i;
    }
    int prime[25]={};
    for(int i=1;i<=N;i++){
        int e=i;
        while(e!=1){
            OREP(j,e){
                if(e%j==0){
                    if(j==1)continue;
                    prime[G[j]]++;
                    e=e/j;
                    break;
                }
            }
        }
    }
    //REP(i,25){cout << P[i] << " " << prime[i] << endl;}
    int F=0,T=0,N14=0,N24=0,N74=0;
    REP(i,25){
        
        if(prime[i]>=74){
            N74++;
        }
        if(prime[i]>=24){
            N24++;
        }
        if(prime[i]>=14){
            N14++;
        }
        if(prime[i]>=4){
            F++;
        }
        if(prime[i]>=2){
            T++;
        }
    }
    //cout << F << " " << T <<  endl;
    //cout << N14 << " " << N24 << " " << N74<<  endl;
    int Ans=0;
    Ans+=N74;
    Ans+=N24*(T-1);
    Ans+=N14*(F-1);
    Ans+=F*(F-1)*(T-2)/2;
    cout << Ans << endl;
    return 0;
}   


Measured memory_bytes: 256
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

int n,a[1111];
int main()
{
	get1(n);
	for(int i=1;i<=n+n;i++)get1(a[i]);
	sort(a+1,a+n+n+1);
	int sum=0;
	for(int i=1;i<=n+n;i+=2)sum+=a[i];
	printendl(sum);
	return 0;
}

Measured memory_bytes: 256
def insertionSort(A,n,g):
    global cnt
    for i in range(g,n):
        v=A[i]
        j=i-g
        while j>=0 and A[j]>v:
            A[j+g]=A[j]
            j-=g
            cnt+=1
        A[j+g]=v

def shellSort(A,n):
    G=[]
    k=n
    while True:
        k=max(k//2-1,1)
        G.append(k)
        if k==1:
            break
    m=len(G)
    print(m)
    for i in range(m):
        if i<m-1:
            print(G[i],end=' ')
        else:
            print(G[i])
        insertionSort(A,n,G[i])

n=int(input())
A=[]
for i in range(n):
    A.append(int(input()))

cnt=0

shellSort(A,n)

print(cnt)
for Ai in A:
    print(Ai)


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

int main() {
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int ans = 0;
  
  for(int i=0; i<=a; i++){
    for(int j=0; j<=b; j++){
      for(int k=0; k<=c; k++){
        int sum = 500*i + 100*j + 50*k;
        if (sum == x)
          ans ++;
      }
    }
  }
  
  cout << ans << endl;
  
}

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

const int maxn = 4010;

char a[maxn], b[maxn];

struct cnt {
  int num[26];
  void init() { memset(num, 0, sizeof(num)); }
  bool operator<(const cnt &b)const {
    for (int i = 0; i < 26; i++)
      if (num[i] != b.num[i]) return num[i] < b.num[i];
    return 0;
  }
  friend ostream &operator<<(ostream &out, cnt &a) {
    for (int i = 0; i < 26; i++) out << a.num[i] << " ";
    return out;
  }
};

bool can(int x) {
  set<cnt> cs;
  cnt cmp; cmp.init();
  for (int i = 0; a[i]; i++) {
    cmp.num[a[i]-'a']++;
    if (i >= x) cmp.num[a[i-x]-'a']--;
    if (i >= x-1) cs.insert(cmp);
  }
  cmp.init();
  for (int i = 0; b[i]; i++) {
    cmp.num[b[i]-'a']++;
    if (i >= x) cmp.num[b[i-x]-'a']--;
    if (i >= x-1) 
      if (cs.find(cmp) != cs.end()) return 1;
  }
  return 0;
}

int main()
{
  scanf("%s%s", a, b);
  bool flag = false;
  for (int i = strlen(a); i > 0; i--) 
    if (can(i)) { printf("%d\n", i); flag = true; break; }
  if (!flag) printf("0\n");
  return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  if(A>8||B>8) cout << ":(" << endl;
  else cout << "Yay!" << endl;
  return 0;
}

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

using namespace std;

const int MAX_N = 100000;
int n;
int64_t a[MAX_N];

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

  sort(a, a+n);

  int64_t s = a[n-1] - a[0];
  int i = 0, j = n-1;
  int k = 1, l = n-2;
  while (k <= l) {
    if (a[l] - a[i] > a[j] - a[k]) {
      s += a[l] - a[i];
      i++;
      l--;
    } else {
      s += a[j] - a[k];
      j--;
      k++;
    }
  }
  cout << s << endl;


  return 0;
}


Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	m := getNextInt(scanner)

	boxes := make([]*Box, n)
	boxes[0] = &Box{
		color: 1,
		balls: 1,
	}
	for i := 1; i < n; i++ {
		boxes[i] = &Box{
			color: 0,
			balls: 1,
		}
	}

	for i := 0; i < m; i++ {
		x := getNextInt(scanner) - 1
		y := getNextInt(scanner) - 1
		if boxes[y].balls == 0 {
			boxes[y].color = boxes[x].color
		}
		if boxes[x].color == 1 {
			boxes[y].color = 1
		}
		boxes[x].balls--
		boxes[y].balls++
	}

	ans := 0
	for i := 0; i < n; i++ {
		if boxes[i].color == 1 && boxes[i].balls >= 1 {
			ans++
		}
	}

	fmt.Fprintln(writer, ans)

	writer.Flush()
}

type Box struct {
	color int
	balls int
}


Measured memory_bytes: 4608
def main():
    import heapq
    n,m = map(int,input().split())
    alb = {}
    for i in range(n):
        a,b = map(int,input().split())
        if a not in alb.keys():
            alb[a] = [b]
        else:
            alb[a] += [b]
    h = []
    s = 0
    for i in range(1,m+1):
        if i in alb.keys():
            for j in range(len(alb[i])):
                heapq.heappush(h, -1*alb[i][j])
        if len(h)>0:
            m = heapq.heappop(h)
            s += -1*m
    print(s)

if __name__ == "__main__":
    main()

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

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

    std::vector<int> H(N+1);
    for (int i = 1; i <= N; ++i) cin >> H[i];

    H[0] = 0;
    bool success = true;
    for (int i = N; i >= 0; --i){
        
        //NGパターン
        if( H[i] < ( H[i-1] - 1 ) ) {
            success=false;
            break;
        }
        //OKパターン数値変更不要
        if( H[i] >= H[i-1] ){
            //なにもしない
        } else {
            H[i-1]--;
        }
    }

    if (success) {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {

	private static List<Abcdn> getStrings(Scanner sc, int num) {
		List<Abcdn> stringList = new ArrayList<>();
		while(num>0) {
			long n = sc.nextLong();
			long a = sc.nextLong();
			long b = sc.nextLong();
			long c = sc.nextLong();
			long d = sc.nextLong();
			stringList.add(new Abcdn(n,a,b,c,d));
			num--;
		}
		return stringList;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Abcdn> array = getStrings(sc, n);
		for (int i = 0; i < n; i++) {
			Abcdn abcdn = array.get(i);

			Map<Long, Long> map = new HashMap<>();
			map.put(0L, 0L);
			map.put(1L, abcdn.d);
			calc(abcdn, map, abcdn.n);
			System.out.println(map.get(abcdn.n));
		}
	}

	private static Long calc(Abcdn abcdn, Map<Long, Long> map, long n) {
		if (map.containsKey(n)) {
			return map.get(n);
		}
		long la = (n/2)*2;
		long ua = ((n+1)/2)*2;
		long lb = (n/3)*3;
		long ub = ((n+2)/3)*3;
		long lc = (n/5)*5;
		long uc = ((n+4)/5)*5;
		long res = Long.MAX_VALUE;
		if (n < res/abcdn.d) {
			res = n*abcdn.d;
		}
		res = Math.min(res, calc(abcdn, map, la/2) + abcdn.a + Math.abs(la-n)*abcdn.d);
		res = Math.min(res, calc(abcdn, map, ua/2) + abcdn.a + Math.abs(ua-n)*abcdn.d);
		res = Math.min(res, calc(abcdn, map, lb/3) + abcdn.b + Math.abs(lb-n)*abcdn.d);
		res = Math.min(res, calc(abcdn, map, ub/3) + abcdn.b + Math.abs(ub-n)*abcdn.d);
		res = Math.min(res, calc(abcdn, map, lc/5) + abcdn.c + Math.abs(lc-n)*abcdn.d);
		res = Math.min(res, calc(abcdn, map, uc/5) + abcdn.c + Math.abs(uc-n)*abcdn.d);
		map.put(n, res);
		return res;
	}

}

class Abcdn  {
	long n;
	long a;
	long b;
	long c;
	long d;

	public Abcdn(long n, long a, long b, long c, long d) {
		this.n = n;
		this.a = a;
		this.b = b;
		this.c = c;
		this.d = d;
	}
}



Measured memory_bytes: 56080
#include <stdio.h>
#include <string.h>
int main(void){
    int n;
    scanf("%d", &n);
    int rate[9+5];
    for(int i=0; i<9; i++)rate[i]=0;
    
    for(int i=0; i<n; i++){
        int a;
        scanf("%d", &a);
        if(a<400)rate[0]=1;
        else if(a<800)rate[1]=1;
        else if(a<1200)rate[2]=1;
        else if(a<1600)rate[3]=1;
        else if(a<2000)rate[4]=1;
        else if(a<2400)rate[5]=1;
        else if(a<2800)rate[6]=1;
        else if(a<3200)rate[7]=1;
        else rate[8]+=1;
    }
    
    int min=0;
    for(int i=0; i<8; i++)min+=rate[i];
    
    if(min==0){
        min++;
        rate[8]--;
    }
    printf("%d %d\n", min, min+rate[8]);
    
    return 0;
}


Measured memory_bytes: 1676
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    for(int i = 0; i < n; i++){
        cin >> x[i];
        y[i] = x[i];
    }
    sort(x.begin(), x.end());
    for(int i = 0; i < n; i++){
        auto itr = lower_bound(x.begin(), x.end(), y[i]);
        //cout << "y: " << y[i] << endl;
        //cout << "itr: " << itr-x.begin() << endl;
        if(itr-x.begin() < n/2){
            if(itr-x.begin() == n/2){
                cout << x[n/2-1] << endl;
            }else{
                cout << x[n/2] << endl;
            }
        }else{
            cout << x[n/2-1] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4836
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    vector<ll> A(N);

    rep(i,N) cin>>A[i];

    ll M0=0;

    rep(i,N){
        if(i%2 ==  0){
            M0+=A[i];
        }else{
            M0-=A[i];
        }
    }
    cout<<M0<<" ";
    ll M = M0;
    rep(i,N-1){
        M = 2*A[i]-M;
        cout<<M<<" ";
    }
    cout<<endl;

    return 0;
    

}

Measured memory_bytes: 4044
#include <bits/stdc++.h>
#include <bitset>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>N>>M;
    ll pa = -1, nm = N + M - 1;
    mat G(N, vec(0));
    vec num_in(N, 0), ans(N,0);
    rep(i,nm){
        cin>>A>>B;
        --A, --B;
        G[A].push_back(B);
        ++num_in[B];
    }
    rep(i,N) if(num_in[i] == 0) pa = i;
    queue<ll> que;
    que.push(pa);
    ans[pa] = -1;
    while(!que.empty()){
        ll v = que.front();
        que.pop();
        for(ll to : G[v]){
            --num_in[to];
            if(num_in[to] == 0){
                ans[to] = v;
                que.push(to);
            }
        }
    }
    rep(i,N) cout<<ans[i] + 1<<endl;
}

Measured memory_bytes: 7808
N = int(input())
A =  list(map(int, input().split())) 

s_count = 0
i = 0

while i < N:

    min_j = i
    j = i

    while j < N:

        if A[j] < A[min_j]:

            min_j = j

        j += 1

    A[i], A[min_j] = A[min_j], A[i]

    if i != min_j :
        s_count += 1

    i += 1

s = ''

for x in A:

    s = s + str(x) + ' '

print(s.rstrip())
print(s_count)



Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-14;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n, x; cin >> n >> x;
    if (x == 1 || x == 2 * n - 1)cout << "No\n";
    else {
        cout << "Yes\n";
        deque<int> ans = { 1,x,2 * n - 1 };
        bool f = false;
        eFOR(i, 2, 2 * n - 2) {
            if (i == x)continue;
            if (f)ans.push_front(i);
            else ans.push_back(i);
            f ^= true;
        }
        FOR(i, 0, 2 * n - 1)cout << ans[i] << "\n";
    }
}


Measured memory_bytes: 2304
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const ll MOD = 1000000007;
// const int INF = 2000000000;

int gcd(int a, int b) {
  if (a < b) {
    return gcd(b, a);
  }

  while (a % b != 0) {
    int tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}

int N;
vector<int> A;
vector<int> cum_A;
vector<int> cum_rev_A;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  A.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  cum_A.resize(N, 0);
  cum_A[0] = A[0];
  for (int i = 1; i < N; i++) {
    cum_A[i] = gcd(cum_A[i - 1], A[i]);
  }
  cum_rev_A.resize(N, 0);
  cum_rev_A[0] = A[N - 1];
  for (int i = 1; i < N; i++) {
    cum_rev_A[i] = gcd(cum_rev_A[i - 1], A[N - i - 1]);
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (i == 0) {
      ans = max(ans, cum_rev_A[N - 2]);
    } else if (i == N - 1) {
      ans = max(ans, cum_A[N - 2]);
    } else {
      ans = max(ans, gcd(cum_A[i - 1], cum_rev_A[N - i - 2]));
    }
  }

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

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
#define ll long long

int main(void){
    int N,K;
    string S;
    cin>>N>>K>>S;
    vector<char> Str(N);
    for(int i=0;i<N;i++) {
        Str.at(i)=S.at(i);
        if(i+1==K && S.at(i)=='A') Str.at(i)='a';
        else if(i+1==K && S.at(i)=='B') Str.at(i)='b';
            else if(i+1==K && S.at(i)=='C') Str.at(i)='c';
                cout<<Str.at(i);
            }
    cout<<endl;
}


Measured memory_bytes: 256
def main():
    H,W,K = map(int, input().split())
    table = [list(input()) for _ in range(H)]

    res = [[0] * W for _ in range(H)]

    cnt = 0
    for h in range(H):
        line_flg = False
        for w in range(W):
            c = table[h][w]
            if c == "#":
                cnt += 1
                line_flg = True
            if line_flg:
                res[h][w] = cnt

    for h in range(H):
        for w in list(range(W-1))[::-1]:
            if res[h][w] == 0:
                res[h][w] = res[h][w+1]

    for h in range(1,H):
        for w in range(W):
            if res[h][w] == 0:
                res[h][w] = res[h-1][w]

    for h in list(range(H-1))[::-1]:
        for w in range(W):
            if res[h][w] == 0:
                res[h][w] = res[h+1][w]

    for l in res:
        print(*l)
if __name__ == "__main__":
    main()

Measured memory_bytes: 13376
N,M,X,Y=(int(i) for i in input().split())
xlist=[int(i) for i in input().split()]
ylist=[int(i)for i in input().split()]
xmax=max(xlist)
ymin=min(ylist)
if xmax<ymin:
  if xmax<Y and X<ymin:
    print('No War')
  else:
    print('War')
else:
  print('War')

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;

int f(int x){
  int c = 0;
  while (x >0){
    c += x%10;
    x /= 10;
  }
  return c;
}

int main(){
  int n, a, b;
  cin >> n >> a >> b;
  int ans = 0;
  rep(i, n+1){
    int y = f(i);
    if (a <= y && y <= b) ans += i;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int Check(int N, int K, int D[K]){
  int i, c;
  while(N != 0){
    c = N % 10;
    for(i = 0;i < K;i++) if(c == D[i]) return 1;
    N /= 10;
  }
  return 0;
}

void Do(int N, int K){
  int i;
  int D[K];
  for(i = 0;i < K;i++) scanf("%d", &D[i]);
  while(1){
    if(Check(N, K, D) == 0){
      printf("%d\n", N);
      return;
    }
    N++;
  }
}

int main(void){
  int N, K;
  scanf("%d %d", &N, &K);
  Do(N, K);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int ans = 0;
  if (a == b && b == c) {
    ans = 1;
  }
  else if (a != b && b != c && c != a) {
    ans = 3;
  }
  else {
    ans = 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int n;
  bool success;

  cin >> n;
  while(n--){
    success = false;
    int b = 0, c = 0;
    int a[10];
    for(int i=0; i<10; i++){
      cin >> a[i];
    }

    for(int i=0; i<10; i++){ 
      if(b < a[i] && c < a[i]){
        if(b < c)
          c = a[i];
        else
          b = a[i];
      }
      else if(b < a[i]){
          b = a[i];
      }
      else if(c < a[i]){
          c = a[i];
      }
      else{
        success = false;
        break;
      }

      if(i == 9)
        success = true;
    }

    if(success)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}

Measured memory_bytes: 1152
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>

#define P pair<int, int>

using namespace std;

int main(){
  int n, a, b, check[109];
  memset(check, 0 , sizeof(check));
  cin >> n;
  vector<P> v1, v2;
  for(int i=0;i<n;i++){
    cin >> a >> b;
    v1.push_back(P(a,b));
  }
  for(int i=0;i<n;i++){
    cin >> a >> b;
    v2.push_back(P(a,b));
  }
  sort(v1.begin(), v1.end());
  sort(v2.begin(), v2.end());
  int cnt=0;
  for(int j=0;j<n;j++){
    int mxi=-1, mx=-1;
    for(int i=0;i<n;i++){
      if(check[i]==0 && v1[i].first<v2[j].first && v1[i].second<v2[j].second && mx<v1[i].second){
        mxi = i;
        mx = v1[i].second;
      }
    }
    if(mxi!=-1){
      check[mxi]=1;
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
using namespace std;
typedef pair<int,int> P;//Pでpair<-,->を表す。
typedef long long LL; 
LL MOD=1000000007;

int main()
{ 
    int n;
    cin>>n;
    LL A[n];
    LL s[60][2];
    for(int i=0;i<60;i++){
        s[i][0]=0;
        s[i][1]=0;
    }
    LL a=0;
    for(int i=0;i<n;i++){
        cin>>A[i];
        for(int j=0;j<60;j++){
            a=A[i]%2;
            if(a==0){s[j][0]++;}
            else{s[j][1]++;}
            A[i]=A[i]/2;
        }
    }
    LL S[60];
    for(int i=0;i<60;i++){
        S[i]=(s[i][0]*s[i][1])%MOD;
    }
    LL ans=0;
    LL k=1;
    for(int i=0;i<60;i++){
        ans=ans+S[i]*k;
        ans=ans%MOD;
        k=k*2;
        k=k%MOD;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> P(N);
    rep(i, N) {
        cin >> P[i];
    }
    sort(P.rbegin(), P.rend());
    int ans = 0;
    rep(i, N) {
        if (i == 0) ans += P[i]/2;
        else ans += P[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
const int mod = 1e9 + 7;
const int INF = 1e9;
using namespace std;
typedef long long ll;

int main()
{
    vector<int> a;
    for(int i = 0; i < 3; i++){
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }
    sort(a.begin(),a.end());
    for(int i = 0; i < 3; i++){
        cout << a[i];
        if(i < 2){
            cout << ' ';
        }
    }
    cout << endl;
}



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

int main (void){
  string s,t;
  cin >> s >> t;
  int y = 0;
  y = s.size();
  for(int i = 0;i < y;i++){
    if(s[i] !=t[i]){
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  return 0;
}

Measured memory_bytes: 3628