akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll Pow(ll A, ll N){
  if (N==0) return 1;
  if (N%2==0) return Pow(A*A%MOD, N/2);
  return Pow(A*A%MOD, N/2)*A%MOD;
}

int N, A[int(1e5 + 5)], two;
int visited[int(1e5 + 5)];
ll L, R;
ll nCk1[int(1e5 + 5)], nCk2[int(1e5+5)];


int main(){
  scanf("%d", &N);
  for (int i = 1; i <= N + 1; i++){
    scanf("%d", A + i);
    if (visited[A[i]] > 0){
      L = visited[A[i]] - 1;
      R = N + 1 - i;
    }
    visited[A[i]] = i;
  }

  nCk1[0] = 1;
  for (ll i = 1; i <= N + 1; i++){
    nCk1[i] = nCk1[i-1] * (N+2-i);
    nCk1[i] %= MOD;
    nCk1[i] *= Pow(i, MOD-2);
    nCk1[i] %= MOD;
  }

  nCk2[1] = 1;
  for (ll i = 2; i <= L+R+1; i++){
    nCk2[i] = nCk2[i-1] *(L+R-i+2);
    nCk2[i] %= MOD;
    nCk2[i] *= Pow(i-1, MOD-2);
    nCk2[i] %= MOD;
  }

  for (ll i = 1; i <= N + 1;i++){
    ll ans = nCk1[i] - nCk2[i];
    ans %= MOD;
    if (ans < 0) ans += MOD;
    printf("%lld\n", ans);
  }

  return 0;
}


Measured memory_bytes: 5884
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,sum=0;
	cin>>n>>m;
	if(n>1)
		sum+=n*(n-1)/2;
	if(m>1)
		sum+=m*(m-1)/2;
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
ll N, K;
int f(int a, int b)
{
    return a - a / b;
}

int main()
{
    cin >> N >> K;
    if (K == 0)
    {
        cout << N * N << endl;
        return 0;
    }
    ll result = 0;
    for (int b = K + 1; b <= N; b++)
    {
        ll x = N / b;
        ll y = b - K;
        ll z = max(0LL, N % b - K + 1);
        result += x * y + z;

    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
/*using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) (int)s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
//int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
bool dp[N];
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
       int n,k;
       cin>>n>>k;
       int arr[n];
       rep(i,0,n)
       cin>>arr[i];
       for(int i=0;i<=k;++i)
       {
           for(int j=0;j<n;++j)
           {
               if(i-arr[j]>=0&&dp[i-arr[j]]==0)
               {
                   dp[i] = true;
               }
           }
       }
       if(dp[k])
        cout<<"First"<<el;
       else
        cout<<"Second"<<el;
    }
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define ss st.st
#define sn st.nd 
/****************************/
int n;
int a[100010];
int b[100010];
ll numa,numb;
vi c;
bool cmp(int a,int b)
{
	return a>b;
}
int main()
{
    cin>>n;
    rep(i,n)
    { 
    	cin>>a[i];
    	numa+=a[i];
	}
	rep(i,n)
	{
		cin>>b[i];
		numb+=b[i];
	}
	if(numa<numb)
	{
		cout<<"-1";
		return 0;
	}
	ll neednum=0;
	int ans=0;
	rep(i,n)
	{
		if(a[i]<b[i])
		{
			neednum+=b[i]-a[i];
			ans++;
		}
		c.pb(a[i]-b[i]);
	}
	sort(c.begin(),c.end(),cmp);
	rep(i,SZ(c))
	{
		if(neednum<=0)
		{
			break;
		}
		ans++;
		neednum-=c[i];
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 1660
import java.util.ArrayList;
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        boolean state = true;
        ArrayList<Integer> list = new ArrayList<Integer>();

        while (state) {
            int input = scanner.nextInt();
            int input2 = scanner.nextInt();
            list.add(input); list.add(input2);
            if ( input == 0 && input2 == 0)  state = false;
        }

        int temp;

        for (int i=0;i<list.size()-2;i=i+2){
            if(list.get(i) > list.get(i+1)){
                //System.out.println("test: " + list.get(i) + " " + list.get(i+1));
                temp = list.get(i);
                list.set(i,list.get(i+1));
                list.set(i+1, temp);
            }
            System.out.println(list.get(i) + " " + list.get(i+1));
        }

    }
}


Measured memory_bytes: 36424
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	// sc.Split(bufio.ScanWords)

	var S string
	fmt.Scan(&S)
	m := map[string]int{"N": 0, "W": 0, "S": 0, "E": 0}

	for _, ss := range S {
		m[string(ss)]++
	}

	if (m["N"] == m["S"]) && (m["W"] == m["E"]) {
		fmt.Println("Yes")
	} else if (m["N"] > 0 && 0 < m["S"]) && (m["W"] == 0 && m["E"] == 0) {
		fmt.Println("Yes")
	} else if (m["N"] == 0 && m["S"] == 0) && (m["W"] > 0 && 0 < m["E"]) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void) {
    int N, i;
    char S[105], T[105];
    scanf("%d%s%s", &N, S, T);
    for (i=0; i<N; i++) {
        printf("%c", S[i]);
        printf("%c", T[i]);
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
    using namespace std;
    vector<vector<long long>>adj,dp;
    #define MOD 1000000007
    long long dfs(int v,int p,int colour){
        if(dp[v][colour]!=-1) return dp[v][colour];
        else{
            dp[v][colour]=1;
            
            for(int i=0;i<adj[v].size();i++){
                long long sub;
                if(adj[v][i]!=p){
                    if(colour==0)
                        sub=dfs(adj[v][i],v,1)%MOD;
                    else{
                        sub=(dfs(adj[v][i],v,0)+dfs(adj[v][i],v,1))%MOD;
                    }
                    dp[v][colour]*=sub;
                 dp[v][colour]%=MOD;
                }
                
            }
            return dp[v][colour]%MOD;
        }
        
    }
    int main(){
        long n;
        cin>>n;
        adj.resize(n+1,vector<long long>(0));
        dp.resize(n+1,vector<long long>(2,-1));
        for(int i=0;i<n-1;i++){
            int x,y;
            cin>>x>>y;
            adj[x].push_back(y);
            adj[y].push_back(x);
        }
        long long ans=(dfs(1,-1,0)+dfs(1,-1,1))%MOD;
        // cout<<dp[1][0];
        cout<<ans;
        return 0;
    }

Measured memory_bytes: 19584
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#define rep(i,n) for (int i = 0; i < (n);i++)
typedef long long ll;
using namespace std;
/*#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;*/


void Main()
{
	double n; cin>>n;
	vector<double> v(n); rep(i,n) cin>>v.at(i);
	sort(v.begin(),v.end());
	v.at(0)/=pow(2.0,n-1);
	for(int i=1;i<=n-1;i++) {
		v.at(i)/=pow(2.0,n-i);
	}
	double sum;
	rep(i,n) sum+=v.at(i);
	cout << sum << endl;

}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

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

int main(){
    int A;
    cin >> A;
    for (int i = 1; i <= 9; i++){
        for (int j = 1; j <= 9; j++){
            if (i*j == A){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
import sys
N=int(input())
a=list(map(int,input().split()))
b,c,d=0,1,0
while True:
    while True:
        if a[b]%(2**c)>=2**(c-1):
            d+=1
        b+=1
        if b==N:
            if d%2==1:
                print('No')
                sys.exit()
            else:
                break
    b,d=0,0
    c+=1
    if c==27:
        break
print('Yes')

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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<vector<ll>> a(n, vector<ll>(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a.at(i).at(j);
    }
  }
  
  vector<ll> cost(1 << n, 0);
  for (int bit = 1; bit < (1 << n); bit++) {
    for (int i = 0; i < n - 1; i++) {
      for (int j = i + 1; j < n; j++) {
        if ((bit & (1 << i)) && (bit & (1 << j))) cost.at(bit) += a.at(i).at(j);
      }
    }
  }
  
  vector<ll> dp(1 << n);
  dp.at(0) = 0;
  
  for (int bit = 1; bit < (1 << n); bit++) {
    dp.at(bit) = cost.at(bit);
    for (int s = bit; s > 0; s = (s - 1) & bit) {
      if (bit == s) continue;
      dp.at(bit) = max(dp.at(bit), dp.at(bit - s) + cost.at(s));
    }
  }
  
  cout << dp.at((1 << n) - 1) << '\n';
}

Measured memory_bytes: 1280
S=input()
n=len(S)
L=[0]*n
flag=0
c=1
for i in range(n-1):
    if S[i]==S[i+1]:
        c+=1
    else:
        if flag==0:
            L[i]+=c//2 if c%2==0 else c//2+1
            L[i+1]+=c//2
        else:
            L[i-c+1]+=c//2 if c%2==0 else c//2+1
            L[i-c]+=c//2
        c=1
        if flag==0:
            flag=1
        else:
            flag=0
L[i-c+2]+=c//2 if c%2==0 else c//2+1
L[i-c+1]+=c//2
print(' '.join(map(str,L)))

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX;
const ll MINF = LONG_LONG_MIN;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    vector<ll> street(n);
    rep(i, n)cin >> street[i];

    ll ans = 0;
    for (ll i = 0; i < n - 1; i++) {
        ll now = (street[i + 1] - street[i]) * a;
        cmin(now, b);
        ans += now;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
from collections import deque
def solve():
    N, M, P = map(int, input().split())
    G = [[] for i in range(N)]
    RG = [[] for i in range(N)]
    for i in range(M):
        a, b, c = map(int, input().split())
        G[a-1].append((b-1, P-c))
        RG[b-1].append((a-1, P-c))

    def chk(s, G):
        P = [0]*N
        que = deque([s])
        used = [0]*N
        used[s] = 1
        while que:
            v = que.popleft()
            P[v] = 1
            for w, c in G[v]:
                if used[w]:
                    continue
                que.append(w)
                used[w] = 1
        return P
    P0 = chk(0, G); P1 = chk(N-1, RG)
    F = [P0[i] == P1[i] == 1 for i in range(N)]
    I = [i for i in range(N) if F[i]]

    E0 = []
    for v in I:
        for w, c in G[v]:
            if not F[w]:
                continue
            E0.append((v, w, c))

    dist = [10**18]*N
    dist[0] = 0
    L = len(I)
    for i in range(L):
        update = 0
        for v, w, c in E0:
            x = c + dist[v]
            if x < dist[w]:
                dist[w] = x
                update = 1
        if not update:
            break
    else:
        print("-1")
        return

    print(max(-dist[N-1], 0))
solve()

Measured memory_bytes: 5748
#include <vector>
#include <iostream>
#include <numeric>
#include <algorithm>

using mass_t = std::vector<std::vector<int>>;

int solve_impl(const mass_t & a, int r) {
  return std::accumulate(std::begin(a[1]) + r, std::end(a[1]),
      std::accumulate(std::begin(a[0]), std::begin(a[0]) + r + 1, 0));
}

int solve(const mass_t & a, int n) {
  int ans { 0 };
  for(int i = 0; i < n; ++i) {
    ans = std::max(ans, solve_impl(a, i));
  }
  return ans;
}

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

  mass_t a;
  for(int i = 0; i < 2; ++i) {
    std::vector<int> v;
    for(int j = 0; j < n; ++j) {
      int tmp;
      std::cin >> tmp;
      v.push_back(tmp);
    }
    a.push_back(v);
  }

  std::cout << solve(a, n) << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n=0;
    char arr[105]={};
    scanf("%d", &n);
    scanf("%s", &arr[0]);
    int x=0;
    int max=0;
    for(int i=0;i<n;i++){
        if (arr[i]=='I')
        x++;
        else if (arr[i]=='D')
        x--;
        if (x>max){
            max=x;
        }
    }
    printf("%d", max);
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    TreeMap<Integer,Integer> lastMonth = new TreeMap<Integer,Integer>();
    while(true) {
      String str = sc.nextLine();
      if (str.equals("")) {
        break;
      }
      int id = Integer.parseInt(str.split(",")[0]);
      if (lastMonth.containsKey(id)) {
        lastMonth.put(id,lastMonth.get(id)+1);
      }
      else {
        lastMonth.put(id,1);
      }
    }
    TreeMap<Integer,Integer> thisMonth = new TreeMap<Integer,Integer>();
    while(sc.hasNext()) {
      int id = Integer.parseInt(sc.next().split(",")[0]);
      if (thisMonth.containsKey(id)) {
        thisMonth.put(id,thisMonth.get(id)+1);
      }
      else {
        thisMonth.put(id,1);
      }
    }
    Iterator it = thisMonth.keySet().iterator();
    while (it.hasNext()) {
      Object idOb = it.next();
      int id = Integer.parseInt(idOb.toString());
      if (lastMonth.containsKey(id)) {
        System.out.println(id + " " + (thisMonth.get(id)+lastMonth.get(id)));
      }
    }
  }
}

Measured memory_bytes: 11000
# @oj: atcoder
# @id: hitwanyang
# @email: 296866643@qq.com
# @date: 2020-05-10 20:01
# @url:
import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string
# region fastio

BUFSIZE = 8192

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# ------------------------------
def main():
    s=str(input())
    t=str(input())
    if t.startswith(s):
        print ("Yes")
    else:
        print ("No")
if __name__ == "__main__":
    main()

Measured memory_bytes: 68364
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9,MOD = 1e9+7,ohara = 1e6;
const ll LINF = 1e18;
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt=0,ans=0,a,b,c[ohara],d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>n>>a>>b;
    rep(i,n)cin>>c[i];
    ans=abs(c[n-1]-b);
    if(n>=2)ans=max(ans,abs(c[n-1]-c[n-2]));
    Cout(ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
#define int long long

signed main(){
  int n,m;
  bool disable[100006]={};
  int cnt[100006]={};
  cin >> n>>m;
  LOOP(i,m){
    int a;
    cin >> a;
    disable[a]=true;
  }
  cnt[1] = !disable[1];
  cnt[2] = ((!disable[2])? 1 + cnt[1] : 0);
  FOR(i,3,n+1){
    if(disable[i]==false){
      cnt[i]=cnt[i-1]+cnt[i-2];
      cnt[i]%=1000000007;
    }
  }
  cout << cnt[n] << endl;
}


Measured memory_bytes: 1152
<?php

$a = trim(fgets(STDIN));

$s = trim(fgets(STDIN));

if($a >= 3200) {
	echo $s."\n";
} else {
	echo "red\n";
}

// $arr = [$input[0]];
// $tmp = '';
// for($i = 1;$i < strlen($input);$i++) {
//   $m = count($arr);
//   $tmp .= $input[$i];

//   if($arr[$m - 1] === $tmp) {

//   } else {
//     $arr[] = $tmp;
//     $tmp = '';
//   }
// }

// echo count($arr)."\n";

Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int a,b,x,y,k,m=0;
	cin>>a>>b>>x>>y>>k;
	if(y>=b)
    {
        m=y-b+(x-a)*60;
        cout<<m-k<<endl;
    }
    else
    {
        x--;
        y+=60;
        m=y-b+(x-a)*60;
        cout<<m-k<<endl;
    }
	return 0;
}


Measured memory_bytes: 3656
import math

c = 0
n = int(input())

for i in range(n):
    m = int(input())

    if m == 2:
        c += 1
    elif m > 2:
        for j in range(2, int(math.sqrt(m)) + 2):
            if m % j == 0:
                break
            if j == int(math.sqrt(m)) + 1:
                c += 1

print(c)


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

int main() {
  ll x, y, rev;
  cin >> x >> y;
  if (x*y == 1) rev = 1;
  else if (min(x,y) == 1) rev = x*y-2;
  else rev = (x-2)*(y-2);
  cout << rev << endl;
}

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

char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char c;

int main(){
    cin>>c;
    for(int i=0;i<26;i++){
        if(c==alp[i]){
            cout<<alp[i+1]<<endl;
        }
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
      Scanner sc=new Scanner(System.in);
      String[] param = sc.nextLine().split(" ");
      Integer N = Integer.parseInt(param[0]);
      Integer M = Integer.parseInt(param[1]);
      Integer C = Integer.parseInt(param[2]);
      
      String[] strB = sc.nextLine().split(" ");
      List<Integer> A = new ArrayList<>();
      List<Integer> B = new ArrayList<>();
      for(String b : strB) {
        B.add(Integer.parseInt(b));
        A.add(0);
      }
      
      int counter = 0;
      for(int index=0; index<N; index++) {
        int chk = 0;
        String[] strA = sc.nextLine().split(" ");
        for(int inner=0; inner<M; inner++) {
          A.set(inner, Integer.parseInt(strA[inner]));
          chk += A.get(inner) * B.get(inner);
        }
        
        chk += C;
        if( chk > 0 ) { counter++; }
      }
      
      System.out.println(counter);

    }
}


Measured memory_bytes: 22608
import java.util.*;
public class Main {
	
	void doIt() {
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			int N = stdIn.nextInt();
			int P = stdIn.nextInt();
			if(N == -1 && P == -1) break;
			
			ArrayList<Integer> list = new ArrayList<Integer>();
			int num = N;
			
			//せっきーの方法
			while(list.size() < 100) {
				boolean flag = true; //素数であると仮定
				if(N == 1) flag = false;
				for(int c = 2; c * c <= N; c++) {
					if(N % c == 0) {
						flag = false;
						break;
					}
				}
				if(flag) list.add(N);
				N++;
			}
			
			
			
			for(int r = 0; r < list.size(); r++) {
				if(list.get(r) > num) { 
					num = r; //添字にする 
					break;
				}
			}
			
			ArrayList<Integer> output = new ArrayList<Integer>();
			for(int r = num; r < list.size(); r++) {
				for(int c = r; c < list.size(); c++) {
					output.add(list.get(r) + list.get(c));
				}
			}
			Collections.sort(output);
			System.out.println(output.get(P - 1));
		}
	}
	
	public static void main(String[] args) {
		new Main().doIt();
	}
}

Measured memory_bytes: 102604
#include<stdio.h>

int binarySearch(int S[], int n, int key){
    int left=0;
    int right=n;
    int mid;

    while(left<right){
        mid = (left+right)/2;
        if(S[mid]==key){
            return 1;
        }else if(key<S[mid]){
            right=mid;
        }else if(key>S[mid]){
            left=mid+1;
        }
    }
    return 0;
}

int main(){
    int S[500000], i, n, q, k, cnt;
    cnt=0;

    scanf("%d", &n);
    for(i=0;i<n;i++){
        scanf("%d", &S[i]);
    }

    scanf("%d", &q);
    for(i=0;i<q;i++){
        scanf("%d", &k);
        if(binarySearch(S,n,k) == 1){
            cnt++;            
        }
    }

    printf("%d\n", cnt);

    return 0;
}

Measured memory_bytes: 2096
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<complex>
#define lol(i,n) for(int i=0;i<n;i++)
#define INF 1234567890123456789
#define mod 1000000007
typedef long long ll;
using namespace std;
int main(){
	int n,q;cin>>n>>q;
	int cnt=0;
	lol(i,q){
		int a,b;cin>>a>>b;
		cnt+=a*b;
	}
	if(cnt==0){
		cout<<"0"<<endl;
		return 0;
	}
	cnt=-cnt;
	cout<<1<<endl;
	if(cnt<0)cout<<"-1 ";
	else cout<<"1 ";
	cout<<abs(cnt)<<endl;
	return 0;
}

Measured memory_bytes: 3116
def main():
    n = int(input())
    p = list(map(int, input().split()))
    count = 0
    for i in range(1, n-1):
        p_sorted = sorted(p[i-1:i+2])
        if p[i] == p_sorted[1] and p[i] != p_sorted[0]:
            count += 1
    print(count)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <map>
using namespace std;
map<int, bool> m;
int n,x;
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> x;
		if (m.find(x) != m.end())
		{
			cout << "NO";
			return 0;
		}
		m[x] = 1;
	}
	cout << "YES";
	return 0;
}

Measured memory_bytes: 9600
#include "bits/stdc++.h"
using namespace std;
typedef long long lint;
typedef long long i64;
//#define rep(i,n) for(int i=0;i<n;++i)
#define _vcppunko4(tuple) _getname4 tuple
#define _getname4(_1,_2,_3,_4,name,...) name
#define _getname3(_1,_2,_3,name,...) name
#define _trep2(tuple) _rep2 tuple
#define _trep3(tuple) _rep3 tuple
#define _trep4(tuple) _rep4 tuple
#define _rep1(n) for(int i=0;i<n;++i)
#define _rep2(i,n) for(int i=0;i<n;++i)
#define _rep3(i,a,b) for(int i=a;i<b;++i)
#define _rep4(i,a,b,c) for(int i=a;i<b;i+=c)
#define _trrep2(tuple) _rrep2 tuple
#define _trrep3(tuple) _rrep3 tuple
#define _trrep4(tuple) _rrep4 tuple
#define _rrep1(n) for(int i=n-1;i>=0;--i)
#define _rrep2(i,n) for(int i=n-1;i>=0;--i)
#define _rrep3(i,a,b) for(int i=b-1;i>=a;--i)
#define _rrep4(i,a,b,c) for(int i=a+(b-a-1)/c*c;i>=a;i-=c)
#define rep(...) _vcppunko4((__VA_ARGS__,_trep4,_trep3,_trep2,_rep1))((__VA_ARGS__))
#define rrep(...) _vcppunko4((__VA_ARGS__,_trrep4,_trrep3,_trrep2,_rrep1))((__VA_ARGS__))

int main(){
  lint n,ans=0,tmp=0; cin>>n;
  vector<lint>a(n); rep(n)cin>>a[i];
  rep(i,n-1){//rep(i,0,n)
    if(a[i]<a[i+1])tmp=0;
    else ++tmp;
    ans=max(ans,tmp);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
def main():
    n = int(input())
    str_list = []
    for _ in range(n):
        str_list.append(list(input().split()))
        
    money_sum = 0
    for i in range(n):
        if str_list[i][1] == 'JPY':
            money_sum += int(str_list[i][0])
        else:
            money_sum += 380000 * float(str_list[i][0])

    print(money_sum)      

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
import java.util.Scanner;


public class Main
{
    public static void main(String [] args)
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        double sum=0;
        for (int i=0;i<n;i++)
        {
            sum+=1/sc.nextDouble();
        }

        System.out.println(1/sum);

    }
}


Measured memory_bytes: 25172
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define mset multiset
# define umap unordered_map
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)
# define lr(i,l,r) for(int i=l;(l>r?i>=r:i<=r);(l>r?--i:++i))

using namespace std;

template<class T> void umin(T &a,T b){a=min(a,b);}
template<class T> void umax(T &a,T b){a=max(a,b);}

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

const int dx[]={1,0,-1,0,-1,-1,1,1},dy[]={0,1,0,-1,-1,1,-1,1}; 
const int mod = 1e9+7;
const ll N = 2e5+5;


void solve(){
	int n;
	cin>>n;
	string s;
	cin>>s;
    int cnt=0;
    string t="";
    for(int i=0;i<sz(s);++i){
    	if(s[i]=='('){
    		t+='(';
    		cnt++;
    	}
    	else{
    		if(cnt){
    			cnt--;
    			t+=')';
    		}
    		else{
    			t='('+t;
    			t+=')';
    		}
    	}
    }
    while(cnt)t+=')',cnt--;
    cout<<t;
 	

}

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

Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int v, w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

struct union_find {
	vector<int> v;
	union_find(int n) : v(n, -1) {}
	int find(int x) { return (v[x] < 0) ? x : (v[x] = find(v[x])); }
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x != y) {
			if (-v[x] < -v[y]) swap(x, y);
			v[x] += v[y]; v[y] = x;
		}
	}
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -v[find(x)]; }
};

int main() {
	int n, m; cin >> n >> m;
	vector<int> a(m), b(m);
	for (int i = 0; i < m; i++) {
		scanf("%d%d", &a[i], &b[i]);
		a[i]--;
		b[i]--;
	}
	vector<bool> rm(n);
	for (;;) {
		vector<int> d(n);
		union_find uf(n);
		for (int i = 0; i < m; i++) {
			d[a[i]]++;
			d[b[i]]++;
			uf.unite(a[i], b[i]);
		}
		vector<vector<int> > v(n);
		for (int u = 0; u < n; u++) {
			if (rm[u]) continue;
			int p = uf.find(u);
			if (d[u] == uf.size(p) - 1)
				v[p].push_back(u);
		}
		bool updated = false;
		for (int p = 0; p < n; p++) {
			if (rm[p]) continue;
			if (uf.find(p) != p) continue;
			if (v[p].size() == uf.size(p)) continue;
			updated = true;
			for (int j = 0; j < v[p].size(); j++)
				rm[v[p][j]] = true;
		}
		if (!updated) {
			int x = 0, y = 1;
			for (int p = 0; p < n; p++) {
				if (rm[p]) continue;
				if (uf.find(p) != p) continue;
				x++;
				y = (ll)y * uf.size(p) % _MOD;
			}
			cout << x << endl << y << endl;
			return 0;
		}
		vector<int> _a, _b;
		for (int i = 0; i < m; i++)
			if (!rm[a[i]] && !rm[b[i]]) {
				_a.push_back(a[i]);
				_b.push_back(b[i]);
			}
		m = _a.size();
		a = _a;
		b = _b;
	}
}

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

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    if (v.empty()) {
        ostr << "{ }";
        return ostr;
    }
    ostr << "{" << v.front();
    for (auto itr = ++v.begin(); itr != v.end(); itr++) {
        ostr << ", " << *itr;
    }
    ostr << "}";
    return ostr;
}

int main(void){


  int N;
  cin  >> N;

  vector<int> H(N);

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

  for (int i = 0; i < N - 1; i++){
    if (H[i + 1] > H[i]){
      H[i + 1] = H[i + 1] - 1;
    }

    if (H[i + 1] == H[i]){
      H[i + 1] = H[i + 1];
    }
  }

  bool flag = true;

  for (int i = 0; i < N - 1; i++){
  if (H[i + 1] < H[i]){
    flag = false;
  }
  }

  if (flag == false){cout << "No" << endl;}
  if (flag == true){cout << "Yes" << endl;}


  return 0;
}



Measured memory_bytes: 640
#include<iostream> 
#include<string> 
#include<vector> 
#include<algorithm> 
#include<cmath>
#include<set>
#include<utility>

using namespace std;


int main()
{
	string s;
	cin >> s;
	int k;
	cin >> k;
	set<string> a;
	int y = 0;
	int ss = s.size();
	int size = min(k, ss);
	for (int i = 0; i <s.size(); i++)
	{
		string x = "";
		for (int j = i; j < s.size(); j++)
		{
			x += s.at(j);
			if (x.size() > k)
			{
				break;
			}
			a.insert(x);
			y++;
			
			

		}
	}
	int cnt = 0;
	for (auto i : a) {
		cnt++;
		if (cnt == k) {
			cout << i << endl;
			return 0;
		}
	}
}


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

int main(){
  ll N,Q;
  cin >> N >> Q;
  vector<vector<ll>> Graph(N);
  for(ll i=0;i<N-1;i++){
    ll a,b;
    cin >> a >> b;
    a--;
    b--;
    Graph[a].push_back(b);
    Graph[b].push_back(a);
  }
  map<ll,ll> Point;
  for(ll i=0;i<Q;i++){
    ll p,x;
    cin >> p >> x;
    p--;
    Point[p]+=x;
  }
  vector<ll> ans(N,-1);
  stack<ll> stack;
  stack.push(0);
  while(stack.size()!=0){
    ll state=stack.top();
    stack.pop();
    ans[state]=Point[state];
    for(ll y:Graph[state]){
      if(ans[y]!=-1){
        continue;
      }
      Point[y]+=Point[state];
      stack.push(y);
    }
  }
  for(ll i=0;i<N;i++){
    if(i!=N-1){
      cout << ans[i] << " ";
    }
    else{
      cout << ans[i] << endl;
    }
  }
}

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

#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to));
#define sort(a) sort(a.begin(), a.end())
using namespace std;

template <class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

int main() {
  //解答閲覧後のコーディング
  int n;
  cin >> n;

  vector<int> h;
  load(h, n);

  for (int i = n - 2; i >= 0 ; --i) {
    if (h[i + 1] >= h[i]) {
      continue;
    } else if (h[i] - h[i + 1] == 1) {
      h[i]--;
      continue;
    } else {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define F(i, j, k) for(int i = j; i <= k; ++i)
#define pp pair<int, int>
#define mp make_pair
const int maxn = 2e5+5;
int n, m, x;
int a[maxn];
int read() {
    char ch = getchar();
    int x = 0,f = 1;
    while(!isdigit(ch)) {
	if(ch == '-') f = -1;
	ch = getchar();
    }
    while(isdigit(ch)) {
	x = x * 10 + ch - '0';
	ch = getchar();
    }
    return x * f;
}
int main() {
#ifdef orz
    freopen("input", "r", stdin);
#endif
    cin >> n;
    int fl = 0;
    while(n--) {
	cin >> x;
	a[x]++;
	if(x != 0) a[x-1]++;
	else fl++;
	a[x+1]++;
    }
    F(i, 0, 100000) fl = max(fl, a[i]);
    cout << fl;
    return 0;
}


Measured memory_bytes: 640
rect = 0
loze = 0

while True:
    try:
        n, m, o = map(int, input().split(','))
        if n ** 2 + m ** 2 == o ** 2:
            rect += 1
        if n == m:
            loze += 1
    except:
        print(rect)
        print(loze)
        break

Measured memory_bytes: 6716
N,Y=map(int, input().split())
max10000=Y//10000
for i in range(max10000,-1,-1):
  max5000=(Y-i*10000)//5000
  for j in range(max5000,-1,-1):
    k = N-i-j
    s = 10000*i + 5000*j + 1000*k
    if s == Y:
      print(i,j,k)
      exit()
else:
  print(-1,-1,-1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define eps 1e-3
#define pi acos(-1.0)
#define inf 0x3f
#define INF 0x3f3f3f3f
#define pb push_back
#define debug1 cout<<"&&";
#define debug2 cout<<"**";
#define ms(a, x) memset(a, x, sizeof(a))
#define for0(i, n) for(int i = 0; i < n; ++i)
#define for1(i, n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, int> pli;
typedef pair<long long, long long> pll;
const int mod = 1e9 + 7;
const int N = 1e5+10;
const int M = 1e6+10;
/*=================================================================================*/

int a, b, x;
ll Pow(ll k) {
   return k*k*k*k*k;
}

int main() {
   cin>>x;
   for1(i, 1000) {
      ll tmp = Pow(i) -x;
      ll l = -1000, r = 1000;
      while(l<=r) {
         ll mid = (l+r)>>1;
         if(Pow(mid) == tmp) {
            printf("%d %lld\n", i, mid); return 0;
         }
         if(Pow(mid) < tmp) l=mid+1;
         else r=mid-1;
      }
   }
   return 0;
}

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

#define MODSIZE 2019

int cnt[2026];

int main(){
  char s[200005];
  int n,i,j;
  char t;
  int x = 1;
  int tot = 0;
  long long ans = 0;

  scanf("%s", s);
  n = strlen(s);

  for(i = 0;i <= 2020;i++) cnt[i] = 0;

  for(i = 0,j = n - 1;i < n/2;i++,j--){
    t = s[i]; s[i] = s[j]; s[j] = t;
  }

  for(i = 0;i < n;i++){
    cnt[tot]++;
    tot += (s[i] - '0')*x;
    tot %= MODSIZE;
    ans += cnt[tot];
    x = x*10 % MODSIZE;
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 1856
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
//const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
///////////////////////////////////////////////////////////////////////////////////////////////////

struct kazu {
    vector<int> A;
    int keta;
    kazu() {
        A.assign(10,0);
        keta = -1e9;
    }

    void update(int x) {
        A[x]++;
        keta++;
    }
    bool operator<(const kazu &b) const {
        if (keta != b.keta) return keta < b.keta;
        for (int i = 9; i >= 0; --i) {
            if (A[i] != b.A[i]) return A[i] < b.A[i];
        } 
    }
};

const int honsuu[10] = {0,2,5,5,4,5,6,3,7,6};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,M; cin >> N >> M;
    vector<int> A(M);
    rep(i,M) cin >> A[i];


    vector<kazu> dp(N+1);
    dp[0].keta = 0;
    rep(i,M) {
        rep(j,N+1) {
            if (j >= honsuu[A[i]]) {
                kazu val = dp[j-honsuu[A[i]]];
                val.update(A[i]);
                chmax(dp[j],val);
            }
        }
    }

    string ans = "";
    for (int i = 9; i > 0; --i) {
        rep(j,dp[N].A[i]) ans += char(i+'0');
    }

    cout << ans << ln;
}


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

bool solve(void){
  vector<char> c(6);
  for(int i = 0 ; i < 6 ; i++){
    cin >> c[i];
  }
  for(int i = 0 ; i < 3 ; i++){
    if(c[i] != c[5-i]){
      return false;
    }
  }
  return true;
}

int main(){
  if(solve()){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const int MOD = 100000;

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

    vector<int> sum(n, 0);
    for(int i=1; i<n; ++i){
        cin >> sum[i];
        sum[i] += sum[i-1];
    }

    int ret = 0;
    int prev = 0;
    for(int i=0; i<m; ++i){
        int a;
        cin >> a;
        if(a > 0)
            ret += sum[prev+a] - sum[prev];
        else
            ret += sum[prev] - sum[prev+a];
        ret %= MOD;
        prev += a;
    }
    cout << ret << endl;

    return 0;
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;

int main(){
    ll N; cin >> N;
    ll res=LINF;
    for(ll i=1; i*i<=N; i++){
        if(N%i == 0){
            res=min(res, i-1+N/i-1);
        }
    }
    cout <<res << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	
	int n;
	int tmp;
	int sum = 0;
	int min = 101;// min%10 != 0

	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> tmp;
		sum += tmp;
		if (tmp < min && tmp % 10 != 0) {
			min = tmp;
		}
	}

	if (sum % 10 != 0) {
		cout << sum << endl;
	}
	else if (min != 101) {
		cout << sum - min << endl;
	}
	else {
		cout << '0' << endl;
	}
}

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

int main(){
    int a,b;
    cin>>a>>b;
    int num;
    if(b>=100)num=1000*a+b;
    else if(b>=10&&b<100)num=100*a+b;
    else if(b<=9)num=10*a+b;
    bool flag=false;
    for(int i=1;i*i<=num;i++){
        if(i*i==num)flag=true;
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3612
#include<cstdio>
#define LL long long
LL gcd(LL a,LL b)
{
	if(!b) return a;
	return gcd(b,a%b);
}
int main()
{
	LL a,b,g;
	while(~scanf("%lld%lld",&a,&b))
	{
		g=gcd(a,b);
		a*=b;
		printf("%lld %lld\n",g,a/g);
	}
}

Measured memory_bytes: 2668
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;

const int CASES = 2;

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) v += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr istream& operator >> (istream &is, Fp<MOD>& x) noexcept {
        return is >> x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

const int MOD = 1000000007;
using mint = Fp<MOD>;

void solve() {
    ll n; cin >> n;
    vector<mint> a(n);
    mint sum = 0;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        sum += a[i];
    }
    mint ans = 0;
    for(int i = 0; i < n; ++i){
        ans += (sum-a[i]) * a[i];
        sum -= a[i];
    }
    cout << ans << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 4852
import sys

def main():
    line_num = int(sys.stdin.readline().strip())
    sum_total = 0.0
    for i in range(line_num):
        line = sys.stdin.readline().strip()
        qua, cur = line.split(" ")
        if cur == "BTC":
            sum_total += 380000.0 * float(qua)
        else:
            sum_total += float(qua)
    print(sum_total)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
n, m = map(int, input().split())

import math
gs = []
for i in range(1, int(math.sqrt(m))+1):
  if m%i == 0:
    gs.append(i)
    if i != m//i:
      gs.append(m//i)

gs.sort(reverse=True)

#print(gs)
for j in gs:
  if m//j >= n:
    print(j)
    exit()

Measured memory_bytes: 38640
S = list(input())

res_dict = {}

for ch in S:
    if( ch not in res_dict ):
        res_dict[ch] = 1
    else:
        res_dict[ch] += 1

res_flag = False
if( len(res_dict) == 2 ):
    for v in res_dict.values():
        if( v == 2 ):
            res_flag = True
        else:
            res_flag = False
            break

print('YNeos'[not(res_flag)::2])

Measured memory_bytes: 3064
sosuulist =[]

for i in range(2,2000):
    count =0
    for j in range(2,i):
        if int(i)%int(j)==0:
            count =10000
            j =i
        else:
            j +=1
    if count==0:
        sosuulist.append(i)
        i +=1
    else:
        i +=1

#print(len(sosuulist))
sosuulist2=[]
for l in range(len(sosuulist)):
    if int(sosuulist[l])%10==7:
        sosuulist2.append(sosuulist[l])
        l +=1
    else:
        l +=1
        
#print(len(sosuulist2))
answer =""
num = input()
for k in range(int(num)):
    answer=answer+str(sosuulist2[k])+" "
answer=answer.rstrip()
print(answer)

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    int q;
    cin >> q;
    vi b(q), c(q);
    rep(i, q) cin >> b[i] >> c[i];
    ll sum = 0;
    map<int, int> mp;
    rep(i, n) {
        sum += a[i];
        mp[a[i]]++;
    }
    rep(i, q) {
        sum += (ll)(c[i] - b[i]) * mp[b[i]];
        mp[c[i]] += mp[b[i]];
        mp[b[i]] = 0;
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 8720