akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcorder_text
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            long n = long.Parse(input[0]);
            long k = long.Parse(input[1]);

            long[] Enemy = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            Array.Sort(Enemy);

            if (k >= n)
            {
                Console.Write(0);
            }
            else
            {
                long[] hp = new long[n - k];
                Array.Copy(Enemy, 0, hp, 0, n - k);

                long sum = hp.Sum();

                Console.Write(sum);
            }
            Console.Read();
        }
    }
}


Measured memory_bytes: 39168
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;
using static System.Console;

namespace B_ABC127
{
    class MainClass
    {

        static int[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            if(s[0]<=5){
                Console.WriteLine(0);
            }else if(s[0]>=13){
                Console.WriteLine(s[1]);
            }else{
                Console.WriteLine(s[1]/2);
            }
        }
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
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; }
typedef long long ll;
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; }

const ll MOD = 1e9+7;
string s;
vector< vector<ll> > dp(100100, vector<ll>(15, 0));

int main() {
    cin >> s;
    int slen = s.length();

    dp[0][0] = 1;
    for(int i = 0; i < slen; ++i) {
        if(s.at(i) == '?') {
            for(int k = 0; k < 10; ++k) {
                for(int j = 0; j < 13; ++j) {
                    dp[i+1][(j*10+k)%13] += dp[i][j];
                    dp[i+1][(j*10+k)%13] %= MOD;
                }
            }
        }else {
            int ch = (int)(s.at(i) - '0');
            for(int j = 0; j < 13; ++j) {
                dp[i+1][(j*10+ch)%13] += dp[i][j];
                dp[i+1][(j*10+ch)%13] %= MOD;
            }
        }
    }

    cout << dp[slen][5] << endl;
}

Measured memory_bytes: 15360
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

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

  int ans = 0;
  set<char> L;
  for (int i = 0; i < N - 1; i++) {
    L.emplace(S[i]);
    set<char> R, res;
    for (int j = i + 1; j < N; j++) {
      R.emplace(S[j]);
    }
    set_intersection(ALL(L), ALL(R), inserter(res, res.end()));
    ans = max(ans, static_cast<int>(res.size()));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		if (A + B > C + D)
			System.out.println("Left");
		else if (A + B == C + D)
			System.out.println("Balanced");
		else
			System.out.println("Right");
	}

}


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

#define f1 first
#define s2 second
#define pb push_back
#define ll long long

using namespace std;

long long n,t,a,b,dp[3005][3005][2];
pair<int,int>p[3005];

long long dpf(int i,int j,int k){
	if(dp[i][j][k]!=-1)return dp[i][j][k];
	if(i==n && j>=0){
		return 0;
	}
	if(j<0)return -9999999;
	if(!k){
		dp[i][j][k]=dpf(i+1,j,1)+p[i].s2;
	}
	dp[i][j][k]=max(dp[i][j][k],dpf(i+1,j,k));
	if(j-p[i].f1>=0)
		dp[i][j][k]=max(dp[i][j][k],dpf(i+1,j-p[i].f1,k)+p[i].s2);
	return dp[i][j][k];

}

int main(){
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	cin>>n>>t;
	for(int i=0;i<n;i++){
		cin>>a>>b;
		p[i]={a,b};
	}
	memset(dp,-1,sizeof(dp));
	cout<<dpf(0,t-1,0);
	return 0;
}

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

int main()
{
  int n, m, c, ans = 0;
  cin >> n >> m >> c;
  vector<int> b(m);
  vector<vector<int>> a(n, vector<int>(m));
  for (int i = 0; i < m; i++)
    cin >> b[i];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      cin >> a[i][j];
  for (int i = 0; i < n; i++)
    if (inner_product(begin(a[i]), end(a[i]), begin(b), c) > 0)
      ans++;
  cout << ans << endl;
}


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


int main()
{
    int n;
    string s;
    cin >> n;
    cin >> s;
    int ans = 0;
    for (int i = 0; i <= n - 3; i++) {
        if (s.substr(i, 3) == "ABC")
            ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
c=0
d=0
a=0
k=0
for i in range(n):
    s=input()
    if "AB" in s:
        c+=s.count("AB")
    if s[0]=="B" and s[len(s)-1]=="A":
        d+=1
    if s[0]=="B" and s[len(s)-1]!="A":
        a+=1
    if s[len(s)-1]=="A" and s[0]!="B":
        k+=1
if a+k==0:
    print(max(c+d-1,c))
elif a+k>0:
    print(c+min(d+a,d+k))
else:
    print(c+min(a,k))

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

int main(){
  int N,m,ans,i;
  ans=0;
  i=0;
  while(1){
    ans =0;
    cin >> N;
    for(int a=1;a<N;a++){
      m=0;
      for(i=a;i<N;i++){
	m+=i;
	if(m==N){
	  ans++;
	}
      }
    }
    if(N==0){
      break;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3052
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n,k;
vector<int> divs[100005];
bool c[100005];
ll euler[100005],suma,ans,s[100005];
ll pw(ll a, ll b)
{
    ll r=1;
    while(b)
    {
        if(b%2)
            r=(r*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return r;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>k;
    for(ll i=1;i<=k;i++)
        for(ll j=i;j<=k;j+=i)
            divs[j].push_back(i);
    for(ll i=2;i<=k;i++)
    {
        reverse(divs[i].begin(),divs[i].end());
        for(auto j:divs[i])
            s[j]=0;
        for(auto j:divs[i])
        {
            ll nr=i/j;
            ll rez=pw(nr,n);
            rez-=pw(nr-1,n);
            if(rez<0)
                rez+=mod;
            rez-=s[j];
            if(rez<0)
                rez+=mod;
            ans=(ans+(j*rez)%mod)%mod;
            for(auto l:divs[i])
                if(j%l==0)
                    s[l]=(s[l]+rez)%mod;
        }
    }
    cout<<(ans+1)%mod;
    return 0;
}


Measured memory_bytes: 14784
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,n) for(int i=(a); i<(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const ll mod = 1e9+7;
int N,M ;
vvi A;
vi seen;
int cnt;
void dfs(int x){
  seen[x] = 1;
  if(A[x].size() == 0) return;
  rep(i,A[x].size()){
    if(seen[A[x][i]]==0){
      cnt++;
      dfs(A[x][i]);
    }
  } 
  return;
}


int main(){
  cin >> N >> M;
  A.resize(N);
  rep(i,M){
    int a, b; cin >> a >> b;
    a--; b--;
    A[a].push_back(b);
    A[b].push_back(a);
  }
  seen.resize(N); rep(i,N) seen[i]=0;
  
  int ans = 0;
  rep(i,N){
    if(seen[i]==1) continue;
    cnt = 1;
    dfs(i);
    ans = max(ans, cnt);
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 21124
#include<bits/stdc++.h>
#include<atcoder/all>

typedef long long ll;

using namespace std;

int main(){
    ll n;
    cin >> n;
    vector<int> x2i(n), i2y(n);
    int a,b;
    for(int i = 0;i<n;++i){
        cin >> a >> b;
        x2i[n-a] = i;
        i2y[i] = b-1;
    }
    vector<int> ans(n, 0);

    int pre = 0, mx = 0;
    for(int x = 0; x < n;++x){
        int i = x2i[x];
        int y = i2y[i];
        mx = max(mx, y);
        if(mx == x){
            for(int p = pre; p <= x;++p){
                ans[x2i[p]] = x + 1 - pre;
            }
            pre = x + 1;
        }
    }
    for(auto x: ans)cout << x << endl;
}

Measured memory_bytes: 5648
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  string ans;
  for(int i=0;i<s.size();i++){
    if(i%2==0){
      ans+=s.at(i);
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <set>

#define rep(i,n)  for (int i = 0; i < (int)(n); i++)
#define INF 9999999999
#define PI 3.14159265359
using namespace std;

int main()
{
	int x,y;
	string ans="No";
	cin >> x>> y;
	if (y>=2*x && y<=4*x && y%2==0) ans="Yes";
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3124
#include<stdio.h>
int gcd(int a,int b){
  if(a==0)
    return b;
  else if(b==0)
    return a;
  int i;
  while(a!=0 && b!=0){
    i=b;
    b=a%b;
    a=i;
  }
  return a;
}

int main(){
  int n,i,max=0;
  scanf("%d",&n);
  int a[n+2],l[n+2],r[n+2];
  for(i=1;i<=n;i++)
    scanf("%d",&a[i]);
  l[0]=0;
  r[n+1]=0;
  for(i=0;i<n;i++){
    l[i+1]=gcd(l[i],a[i+1]);
    r[n-i]=gcd(r[n-i+1],a[n-i]);
  }
  for(i=0;i<n;i++)
    if(max<gcd(l[i],r[i+2]))
      max=gcd(l[i],r[i+2]);
  printf("%d\n",max);
  return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>

using namespace std;

//Nayeem Shahriar Joy,Applied Physics And Electronic Engineering,University of Rajshahi.


int main(){

 int a,b,c;

 cin>>a>>b>>c;

 if(a<b&&b<c)

 {
     cout<<"Yes"<<endl;
 }

 else

 {
     cout<<"No"<<endl;
 }

 return 0;

}

Measured memory_bytes: 3080
const s:array[0..9] of ansistring=('000','111','222','333','444','555','666',
'777','888','999');
var n,i,j:longint;
var ss:ansistring;
begin
  read(n);str(n,ss);
  if length(ss)<>4 then writeln('No');
  for i:=0 to 9 do if pos(s[i],ss)>0 then begin writeln('Yes');exit;end;
  writeln('No');
end.

Measured memory_bytes: 128
#include <stdio.h>
int main(){
  int n, q, i, j, cnt = 0;
  scanf("%d", &n);
  int s[n];
  for(i = 0; i < n; i++)
    scanf("%d", &s[i]);
  scanf("%d", &q);
  int t[q];
  for(i = 0; i < q; i++){
    scanf("%d", &t[i]);
    for(j = 0; j < n; j++)
      if(t[i] == s[j]){
	cnt++;
	break;
      }
  }
  printf("%d\n", cnt);
  return 0;
}

Measured memory_bytes: 636
#include<stdio.h>
int main(){
    double a,b,c,d,e,f,x,y;
    while (scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f) != EOF)
    {
        y = (c * d - a * f) / (b * d - e * a);
        x = (c - (b * y)) / a;
        printf("%.3lf %.3lf\n",x,y);
    }
    return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
using namespace std;
int main (){
	int n,ti,mi;
	mi=10000;
	cin>>n>>ti;
	int c[n],t[n];
	for(int i=0;i<n;i++){
		cin>>c[i]>>t[i];
	}
	for(int j=0;j<n;j++){
		if(ti>=t[j]){
			mi=min(mi,c[j]);
		}
	}
	if(mi==10000){
		cout<<"TLE"<<endl;
	}
	else{
		cout<<mi<<endl;
	}
}
	


Measured memory_bytes: 256
#include <iostream>
#include <vector>
int main(int argc, char** argv)
{
    int N;
    std::cin >> N;

    std::vector<int> F(N);
    for (int i = 0; i < N; i++) {
        std::cin >> F[i];
    }

    bool ret = true;
    int pre = F[N-1];
    for (int i = N-2; i >= 0; i--) {
        int cur = F[i];
        if (pre < cur) {
            cur--;
        }

        if (pre < cur) {
            ret = false;
            break;
        }
        pre = cur;
    }

    std::cout << ((ret) ? "Yes" : "No") << std::endl;

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define RREP(i, n) for(int i=0; i>(int)(n); i--)
#define ALL(v) v.begin(), v.end()
#define INF 2e9
typedef long long ll;
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(a>b){a=b; return 1;}return 0;}

using namespace std;

int dpA[100001], dpB[100001], dpC[100001];
int main(void){
	int N;
	int a[100001], b[100001], c[100001];
	cin >> N;
	REP(i, N){
		cin >> a[i] >> b[i] >> c[i];
	}
	dpA[0] = a[0];
	dpB[0] = b[0];
	dpC[0] = c[0];
	REP(i, N-1){
		dpA[i+1] = max(dpB[i], dpC[i])+a[i+1];
		dpB[i+1] = max(dpC[i], dpA[i])+b[i+1];
		dpC[i+1] = max(dpA[i], dpB[i])+c[i+1];
	}
	int dp = max(max(dpA[N-1], dpB[N-1]),max(dpA[N-1], dpC[N-1]));
	cout << dp << "\n";
	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1e+9 + 7;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

using ld = long double;

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

    ld L;
    cin >> L;
    ld ans = L / 3;
    ans = ans * ans * ans;
    cout << fixed << setprecision(10);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

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

ll N, K;

const ll MAXN = 5000;
ll P[MAXN];
ll C[MAXN];

ll Score[MAXN];
ll Step[MAXN];

ll solve(ll startIndex)
{
    fill(Step, Step + N, -1);

    ll res = C[startIndex];

    ll score = 0;
    ll index = startIndex;

    ll k = 0;

    while (Step[index] == -1)
    {
        Step[index] = k;
        Score[index] = score;

        const auto nextIndex = P[index];
        index = nextIndex;
        score += C[nextIndex];

        res = max(res, score);
        ++k;
        if (k == K) { return res; }
    }

    const auto dscore = score - Score[index];
    const auto dstep  = k - Step[index];

    const auto dk = ((K - k) / dstep) - 1;

    if (dk > 0)
    {
        if (dscore >= 0) { score += dscore * dk; }
        k += dk * dstep;

        res = max(res, score);
    }

    while (k < K)
    {
        index = P[index];
        score += C[index];

        ++k;

        res = max(res, score);
    }

    return res;
}


int main()
{
    cin >> N >> K;
    rep (i, N) { cin >> P[i]; --P[i]; }
    rep (i, N) { cin >> C[i]; }

    ll ans = 0;

    rep (i, N)
    {
        const auto res = solve(i);
        ans = i == 0 ? res : max(ans, res);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    string S;
    cin >> S;
    int sum = 700;
    if (S[0] == 'o') sum += 100;
    if (S[1] == 'o') sum += 100;
    if (S[2] == 'o') sum += 100;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()

def solve():
    N, M = map(int, input().split())
    A = [None] * N
    for i in range(N):
        A[i] = list(map(int, line_input()))
    pointer = [0] * N
    used = set()
    minmax = 500
    for m in range(M):
        num_people = [0] * M
        maxgather = (0, 0)
        for n in range(N):
            num_people[A[n][pointer[n]] - 1] += 1
            if num_people[A[n][pointer[n]] - 1] > maxgather[0]:
                maxgather = (num_people[A[n][pointer[n]] - 1], A[n][pointer[n]])
        used |= {maxgather[1]}
        minmax = min(minmax, maxgather[0])
        for n in range(N):
            while pointer[n] < M:
                if A[n][pointer[n]] in used:
                    pointer[n] += 1
                else: break
    print(minmax)
    return 0
  
if __name__ == "__main__":
    solve()

Measured memory_bytes: 4312
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{

	public static void main(String[] arg) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str = br.readLine().split(" ");

		double a = Double.parseDouble(str[0]);
		double b = Double.parseDouble(str[1]);

		double rad = Math.toRadians(Double.parseDouble(str[2]) );

		double cx = b * Math.cos(rad) * (-1) + a;
		double cy = b * Math.sin(rad);

		double sq = (a*cy) / 2;
		double len = Math.sqrt(cx*cx + cy*cy) + a + b;

		System.out.printf("%.5f %.5f %.5f\n",sq ,len ,cy);
	}
}

Measured memory_bytes: 24736
#include <stdio.h>

#define N 100000
char vS[N+3], vT[N+3];
short K = 'A' - 1;

int main(void){
    int i, q;char c1, c2;
    gets(vS + 1);
    vS[0] = 0; i = 1; while(vS[i] != '\0') {vS[i] = (vS[i] - K + vS[i-1]) % 3; i++;}
    gets(vT + 1);
    vT[0] = 0; i = 1; while(vT[i] != '\0') {vT[i] = (vT[i] - K + vT[i-1]) % 3; i++;}
    scanf("%d", &q);
    while(q--){
        int a, b, c, d; scanf("%d%d%d%d", &a, &b, &c, &d); a--; c--;
        c1 = (vS[b] - vS[a] + 3) % 3;
        c2 = (vT[d] - vT[c] + 3) % 3;
        puts(c1 == c2 ? "YES" : "NO");
    }
    return 0;
}

Measured memory_bytes: 640
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
  let n:usize = read();
  let k:usize = read();
  let mut v = vec![0; n+1];
  for _ in 0..n {
    v[read::<usize>()] += 1;
  }
  v.retain(|&x| x != 0);
  v.sort();
  
  if v.len() <= k {
    println!("0");
    return
  }

  let mut cnt = 0;
  for i in 0..v.len()-k {
    cnt += v[i];
  }
  println!("{}", cnt);
}

Measured memory_bytes: 2872
#include <cstdio>
#include <cstdlib>


long long a[10];

int cmp (const void *p1, const void *p2) {
  if (* (long long *)p1 > * (long long *)p2) return 1;
  if (* (long long *)p1 == * (long long *) p2) return 0;
  return -1;
}

int main () {
  int i;
  for (i = 0; i < 10; i++) {
    scanf("%lld", a + i);
  }
  qsort(a, 10, sizeof(long long),  cmp);
  for (i = 0; i < 3; i++) {
    printf("%lld\n", a[9-i]);
  }
  return 0;
}

Measured memory_bytes: 1032
#include <iostream>

using namespace std;

int main(){
    int n,k;
    cin >> n >> k;
    unsigned long long count = 0;
    //mod k = k/2 or mod k = 0
    if(k % 2 == 0){
        unsigned long long oddnum = 0;
        if ( n < k / 2){
            oddnum = 0;
        } else {
            oddnum = (n - (k / 2)) / k + 1;
        }
        //cout << oddnum << endl;
        count += oddnum * oddnum * oddnum;
    }
    unsigned long long evennum = n / k;
    count += evennum * evennum * evennum;

    cout << count << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long int lli;

int main() {
    int a;
    cin >> a;
    int temp = a % 1000;
    if (temp != 0) temp = 1000 - temp;
    cout << temp << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

ll gcd(ll a, ll b){
	return (b > 0)? gcd(b, a % b) : a ;
}
map< int64_t, ll > prime_factor(int64_t n) {
  map< int64_t, ll > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main(){
    ll a,b;
    cin >> a >> b;
    ll s = gcd(a,b);
    cout << prime_factor(s).size()+1 << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18L + 1;

void max_self(long long& a , long long b){
	a = max(a , b);
}

void min_self(long long& a , long long b){
	a = min(a , b);
}

int main(){
	ios::sync_with_stdio(0);
	cout << setprecision(10) << fixed;
	int n , w;
	cin >> n >> w;
	long long sum = 0ll;
	vector<long long> weight(n);
	vector<int> val(n);
	for (int i = 0; i < n; i++){
		cin >> weight[i] >> val[i];
		sum += val[i];
	}
	vector<long long> dp(sum + 1 , INF);
	dp[0] = 0ll;
	for (int i = 0; i < n; i++){
		for (int j = sum - val[i]; j >= 0; --j){
			min_self(dp[j + val[i]] , dp[j] + weight[i]);
		}
	}
	long long ans = 0ll;
	for (int i = 0; i <= sum; i++){
		if (dp[i] <= w){
			max_self(ans , i);
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 1024
using System;

namespace ITP1_2_B
{
  class Program
  {
    static void Main(string[] args)
    {
      var input = Console.ReadLine();
      string[] line = input.Split(' ');
      if (int.Parse(line[0]) < int.Parse(line[1]) && int.Parse(line[1]) < int.Parse(line[2]))
      {
        Console.WriteLine("Yes");
      }
      else
      {
        Console.WriteLine("No");
      }

    }
  }
}



Measured memory_bytes: 15940
#include <bits/stdc++.h>
#define rep1(i,s,e,c) for(int i=s;i<e;i=i+c)
#define rep2(i,s,e,c) for(int i=s;i<=e;i=i+c)
#define rep3(i,e,s,c) for(int i=e;i>=s;i=i-c)
using namespace std;
typedef long long ll;
const int MAX=1e5+1;
const int MOD=1e9+7;
struct node{
	int B,C;
	bool operator<(const node& temp) const{
		return this->C<temp.C;
	}
}no;
int arr[MAX]={0};
vector<node> v;
int main()
{    
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++){
    	scanf("%d",&arr[i]);
	}
	sort(arr,arr+n);
	for(int i=1;i<=m;i++){
		int B,C;
		scanf("%d%d",&no.B,&no.C);
		v.push_back(no);
	}
	sort(v.begin(),v.end());
	int k=v.size()-1;
	long long sum=0;
	for(int i=0;i<n;i++){
		if(arr[i]<v[k].C && k>=0){
			arr[i]=v[k].C;
			v[k].B--;
			if(v[k].B==0) k--;
		}
    	sum+=arr[i];
	}
	cout<<sum<<"\n";
    return 0;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005,INF=1<<30;

int main(){
    
    string S;cin>>S;
    bool ok=true;
    for(int i=0;i<S.size();i++){
        if(S[i]=='L'&&i%2==0) ok=false;
        if(S[i]=='R'&&i%2==1) ok=false;
    }
    
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}



Measured memory_bytes: 256
#include <stdio.h>
int main() {
  int K,A,B;
  scanf("%d\n", &K);
  scanf("%d %d\n", &A, &B);
  
  if(K < A && (2*K > B) ){
    
          printf("NG");
    
  }else if(K > B ){
    
    printf("NG");
    
  }else{
      printf("OK");
  }
  return 0;
}

Measured memory_bytes: 1728
n, m, k = map(int, input().split())
if k % n == 0 or k % m == 0:
    print('Yes')
    exit()
for i in range(n):
    for j in range(m):
        if m*i + n*j - i*j*2 == k:
            print('Yes')
            exit()
print('No')


Measured memory_bytes: 3064
# ARC078C - Splitting Pile (ABC067C)
from itertools import accumulate


def main():
    N, *A = map(int, open(0).read().split())
    A = list(accumulate(A))
    total = A[-1]
    ans = min(abs(total - i * 2) for i in A[:-1])
    print(ans)


if __name__ == "__main__":
    main()


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

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

using namespace std;

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

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

const double PI11 = 3.14159265359;

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

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

map<int, int> dictionary;

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

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

	cin >> m;

	for (int i = 0; i < m; i++) {
		int t;
		cin >> t;
		dictionary[t]--;
	}

	for (auto difficulty : dictionary) {
		if (difficulty.second < 0) {
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;

	return 0;
}


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

#define REP(i,a,b)	for (int i = (a); i < (b); i++)
#define FOR(i,n)	REP (i, 0, n)

int main(void)
{
  int n, y;
  cin >> n >> y;

  int res[3] = {-1,-1,-1};
  for(int i = 0; i <= n; i++)
  {
    for (int j = 0; i+j <= n; j++)
    {
      int k = n - i - j;
      if (i+j+k == n && i*10000 + j*5000 + k*1000 == y)
      {
        res[0] = i;
        res[1] = j;
        res[2] = k;
      }
    }
  }
  cout << res[0] << " " << res[1] << " " << res[2] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    int money[a];
    
    for(int i=0;i<a;i++){
        cin >> money[i];
    }
    int max =0;
    for(int i=0;i<a;i++){
        if(max <=money[i]){
            max = money[i];
        }
    }
    int sum =0;
    int min =max;
    for(int i=0;i<b;i++){
        for(int j = 0; j < a;j++){
            if(min >=money[j]){
                min = money[j];
            }
        }
        sum += min;
        for(int j = 0; j < a;j++){
            if(min == money[j]){
                //cout << money[j];
                
                money[j] = max;
                //cout << money[j];
                min = max;
                break;
            }
        }
        
    }
    
    cout << sum;
    
}

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

class Program {
    static void Main (string[] args) {
        long NN = long.Parse (Console.ReadLine ());

        long dig = 1;
        long output = 1;


        for (long i = 0; i < NN ; i++) { //10^10超えてからが本番
            long s = sn(output);//
            if (s*dig < output){
                output += 9 * dig;
                dig*=10;
                i--;
            }else{
                Console.WriteLine (output);
                output += dig;
            }
        }
    }

    static long sn(long NN) {
        long s = 0;
        double f = Math.Log10(((double)NN) ) + 1;
        for (int i = 0; i < f; i++) {
            s += NN % 10;
            NN /= 10;
        }
        return s;
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, n) FOR(i, 0, n - 1)
typedef long long ll;
const int INF = 1e9 + 7;
using namespace std;

int main(){
    ll H; cin >> H;
    int cnt=0;
    while(pow(2,cnt)<=H){
        cnt++;
    }
    cnt--;
    
    ll ans=0;
    while(1){
        if (cnt==0){
            ans+=1;
            break;
        }
        else{
            ans+=pow(2,cnt);
            cnt--;
        }
    }
    cout << ans;
}

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

string str;
int main() {
    int s = 0, t = 0;
    cin >> str;
    int len = str.length();
    for (int i = 0; i < len; i++) {
        if (str[i] == 'S') s++;
        else s > 0 ? s-- : t++;
    }
    cout << t + s << endl;
    return 0;
}


Measured memory_bytes: 3668
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>

using namespace std;

int main(void){
	string a;

	cin >> a;

	if (a[0] == a[1] && a[1] == a[2])
		cout << "Yes" << endl;
	else if (a[3] == a[1] && a[1] == a[2])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}	


Measured memory_bytes: 256
use std::cmp::max;
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (n, x) = scan!(usize, i64);
    let mut vs = scan!(i64;;);

    let mut ans = 0;
    for i in 1..vs.len() {
        let sum = vs[i - 1] + vs[i];
        if x < sum {
            let diff = sum - x;
            ans += diff;
            vs[i] = max(vs[i] - diff, 0);
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 8444
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#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 out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    int ans = 0;
    FOR(i,1,n+1){
        auto p = prime_factor(i);
        int number = 1;
        for(auto x:p) number*=(x.second+1);
        if(number==8)ans++;
        i++;
    }
    out(ans);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  string S;
  cin>>S;
  
  
  int odd=0;
  int even=0;
  
  for(int i=0;i<S.size();i++){
    if(i%2==0){
      if(S[i]=='R'||S[i]=='U'||S[i]=='D'){
        even++;
      }
    }
    else{
      if(S[i]=='L'||S[i]=='U'||S[i]=='D'){
        odd++;
      }
    }
  }
  
  if(S.size()%2==0){
    if(even==S.size()/2&&odd==even){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
  }
  else{
    if(even==S.size()/2+1&&even==odd+1){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
  }
}

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

int main() {
  
  int a,b;
  cin >> a >> b;
  
  if(a%2==1 && b%2==1){
   cout << "Odd" << endl; 
  }
  
  else{
   cout << "Even" << endl; 
  }
  
}


Measured memory_bytes: 256
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

pub fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}
pub fn lcm(a: u64, b: u64) -> u64 {
    a / gcd(a, b) * b
}

fn main() {
    input! {
        a: u64,
        b: u64,
    }
    println!("{}", lcm(a,b));
}
/* vim:set foldmethod=marker: */


Measured memory_bytes: 4352
n, k, q  = list(map(int, input().split()))
#x = list(map(int, input().split()))
a = []
for i in range(q):
    a.append(int(input()))

point = [0]*n
for i in range(q):
    point[a[i]-1] += 1

for i in range(n):
    if k-(q-point[i]) > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 8592
import sys
def oncount(x):
    r=0
    while x>0:
        r+=x&1
        x=x>>1
    return r

dp=[[0]*331 for i in range(1024)]
for i in range(10):
    dp[1<<i][i]=1
for i in range(1024):
    for j in range(331):
        t=oncount(i)
        for k in range(10):
            if 1&(i>>k):
                x=j-t*k
                if x>=0: dp[i][j]+=dp[i&~(1<<k)][x]
                
for a in sys.stdin:
    n,s=map(int,a.split())
    ans=0
    if s<=330:
        for i in range(1024):
            if oncount(i)==n:ans+=dp[i][s]
    print ans

Measured memory_bytes: 9004
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

struct node{int l,r,key;};
node t[500001];
int sz;
vector<int> preord,inord;
void dfs(int vi){
    preord.pb(t[vi].key);
    if(t[vi].l!=-1)dfs(t[vi].l);
    inord.pb(t[vi].key);
    if(t[vi].r!=-1)dfs(t[vi].r);
 
}
int main(){
    int n,k;
    cin>>n;
    string s;
    rep(i,n){
        cin>>s;
        if(s[0]=='i'){
            cin>>k;
            int cur=0;
            while(cur<sz){
                if(k>t[cur].key){
                    if(t[cur].r!=-1) cur=t[cur].r;
                    else{
                        t[cur].r=sz;break;
                    }
                }
                else{
                    if(t[cur].l!=-1) cur=t[cur].l;
                    else{
                        t[cur].l=sz;break;
                    }
                }
            }
            t[sz].l=t[sz].r=-1;
            t[sz].key=k;++sz;
        }
        else{
            preord.clear(),inord.clear();
            dfs(0);
            int m=inord.size();
            rep(i,m) cout<<" "<<inord[i];
            cout<<endl;
            rep(i,m) cout<<" "<<preord[i];
            cout<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 12848
n=gets.to_i

def func(a, b)
    [a.to_s.size, b.to_s.size].max
end

mi=11
n.times do |a|
    a+=1
    if a*a>n
        break
    end
    if n%a!=0
        next
    end
    mi=[mi, func(a, n/a)].min
end

puts mi

Measured memory_bytes: 3836
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9

typedef long long ll;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
ll Max(ll a, ll b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main(){
	int n,m;
	scanf("%d%d", &n,&m);
	PRINTD(n-m+1);
}

Measured memory_bytes: 128
#include <iostream>
#define N_MAX 100000
using namespace std;

long long gcd(long long a, long long b) {
	if (a < 0) a = -a;
	if (b < 0) b = -b;
	while (a != 0) {
		long long tmp = b % a;
		b = a;
		a = tmp;
	}
	return b;
}

int main() {
	int n;
	cin >> n;
	int a[N_MAX+1];
	for (int i = 1; i <= n; i++) cin >> a[i];
	int L[N_MAX+2], R[N_MAX+2];
	L[0] = 0; R[n+1] = 0;
	for (int i = 1; i <= n; i++) {
		L[i] = gcd(L[i-1], a[i]);
	}
	for (int i = n; i >= 1; i--) {
		R[i] = gcd(R[i+1], a[i]);
	}
	int ans = 0;
	for(int i = 1; i <= n; i++) {
		int now = gcd(L[i-1], R[i+1]);
		ans = max(ans, now);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
 
using namespace __gnu_pbds;
using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

template<typename has_less>
using ordered_set =
tree<has_less,
	null_type,
	less<has_less>,
	rb_tree_tag,
	tree_order_statistics_node_update>;
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define F first
#define S second
#define ALL(v) v.begin(),v.end()
#define fast_cin() ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define lc (sidx * 2)
#define rc (lc + 1)

typedef long long ll;
typedef long double ld;
typedef pair <ll,ll> pll;
typedef pair <int,int> pii;

#define TRACE
#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

bool bit(int n, int i) { return (n >> i) & 1; }
int ceil(int a, int b) { return ceil(((ld)a) / b); }

int faltu;

const int mod = 1e9+7;
const ll inf = 5e18;
const int N = 2e5 + 100;

ll n, m, q, cw, ans;

int main()
{
	fast_cin();
	srand(time(0));

	string s;
	cin >> s;
	n = s.size();
	for(int i = 0; i < n; i++) {
		cw += (s[i] == 'W');
	}
	for(int i = 0; i < n; i++) {
		if(s[i] == 'W') {
			cw --;
		} else {
			ans += cw;
		}
	}
	cout << ans << endl;


	return 0;
}

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

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n, 0);
    for(ll i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end(), greater<ll>());
    vector<ll> leng(n, 0);
    ll tmp = 0;
    for(int j = 0; j < 2; j++){
        for(ll i = tmp; i < n - 1; i++){
            if(a[i] == a[i + 1]){
                leng[j] = a[i];
                tmp = i + 2;
                break;
            }
        }
    }
    cout << leng[0] * leng[1] << endl;
}

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

#define norm(X) ((X) * (X))

int a, b, h, m;

double hour;
double x_1, y_1;
double x_2, y_2;

int main() {
    cin >> a >> b >> h >> m;

    hour = h + m / 60.0;

    x_1 = a * sin(hour * M_PI / 6);
    y_1 = a * cos(hour * M_PI / 6);

    x_2 = b * sin(hour * 2 * M_PI);
    y_2 = b * cos(hour * 2 * M_PI);

    printf("%.*lf\n", 15, sqrt(norm(x_1 - x_2) + norm(y_1 - y_2)));
}


Measured memory_bytes: 4036
#include<stdio.h>
int main(void)
{
	printf("1x1=1\n1x2=2\n1x3=3\n1x4=4\n1x5=5\n1x6=6\n1x7=7\n1x8=8\n1x9=9\n2x1=2\n2x2=4\n2x3=6\n2x4=8\n2x5=10\n2x6=12\n2x7=14\n2x8=16\n2x9=18\n3x1=3\n3x2=6\n3x3=9\n3x4=12\n3x5=15\n3x6=18\n3x7=21\n3x8=24\n3x9=27\n4x1=4\n4x2=8\n4x3=12\n4x4=16\n4x5=20\n4x6=24\n4x7=28\n4x8=32\n4x9=36\n5x1=5\n5x2=10\n5x3=15\n5x4=20\n5x5=25\n5x6=30\n5x7=35\n5x8=40\n5x9=45\n6x1=6\n6x2=12\n6x3=18\n6x4=24\n6x5=30\n6x6=36\n6x7=42\n6x8=48\n6x9=54\n7x1=7\n7x2=14\n7x3=21\n7x4=28\n7x5=35\n7x6=42\n7x7=49\n7x8=56\n7x9=63\n8x1=8\n8x2=16\n8x3=24\n8x4=32\n8x5=40\n8x6=48\n8x7=56\n8x8=64\n8x9=72\n9x1=9\n9x2=18\n9x3=27\n9x4=36\n9x5=45\n9x6=54\n9x7=63\n9x8=72\n9x9=81\n");
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  int a[n];
  int q[n+1];
  for(int i=0; i<n; i++){
    cin >> a[i];
    q[a[i]] = i + 1;
  }
  for(int i=0; i<n; i++){
    cout << q[i+1] << " ";
  }
  cout << endl;
}

Measured memory_bytes: 1536
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

constexpr int64_t kMaxNumberOfTowns = 200000;

int64_t A[kMaxNumberOfTowns + 1];
int64_t visited_time[kMaxNumberOfTowns + 1];

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  int64_t number_of_towns, K;
  cin >> number_of_towns >> K;

  for (int64_t i = 1; i <= number_of_towns; ++i) {
    cin >> A[i];
  }

  constexpr int64_t kInitialTown = 1;
  int64_t offset = -1;
  int64_t cycle = -1;
  int64_t c_town = kInitialTown;
  for (int64_t i = 0; i <= number_of_towns; ++i) {
    visited_time[i] = -1;
  }
  visited_time[kInitialTown] = 0;
  for (int64_t i = 1; i <= number_of_towns + 1; ++i) {
    c_town = A[c_town];
    if (visited_time[c_town] >= 0) {
      cycle = i - visited_time[c_town];
      offset = visited_time[c_town];
      break;
    }
    visited_time[c_town] = i;
  }
  const int64_t modified_k = (K > offset) ? ((K - offset) % cycle) + offset : K;
  c_town = kInitialTown;
  for (int64_t i = 1; i <= modified_k; ++i) {
    c_town = A[c_town];
  }
  cout << c_town << endl;

  return 0;
}


Measured memory_bytes: 6780
n,m,x,y = map(int,input().split())
xx = list(map(int,input().split()))
yy = list(map(int,input().split()))
if x < y:
    for i in range(x+1, y+1):
        if max(xx) < i and min(yy) >= i:
            print("No War")
            exit()

print("War")

Measured memory_bytes: 38480
#include <stdio.h>
#include <string.h>
int main(void) {
    char t[11];
    int n,m,i,j,key=0;
    char u[256][11];
    scanf("%d\n",&n);
    for (i=0; i<n; i++) scanf(" %s",u[i]);
    scanf(" %d",&m);
    for (i=0; i<m; i++) {
        scanf(" %s",t);
        for (j=0; j<n; j++) {
            if (strcmp(t,u[j])==0) break;
        }
        if (j==n) {
            printf("Unknown %s\n",t);
        } else if (key==0) {
            key=1;
            printf("Opened by %s\n",t);
        } else {
            key=0;
            printf("Closed by %s\n",t);
        }
    }
    return 0;
}

Measured memory_bytes: 608
n,q=map(int,input().split())
s=input()

ac_num=0
ac_nums=[0]
for i in range(n-1):
    if s[i]=='A' and s[i+1]=='C':
        ac_num+=1
    ac_nums.append(ac_num)

for i in range(q):
    l,r=map(int,input().split())
    print(ac_nums[r-1]-ac_nums[l-1])


Measured memory_bytes: 6100
import java.util.Scanner;

public class Main{
    public static void main(String[]argc){
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String answer = "";
        int length = line.length();
        for(int i=0;i<length;i++){
            char ch = line.charAt(i);
            if(ch>='a'&&ch<='z'){
                ch = (char)(ch - 32);
            }else if(ch>='A'&&ch<='Z'){
                ch = (char)(ch + 32);
            }
            answer += ch;
        }
        System.out.println(answer);
    }
}



Measured memory_bytes: 31340