akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
using ull = uint_fast64_t;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vull = vector<ull>;
#define rep(i, n) for (ull i = 0; i < n; ++i)
#define rep1(i, n) for (ull i = 1; i < n; ++i)
#define iter(it, v) for (auto it = v.begin(); it != v.end(); ++it)
#define pb push_back
#define fi first
#define se second
#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }
template <typename T> void vecout(const T &v) {
  for (auto it = v.begin(); it != v.end();
       ++it, cout << (it != v.end() ? " " : "\n")) {
    cout << *it;
  }
}
template <typename T> void arrout(const T arr, ull n) {
  for (ull i = 0; i < n; ++i, cout << (i != n ? " " : "\n")) {
    cout << arr[i];
  }
}

void solve() {
  // main coding
  ll a,b,t; cin>>a>>b>>t;
  cout<<b*(t/a)<<endl;
}

int main() {
  cout << fixed << setprecision(10);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
void print_array(int a[], int n){
int i = 0;
    for(i = 0; i<n-1; i++)
        printf("%d ",a[i]);
    printf("%d\n",a[i]);
}

void selection_sort(int a[], int n){
    int res = 0;
    for(int i = 0; i<n; i++){
        int mini = i;
        for(int j=i; j<n;j++){
            if(a[j] < a[mini]) mini = j;
        }
        //swap
        int temp = a[i];
        a[i] = a[mini];
        a[mini] = temp;
        if(mini!=i)
            res++;
    }
    print_array(a,n);
    printf("%d\n",res);
}
//bubble sort
int main()
{
    int n = 0;
    scanf("%d",&n);
    int a[n+1];
    for(int i = 0; i<n; i++){
        scanf("%d",&a[i]);
    }
    //print_array(a,n);
    selection_sort(a,n);

    return 0;
}



Measured memory_bytes: 2724
function Main(input) {
    const [N, As] = input.split("\n")
    const A = As.split(" ")
    const ans = new Array(Number(N)).fill().map(_ => 0);
    // 計算量削減のためarray.prototype.reduceではなくforを使う
    for (let i=0; i < A.length; i++) {
        ans[Number(A[i]-1)]++
    }
    console.log(ans.join("\n"))

}
// Main(`5
// 1 1 2 2`)
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 53084
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#define MAX(a,b) ((a)>(b)?(a):(b))
int cmp(const void *a, const void *b)
{
  return *(long long int*)a - *(long long int*)b;
}

int main()
{
  int n, i, n_half;
  long long int a[100000];
  long long int ans=0;
  long long int ans1, ans2;

  scanf("%d",&n);
  for(i=0;i<n;i++) {
    scanf("%lld",&a[i]);
  }
  qsort(a, n, sizeof(long long int), cmp);
  if(n%2==0) {
    n_half = n/2;
    for(i=0;i<n_half-1;i++) {
      ans = ans + 2*a[n-1-i] - 2*a[i];
    }
    ans = ans + a[n_half] - a[n_half-1];
  } else {
    n_half = n/2;
    for(i=0;i<n_half-1;i++) {
      ans = ans + 2*a[n-1-i] - 2*a[i];
    }
    ans1 = ans - 2*a[n_half-1] + a[n_half] +   a[n_half+1];
    ans2 = ans -   a[n_half-1] - a[n_half] + 2*a[n_half+1];
    ans = MAX(ans1, ans2);
  }
  printf("%lld",ans);
  //printf("\n%d",n_half);
  return 0;
}


Measured memory_bytes: 1788
n=int(input())
mod=10**9+7
r=[1]*(n+1)
for i in range(1,n+1):
    for j in range(2,i+1):
        while i%j==0:
            r[j]+=1
            i//=j
ans=1
for i in r:
    ans*=i
    ans%=mod
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


int main(){
    int n, i, count = 0;
    cin >> n;
    int a[n];
    for(i=0; i<n; i++){
        cin >> a[i];
        if(count+1 == a[i]) count++;
    }
    cout << (count ? n-count : -1) << "\n";
    return 0;
}

Measured memory_bytes: 1024
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200005
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


int main()
{
	int n;
	cin >> n;
	n==0? cout << 1 << endl : cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 3592
//============================================================================
// Name        : ITP_1_7_C.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;

int main() {
	int r,c,n,rsum;
	vector<int> csum;
	cin >> r >> c;
	csum.resize(c+1);
	for(int i=0;i<c+1;++i) {
		csum[i]=0;
	}
	for(int i=0;i<r;++i) {
		rsum=0;
		for(int j=0;j<c;++j) {
			scanf("%d",&n);
			printf("%d ",n);
			csum[j]+=n;
			rsum+=n;
		}
		printf("%d\n",rsum);
		csum[c]+=rsum;
	}
	for(int j=0;j<c;++j) {
		printf("%d ",csum[j]);
	}
	printf("%d\n",csum[c]);
	return 0;
}

Measured memory_bytes: 3188
#include<iostream>
#include<map>

using namespace std;
int cnt=0;
long long n;
void counter(long long m){
    if(m>n)return;
    long long tmp = m;
    map<int, int> mp;
    mp[3]=0;mp[5]=0;mp[7]=0;
    while(tmp>0){
        mp[tmp%10]++;
        tmp/=10;
    }
    if(mp[3]*mp[5]*mp[7]>0)cnt++;
    counter(10*m+3);
    counter(10*m+5);
    counter(10*m+7);
}

int main(){
    cin >> n;
    counter(3);
    counter(5);
    counter(7);
    cout << cnt << endl;
}

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

long long int MOD = 1000000007;

long long int modpow(long long int a, long long int n, long long int mod) {
  long long int res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int main() {
  int N;
  cin >> N;
  vector<int> B(N);
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    B.at(A) += 1;
  }
  if (N % 2 == 1) {
    bool X = true;
    if (B.at(0) != 1) X = false;
    for (int i = 2; i < N; i += 2) {
      if (B.at(i) != 2) {
        X = false;
        break;
      }
    }
    if (X) cout << modpow((long long int)2, (long long int)(N - 1) / 2, MOD) << endl;
    else cout << 0 << endl;
  }
  else {
    bool X = true;
    for (int i = 1; i < N; i += 2) {
      if (B.at(i) != 2) {
        X = false;
        break;
      }
    }
    if (X) cout << modpow((long long int)2, (long long int)N / 2, MOD) << endl;
    else cout << 0 << endl;
  }
}

Measured memory_bytes: 640
/*
  Contest 075
  A - One out of Three
  Rakesh Kumar --> 11/09/2020
 */

#include <bits/stdc++.h>

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

    int r = 0, g = 0;
    std::cin >> r >> g;
    std::cout << ((g << 1) - r) << std::endl;

    return 0;
}


Measured memory_bytes: 3616
#include <cstdlib>
#include <iostream>
#include <string>

constexpr int length = 100;
template <class T>
class Stack{
public:
    Stack(){
        initial = top = new T[length];
    }

    bool IsEmpty(){
        return top == initial;
    }

    int GetRest(){
        int num = 0;
        for( auto itr = initial+1; itr <= top; ++itr ){
            ++num;
        }
        return num;
    }

    void Push( T x ){
        ++top;
        *top = x;
    }

    T Pop(){
        if( IsEmpty() ){
            std::cerr << "Stack Underflow!\n";
        }else{
            --top;
        }
        return *(top + 1);
    }

    void Print(){
        for( auto itr = initial+1; itr <= top; ++itr ){
            std::cout << "Rest[" << GetRest() << "] " <<  *itr << " ";
        }
        std::cout << '\n';
    }

private:
    T* top;
    T* initial;
};

template <typename T>
T CalcByOperator(T a, T b, char oprtr){
    switch(oprtr){
        case '+':
            return a + b;
        case '-':
            return a - b;
        case '*':
            return a * b;                
        default:
            std::cerr << "Input Error\n";
            std::exit(0);
    }

}

int main(){
    Stack<int> stack;
    std::string str;
    int tmp;
    const char* input;

    while( std::cin >> str ){
        input = str.c_str();
        if( *input == '+' || *input == '-' || *input == '*' ){
            stack.Push( CalcByOperator<int>( stack.Pop(), stack.Pop(), char(*input) ) );
        }else{
            stack.Push( std::atoi(input) );
        }
        //stack.Print();
    }

    while( stack.GetRest() > 1 ){
        stack.Push( CalcByOperator<int>( stack.Pop(), stack.Pop(), '+' ) );
    }

    std::cout << stack.Pop() << "\n";
}


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

int n;
ll ans = 0;

int main() {
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		int j = (n - 1) / i;
		ans += j;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3632
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"sort"
	"strconv"
)

func main() {
	x := readInt()
	n := readInt()
	p := readIntSlice(n)

	if n == 0 {
		fmt.Println(x)
		return
	}

	sort.Ints(p)

	result := contain(p, x)

	if result == -1 {
		fmt.Println(x)
		return
	}

	bestPlus := 0
	for i := 1; i < len(p)-result; i++ {
		if p[result]+i < p[result+i] {
			bestPlus = p[result] + i
			break
		}
	}
	if bestPlus == 0 {
		bestPlus = p[len(p)-1] + 1
	}

	//マイナス方向
	bestMinus := 0
	for i := 1; i < result; i++ {
		if p[result]-i > p[result-i] {
			bestMinus = p[result] - i
			break
		}
	}
	if bestMinus == 0 {
		bestMinus = p[0] - 1
	}

	if x == 1 {
		fmt.Println(0)
		return
	}
	if math.Abs(float64(x-bestMinus)) <= math.Abs(float64(bestPlus-x)) {
		fmt.Println(bestMinus)
		return
	} else {
		fmt.Println(bestPlus)
		return
	}

}

var (
	scanner *bufio.Scanner
)

func init() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
}

func readInt() int {
	var t string

	if scanner.Scan() {
		t = scanner.Text()
	}

	n, err := strconv.Atoi(t)
	if err != nil {
		log.Fatal(err)
	}

	return n

}

func readIntSlice(n int) []int {
	s := make([]int, n)
	var t string

	for i := 0; i < int(n); i++ {
		if scanner.Scan() {
			t = scanner.Text()
		}

		num, err := strconv.Atoi(t)
		if err != nil {
			log.Fatal(err)
		}
		s[i] = num
	}

	return s
}

func contain(p []int, x int) int {
	for i, v := range p {
		if v == x {
			return i
		}
	}
	return -1
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}


Measured memory_bytes: 1828
import java.util.Scanner;

public class Main{
	public static void main (String args[]){

		//???????????¨????????°???????????¨???
		Scanner sc = new Scanner(System.in);
		String word = sc.next();
		int q = sc.nextInt();

		//????????°???????????????????????¨???
		for(int i = 0; i < q; i++){
			String command = sc.next();

			//print a b: str str ??? a ??????????????? b ??????????????§??????????????????
			if(command.equals("print")){
				int a = sc.nextInt();
				int b = sc.nextInt();

				String str = word.substring(a,b+1);
				System.out.println(str);
			}

			//reverse a b: str str ??? a ??????????????? b ??????????????§?????????????????????
			if(command.equals("reverse")){
				int a = sc.nextInt();
				int b = sc.nextInt();

				String mae = word.substring(a,b+1);

				StringBuffer sb = new StringBuffer(mae);
				StringBuffer ato = sb.reverse();
				word = word.substring(0,a) + ato + word.substring(b+1);
			}


			//replace a b p: str str ??? a ??????????????? b ??????????????§??? p ?????????????????????
			if(command.equals("replace")){
				int a = sc.nextInt();
				int b = sc.nextInt();
				String ato = sc.next();

				word.substring(a,b+1);
				word = word.substring(0,a) + ato + word.substring(b+1);
			}
		}
		sc.close();
	}
}

Measured memory_bytes: 29208
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
    int a,b;
    
    cin >> a >> b;
    
    int d;
    int r;
    double f;
    
    d = a/b;
    r = a%b;
    f = (double)a / (double)b;
    
    printf("%d %d %.5lf\n", d,r,f);
    
    
    
    return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  char a;
  cin  >> a;
  int x = a-'a';
  if(x>=0)cout<<'a'<<endl;
  else cout<<'A'<<endl;
  return 0;
}

Measured memory_bytes: 3620
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

// -------------------</optimizations>--------------------
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#define d long double
#define pii pair<int,int>
#define pb push_back
#define cases int tc;cin>>tc;while(tc--)
#define N 100003
#define M 103
#define inf 1e18
#define Arena ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//int mod=1e9+7;
//int mod=998244353;
int dp[N];

signed main()
{
    Arena
    
    int n,W;
    cin>>n>>W;
    int w[n+1],v[n+1],i,j, sum=0;
    for(i=1;i<=n;++i)
        cin>>w[i]>>v[i], sum+=v[i];
    
    int ma=0, ans=0;
    fill(dp+1,dp+N,inf);    
    for(i=1;i<=n;++i)
    {
        for(j=sum;j>=v[i];--j)
            dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
    }
    
    for(j=sum;j>=1;--j)
        if(dp[j]<=W)
            return cout<<j, 0;
        
        
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

template<class T> vector<int> z_algorithm(const T& s) {
  vector<int> prefix(s.size());
  prefix[0] = s.size();
  int i = 1, len = 0;
  while (i < s.size()) {
    while (i + len < s.size() && s[i + len] == s[len]) ++len;
    prefix[i] = len;
    if (!len) { ++i; continue; }
    int j = 1;
    while (i + j < s.size() && prefix[j] < len - j) {
      prefix[i + j] = prefix[j];
      ++j;
    }
    i += j;
    len -= j;
  }
  return prefix;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  vector<int> a2(n), b2(n);
  rep(i, n) {
    a2[i] = a[i]^a[(i+1)%n];
    b2[i] = b[i]^b[(i+1)%n];
  }
  vector<int> s = b2;
  rep(i, 2) rep(j, n)
    s.push_back(a2[j]);
  auto res = z_algorithm(s);
  for (int i = n; i < n*2; i++) {
    if (res[i] >= n) {
      int x = a[i-n]^b[0];
      cout << i-n << ' ' << x << '\n';
    }
  }
  return 0;
}

Measured memory_bytes: 11348
K = input()
A, B = map(int, input().split())

list=[]
up = int(A)

for i  in  range(int(B)-int(A)):
	list = list + [up]
	up += 1
list = list + [up]

count = 0

for t in list:
	if int(t) % int(K) ==0:
  		count+=1

if count == 0:
  print('NG')
else:
  print('OK')
  		


Measured memory_bytes: 9184
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main()
{
    int a, b;
    scanf("%d%d", &a, &b);
    int i;
    int h = 1;
    for (i=2; i<=b-a; i++)
    {
        h += i;
    }
    printf("%d\n", h-b);
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
import java.util.Arrays;

public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();	// N種類の果物
        int K = in.nextInt();	// K種類の果物
        int p[] = new int[N];
		for(int i = 0; i<N; i++)
			p[i] = in.nextInt();	// 果物一個あたりの価格
		int sum = 0;
      
        Arrays.sort(p);
		for(int i = 0; i<K; i++)
			sum += p[i];
		System.out.println(sum);
	}
}

Measured memory_bytes: 38924
#include<bits/stdc++.h>
using namespace std;
const double eps=1e-10;
int sign(double x)
{
    if(fabs(x)<=eps)return 0;
    if(x>0)return 1;
    return -1;
}
struct Point{
    double x,y;
    Point(double _x=0,double _y=0):x(_x),y(_y){}
    Point operator + (Point p){return Point(x+p.x,y+p.y);}
    Point operator - (Point p){return Point(x-p.x,y-p.y);}
    Point operator * (double k){return Point(x*k,y*k);}
    Point operator / (double k){return Point(x/k,y/k);}
    double norm(){return x*x+y*y;}
    double abs(){return sqrt(norm());}
};
typedef Point Vector;
typedef vector<Point> polygon;
int n;
Point p;
polygon g;
double dot(Vector a,Vector b){return a.x*b.x+a.y*b.y;}
double cross(Vector a,Vector b){return a.x*b.y-a.y*b.x;}
int ccw(Point a,Point b,Point c)
{
    if(sign(cross(b-a,c-a))==-1)return 1;
    return -1;
}
int main()
{
    scanf("%d",&n);
    while(n--){
        scanf("%lf%lf",&p.x,&p.y);
        g.push_back(p);
    }
    g.push_back(g[0]);
    for(int i=0;i<g.size()-2;i++){
        if(ccw(g[i],g[i+1],g[i+2])==1){
            printf("0\n");
            return 0;
        }
    }
    printf("1\n");
    return 0;
}



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

#define ll long long
#define mx  3005
#define mod 1000000009
#define lim 10000000
#define inf 1e15
#define N 18
using namespace std;
string s,t;
int pref[105],lt,ls;

void prefSuf()
{
    int i=0,j=1;
    pref[i]=0;

    while(j<lt)
    {
    	  if(t[i]==t[j])
	  {
	  	pref[j]=i+1;
	  	i++,j++;
	  }
	  else if(i)
	  {
	  	i=pref[i-1];
	  }
	  else
	  {
	  	pref[j]=0;
	  	j++;
	  }
    }
}

bool kmp()
{
	prefSuf();
	int i=0,j=0;
	while(i<ls)
	{
		if(s[i]==t[j])
		{
			i++,j++;
		}
		else if(j)
		{
			j=pref[j-1];
		}
		else
		{
			i++;
		}

		if(j==lt)
				break;
	}
	if(j==lt)return true;
	else return false;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin>>s>>t;
	s+=s;
	ls=s.size();
	lt=t.size();

     if(kmp())cout<<"Yes\n";
     else cout<<"No\n";
     return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv){
    string a, b;
    cin >> a >> b;
    vector<vector<int>> dp(a.length() + 1, vector<int>(b.length() + 1));
    string res = "";

    vector<vector<pair<int,int>>> path(a.length() + 1, vector<pair<int,int>>(b.length() + 1));

    for(int i = 0; i < a.length(); ++i){
        for(int j  = 0; j < b.length(); ++j){
            if(a[i] == b[j]){
                dp[i+1][j+1] = 1 + dp[i][j];
                path[i+1][j+1] = make_pair(i,j);
            }else{
                int v1 = dp[i+1][j];
                int v2 = dp[i][j+1];
                if(v1 > v2){
                    dp[i+1][j+1] = v1;
                    path[i+1][j+1] = make_pair(i+1, j);
                }else{
                    dp[i+1][j+1] = v2;
                    path[i+1][j+1] = make_pair(i, j+1);
                }
            }
        }
    }

    /*
    for(const auto& v : dp){
        for (const auto& i : v){
            cout << i << " ";
        }
        cout << "\n";
    }
    */
    
    pair<int, int> c{a.length(), b.length()};

    while(c.first != 0 && c.second != 0){
        if(a[c.first-1] == b[c.second-1]){
            res.push_back(a[c.first-1]);
        }

        c = path[c.first][c.second];
    }
    //cout << "\n";
    reverse(res.begin(), res.end());
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 105984
#include <iostream>

using namespace std;

int n;
int a[100005];
int l[100005], r[100005];

int gcd(int a, int b)
{
	if(b==0) return a;
	return gcd(b, a%b);
}

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

	for(int i = 1; i <= n; i++) l[i] = gcd(l[i-1], a[i]);
	for(int i = n; i >= 1; i--) r[i] = gcd(r[i+1], a[i]);

	int ans = 0;
	for(int i = 1; i <= n; i++){
		ans = max(ans, gcd(l[i-1], r[i+1]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
// #include <boost/multiprecision/cpp_int.hpp> 
 
#define gc getchar//_unlocked
#define pc putchar//_unlocked
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pp pair<int,int>
#define ppl pair<ll,ll>
#define bigint boost::multiprecision::cpp_int
#define finp ios_base::sync_with_stdio(0);cin.tie(0);
#define bc __builtin_popcountll
#define afor(i,a,b) for(int i=a;i<=b;++i)
#define bfor(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vpp vector<pp>
#define vll vector<ll>
#define fr first
#define se second
 
using namespace std;
using namespace __gnu_pbds;
 
char putnb[20];
void putn(ll n) {if(!n)pc('0');if(n<0)pc('-'),n=0-n;int pi=0;while(n)putnb[pi++]=(n%10)+'0',n/=10;while(pi)pc(putnb[--pi]);}
void sci(int *x) {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x = (int)((((*x)<<1) + ((*x)<<3)) + c - 48);}
void scll(ll *x)  {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x =  (ll)((((*x)<<1) + ((*x)<<3)) + c - 48);}
ll fp(ll a,ll b,ll c) {if(b==0)return 1%c; if(b==1)return a%c; ll ret=fp(a,b/2,c); ret=(ret*ret)%c; if(b&1)ret=(ret*a)%c; return ret;}
 
const ll mod=1e9 +7;
const ll mod2=1999999973;
const ll inf=1e18;
const int infs=1e9 + 1000;
const int N=100000;
const long double PI = acos(-1);
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
 
 
int main()
{
  finp;
string s;
int k;
cin>>s>>k;
for(int i=0;i<s.size();i+=k)
{
cout<<s[i];
}
  
return 0;
}

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

int main() {
  int a;
  cin >> a;
  int b[1000000];
  int c = 0;
  int d;
  for(int i = 0; i < 1000000;i++){
    if(i == 0){
      b[i] = a;
    }else if(b[i-1]%2 == 0){
      b[i] = b[i-1]/2;
    }else{
      b[i] = b[i-1]*3+1;
    }
    if(i != 0){
      for(int j = 0;j < i;j++){
        if(b[j] == b[i]){
          d = i + 1;
          c = 1;
          break;
        }
      }
    }
    if(c == 1){
      break;
    }
    
  }
  cout << d << endl;
}


Measured memory_bytes: 256
from operator import itemgetter
n = int(input())
red = []
blue = []
for _ in range(n):
    red.append(list(map(int, input().split())))
for _ in range(n):
    blue.append(list(map(int, input().split())))
red.sort(key=itemgetter(0), reverse=True)
blue.sort(key=itemgetter(1), reverse=False)
for i in range(n):
    for j in range(len(blue)):
        if red[i][0] < blue[j][0] and red[i][1] < blue[j][1]:
            blue.pop(j)
            break
print(n-len(blue))

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<vector<pair<int, int> > > vvp;
typedef vector<pair<int, int> > vp;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
typedef vector<vector<ll> > vvl;
typedef vector<ll> vl;
typedef vector<vector<bool> > vvb;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<string, int> psi;
typedef pair<int, int> pii;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define yn(f) (f?"yes":"no")
#define YN(f) (f?"YES":"NO")
#define Yn(f) (f?"Yes":"No")
#define mod (1e9+7)
#define inf (1e9+7)
#define nil -1
int main() {
	int A, B, C;
	cin >> A >> B >> C;
	int n = A - B;
	cout << (max(0,C-n)) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007

//qsort用、昇順
int compare_int(const void *a, const void *b)
{
	return *(int*)a-*(int*)b;
}
//qsort(data, 10, sizeof(int), compare_int)


int main(){
	int n;
	scanf("%d", &n);
	int amari = n%1000;
	int ans = 1000 - amari;
	if(ans == 1000) ans = 0;
	
	printf("%d\n", ans);
	
	
	return 0;
}


Measured memory_bytes: 1728
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n = II()
    print((pow(10, n, mod) - pow(9, n, mod) * 2 + pow(8, n, mod)) % mod)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 76728
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 310;
const int MAXM = 1000010;
const int MAXK = 510;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int a, b;
    cin >> a >> b;
    cout << a / (b * 2 + 1) + (a % (b * 2 + 1) > 0);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29

int n, ans = 0, a[3][100000], dp[100100][3];

int main(){
	cin >> n;
	rep(i, n) rep(j, 3) cin >> a[j][i];
	rep(i, n) {
		rep(j, 3) {
			rep(k, 3) {
				if (j == k) continue;
				dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + a[k][i]);
			}
		}
	}
	cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
}



Measured memory_bytes: 2560
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

int n;
set<int> s;

int main(){
  cin >> n;
  rep(n){
    int x;
    cin >> x;
    s.insert(x);
  }
  cout << s.size() - (s.size() % 2 == 0) << endl;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef long long l;
l ans;
int main()
{
	l a,b,c,d;
	cin>>a>>b>>c>>d;
	ans+=min(a,d);
	d=d-a;
	if(d<=0)
	{
		cout<<ans<<endl;
		return 0;
	}
	d-=b;
	if(d<=0)
	{
		cout<<ans<<endl;
		return 0;
	}
	cout<<ans-d<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

//素因数分解
map<ll, int> prime_factor(ll n) {
    map<ll, int> ret;
    for(ll i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1)
        ret[n] = 1;
    return ret;
}

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while(n) {
        if(n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll modinv(ll a, ll mod) {
    return modpow(a, mod - 2, mod);
}

ll calc(map<ll, int> mp) {
    ll res = 1;
    for(auto p : mp) {
        res = res * modpow(p.first, p.second, MOD) % MOD;
    }
    return res;
}

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    map<ll, int> factors;
    rep(i, N) {
        auto f = prime_factor(A[i]);
        for(auto x : f) {
            factors[x.first] = max(factors[x.first], x.second);
        }
    }
    ll lcm = calc(factors);
    ll res = 0;
    rep(i, N) { res = (res + ((lcm * modinv(A[i], MOD)) % MOD)) % MOD; }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1536
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}
func floatSum(a []float64) float64 {
	x := 0.
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	x := make([][10]int, 10)
	for i := 1; i <= n; i++ {
		j := strconv.Itoa(i)
		x[stringToInt(string(j[0]))][stringToInt(string(j[len(j)-1]))]++
	}
	ans := 0
	for i := 0; i < 10; i++ {
		for j := 0; j < 10; j++ {
			ans += x[i][j] * x[j][i]
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  int q;
  cin >> q;
  while (q--) {
    int m, b, e;
    cin >> m >> b >> e;
    if (m) {
      cout << *max_element(v.begin() + b, v.begin() + e) << endl;
    } else {
      cout << *min_element(v.begin() + b, v.begin() + e) << endl;
    }
  }
}


Measured memory_bytes: 3140
#pragma region template 2.3
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), cout, ", ") << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, ostream &os = cout, string sep = " ")
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), os, ", ") << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, X);
    IN(ll, Y);
    IN(ll, Z);
    vi ans = {Z, X, Y};
    JOUT(ALL(ans));
}

Measured memory_bytes: 256
n,k = map(int,input().split())
s = list(map(int,input()))
s_list = list()
num = s[0]
temp_streak = 0
# temp_max = 0
# temp_sum = 0
[s_list.append(0) for i in range(1+s[0])]

for i in s:
    if i == num:
        temp_streak += 1
    else:
        s_list.append(temp_streak)
        temp_streak = 1
        num = i

s_list.append(temp_streak)
[s_list.append(0) for i in range(1+s[-1])]
# odd = len(s_list)%2
num_i = len(s_list) // 2 
# print(s_list)
temp_max = sum(s_list[0:min(k*2+1,len(s_list) + 1)])
temp_sum = temp_max
temp_max_debug = temp_max
# print(temp_max)
for i in range(1,max(num_i+1-k,1)):
    temp_sum = temp_sum - s_list[i*2-2] - s_list[i*2-1] + s_list[i*2+k*2-1] + s_list[i*2+k*2]
    temp_max = max(temp_max,temp_sum)
    # temp_max_debug = max(temp_max_debug,sum(s_list[i*2:i*2+k*2+1]))
print(temp_max)
# print(temp_max_debug)



#print(s_list)

Measured memory_bytes: 5152
n, a, b = map(int, input().split())
mod = 10 ** 9 + 7


def choose(n, r, mod):
    r = min(r, n - r)
    x = 1
    y = 1
    for i in range(r):
        x = x * (n - i) % mod
        y = y * (i + 1) % mod
    y = pow(y, mod-2, mod)
    return x * y % mod


ans = pow(2, n, mod) - 1 - choose(n, a, mod) - choose(n, b, mod)

while ans < 0:
    ans += mod
print(ans)


Measured memory_bytes: 3064
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N =sc.nextInt();
        int X = sc.nextInt();
        int opt=1;
        int len=0;
        ArrayList<Integer> L = new ArrayList<>();
        for(int i=0;i<N;i++){
            int l = sc.nextInt();
            len+=l;
            if(len<=X)opt++;
            else if(len>X)break;
        }
        System.out.println(opt);
    }
}


Measured memory_bytes: 21844
st = input()
if st == "SSS":
    print(0)
elif st == "SSR":
    print(1)
elif st == "SRS":
    print(1)
elif st == "SRR":
    print(2)
elif st == "RSS":
    print(1)
elif st == "RSR":
    print(1)
elif st == "RRS":
    print(2)
elif st == "RRR":
    print(3)


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

int h, w;
mt19937 ei(1333333);

bool check(vector<string> s) {
  int h = s.size();
  vector<string> t = s;
  for (auto &i : t) reverse(i.begin(), i.end());

  int cnt = 0;
  vector<bool> used(h);
  for (int i = 0; i < h; ++i) {
    if (used[i]) continue;
    for (int j = i + 1; j < h; ++j) {
      if (used[j]) continue;
      if (s[i] == t[j]) {
        used[i] = used[j] = true;
        cnt += 2;
        break;
      }
    }
  }

  if (h - cnt >= 2) return false;

  if (h & 1) {
    for (int i = 0; i < h; ++i) {
      if (used[i]) continue;
      if (s[i] == t[i]) cnt++;
    }
  }

  return cnt == h;
}

bool solve(vector<string> &t, int q = 400000) {
  vector<string> s = t;
  vector<int> v(w);
  for (int i = 0; i < w; ++i) v[i] = i;
  while (q--) {
    //怒りの乱択
    if (check(s)) return true;
    shuffle(v.begin(), v.end(), ei);
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        s[i][j] = t[i][v[j]];
      }
    }
  }

  return false;
}

int main() {
  cin >> h >> w;

  vector<string> s(h);
  for (auto &i : s) cin >> i;

  cout << (solve(s) ? "YES" : "NO") << endl;
}


Measured memory_bytes: 384
S=int(input())
L=list(map(int,input().split()))
ans=0
for l in range(len(L)-2):
  if L[l]<L[l+1] and L[l+1]<L[l+2]:
    ans=ans+1
  elif L[l]>L[l+1] and L[l+1]>L[l+2]:
    ans=ans+1
  else:
    continue
print(ans)
  

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

long long gcd(long long aaa,long long bbb) {
    if(bbb==0) {
        return aaa;
    }
    return gcd(bbb,aaa%bbb);
}

int main (){

    ll N,X;
    cin >> N >> X;
    ll x[N],x2[N+1],m=1e9,mn;
    for(ll i = 0; i < N; i++) {
        cin >> x[i];
        if(abs(x[i] - X) < m) {
            m = abs(x[i] - X);
        }
    }

    sort(x,x+N);

    for(ll i = 1; i < N; i++) {
        m = gcd(abs(x[i-1] - x[i]),m);
    }

    cout << m << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD =1e9+7;
using ll=long long;
using Graph = vector<vector<int>>;

int main() {
    string s,t;
    cin >> s >> t;
    int ans = 0;
    rep(i,s.size()){
        if(s[i] != t[i]) ans++;      
    }
    cout << ans << endl;
}

Measured memory_bytes: 3840
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#include <cmath>
#define WMAX 10000
#define HMAX 10000
#define NMAX 102

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef long long ll;
typedef pair<int ,int > P;

struct edge{
  int to,cost;
};

int A[NMAX],B,C,N,W,H,ans = 0,dp[HMAX][WMAX],sum = 0;
string S;
vector<char > v;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};

void solve(){
	if(sum%10){
		ans = sum;
		return;
	}
	for (int i = 0; i < N; ++i)
	{
		if((sum-A[i])%10){
			ans = max(ans,sum-A[i]);
		}
	}
}

void debug(){

}

void answer(){
	cout << ans << endl;
}

int main(){
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		cin >> A[i];
		sum+=A[i];
	}
	solve();
	#ifdef DEBUG
	debug();
	#endif
	answer();

	return 0;
}

Measured memory_bytes: 256
from collections import Counter

N = int(input())
D = Counter(map(int,input().split()))
M = int(input())
T = list(map(int,input().split()))

for i in range(M):
    if 0 < D[T[i]]:
        D[T[i]] -= 1
    else:
        print("NO")
        break
else:
    print("YES")

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

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

    for (int i = 1; i <= 100; i++)
    {
        for (int j = 1; j <= 100; j++)
        {
            for (int k = 1; k <= 100; k++)
            {
                int t = i * i + j * j + k * k + i * j + j * k + k * i;
                if (t <= n)
                    f[t]++;
            }
        }
    }

    for (int i = 1; i <= n; i++)
        cout << f[i] << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;



int main(int argc, char* argv[])
{
    char str[105]={0};
    char str1[105]={0};
    scanf("%s%s", str, str1);

    int len=strlen(str);
    int len1=strlen(str1);
    char str2[205]={0};
    strcpy( str2, str);
    strcat( str2, str);

    int cnt=0;
    int i;
    for(i=0; i<len; i++) {
        if(strncmp( str2+i, str1, len1 )==0) cnt++;
    }
    if(cnt) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }
    return 0;
}



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

int main () {
    int n, d, ans = 0;
    cin >> n >> d;

    for (int i = 0; i < n; i++) {
        double a, b;
        cin >> a >> b;
        if (sqrt(a*a+b*b) <= d) {
            ans ++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <sstream>
#include <vector>
#include<cstdio>
#include<iomanip>
using namespace std;
int main(void){
  long double s;
  cin >> s;
  s = s / 3;
  s = s * s * s;
  cout << setprecision(14) << s << endl;
  
  return 0;
}

Measured memory_bytes: 256
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))



def main():
    x = ii()
    l = [0 for i in range(200005)]

    l[100] = 1
    l[101] = 1
    l[102] = 1
    l[103] = 1
    l[104] = 1
    l[105] = 1
    
    for a in range(6):
        for i in range(150000):
            if l[i] == 1:
                l[i+100+a] = 1
    
    print(l[x])



main()


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

int main(){
  string S,T,U;
  int A,B;
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  
  if(S == U){
    A--;
  }
  if(T == U){
    B--;
  }
  
  cout << A << " " << B << endl;
  
}

Measured memory_bytes: 256
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve

int main(int argc, char const* argv[])
{
  string s;
  unordered_map<string, int> mp;
  int maxi = -1;
  string res = "";
  while(cin >> s){
    mp[s]++;
    if(maxi < int(s.size())){
      maxi = s.size();
      res = s;
    }
  }
  int maxi2 = -1;
  string res2 = "";
  for(auto itr = mp.begin(); itr != mp.end(); ++itr){
    if(maxi2 < itr->second){
      maxi2 = itr->second;
      res2 = itr->first;
    }
  }
  cout << res2 << " " << res << endl;
	return 0;
}



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

int main() {
    int n;
    cin>>n;
    int b[n];
    int first = 0, last=0;
    for(int i=0;i<n-1;i++){
        cin>>b[i];
        first = b[0];
        last = b[n-2];
    }
    long long sum =0;
    for(int i=0;i<n-2;i++){
        sum += min(b[i],b[i+1]);
    }
    
    
    cout << sum + first+ last << endl;
    
}


Measured memory_bytes: 256
import itertools
import sys
input = sys.stdin.readline

n = int(input())
pn = list(map(int, input().split()))
qn = list(map(int, input().split()))

n_list = [x for x in range(1, n+1)]
count = 0 
ans = 0
for i in itertools.permutations(n_list, n):
    count += 1
    if list(i) == pn:
        ans += count
    if list(i) == qn:
        ans -= count

print(abs(ans))

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


int main(void) {
  ll n, t;
  cin >> n >> t;
  vector<ll> tv(n);
  rep(i, n) {
    cin >> tv[i];
  }

  ll ans = t;
  for (int i = 1; i < n; ++i) {
    ans += t;
    if (t > tv[i] - tv[i - 1]) ans = ans - t + tv[i] - tv[i - 1];
  }

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

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

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int main()
{
	IOS;
	int n,a;
	cin>>n>>a;
	cout<<n*n-a;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
using namespace std;

int main(){
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        if(i%3==0){
            printf(" %d",i);
        }else{
            int x = i;
            while(x){
                if(x%10==3){
                    printf(" %d",i);
                    break;
                }
                x /= 10;
            }
        }
    }printf("\n");
}


Measured memory_bytes: 2768