akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define mod 1000000007
using namespace std;
ll binpow(ll x,ll y)/* (x^y)%p in O(log y) */{ll res=1;while (y > 0){if(y&1)res=(res*x);y = y>>1;x=(x*x);}return res;}
ll binpowmod(ll x,ll y,ll p)/* (x^y)%p in O(log y) */{ull res=1;x=x%p;while (y > 0){if(y&1)res=(res*x)%p;y = y>>1;x=(x*x)%p;}return res;}
ll mod_inverse(ll n,ll p)/* Returns n^(-1) mod p */{return binpowmod(n,p-2,p);}
ll gcd(ll x,ll y)
{
    if(y==0)
        return x;
    return gcd(y,x%y);
}
bool comp(pair<int,int> x,pair<int,int> y)
{
    return x.first<y.first;
}
bool comp_pairs_by_s(pair<ll,ll> &x ,pair<ll,ll> &y)
{
    return x.second<y.second;
}
bool isPowerOfTwo (ll x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
}

class cmp      //comparator for priority_queue 
{               //declaration: priority_queue<int,vector<int>,cmp>
public:         
    bool operator()(pair<int,int> A,pair<int,int> B)
    {
        if(abs(A.first-A.second)==abs(B.first-B.second))
            return A.first>B.first;
        return abs(A.first-A.second)<abs(B.first-B.second);
    }
};
// int prime[10000007]={0};
// void sieve(void)
// {
//  int i,j;
//  for(i=0;i<10000007;i++)
//         prime[i]=1;
//  prime[0]=0,prime[1]=0;
//  for(i=2;i<=sqrt(10000007);i++){
//      if(prime[i]==i){
//          for(j=i*i;j<10000007;j+=i){
//             if(!prime[j])
//                 prime[j]=0;
//          }
//      }
//  }
    
// }
void swap(ll &x,ll &y){
    int temp=x;
    x=y;
    y=temp;
}
  
unsigned int onesComplement(unsigned int n) 
{ 
   // Find number of bits in the given integer 
   int number_of_bits = floor(log2(n))+1; 
  
   // XOR the given integer with poe(2,  
   // number_of_bits-1 and print the result  
   return ((1 << number_of_bits) - 1) ^ n; 
}

void solve()
{   
    int n;
    cin>>n;
    if(n%1000==0)
        cout<<0;
    else
    cout<<((n/1000)+1)*1000-n; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}   


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

int main(){
	int n, l;
	cin >> n >> l;
	vector<string> s(n);
	for (int i=0; i<n; i++){
		cin >> s.at(i);
	}
	sort(s.begin(), s.end());
	string sum;
	for(int i=0; i<n; i++){
		sum += s.at(i);
	}
cout << sum << endl;
}


Measured memory_bytes: 3636
#editorial写経
#総数少ないのでしらみつぶしできる
n = int(input())
###小さい数から開始
def f(s):
    if int(s)>n:
        return 0
    ret = 1 if all(s.count(c)>0 for c in '753') else 0
    ####この構文自体覚える
    for c in '753':
        ret += f(s+c)
    return ret
        
print(f('0'))

Measured memory_bytes: 3064
package main

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

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

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

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

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

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
		if len(os.Args) > 2 {
			wfp, _ = os.Create(os.Args[2])
		}
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)
	fmt.Fprintln(writer, 0)
	writer.Flush()
	s := getNextString(scanner)
	if s == "Vacant" {
		p(writer, 0)
		return
	}
	circle := make([]string, n)
	circle[0] = s
	l := 0
	r := n
	for i := 0; i < 19; i++ {
		m := (l + r) >> 1
		p(writer, m)
		s := getNextString(scanner)
		if s == "Vacant" {
			p(writer, m)
			return
		}
		circle[m] = s
		if (m-l)%2 == 1 {
			if circle[l] == circle[m] {
				r = m
				continue
			}
			l = m
			continue
		}
		if (r-m)%2 == 1 {
			if circle[r%n] == circle[m] {
				l = m
				continue
			}
			r = m
			continue
		}
		if circle[l] == circle[m] {
			l = m
			continue
		}
		r = m
	}
	p(writer, r)
}

func p(writer *bufio.Writer, ans int) {
	fmt.Fprintln(writer, ans)
	writer.Flush()
}


Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define ll long long
#define pb push_back
#define F first
#define S second
#define ld long double
#define rep(i,n) for (int i =0;i < (n); ++i)
#define vi vector<ll>
#define all(v) (v).begin(),(v).end()
const int inf = 1e9 + 10;

void solve() {
	ll n, m;
	cin >> n >> m;
	vi a(n, 0), h(n, 0);
	for (int i = 0; i < n; i++) cin >> h[i];
	for (int i = 0; i < m; i++) {
		ll x, y; cin >> x >> y;
		x--; y--;
		a[x] = max(a[x], h[y]);
		a[y] = max(a[y], h[x]);
	}
	ll ans = 0;
	for (int i = 0; i < n; i++) ans += h[i] > a[i];
	cout << ans;
}

int main() {

	FASTIO;


	cout << fixed << setprecision(25);
	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 4764
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let r: i32 = read();
    println!("{}", 3 * r * r);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define FT() int t; scanf("%d",&t); while(t--)
#define pb push_back
#define nl printf("\n")
#define fi(i,start,end) for(int i=start; i < (int)end ; ++i)
#define ip(n)   scanf("%d",&n)
#define mz(a)   memset(a,0,sizeof(a))
#define inpArr(A,n) fi(i,0,n)   ip(A[i]);
#define print(a)  for(auto i : a)   cout<<i<<" "; nl;
#define Fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
ll max(ll a,ll b)   {return a>b?a:b;}
ll min(ll a,ll b)   {return a<b?a:b;}
ll dp[2001];
ll solve(int s)
{
    if(s == 0)
        return 1;
    else if(s<0)
        return 0;
    if(dp[s] == -1)
    {   ll t = 0;
        for(int i=3;i<=2000;i++)
            t+=solve(s-i);
        dp[s] = t;
    }
    return dp[s]%mod;
}
int main() {
    #ifndef ONLINE_JUDGE
    freopen("D:/Sublime/Rough/input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    //std::cout << std::fixed;
    //std::cout << std::setprecision(6);
    Fastio;
    int s;cin>>s;
    memset(dp,-1,sizeof(dp));
    cout<<solve(s);

    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
    #endif
    
    return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    int S, W;
    cin >> S >> W;
    if(S <= W)
        cout << "unsafe";
    else
        cout << "safe";
    return 0;
}

Measured memory_bytes: 3592
import java.util.*;

public class Main {
    static int modP = 1000000007;
    static long inf  = 1 << 61;

    static String s;
    static long sum;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        s = in.next();
        int n = s.length();

        for(int i = 0; i < 1 << n-1; i++) {
            String ss = s;
            for(int j = n-1; j >= 0; j--) {
                if((1 & i >> j) == 1) {
                    ss = ss.substring(0, j+1) + "-" + ss.substring(j+1);
                }
            }
            String[] nums = ss.split("-");

            long subsum = 0;
            for(int j = 0; j < nums.length; j++) {
                subsum += Long.parseLong(nums[j]);
            }

            sum += subsum;
        }

        print(sum);
    }

    static void print(String s) {
        System.out.println(s);
    }

    static void print(int i) {
        System.out.println(i);
    }

    static void print(long i) {
        System.out.println(i);
    }

    static void print(float i) {
        System.out.println(i);
    }
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n, x;
    cin >> n >> x;
    vector<pair<P, P>> v(n);
    int sum = 0;
    rep(i, n)
    {
        int b, l, u;
        cin >> b >> l >> u;
        int d = (x - b) * u + b * l;
        sum += b * l;
        v[i].first.first = d;
        v[i].first.second = b;
        v[i].second.first = l;
        v[i].second.second = u;
    }
    sort(all(v));
    reverse(all(v));
    int L = -1, R = n * x;
    while (R - L > 1)
    {
        int mid = (R + L) / 2;
        int q = mid / x, r = mid - q * x;
        int score = -sum;
        for (int i = 0; i < q; i++)
            score += v[i].first.first;
        bool f = (score >= 0);
        for (int i = 0; i < n; i++)
        {
            int score_tmp = score;
            int b = v[i].first.second, l = v[i].second.first, u = v[i].second.second;
            int d = r - b;
            if (i < q)
            {
                score_tmp -= v[i].first.first;
                score_tmp += v[q].first.first;
            }
            score_tmp += l * min(b, r);
            score_tmp += u * max(0LL, d);
            f = f | (score_tmp >= 0);
        }
        if (f)
            R = mid;
        else
            L = mid;
    }
    cout << R << endl;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> c(n), s(n), f(n);
    rep(i, 0, n) {
        cin >> c[i] >> s[i] >> f[i];
    }
    rep(i, 0, n) {
        int t = 0;
        rep(j, i, n - 1) {
            if (t < s[j])t = s[j];
            else if (t % f[j] == 0);
            else t = t + f[j] - t % f[j];
            t += c[j];
        }
        printf("%d\n", t);
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

class element {
public:
  i64 index, value;
  element(const i64 index, const i64 value) :
    index(index), value(value) {
  }
};

class range {
public:
  i64 begin_included, end_included;
  range(const i64 begin_included, const i64 end_included) :
    begin_included(begin_included), end_included(end_included) {
  }
  bool operator<(const range& other) const {
    return this->end_included < other.end_included;
  }
};

namespace std {
  std::ostream& operator<<(std::ostream& os, const range& self) {
    return os << '[' << self.begin_included << ", " << self.end_included << ']';
  }
}

int main() {
  i64 N;
  std::cin >> N;
  std::vector<i64> a;
  tools::read(a, N);

  std::vector<element> elements;
  elements.reserve(N);
  for (i64 i = 0; i < N; ++i) {
    elements.emplace_back(i + 1, a[i]);
  }
  std::sort(elements.begin(), elements.end(), [](const element& x, const element& y) {
    return x.value < y.value;
  });

  i64 answer = 0;
  std::set<range> ranges({range(0, N + 1)});
  for (const element& element : elements) {
    auto it = ranges.lower_bound(range(element.index, element.index));
    answer += element.value * (element.index - it->begin_included) * (it->end_included - element.index);
    const std::array<range, 2> new_ranges = {range(it->begin_included, element.index), range(element.index, it->end_included)};
    ranges.erase(it);
    ranges.insert(new_ranges[0]);
    ranges.insert(new_ranges[1]);
  }

  std::cout << answer << std::endl;
  return 0;
}

Measured memory_bytes: 17408
S = input()
ans = [0]*(len(S)+1)

for i in range(len(S)):
    if S[i] =='<':
        ans[i+1] = ans[i]+1
        
for i in range(len(S)-1,-1,-1):
    if S[i]=='>':
        ans[i]= max(ans[i],ans[i+1]+1)
print(sum(ans))

Measured memory_bytes: 46320
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    long I, O, T, J, L, S, Z;
    cin >> I >> O >> T >> J >> L >> S >> Z;
    long ijl = 0;
    if ((I%2 + J%2 + L%2)%3 > 0) {
        if (I * J * L == 0) ijl = (I % 2 + J % 2 + L % 2) % 3;
        else ijl = 1;
    }
    cout << I + O + J + L - ijl << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{	int i;
 	char n[3];
 	scanf("%s",n);
 	for(i=0;i<=2;i++)
    {
      if(n[i]=='1'){n[i]='9';}
      else{n[i]='1';}
    }
 	printf("%s",n);
return 0;
}

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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			//出力の都度更新をやめる
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);


			Ans();

			//更新する
			Console.Out.Flush();
			
		}

 	public static void Ans() {

			var inputArray = retreiveLongArray();
			var inputCount = 2;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];
			long K = inputArray[1];


			var scores = retreiveLongArray();


			for (var i = K; i < N; i++) {
				var ans = scores[i] > scores[i - K] ? "Yes" : "No";
				Console.WriteLine(ans);
			}


		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}


Measured memory_bytes: 47124
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> X(N);
    for(int i = 0; i < N; ++i){
        cin >> X[i];
    } 
    sort(X.begin(), X.end());
    cout << (X.back()-X[0]+1)/2 << endl;
}


Measured memory_bytes: 3152
import math

a,b,x = (int(a) for a in input().split())
if 2 * x <= a**2 * b :
    t = b
    s = 2 * x / (a*b)
    r = s / t
    print(90 - math.degrees(math.atan(r)))
else : 
    t = a
    s = 2 * b - 2 * x / (a ** 2)
    r = s / t
    print(math.degrees(math.atan(r)))



Measured memory_bytes: 3316
#include<bits/stdc++.h>
#include<iostream>     //Mir Rifat
using namespace std;
int main()
{
    int c1=0,c2=0,d,g;
    string s;cin>>s;//cout<<s;
    int len=s.size();//cout<<len;
    for(int i=0;i<len;i++){
        if(s[i]=='R'){
            for(int j=i;j<len;j++){
                if(s[j]=='R')
                    c1++;
                    else
                        break;
            }

        }

     c2=max(c1,c2);
            c1=0;
    }
    cout<<c2<<endl;
    return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  ll x;cin>>x;
  ll result=0;
  result += (x/500)*1000;
  x %= 500;
  result += (x/5)*5;
  cout<<result;

  return 0;
}



Measured memory_bytes: 256
'use strict';
process.stdin.on('data', function(chunk) {
  var inputs = chunk.toString().trim().split(' ');
  var a = Number(inputs[0]);
  var b = Number(inputs[1]);

  if (a < b) {
    console.log('a < b');
  } else if (a > b) {
    console.log('a > b');
  } else {
    console.log('a == b');
  }

});
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 15532
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define F first 
#define S second
int const M=32000+10,M2=1e6+10,M3=1e3+10,inf=1e9+10,mod=1e9+7;
string tmp;
int x,y;
vector<int>cur[2];
bool mark[M],mark2[M];
bool fans(int ch,int ind)
{
//	for(int i=0;i<cur[ind].size();i++)cout<<cur[ind][i]<<" ";
//	cout<<endl;
	for(int j=0;j<=16000;j++)
	{
		mark[j]=0;
		mark2[j]=0;
	}
	int maxn=8000;
	if(ind==0)
		mark[cur[ind][0]+maxn]=1;
	else
		mark[maxn]=1;
	int be=0;
	if(ind==0)be=1;
	for(int i=be;i<cur[ind].size();i++)
	{
		for(int j=0;j<=2*maxn;j++)
		{
			mark2[j]=0;
			//mark[j]=0;
		}
		for(int j=0;j<=2*maxn;j++)
		{
			if(mark[j])
			{
				mark2[j-cur[ind][i]]=1,mark2[j+cur[ind][i]]=1;
			}
		}
		for(int j=0;j<=2*maxn;j++)
			mark[j]=mark2[j];
	}
	if(mark[ch+maxn])return 1;
	return 0;
}
main()
{
	cin>>tmp>>x>>y;
	int now=0,cnt=0;
	for(int i=0;i<tmp.size();i++)
	{
		if(tmp[i]=='T')
		{
			cur[now].pb(cnt);
		//	cerr<<cnt<<" ";
			cnt=0;
			now=1-now;
		}
		else cnt++;
	}
	cur[now].pb(cnt);
	if(fans(x,0) && fans(y,1))
	{
		cout<<"Yes";
	}
	else cout<<"No";
}

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

int main() {
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int t1 = h1 * 60 + m1;
  int t2 = h2 * 60 + m2;
  cout << t2 -t1 - k << endl;
}


Measured memory_bytes: 3624
N, M, X = map(int, input().split())
A_list = list(map(int, input().split()))

cost_to_zero = sum([1 for A in A_list if 0 < A < X])
cost_to_n = sum([1 for A in A_list if X < A < N])

print(min(cost_to_zero, cost_to_n))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)

class Sushi{
public:
	lli kind;
	lli value;
	Sushi(lli t,lli d){kind = t,value = d;}
};

Sushi make_sushi(lli t,lli d){
	Sushi s(t,d);
	return s;
}

bool operator< (const Sushi &sushi1,const Sushi &sushi2){
	return sushi1.value>sushi2.value;
}

signed main(){

	lli k,n;
	cin>>n>>k;

	vector<Sushi> v;

	REP(i,0,n){
		lli t,d;
		cin>>t>>d;
		v.push_back(make_sushi(t,d));
	}

	sort(v.begin(),v.end());
	
	priority_queue<Sushi> q;

	lli sum=0;
	set<lli> s;
	lli kindD[100010]={0};
	REP(i,0,k){
		q.push(v[i]);
		sum += v[i].value;
		s.insert(v[i].kind);
		kindD[v[i].kind]++;
	}

	lli ans=sum + (s.size()*s.size());

	lli now=k;
	while(q.size() && now<n){
		lli topKind  = q.top().kind;
		lli topValue = q.top().value;
		q.pop();
		if(kindD[topKind]==1)continue;

		/*入れ替えを行う*/
		sum -= topValue;
		sum += v[now].value;
		s.insert(v[now].kind);
		q.push(v[now]);
		kindD[v[now].kind]++;
		ans = max((unsigned lli)ans, sum+(s.size()*s.size()));
		now++;
	}


	cout<<ans<<endl;

	return 0;
}

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

int main(){
    int n;
    cin >> n;
    
    int p[23];
    for(int i = 1;i <= n;i++){
        cin >> p[i];
    }
    
    int cnt = 0;
    for(int i = 2;i < n;i++){
        if(min(p[i - 1],p[i + 1]) < p[i] && max(p[i - 1],p[i + 1])>p[i]){
            ++cnt;
        }
    }
    
    cout << cnt << endl;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000 + 0;
inline int in(){ int x; scanf("%d", &x); return x; }

int main() {
  int field[128][128];
  int piece[4][64][64];
  int N, M;
  while (N = in(), M = in()) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        field[i][j] = in();
      }
    }
    for (int i = 0; i < M; i++) {
      for (int j = 0; j < M; j++) {
        piece[0][i][j] = in();
      }
    }
    for (int r = 1; r < 4; r++) {
      for (int i = 0; i < M; i++) {
        for (int j = 0; j < M; j++) {
          piece[r][i][j] = piece[r - 1][M - j - 1][i];
        }
      }
    }
    vector<duo> ps;
    for (int i = 0; i <= N - M; i++) {
      for (int j = 0; j <= N - M; j++) {
        for (int r = 0; r < 4; r++) {
          bool ok = true;
          for (int k = 0; k < M; k++) {
            for (int l = 0; l < M; l++) {
              if (piece[r][k][l] == -1) continue;
              if (piece[r][k][l] == field[i + k][j + l]) continue;
              ok = false;
              goto END1;
            }
          }
END1:;
          if (ok){
            for (int k = 0; k < M; k++){
              for (int l = 0; l < M; l++){
                if (piece[r][k][l] == -1) continue;
                ps.emplace_back(i + k + 1, j + l + 1);
                goto END2;
              }
            }
END2:;
          }
        }
      }
    }
    sort(begin(ps), end(ps));
    if (ps.size()) printf("%d %d\n", get<1>(ps[0]), get<0>(ps[0]));
    else puts("NA");
  }
  return 0;
}

Measured memory_bytes: 1424
#include <iostream>

using namespace std;

int main() {
	int d, n, k = 1, ans;
	cin >> d >> n;
	for(int i = 0;i < d;++i){
		k *= 100;
	}
	if(n == 100) ++n;
	ans = k * n;
	cout << ans << endl; 
	return 0;
}


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

int main(){
    int sum=0;
    double avg=0;
    double d;
    int i,j,cnt=0;
    while(scanf("%d,%d",&i,&j) != EOF){
        sum += i * j;
        avg += j;
        cnt++;
    }
    d = avg / cnt;
    d += 0.5;
    printf("%d\n%.0lf\n",sum,d);
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>p;
int main(){
  int n;
  cin>>n;
  p arr[n];
  for(int i=0;i<n;i++){
    int x,l;
    cin>>x>>l;
    arr[i]=p(x+l,x-l);
  }
  sort(arr,arr+n);
  int cur=-1000000000;
  int ans=0;
  for(int i=0;i<n;i++){
    if(cur<=arr[i].second){
      ans++;
      cur=arr[i].first;
    }
  }
  cout<<ans;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define int long long
using namespace std;
const int N = 2005;
const int MOD = 924844033;

int f[N];

int n, k;
int path_match[2 * N][N][2];

bool vis[N][2];
int path_len;
void DFS(int v, int side = 0)
{
    if(vis[v][side])
        return;

    path_len++;
    vis[v][side] = true;

    if(v + k <= n)
        DFS(v + k, side ^ 1);
    if(v - k >= 1)
        DFS(v - k, side ^ 1);
}

int dp[N], new_dp[N];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    cin >> n >> k;

    f[0] = 1;
    for(int i = 1; i <= n; i++)
        f[i] = (1LL * f[i - 1] * i) % MOD;

    path_match[0][0][0] = 1;
    for(int i = 1; i <= 2 * n; i++)
    {
        for(int j = 0; j <= i; j++)
        {
            path_match[i][j][0] = (path_match[i - 1][j][0] + path_match[i - 1][j][1]) % MOD;
            path_match[i][j][1] = path_match[i - 1][j - 1][0];
        }
    }

    dp[0] = 1;
    for(int i = 1; i <= n; i++)
    {
        if(!vis[i][0])
        {
            path_len = -1;
            DFS(i);
            for(int j = 0; j <= n; j++)
                new_dp[j] = 0;

            for(int j = 1; j <= (path_len + 1) / 2; j++)
                for(int k = n - j; k >= 0; k--)
                {
                    int x = (path_match[path_len][j][0] + path_match[path_len][j][1]) % MOD;
                    x = (1LL * dp[k] * x) % MOD;
                    new_dp[k + j] = (new_dp[k + j] + x) % MOD;
                }
            for(int j = 0; j <= n; j++)
                dp[j] = (dp[j] + new_dp[j]) % MOD;
        }
    }


    int ans = 0;
    for(int i = 1; i <= n; i++)
    {
        int x = (1LL * dp[i] * f[n - i]) % MOD;
        if(!(i & 1))
            x = MOD - x;

        ans = (ans + x) % MOD;
    }

    ans = (0LL + MOD + f[n] - ans) % MOD;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 124032
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N,K = LI()
    A = LI()

    for i in range(K,N):
        if A[i] > A[i-K]:
            print('Yes')
        else:
            print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 95724
import java.util.Scanner;
import java.util.Stack;

public class Main {

	void run() {
		Scanner sc = new Scanner(System.in);
		Stack<Integer> st = new Stack<Integer>();

		while (sc.hasNext()) {
			int p = sc.nextInt();

			if (p == 0) {
				System.out.println(st.pop());
			}
			else {
				st.push(p);
			}
		}
		sc.close();

	}

	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 17212
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

    rep(i,ty-sy) cout << 'U';
    rep(i,tx-sx) cout << 'R';
    rep(i,ty-sy) cout << 'D';
    rep(i,tx-sx+1) cout << 'L';
    rep(i,ty-sy+1) cout << 'U';
    rep(i,tx-sx+1) cout <<'R';
    cout << 'D' << 'R';
    rep(i,ty-sy+1) cout << 'D';
    rep(i,tx-sx+1) cout << 'L';
    cout << 'U' << endl;
}



Measured memory_bytes: 256
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim_right().to_owned()
}

fn str_to_ints(s: String) -> std::vec::Vec<i32> {
    let mut ret = std::vec::Vec::new();
    let ws = s.split_whitespace();
    for w in ws {
        ret.push(w.parse().unwrap());
    }
    ret
}

fn main() {
    let n = str_to_ints(read_line())[0];
    let ls = str_to_ints(read_line());
    let mut max_l = 0;
    let mut sum_l = 0;
    for l in ls {
        if l > max_l {
            max_l = l;
        }
        sum_l += l;
    }
    if max_l < sum_l - max_l {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i,a,b) for(ll i=(a);i<ll(b);i++)
#define rep(i,b) loop(i,0,b)

bool isPrime(const ll &n){
    if(n == 2) return true;
    if(n < 2 || n%2 == 0) return false;
    const ll m = n-1, d = m / (m & -m);
    auto modpow = [&](ll a, ll b){
        ll res = 1;
        while(b){
            if(b&1) res = res*a%n;
            a = a*a%n;
            b >>= 1;
        }
        return res;
    };
    auto suspect = [&](ll a, int t){
        a = modpow(a,t);
        while(t != -1+n && a != 1 && a != -1+n){
            a = a*a%n;
            t *= 2;
        }
        return a == n-1 || t%2 == 1;
    };
    const int witness[] = {2,3,5,61,0}; // 要検証
    for(const int *w = witness; *w < n && *w; w++){
        if(!suspect(*w,d)) return false;
    }
    return true;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int ans = 0;
    rep(i,n){
        ll x;
        cin >> x;
        ans += isPrime(x);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1204
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.close();
        int number = 1;
        while (number * 2 <= n) {
            number *= 2;
        }
        System.out.println(number);
    }
}

Measured memory_bytes: 22996
n, m = map(int, input().split())
if n == 2 or m == 2:
    print(0)
elif n == 1 and m == 1:
    print(1)
elif n == 1:
    print(m - 2)
elif m == 1:
    print(n - 2)
else:
    print((n - 2) * (m - 2))


Measured memory_bytes: 9072
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}
 
ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}
 
ll RS(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P < 0) {
        return 0;
    }
    if(P%2==0){
        ll t = RS(N, P/2, M);
        return t*t % M;
    }
    return N * RS(N, P-1, M) % M;
}

int main() {
    ll A,V,B,W;
    cin >> A >> V >> B >> W;
    ll T;
    cin >> T;
    if(A < B) {
        if(A + T * V >= B + T * W) {
            cout << "YES" << endl;
        }
        else {
            cout << "NO" << endl;
        }
    }
    else {
        if(A - T * V <= B - T * W) {
            cout << "YES" << endl;
        }
        else {
            cout << "NO" << endl;
        }
    }
}

Measured memory_bytes: 3636
#include <cstdio>

using namespace std;

typedef long long ll;

const int N = 1e5 + 500;

int n;
ll A[N], P[2 * N], pot, P2[2 * N];

int main(){
	scanf("%d", &n);
	for(int i = 0;i < n;i++){
		scanf("%lld", A + i);
		pot += A[i];
	}
	if(pot % ((ll)n * (n + 1) / 2) != 0){
		printf("NO\n");
		return 0;
	}
	pot /= (ll)n * (n + 1) / 2;
	for(int i = 0;i < n;i++){
		ll x = pot - (A[i] - A[(n + i - 1) % n]);
		if(x % (ll)n != 0 || x < 0){
			printf("NO\n");
			return 0;
		}
		x /= n;
		P[i] += x; P[i + n] -= x;
		P2[i + n] -= x * n;
	}
	for(int i = 1;i < 2 * n;i++)
		P[i] += P[i - 1];
	P2[0] += P[0];
	for(int i = 1;i < 2 * n;i++)
		P2[i] += P2[i - 1] + P[i];
	for(int i = 0;i < n;i++){
		if(A[i] != P2[i] + P2[i + n]){
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}


Measured memory_bytes: 5512
#include <cstdio>
using namespace std;
const long long NR=410000;
long long n,k,a,cnt;
double d[NR],s[NR],ans;
int main()
{
	scanf("%lld%lld",&n,&k);
	for(long long i=1;i<=n;i++)
	{
		scanf("%lld",&a);
		d[i]=(a+1)*0.5;
		s[i]=s[i-1]+d[i];
	}
	for(long long i=1;i<=n;i++)
	{
		if(s[i+k-1]-s[i-1]>ans)
		{
			ans=s[i+k-1]-s[i-1];
		}
	}
	printf("%.12lf",ans);
	return 0;
}

Measured memory_bytes: 5760
#include <stdio.h>
#include <stdlib.h>
typedef long long ll;
int cmpint(const void *x, const void *y) {
	return *(int *)y - *(int *)x;
}
int main() {
	int n, a[300000];
	ll sum = 0;
	scanf("%d", &n);
	for (int i = 0; i < 3 * n; i++) {
		scanf("%d", &a[i]);
	}
	qsort(a, n * 3, sizeof(int), cmpint);
	for (int i = 1; i < 2 * n; i += 2) {
		sum += a[i];
	}
	printf("%lld\n", sum);
	return 0;
}

Measured memory_bytes: 2556
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han Elmuzaffer Daima
//Bismillahirrahmanirrahim

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=0;i<n;i++)
#define mid (start+end)/2
#define ort (bas+son)/2

const lo MAX = -1000000000000000000; 
const lo MIN = 1000000000000000000; 
const lo inf = 1000000000; 
const lo KOK = 100000; 
const lo LOG = 30; 
const lo li = 100005; 
const lo mod = 1000000007; 

int n,m,cev,b,a[li],k,mpp[100][100];
string s;
vector<int> v;

inline int solve(){
	int t;cin>>t;
	n=t;
	while(t--){
		//~ cout<<t<<endl;
		cin>>s;
		for(int i=0;i<(int)s.size();i++){
			mpp[t][s[i]-'a']++;
		}
	}
	for(int j='a'-'a';j<='z'-'a';j++){
		int mn=inf;
		FOR{
			mn=min(mn,mpp[i][j]);
		}
		for(int i=1;i<=mn;i++){
			//~ cout<<"*(\n";
			//~ cout<<j<<endl;
			cout<<(char)('a'+j);
		}
	}
	return 0;
}

int main(void){
	solve();
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;
using plli=pair<ll,int>;
using vplli=vector<pair<ll,int>>;
using pllll=pair<ll,ll>;
using vpllll=vector<pair<ll,ll>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    int n;
    cin>>n;
    int ans=(1000-n%1000)%1000;
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 3640
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

int N;
vector<vector<int>> G;
vector<int> C;
vector<i64> ans;

void dfs(int u, vector<int>::const_iterator &itr) {
    if (ans[u]) return;
    ans[u] = *itr++;
    for (const int nxt : G[u]) dfs(nxt, itr);
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    read(N);
    G.resize(N);
    rep(i, 0, N - 1) {
        var(int, a, b);
        --a, --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    C.resize(N);
    read(C);
    sort(all(C), greater<>());

    ans.resize(N);
    auto itr = C.cbegin();
    dfs(0, itr);

    i64 sum = 0;
    rep(u, 0, N) {
        for (const int v : G[u]) {
            sum += min(ans[u], ans[v]);
        }
    }

    print(sum / 2);
    print(ans);

    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = 998244353;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}



void solve(){
	vector<int> v = {5, 5, 7};
	vector<int> q(3);
	rep(i, 3) cin >> q[i];
	sort(all(q));
	cout << (v == q ? "YES" : "NO");
}


 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}

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

using namespace std;

int main(){
  string T;
  cin >> T;
  
  for(int i = 0; i < T.size(); i++){
    if(T[i] == '?') T[i] = 'D';
  }
  
  cout << T << endl;
  
  return 0;
}

Measured memory_bytes: 3724
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
  long long n,a[100000];
  int co=0;
  long long a1,a2,co1=0;
  long long ans;
  cin>>n;
  for(int i=0;i<n;i++){
      cin>>a[i];
  }
  sort(a,a+n);
  for(int j=n-1;j>=0;j--){
      if(a[j]==a[j-1]){
          co++;
          continue;
      }
      else{
          if(co>=3&&co1==0){
              ans=a[j]*a[j];
              cout<<ans<<endl;
              return 0;
          }
          else if(co>=1&&co1==0){
              a1=a[j];
              co1++;
          }
          else if(co>=1&&co1==1){
              a2=a[j];
              ans=a1*a2;
              cout<<ans<<endl;
              return 0;
          }
          co=0;
      }
  }
  cout<<"0"<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
using namespace std;
const int N=2e5+5;
const int mod=1e9+7;
long long ar[N],dp[N],sum[N];
int main(){
	int n,i,j,k;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}
	dp[0]=1;
	for(i=1;i<=n;i++){
		if(ar[i]!=ar[i-1]){
			sum[ar[i]]+=dp[i-1];
		}
		if(sum[ar[i]]>=mod){
			sum[ar[i]]-=mod;
		}
		dp[i]=sum[ar[i]];
	}
	cout<<dp[n];
}

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

#define MAX_LOG 57

#define MAX_N 200000

using namespace std;

typedef long long lint;

const lint sqrInf = (lint)(1e18);

lint n, k;
int a[MAX_N + 1];
int last[MAX_N + 1];
int ap[MAX_N + 1];

int stkLen;
int stk[MAX_N + 1];

int urm[MAX_LOG + 1][MAX_N + 1];
lint sum[MAX_LOG + 1][MAX_N + 1];

int first[MAX_N + 1];

void readFile()
{
    cin >> n >> k;

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

void getNext()
{
    for(int i = n; i >= 1; i --)
    {
        if(first[a[i]] == 0)
        {
            first[a[i]] = last[a[i]] = i;
        }

        else
        {
            urm[0][i] = first[a[i]] % n + 1;
            sum[0][i] = first[a[i]] - i + 1;

            first[a[i]] = i;
        }
    }

    for(int i = 1; i <= MAX_N; i ++)
    {
        if(last[i] != 0)
        {
            urm[0][last[i]] = first[i] % n + 1;
            sum[0][last[i]] = n - last[i] + first[i] + 1;
        }
    }
}

void getJumps()
{
    for(int j = 1; j <= MAX_LOG; j ++)
    {
        for(int i = 1; i <= n; i ++)
        {
            urm[j][i] = urm[j - 1][urm[j - 1][i]];
            sum[j][i] = min(sqrInf, sum[j - 1][i] + sum[j - 1][urm[j - 1][i]]);
        }
    }
}

int cr;

void getStart()
{
    k *= n;

    cr = 1;
    for(int i = MAX_LOG; i >= 0; i --)
    {
        if(sum[i][cr] <= k)
        {
            k -= sum[i][cr];
            cr = urm[i][cr];
        }
    }
}

void getRez()
{
    memset(last, 0, sizeof(last));

    for(int i = 1; i <= k; i ++, cr = cr % n + 1)
    {
        int j = cr;
        if(last[a[j]] != 0)
        {
            int x = last[a[j]];
            while(stkLen >= x)
            {
               // cout << " AM STERS " << stk[stkLen] << " POZ " << stkLen << "\n";
                last[stk[stkLen]] = 0;
                stkLen --;
            }

            last[a[j]] = 0;
        }

        else
        {
            stkLen ++;
            stk[stkLen] = a[j];
            last[a[j]] = stkLen;
        }
    }
}

void solve()
{
    getNext();

    getJumps();

    getStart();

    getRez();
}

void printFile()
{
    for(int j = 1; j <= stkLen; j ++)
        cout << stk[j] << " " ;
    cout << "\n";
}

int main()
{
    readFile();

    solve();

    printFile();

    return 0;
}


Measured memory_bytes: 141312
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int min(int a, int b);

int main(void){
    int number, ans;

    scanf("%d", &number);
    int cost[number], dp[number];
    for (int i = 0; i < number; i++)
    {
        scanf("%d", &cost[i]);
        // printf("%d\n", cost[i]);
    }
    
    for (int i = 0; i < number; i++)
    {
        if (i == 0) {   
            dp[0] = 0;
        } else if (i == 1) {
            dp[1] = abs(cost[0]-cost[1]);
        } else {
            dp[i] = min(dp[i-1]+abs(cost[i]-cost[i-1]), dp[i-2]+abs(cost[i]-cost[i-2]));
        }
    }
    
    printf("%d\n", dp[number-1]);


    return 0;
}

int min(int a, int b){
    if(a > b){
        return b;
    } else {
        return a;
    }
}

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

/*ll gcd(ll a, ll b){
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
ll LCM(ll a,ll b)
{
    return (a*b)/gcd(a, b);
}*/

int main()
{
   int n;
   cin>>n;
   int p=n%1000;
   if(p==0)
    cout<<"0";
   else{
   int x=1000-p;
   cout<<x;
   }
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
const int MaxN = int(2e5)+100;
long long tree[4*MaxN],lazy[4*MaxN];
void update(int node,int L,int R,int a,int b,long long value){
    if(lazy[node]){
        tree[node] += lazy[node];
        if(L != R){
            lazy[node*2] += lazy[node];
            lazy[node*2+1] += lazy[node];
        }
        lazy[node] = 0;
    }
    if(L > R || R < a || L > b) return;
    if(L >= a && R <= b){
        tree[node] += value;
        if(L != R){
            lazy[node*2] += value;
            lazy[node*2+1] += value;
        }
        return;
    }
    int mid = (L+R) >> 1;
    update(node*2,L,mid,a,b,value);
    update(node*2+1,mid+1,R,a,b,value);
}
long long query(int node,int L,int R,int a){
    if(a < L or a > R) return 0;
    if(lazy[node]){
        tree[node] += lazy[node];
        if(L != R){
            lazy[node*2] += lazy[node];
            lazy[node*2+1] += lazy[node];
        }
        lazy[node] = 0;
    }
    if(L == R and L == a){
        return tree[node];
    }
    int mid = (L+R) >> 1;
    long long q1 = query(node*2,L,mid,a);
    long long q2 = query(node*2+1,mid+1,R,a);
    return q1 + q2;
}
bool cmp(int a,int b){return a > b;}
int main(){
    // freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int n,q;
    scanf("%d %d",&n,&q);
    int k = q;
    while(q--){
        long l,r,c;
        scanf("%ld %ld",&l,&r);
        update(1,1,n,l,r,1);
    }
    int B[n+5];
    for(int i = 1; i <= n; i++){
        B[i-1] = query(1,1,n,i);
        //cout << B[i-1] << " ";
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(B[i] == k)ans++;
    }
    cout << ans<< endl;

    return 0;
}


Measured memory_bytes: 8832