akhauriyash/Code-Regression huggingface dataset:
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 03/22/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

template <typename T, T MOD>
class modint {
 private:
  T val_;

 public:
  constexpr modint() : val_(0) {}
  constexpr modint(T v) : val_(v%MOD) {}
  constexpr modint& operator=(T v) { val_ = v%MOD; return *this; }

  constexpr T val() const { return val_; }
  constexpr modint operator+(modint x) const { return (val() + x.val())%MOD; }
  constexpr modint operator+=(modint x) { return *this = *this + x; }
  constexpr modint operator++() { return *this += 1; }
  constexpr modint operator++(int) { modint c = *this; ++(*this); return c; }
  constexpr modint operator-(modint x) const { return (val() + MOD - x.val())%MOD; }
  constexpr modint operator-=(modint x) { return *this = *this - x; }
  constexpr modint operator--() { return *this -= 1; }
  constexpr modint operator--(int) { modint c = *this; --(*this); return c; }
  constexpr modint operator*(modint x) const { return (val() * x.val())%MOD; }
  constexpr modint operator*=(modint x) { return *this = *this * x; }
  friend constexpr modint pow(modint x, T p) {
    modint t = 1;
    modint u = x;
    while (p) {
      if (p & 1)
        t *= u;
      u *= u;
      p >>= 1;
    }
    return t;
  }
  constexpr modint operator/(modint x) const { return *this * pow(modint{x}, MOD-2); }
  constexpr modint operator/=(modint x) { return *this = *this / x; }

  constexpr bool operator==(modint x) const { return val() == x.val(); }
  constexpr bool operator!=(modint x) const { return val() != x.val(); }
  constexpr bool operator<(modint x) const { return val() < x.val(); };
  constexpr bool operator<=(modint x) const { return val() <= x.val(); };
  constexpr bool operator>(modint x) const { return val() > x.val(); };
  constexpr bool operator>=(modint x) const { return val() >= x.val(); };

  friend std::ostream& operator<<(std::ostream& os, modint x) {
    return os << x.val();
  }
  friend std::istream& operator>>(std::istream& is, modint& x) {
    return is >> x.val_;
  }

};

constexpr ll MOD = 998244353;
using mint = modint<unsigned long long, MOD>;

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

  int N,S; cin>>N>>S;
  vector<ll> A(N); for(auto& a : A) cin>>a;

  mint ans = 0;
  vector<mint> dp(S+1);
  for (int i = 0; i < N; i++) {
    dp[0] = i+1;
    for (int s = S-A[i]; s >= 0; s--) {
      dp[s+A[i]] += dp[s];
    }
    ans += dp[S];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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; }

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

#define INF ((1LL<<62)-(1LL<<31))
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p) pom(a,p-2,p)

////////////////////////////////////////////////////////////////////////////////////////
int main(){
    ll n; cin >> n;
    ll a[n]; rep(i,0,n) cin >> a[i];

    ll s = 0, t = 0, res = 0;
    while(s < n){
        ll tmp = a[s]; //色を記憶
        while(t < n && tmp == a[t])
            t++;
        res += (t-s) / 2;
        s = t;
    }
    cout << res << ednl;

}


Measured memory_bytes: 256
N,M= map(int, input().split())
H = list(map(int, input().split()))
X = [list(map(int, input().split())) for i in range(M)]

A=[]

for i in range(M):
    if H[X[i][0]-1] != H[X[i][1]-1]:
        if H[X[i][0]-1] > H[X[i][1]-1]:
            A.append(X[i][1])
        else:
            A.append(X[i][0])
    else:
        A.append(X[i][0])
        A.append(X[i][1])
        
B = sorted(A)

def histogram_sorted(data):
    table = []
    prev = data[0]
    c = 1 
    for i in range(1,len(data)):
        if prev == data[i]:
            c=c+1
        else:
            table.append([prev,c])
            prev = data[i]
            c = 1
    table.append([prev,c])
    return table

C = histogram_sorted(B)

print(N-len(C))

Measured memory_bytes: 37760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
    int n;
    cin >> n;
    deque<ll> a(n + 1), b(n);
    rep(i, n + 1)
    {
        cin >> a[i];
    }
    rep(i, n)
    {
        cin >> b[i];
    }
    ll ans = 0;
    rep(i, n)
    {

        if (b[i] >= a[i])
        {
            ans += a[i];
            b[i] -= a[i];
            a[i] = 0;
        }
        else
        {
            ans += b[i];
            a[i] -= b[i];
            b[i] = 0;
        }
        if (b[i] >= a[i + 1])
        {
            ans += a[i + 1];
            b[i] -= a[i + 1];
            a[i + 1] = 0;
        }
        else
        {
            ans += b[i];
            a[i + 1] -= b[i];
            b[i] = 0;
        }
        // cout << a[i] << "," << b[i] << endl;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1920
{-# LANGUAGE FlexibleContexts #-}
import Control.Monad.ST
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as M

main :: IO ()
main = readLine >>= main'
    where
        main' [n, m] = readContents m >>= print . solve n m

solve :: Int -> Int -> [[Int]] -> Int
solve n m xys = V.length . V.filter snd $ V.create (initialize >>= calc (map (map pred) xys))
    where
        initialize :: ST s (M.STVector s (Int, Bool))
        initialize = M.replicate n (1, False) >>= edit
            where
                edit vs = vs <$ M.unsafeWrite vs 0 (1, True)

        calc ([x, y] : zs) vs = oldValues >>= check >> calc zs vs
            where
                oldValues = (,) <$> M.unsafeRead vs x <*> M.unsafeRead vs y
                check ((pxn, pxb), (pyn, pyb)) = M.unsafeWrite vs x (pxn - 1, xb) >> M.unsafeWrite vs y (pyn + 1, yb)
                    where
                        xb 
                            | pxn > 1 = pxb
                            | otherwise = False
                        yb = pxb || pyb
        calc _ vs = return vs

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 45692
def main():
    N,K = map(int,input().split())
    XY = [list(map(int,input().split())) for _ in [0]*N]
    iX = [0]*N
    iY = [0]*N
    for i,xy in enumerate(XY):
        x,y = xy
        iX[i] = x
        iY[i] = y
    iX.sort()
    iY.sort()
    X = {x:i for i,x in enumerate(iX)}
    Y = {y:i for i,y in enumerate(iY)}

    c = [[0]*(N+1) for i in [0]*(N+1)]
    for x,y in XY:
        c[Y[y]+1][X[x]+1] = 1

    for i in range(N):
        ci1 = c[i+1]
        for j in range(N):
            ci1[j+1] += ci1[j]
    for i in range(N):
        c[i+1] = [ci1j+cij for ci1j,cij in zip(c[i+1],c[i])]

    ans = 10**20
    for u in range(N):
        for d in range(u+K-1,N):
            l = 0
            r = K-1
            dY = iY[d]-iY[u]
            cd = c[d+1]
            cu = c[u]
            while r<N:
                if cd[r+1]+cu[l]-cu[r+1]-cd[l] >=K:
                    ans = min(ans, (iX[r] - iX[l])*dY)
                    l+=1
                else:r+=1

    print(ans)
main()

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <cmath>
using namespace std;

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

	vector <string> s(N);
	vector <int> t(N);
	for (int i = 0; i < N; i++) {
		cin >> s.at(i) >> t.at(i);
	}
	string X; cin >> X;

	bool sleep = false;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (sleep) {
			ans += t.at(i);
		}
		if (s.at(i) == X) sleep = true;
	}

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

Measured memory_bytes: 256
while s=gets
  i=s.chomp.to_i
  count=0
  if i>2000 then
    i=4000-i
  end

  1001.times{ |a|
    if a>i then
      break
    end
    1001.times{ |b|
      if a+b>i || i-a-b>2000 then
        break
      end
      if i-a-b>1000 then
        count+=(2001-(i-a-b))
      else
        count+=(i-a-b+1)
      end

    }
  }
  p count
end



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

namespace ARC078D_2 {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());
            List<int>[] graph = new List<int>[N];
            for (int i = 0; i < N; i++) {
                graph[i] = new List<int>();
            }
            for (int i = 0; i < N - 1; i++) {
                int[] input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
                graph[input[0] - 1].Add(input[1] - 1);
                graph[input[1] - 1].Add(input[0] - 1);
            }
            int[] bnums = Enumerable.Repeat(-1, N).ToArray();
            int[] wnums = Enumerable.Repeat(-1, N).ToArray();
            Queue<int> bqueue = new Queue<int>();
            Queue<int> wqueue = new Queue<int>();
            bnums[0] = 0;
            bqueue.Enqueue(0);
            wnums[N - 1] = 0;
            wqueue.Enqueue(N - 1);
            while (bqueue.Count != 0 || wqueue.Count != 0) {
                if (bqueue.Count != 0) {
                    int n = bqueue.Dequeue();
                    foreach (int i in graph[n]) {
                        if (bnums[i] == -1) {
                            bnums[i] = bnums[n] + 1;
                            bqueue.Enqueue(i);
                        }
                    }
                }
                if (wqueue.Count != 0) {
                    int n = wqueue.Dequeue();
                    foreach (int i in graph[n]) {
                        if (wnums[i] == -1) {
                            wnums[i] = wnums[n] + 1;
                            wqueue.Enqueue(i);
                        }
                    }
                }
            }
            int bcount = 0;
            int wcount = 0;
            for (int i = 0; i < N; i++){
                if(bnums[i] <= wnums[i]) {
                    bcount++;
                } else {
                    wcount++;
                }
            }
            bool ok = true;
            if (bcount <= wcount) {
                ok = false;
            }
            if (ok) {
                Console.WriteLine("Fennec");
            } else {
                Console.WriteLine("Snuke");
            }
        }
    }
}


Measured memory_bytes: 30544
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Numerics;
using System.Text;

namespace AtCoder.ABC
{
	class QuestionC
	{
		public static void Main(string[] args)
		{
            var s = Console.ReadLine();
            var n = int.Parse(s);

            var mod = 0L;

            for(int i = 0; i < n; i++) {
                mod *= 10;
                mod += 7;
                mod %= n;

                if(mod == 0) {
                    Console.WriteLine(i + 1);
                    return;
				}
			}

            Console.WriteLine(-1);
        }
    }
}


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

typedef long long ll;
 
int main(){
  int n;
  cin >> n;
  int ans=0;
  for(int i=0; i<n; i++){
    int l, r;
    cin >> l >> r;
    ans += r - l + 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO.Pipes;
using System.Linq;
using System.Runtime.InteropServices;

namespace Contest
{


    class Program
    {

        
        static void Main(string[] args)
        {
            var d = int.Parse(Console.ReadLine());
            var c = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[][] s = new int[d][];
            
            for(int i = 0; i < s.Length; i++)
            {
                s[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
            }

            int[] days = new int[26];

            for(int i = 0; i < d; i++)
            {
                // 最小の値で初期化
                var res = int.MinValue;
                var index = -1;
                for(int j = 0; j < s[i].Length; j++)
                {
                    // その日に一番満足度が大きくなるコンテストを探す
                    var happy = s[i][j] - (c[j] * (days[j] + 1));
                    if (res < happy)
                    {
                        res = happy;
                        index = j;
                    }
                }


                Console.WriteLine(index + 1);
                for(int j = 0; j < days.Length; j++)
                {
                    if (index == j) days[j] = 0;
                    else days[j]++;
                }

            }
        }
    }
}

Measured memory_bytes: 28868
n,m,l = gets.split(" ").map(&:to_i)
a_nm = Array.new(n).map{Array.new(m,0)}
b_ml = Array.new(m).map{Array.new(l,0)}
c_nl =Array.new(n).map{Array.new(l,0)}

for i in 0..n-1
   a_nm[i] = gets.split(" ").map(&:to_i)
end

for i in 0..m-1
   b_ml[i] = gets.split(" ").map(&:to_i)
end
for i in 0..n-1
    for j in 0..l-1
        #n????????????????¨????
        for k in 0..m-1
            c_nl[i][j] += a_nm[i][k] * b_ml[k][j]
        end
    end
end
c_nl.each{|x|
   puts  x.join(" ")
}

Measured memory_bytes: 9324
using System;
class Program
{
	static void Main()
	{
	string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
	int a = int.Parse(input[0]);
	int b = int.Parse(input[1]);
    int c = int.Parse(input[2]);
    int x = int.Parse(input[3]);
    int y = int.Parse(input[4]);
      
      long minCost = 0;

       for(int i = 0; i <= x+y; i++)//ABピザをいくつ買うか決める
       {
         long cost = 0;
         cost += 2*c*i;//ABピザの購入
         if(x-i>0) cost += a*(x-i);//Aピザの追加購入
         if(y-i>0) cost += b*(y-i);//Aピザの追加購入
         if(cost < minCost || minCost == 0) minCost = cost;//最小金額の更新確認
       }
      
     	 Console.WriteLine(minCost);
      
	}
}


Measured memory_bytes: 13140
import java.io.BufferedReader; 
import java.io.*;
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.util.*;
import java.math.*;
public class Main 
{ 
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader()
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next()
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine();
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
   public static void main(String args[]) throws Exception
    {
        FastReader sc=new FastReader();
        PrintWriter pw=new PrintWriter(System.out);
        int t=1;//sc.nextInt();
        while(t-->0)
        {
           int n=sc.nextInt();//tt=sc.nextInt(),s=sc.nextInt(),z=0;long ans=0
          long a[]=new long[n],sum=0;
          for(int i=0;i<n;i++)
           {a[i]=sc.nextLong();sum+=a[i];}
          List<Long> l=new ArrayList<>();
          long s=0;
          for(long w:a)
          {
              s+=w;
              l.add(sum-s);
          }sum=0;
          for(int i=0;i<n;i++)
          {
           sum+=((l.get(i)%1000000007)*(a[i]%1000000007))%1000000007;
          }
            pw.println(sum%1000000007);
        }
           pw.close();
    }
}
  


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

int main(){

   int N;
   cin >> N;
   vector<int> V(N);
   vector<int> C(N);

   for(int i=0;i<N;i++){
      cin >> V.at(i);
   }
    for(int i=0;i<N;i++){
      cin >> C.at(i);
   }

   int sum =0;

   for (int i = 0; i < N; i++)
   {
       int diff = V.at(i)-C.at(i);
       if(diff > 0){
           sum += diff;
       }
   }

   cout << sum << endl;

}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;cin >> n >> m;
    vector<pair<int,int>> c(n);
    for(int i=0;i<n;i++){
        int a,b;cin >> a >> b;
        c[i]={a,b};
    }
    sort(c.begin(),c.end());
    priority_queue<int> pq;
    int t=0;
    int ans=0;
    for(int i=1;i<=m;i++){
        while(c[t].first<=i){
            pq.push(c[t].second);
            t++;
        }
        if(!pq.empty()){
            ans+=pq.top();
            pq.pop();
        }
    }
    cout << ans << endl;
}

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

#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define rev(v) reverse(v.begin(), v.end());
#define mx(v) max_element(v.begin(), v.end());
#define mn(v) min_element(v.begin(), v.end()); 
#define fastio() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL));
//ffs = lsb, clz = l0's, ctz = r0's, popcount = 1's 
 //++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;
 //++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

signed main(){
	fastio();
	int x, a; cin >> x >> a;
	if(x < a) return cout << "0\n", 0;
	return cout << "10\n", 0;
	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define ALL(a) (a).begin(),(a).end()
#define EACH(e,v) for(auto& e:v)
#define SORT(v) sort(ALL(v))
#define PERM(v) SORT(v);for(bool c##p=1;c##p;c##p=next_permutation(ALL(v)))
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <class T> void chmax(T & a, T const & b) { if (b > a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = 1000'000'007;
 
signed main(){
    int N,K;
    cin>>N>>K;
    if(N==2){
        if(K>0)cout<<-1<<endl;
        else {
            cout<<1<<endl;
            cout<<1<<" "<<2<<endl;
        }
        return 0;
    }
    if(K<=(N-1)*(N-2)/2){
        int t=(N-1)*(N-2)/2 - K;
        int cen=(N+1)/2;

        int total=t+N-1;

        cout<<total<<endl;

        for(int i=1;i<cen;i++){
            cout<<i <<" "<<cen<<endl;
        }
        for(int j=cen+1;j<=N;j++)
        {
            cout<<j<<" "<<cen<<endl; 
        }

        if(t==0)return 0;

        for(int i=1;i<N;i++){
            for(int j=i+1;j<=N;j++){
                if(i==cen||j==cen)continue;
                cout<<i<<" "<<j<<endl;
                t--;
                if(t==0)return 0;
            }
        }
    }else{
        cout<<-1<<endl;
    }



 
}

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

#define REP(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define REPS(i, n) for (int i = (int)(1); i <= (int)(n); ++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 IREP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define IREPS(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVISORT(v) sort(v.begin(), v.end(), greater<int>());
#define ALL(v) v.begin(), v.end()

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using ll = long long;

typedef long long ll;

template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

const ll mod=1e9+7;
int main()
{
    cin.tie( 0 );
    ios::sync_with_stdio( false );
	
	int x,a;cin>>x>>a;
	int ans;
	if(x<a)ans=0;
	else ans=10;
	cout << ans<<endl;
	

    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main(){
   
   int ans;
   string s;
   cin >> s;

   for(int i = s.size() - 2; i >= 0; i -= 2){
      int flag = 1;
      for(int j = 0; j < i / 2; ++j){
         if(s[j] != s[i / 2 + j]) flag = 0;
      }
      if(flag == 1){
         ans = i;
         break;
      } 
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <queue>
#include <stack>
#include <string.h>
#include <list>
using namespace std;
typedef long long ll;
#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 EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
    int n, m, cx, cy;
    string res;
    cin >> n >> m >> cx >> cy;
    int x[n], y[m];
    rep(i,n) cin >> x[i];
    rep(i,m) cin >> y[i];
  
    sort(x,x+n); sort(y,y+m);
    int maxx, miny;
    maxx = x[n-1]; miny = y[0];
  
    if(cx < cy && maxx < miny && maxx < cy && miny > cx) res = "No War";
    else res = "War";
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>
#include <vector>
#include <map>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int mins = 1;
  int maxs = N;
  for (int i = 0; i < M; i++) {
	  int L, R;
	  cin >> L >> R;
	  mins = max(mins, L);
	  maxs = min(maxs, R);
	}
  cout << max(0, maxs - mins + 1) << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())

b = list(map(int, input().split())) + [10**5+1]

a = [0] * n
a[0] = b[0]
for i in range(n-1):
    if b[i] < b[i+1]:
        a[i+1] = b[i]
    else:
        a[i+1] = b[i+1]

print(sum(a))


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

// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

// type
using ll = int_fast64_t;
using ull = uint_fast64_t;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
//using pair<T1, T2> = p12;

//container
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
#define ALL(v) v.begin(),v.end()

//repetition
#define REP(n) for(int i=0; i<(n); i++)
#define REPj(n) for(int j=0; j<(n); j++)
#define REPinit(i,a,n) for(int i=(a); i<(n); i++)
#define REPinitj(j,a,n) for(int j=(a); j<(n); j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

//constant

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//Optimizer
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/* 
	add utility Algorithm
*/


int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string S, T;
    cin >> S >> T;

    if (S == T.substr(0, T.size() - 1)) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3660
while True:
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        break
    for i in range(h):
        if i == 0 or i == h - 1:
            print('#' * w)
        else:
            print('#' + '.' * (w - 2) + '#')
    print()


Measured memory_bytes: 5604
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
using namespace std;
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

vector<ll> h;
vector<ll> dp;

ll rec(int i) {
  if (dp[i] != INF) return dp[i];
  if (i == 0) return 0;

  ll res = INF;
  chmin(res, rec(i-1) + abs(h[i] - h[i-1]));
  if (i > 1) chmin(res, rec(i-2) + abs(h[i] - h[i-2]));

  return dp[i] = res;
}


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

  h.assign(n, 0);
  dp.assign(n, INF);

  rep(i, n) cin >> h[i];
  cout << rec(n-1) << endl;


  return 0;
}


Measured memory_bytes: 6528
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();
		int k = sc.nextInt();
		
		// 計算
		String result = "";
		TreeSet<String> ts = new TreeSet<String>();
		for(int i = 0; i < s.length(); i++){
		    for(int j = i; j < min(i+k, s.length()); j++){
		        ts.add(s.substring(i, j+1));
		    }
		}
		for(int i = 0; i < k; i++){
		    result = ts.pollFirst();
		}
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 25556
N = int(input())
S = list(input())

res=0
for i in range(N-1):
    SL = list(set(S[:(i+1)]))
    SR = list(set(S[(i+1):]))
    cnt = 0 
    for s1 in SL:
        for s2 in SR:
            if s1==s2 : cnt += 1
    res = max(res,cnt)
print(res)

Measured memory_bytes: 3060
n,m=map(int,input().split())
#lst=[map(int,input().split()) for _ in range(n)]
lst=[list(map(int,input().split())) for _ in range(n)]
sl=sorted(lst,key=lambda x:x[0])
count=0
target_row,target_b=0,0
for i in range(len(sl)):
    if count + sl[i][1] > m:
        target_row = i
        target_b = m-count
        #print('break',i)
        break
    count+=sl[i][1]
    if i==len(sl)-1:
        target_row = i
        target_b = sl[i][1]
    #print('pass',i)
result=0
for i in range(target_row):
    result+=sl[i][0]*sl[i][1]
    #print('test',result)
    
#print('sorted_list ')
#print(sl)
#print('target_row : ',target_row,'  b :',target_b)
print(result+sl[target_row][0]*target_b)
    

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll a, b;
	cin >> a >> b;

	cout << (a*(a-1)/2 + b*(b-1)/2) << endl;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000001

int main() {
    int sx,sy,tx,ty;cin >> sx >> sy >> tx >> ty;

    int dx=tx-sx,dy=ty-sy;
    for(int i = 0; i < dx; i++) {
        cout << 'R';
    }
    for(int i = 0; i < dy; i++) {
        cout << 'U';
    }
    for(int i = 0; i < dx; i++) {
        cout << 'L';
    }
    for(int i = 0; i < dy; i++) {
        cout << 'D';
    }

    cout << 'D';
    for(int i = 0; i < dx+1; i++) {
        cout << 'R';
    }
    for(int i = 0; i < dy+1; i++) {
        cout << 'U';
    }
    cout << 'L';

    cout << 'U';
    for(int i = 0; i < dx+1; i++) {
        cout << 'L';
    }
    for(int i = 0; i < dy+1; i++) {
        cout << 'D';
    }
    cout << 'R' << endl;

    return 0;
}

Measured memory_bytes: 3564
using System;

namespace AtCoder.Contests.Abc176.Takoyaki
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();

            if (String.IsNullOrEmpty(input)) { return; }

            string[] inputs = input.Split(' ');

            if (!Int32.TryParse(inputs[0], out int n)) { return; }

            if (!Int32.TryParse(inputs[1], out int x)) { return; }

            if (!Int32.TryParse(inputs[2], out int t)) { return; }

            int a = n / x;
            int b = n % x;
            int result = t * a;

            if (b > 0) { result += t; }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 27404
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <set>
#include <string>
#include <iomanip>
using namespace std;

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

    int max_x = 0 , x = 0;
    for ( int i = 0 ; i < n ; i++ ){
        if (s[i] == 'I') x++;
        else x--;
        max_x = max(max_x,x);
    }
    cout << max_x << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define INF 100000000000000000LL
using namespace std;
typedef long long LL;
LL f(LL b,LL n)
{
	if(n<b)
		return n;
	return f(b,n/b)+n%b;
}
bool Check(LL b,LL n,LL s)
{
	if(f(b,n)==s)
		return true;
	return false;
}
int main()
{
	LL n,s;
	scanf("%lld %lld",&n,&s);
	if(s>n)
	{
		printf("-1\n");
		return 0;
	}
	if(s==n)
	{
		printf("%lld\n",n+1LL);
		return 0;
	}
	LL n1=n-s;
	LL ans=INF;
	for(LL i=1LL;i*i<=n1;i++)
	{
		if(n1%i==0)//i=b-1
		{
			if(Check(i+1,n,s)==true)
				ans=min(ans,i+1LL);
			if(n1/i!=i&&Check(n1/i+1LL,n,s)==true)
				ans=min(ans,n1/i+1LL);
		}
	}
	if(ans==INF)
		printf("-1\n");
	else
		printf("%lld\n",ans);
	return 0;
}
/*
100000000000 3
*/

Measured memory_bytes: 128
using System;

namespace Otoshidama
{
    class Program
    {
        static void Main(string[] args)
        {
            //var exStdIn = new System.IO.StreamReader("stdin.txt");
            //System.Console.SetIn(exStdIn);

            var input = Console.ReadLine();

            var S = input.Split(' ')[0];
            var T = input.Split(' ')[1];
            Console.WriteLine(T + S);

        //    bool found = false;

        //    for (int num10000 = 0; num10000 <= N; num10000++)
        //    {
        //        for(int num5000 = 0; num5000 <= (N-num10000); num5000++)
        //        {
        //            int num1000 = N - num10000 - num5000;
        //            if (num10000 * 10000 + num5000 * 5000 + num1000 * 1000 == Y)
        //            {
        //                Console.WriteLine(num10000 + " " + num5000 + " " + num1000);
        //                found = true;
        //                goto FOR_LOOP;
        //            }
        //        }
        //    }
        //FOR_LOOP:;

        //    if (!found) Console.WriteLine("-1 -1 -1");
        }
    }
}


Measured memory_bytes: 11092
N,D = map(int,input().split())
P = []
for i in range (N):
    P.append(list(map(int, input().split())))
Pi = 0
for i in range(N):
    for j in range(i+1, N):
        Di = 0
        for k in range (D):
            Di += (P[i][k]-P[j][k])**2
        if int(Di**0.5) == Di**0.5:
            Pi += 1
print(Pi)

Measured memory_bytes: 3064
N, K = map(int, input().split())
numberdict = {}
for j in range(N):
    a, b = map(int, input().split())
    if a in numberdict:
        numberdict[a] += b
    else:
        numberdict[a] = b
numberdict = sorted(numberdict.items())
# print(numberdict)
index = 0
for i in range(len(numberdict)):
    index += numberdict[i][1]
    if index >= K:
        print(numberdict[i][0])
        break


Measured memory_bytes: 14560
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <stack>
using namespace std;
#define ms(a, x) memset(a, x, sizeof(a))
#define fore(i, a, n) for (long long i = a; i < n; i++)
#define ford(i, a, n) for (long long i = n - 1; i >= a; i--)
#define si(a) scanf("%d", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define debug(a) cout << a << endl
#define endl '\n'
#define pi acos(-1.0)
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define IO ios::sync_with_stdio(false), cin.tie(0)
const double eps = 1e-8;
inline int sgn(const double &x) { return x < -eps ? -1 : x > eps; }
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int maxn=100500;

//=================================================
int a[maxn];
int dp[maxn];
int n,k;
void init() {
    for(int i=1;i<=n;i++) {
        if(i==1) {
            dp[i]=0;
        }
        else  {
            dp[i]=inf;
        }
    }
}
int main()
{
    IO;
    cin>>n>>k;
    for(int i=1;i<=n;i++) {
        cin>>a[i];
    }
    init();
    if(k>=n-1) {
        cout<<abs(a[n]-a[1])<<endl;
    }
    else {
        for(int i=2;i<=n;i++) {
            int minn=min(i-1,k);
            for(int j=1;j<=minn;j++)
            dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
        }
        cout<<dp[n]<<endl;
    }
    

    return 0;
}

Measured memory_bytes: 1024
n,a,b = map(int, input().split())
cnt = 0

def digidsum(x):
  s = str(x)
  array_list = list(map(int,s))
  return sum(array_list)



for i in range(n):

  if digidsum(i+1) >= a and digidsum(i+1) <= b:
    cnt += i+1
    
print(cnt)

Measured memory_bytes: 43116
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;

set<string> ans;
int N;

void solve(string s, int ct) {
    if ((int)s.size() == N) {
        ans.insert(s);
    }
    if ((int)s.size() < N) {
        rep(i, ct + 1) {
            solve(s + (char)('a' + i), max(ct, i + 1));
        }
    }
}

int main()
{
    cin >> N;

    solve("a", 1);

    for (auto itr = ans.begin(); itr != ans.end(); itr++) {
        cout << *itr << endl;
    }
    return 0;
}

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

int main() {
	string str;
	int i,n,h;
	while(1) {
		cin >> str;
		if (str=="-") break;
		cin >> n;
		for(i=0; i<n; ++i) {
			cin >> h;
			str+=str.substr(0,h);
			str.erase(str.begin(),str.begin()+h);
		}
		cout << str << endl;
	}
	return 0;
}

Measured memory_bytes: 3192
//PseudoName

    #pragma GCC optimize("O3")
    #include <bits/stdc++.h>
/*
	#include <ext/pb_ds/assoc_container.hpp>
	#include <ext/pb_ds/tree_policy.hpp>
	using namespace __gnu_pbds;
	template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/
    #define FOR(i,n) for(i=0;i<n;i++)
    #define FOR1(i,n) for(i=1;i<=n;i++)
    #define FOR2(I, A, B) for (int I = (A); I <= (B); ++I)
    #define pb push_back
    #define unique_sort(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
    #define print(v) for(auto it:v)cout<<it<<" ";cout<<endl
    #define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    #define endl "\n"
    #define min3(a,b,c) min(a,min(b,c))
    #define forr(n) for(int i=0;i<n;i++)
    #define frr(n) for(int i=1;i<=n;i++)
    #define MAX 200005
    #define inf 200008

    using namespace std;

    typedef long long ll;
    typedef long li;
    typedef vector<int> vi;
    typedef vector<ll> vli;
    typedef vector<vi> vvi;
    typedef vector<vli> vvli;
    typedef pair<int,int> pi;
    typedef pair<ll,ll> pli;
    typedef vector<pi> vpi;
    typedef vector<pli> vpli;



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

       ll ans=0;

       for(int i=1;i<=n;i++)
       {
           for(int j=1;j<=n;j++)
           {
              // if(__gcd(i,j)==1){ans+=n-j;continue;}
               for(int k=1;k<=n;k++)
               {
                   ans+=__gcd(__gcd(i,j),k);
               }
           }
       }
       cout<<ans<<endl;




    }


Measured memory_bytes: 3632
#include <iostream>                                                                                                                                                         
#include <string>                                                                                                                                                           
using namespace std;
string s;
int main() {
  cin >> s;
  int w = 0, l = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == 'o') {
      w++;
    }
  }
  w += 15 - s.length();
  if (w >= 8) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String args[]){
        Scanner s=new Scanner(System.in);
        while(s.hasNext()){
            double v=s.nextDouble();
            System.out.println((int)Math.ceil((v*v/(9.8*2)+5)/5));
        }
    }
}
//by Tuvshee 12.05.2012
//Physical Experiments

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

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"

#ifdef ONLINE_JUDGE
#define debug //HEs
#define whats //HEs
#define file //freopen("in.HEs", "r", stdin);freopen("out.HEs", "w", stdout);
#else
#define debug(x,...) printf(x,__VA_ARGS__)
#define whats(i) cout<<#i<<" = "<<i<<endl;
#define file freopen("out.HEs", "w", stdout);freopen("in.HEs", "r", stdin);
#endif


int main() {

	fast //file;

	int W, H, x, y;

	scanf("%d %d %d %d", &W, &H, &x, &y);

	printf("%lf ", (0.5*W*H));

	if ( (W % 2 == 0 && H % 2 == 0)
		&& ( (x * 2 == H && y * 2 == W) 
			|| (x * 2 == W && y * 2 == H) ) 
		) printf("1\n");
	else printf("0\n");

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
int main(){
    double x1,x2,x3,y1,y2,y3;
    std::cin>>x1>>y1>>x2>>y2>>x3>>y3;
    double a = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)),b = sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3)),c = sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1));
    double s = (double)((a+b+c)/2.0);
    double T = sqrt(s*(s-a)*(s-b)*(s-c));
    double r = T/s;
    double M = std::max(a,std::max(b,c));
    std::cout<<std::setprecision(12)<<(double)(M/(2.0+M/r))<<std::endl;
   //     std::cout<<s<<" "<<T<<" "<<r<<" "<<std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int i = -1, j, k, H[300], W[300], cnt = 0;

  do {
    i++;
    scanf("%d %d", &H[i], &W[i]);
    cnt++;
  } while(H[i] != 0 && W[i] != 0);

  for(k = 0; k < cnt - 1; k++) {
    for(i = 0; i < H[k]; i++) {
      for(j = 0; j < W[k]; j++) {
	if(i == 0 || i == H[k]-1 || j == 0 || j == W[k]-1) {
	  printf("#");
	}else{
	  printf(".");
	}
      }
      printf("\n");
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 572
import sys
from collections import defaultdict, Counter

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    N_MAX = 10 ** 6

    min_factor = list(range(N_MAX + 1))
    min_factor[2::2] = [2] * (N_MAX // 2)
    for i in range(3, int(N_MAX ** 0.5) + 2, 2):
        if min_factor[i] != i:
            continue
        for j in range(i * i, N_MAX + 1, i):
            if min_factor[j] > i:
                min_factor[j] = i

    def prime_factorize_fast(n):
        a = Counter()
        while n != 1:
            f = min_factor[n]
            p = 0
            while min_factor[n] == f:
                p += 1
                n //= f
            a[f] = p

        return a

    lcm_prime = Counter()
    for a in A:
        for p, n in prime_factorize_fast(a).items():
            if lcm_prime[p] < n:
                lcm_prime[p] = n

    l = 1
    for p, n in lcm_prime.items():
        l = l * pow(p, n, MOD) % MOD

    ans = 0
    for a in A:
        ans = (ans + pow(a, MOD - 2, MOD)) % MOD

    ans = ans * l % MOD

    print(ans)
    return


if __name__ == '__main__':
    main()


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

int main() {

  int N;
  cin >> N;

  vector<int> vec(N + 2),cost(N + 1);
  for(int i = 1;i <= N; i++) {
    cin >> vec.at(i);
  }
 

  int sum = 0;
  for(int i = 0; i <= N;i++) {
    cost.at(i) = abs(vec.at(i + 1) - vec.at(i));
    sum += cost.at(i);
  }

  for(int i = 1;i <= N; i++) {
    int sum_copy = sum;
    sum_copy -= cost.at(i) + cost.at(i - 1);
    sum_copy += abs(vec.at(i + 1) - vec.at(i - 1));
    cout << sum_copy << endl;
  }


}


Measured memory_bytes: 2048
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();

    let mut ans = 0;
    for c in s.into_bytes(){
        if c=='+' as u8{ ans+=1 }
        else if c=='-' as u8{
            ans-=1
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
//BISMILLAHIR RAHMANIR RAHIM
//ALLAH HU AKABR
#include<bits/stdc++.h>
using namespace std;
int main()
 {
  int n;
  cin>>n;
  int sum=0;
  for(int i=1;i<=n;i++)
  {
      for(int j=1;j<=n;j++)
      {
          for(int k=1;k<=n;k++)
          {
              sum+= __gcd(i,__gcd(j,k));
          }
      }
  }
  cout<<sum<<endl;
 }







Measured memory_bytes: 3636
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define md 998244353
#define trace(...)
#define ll long long int
#define ld long double
#define fi first
#define se second
#define fr(i,a,b) for(ll i=a;i<=b;i++)
#define frr(i,b,a) for(ll i=b;i>=a;i--)
#define mem(a) memset(a, 0, sizeof(a))
#define vpi std::vector<pair<int,int>>
#define pii pair<int,int>
#define pb push_back
#define sall(v) sort(v.begin(),v.end())
#define all(v) (v.begin(),v.end())
#define minf -10000000
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
    uniform_int_distribution<int> uid(0,lim-1);
    return uid(rang);
}
ll power(ll x, ll y,ll p) { 
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or equal to p 
    while (y > 0) {  
        if (y & 1) // If y is odd, multiply x with result
            res = (res*x) % p;  
        y = y>>1; // y = y/2 // y must be even now
        x = (x*x) % p;   
    } 
    return res; 
}
ll power(ll x, ll y) { 
    ll res = 1;      // Initialize result 
    while (y > 0) {    
        if (y & 1)// If y is odd, multiply x with result 
            res = (res*x) ;  
        y = y>>1; // y = y/2 // y must be even now 
        x = (x*x);   
    } 
    return res; 
}
 
ll max3(ll a,ll b,ll c){
    return max(a,max(b,c));
}
ll min3(ll a,ll b,ll c){
    return min(a,min(b,c));
}
bool isPrime(ll n) { // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
}

void solve() {
    int n;cin>>n;
    int arr[n];
    fr(i,0,n-1)cin>>arr[i];
    int ans=0;
    vector<int> v;
    fr(i,1,n-2){
        // if((arr[i]>arr[i-1])&&(arr[i]<arr[i+1]))ans++;
        v.pb(arr[i]);v.pb(arr[i-1]);v.pb(arr[i+1]);
        sall(v);
        if(v[1]==arr[i])ans++;
        v.clear();
    }
    cout<<ans<<endl;
    return ;
}

int main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout<<fixed<<setprecision(8);
    #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    int t;
    // cin>>t;
    t=1;
    while(t--){
        solve();
    }
    #ifndef ONLINE_JUDGE
    //cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
    #endif
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<=int(b);++i)
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {

int main(void) {
  int r;cin>>r;
  pr(r*2*3.1415926535);
  return 0;
}


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

#define int long long
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
#define vint vector<int>
#define vchar vector<char>
#define vstr vector<string>
#define pb(n) push_back(n)

signed main(){
  int A,B,N,M,count=0,count2=0,count3=0;
  str S,T;
  int C='A'-'a';
  cin>>A>>B;
  vstr W(N);
  if(B/100>=1)N=1000;
  else if(B/10>=1)N=100;
  else N=10;
  M=A*N+B;
  rep(0,M/2){
    REP(0,M/2){
      if(i==j&&i*j==M)count+=1;
    }
  }
  if(count>=1)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256