akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <tuple>

using namespace std;

#define INF 100000000;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
#define eps 1.0e-14;

int main(){
    long long A;
    string B;
    cin >> A >> B;
    B.erase(1,1);
    int Bint = stoi(B);
    ll ans = (A * Bint) / 100;
    cout << ans << endl;
}


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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N, M;
bool broken[100100];
int dp[100100];
const int mod = 1000000007;

signed main() {
    cin >> N >> M;
    rep(i, M) {
        int a;
        cin >> a;
        broken[a] = true;
    }
    dp[0] = 1;
    if (!broken[1])dp[1] = 1;
    for (int i = 2; i <= N; ++i) {
        if (!broken[i]) {
            dp[i] = dp[i - 1] + dp[i - 2];
            dp[i] %= mod;
        }
    }
    cout << dp[N] << endl;
    return 0;
}


Measured memory_bytes: 1152
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
typedef long long ll;
using namespace std;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
int INF=1e+9+1;
int main(){
	int N;
	int A1[100],A2[100];
	int A1sum[100]={0},A2sum[100]={0};
	scan(N);
	rep(i,N){
		scan(A1[i]);
		if(i!=0) A1sum[i]=A1sum[i-1]+A1[i];
		else A1sum[0]=A1[0];
	}
	rep(i,N){
		scan(A2[i]);
	}
	for(int i=N-1;i>=0;i--){
		if(i!=N-1) A2sum[i]=A2sum[i+1]+A2[i];
		else A2sum[N-1]=A2[N-1];
	}
	int maxnum=0;
	rep(i,N){
		maxnum=max(maxnum,A1sum[i]+A2sum[i]);
	}
	prin(maxnum);
	return 0;
}


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

typedef long long ll;

ll n;
ll A[220005];

int main(){
    cin >> n;

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

    sort(A,A+n);

    ll x=n/2;
    ll ans=0;

    for(int i=0;i<n;i++)
        ans+=abs(A[i]-A[x]);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define PI 		    acos(-1)
#define pb          push_back
#define ins         insert
#define INF        	1000000000000000007 //1e18+7
#define mk          make_pair
#define lb(v,x)     lower_bound(all(v),x)
#define ub(v,x)     upper_bound(all(v),x)
#define ff          first
#define ss          second
#define rev         reverse
#define endl        "\n"
#define max3(x,y,z)  max(x,max(y,z))
#define min3(x,y,z)  min(x,min(y,z))
#define sz(a)       (ll)a.size()
#define ld     		long double
#define minpq       priority_queue <ll,vector<ll>,greater<ll> > 
#define fill(x,y)   memset(x,y,sizeof(x))
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define MOD         1000000007		//1e9+7
#define bp(n)       __builtin_popcountll(n)
#define mxt(a)      *(max_element(a.begin(),a.end()))
#define mnt(a)      *(min_element(a.begin(),a.end())
#define unique_sort(c) (sort(all(c)), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define rep(i, a, mp) for(ll i = (a); i<=(mp); ++i)
#define trav(a, x) 	  for(auto &a : x)
#define re(i,n)       for(ll i = 0; i < n; ++i) 
const int N = 5e5 + 7;
const ld eps=1e-7;
typedef pair<ll,ll>   pii;
typedef vector<pii>   vpii;
typedef vector<ll>    vll;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int dx[8]={+1, +1, +1, 0, 0, -1, -1, -1};
int dy[8]={+1, 0, -1, +1, -1, +1, 0, -1};
ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x);y=y>>1;x=(x*x);}return res;}
template <typename T> T gcd(T a,T mp){ if(a==0) return mp; return gcd(mp%a,a); }
template <typename T> T powm(T a,T mp, ll m){T cnt=1; while(mp>0){ if(mp%2==1) cnt=(cnt*a)%m; mp/=2; a=(a*a)%m; }return cnt%m;}
ll ncr(ll n,ll r){ll res=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){res*=(n-i);res/=(i+1);}return res;}
ll sqr(ll x) { return x * x;} 
void prec(){

}
void run(){
	int n,k;cin>>n>>k;
	int a[n+1];
	rep(i,1,n) cin>>a[i];
	int dp[k+2]; // itne stones pe;
	fill(dp,0);
	for(int i=1; i<=k ;++i){
		for(int j=1; j<=n; ++j){
			if(i-a[j]>=0 and !dp[i-a[j]]) dp[i]=1;
		}
	}
	if(dp[k]) cout<<"First\n";
	else cout<<"Second";
}
int main()
{
    cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
    int tc=1;
    //cin>>tc;
    prec();
    re(i,tc)
    	run();
    return 0; 
}

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

using namespace std;

int main(){
    char s[10];
    char ans[11]={'b','b','b' ,'b','b','b','b','b','b' ,'b','b'};
    scanf("%s",s);
    for (int i=0;i<strlen(s);i++) {
        if (s[i]=='0' || s[i]=='1') {
            for (int j=0;j<10;j++){
                if (ans[j]=='b') {
                    ans[j]=s[i];
                    break;
                }
            }
        } else {
            if (ans[0]!='b') {
                for (int j=1;j<10;j++) {
                    if (ans[j]=='b') {
                        ans[j-1]='b';
                        break;
                    }
                }
            }
        }
    }

    for (int i=0;i<10;i++) {
        if (ans[i]!='b') {
            printf("%c",ans[i]);
        }
    }
    printf("\n");

    return 0;
}


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

int main() {
    int k;
    cin >> k;
    if (k % 2 == 0 or k % 5 == 0) {
        cout << -1 << endl;
        return 0;
    }
    int n = 7, cnt = 1;
    while (not(n % k == 0)) {
        n *= 10;
        n += 7;
        n %= k;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3628
//g++  5.4.0

#include<bits/stdc++.h>
using namespace std;

#define ff first
#define ss second
#define int long long
#define pb push_back
#define pii pair< int,int >
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;

const int inf = 1e10;
signed main()
{
    fast;
    int  n , W;
    cin >> n >> W;
    int dp[W+1] = {0};
    
    while( n-- )
    {
        int w , v;
        cin >> w >> v;
        for( int j=W ; j>=w ; j-- )
            dp[j] = max( dp[j] , dp[j-w] + v );
    }
    
    cout << *max_element( dp, dp+W+1 );
}





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

int main(void){
	char s[100];
	scanf("%s", s);
	int len = strlen(s);
	for(int i = 0; i < len - 8; i++){
		printf("%c", s[i]);
	}
	puts("");
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {

		int N = nextInt();
		int[] A = nextInts();
		int[] B = new int[N];
		int[] E = new int[N];

		for(int i=0;i<N;i++){
			B[i]=3;
			if(A[i]%2==0){
				E[i]=1;
			}else{
				E[i]=2;
			}
		}

		long ans = B[0];
		long sub = B[0]-E[0];
		for(int i=1;i<N;i++){
			ans*=B[i];
			sub*=B[i]-E[i];
		}
		System.out.println(ans-sub);
	}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define EM 100000000
using namespace std;
using LL = long long;
using P = pair<LL, LL>;
LL LINF = 1e18;
int INF = 1e9;
using vint = vector<int>;
using vLL = vector<LL>;

int main(){
	int a, b;
	cin >> a >> b;
	if(a >= 13)	cout << b << endl;
	else if(a <= 5)	cout << 0 << endl;
	else 	cout << (b/2) << endl;
}

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

typedef long long ll;

int main(){
	cout.precision(13);
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	ll ax,ay,bx,by;
	cin >> ax >> ay >> bx >> by;
	if(ax == bx || ay == by) {
		cout << 0 << '\n';
	}
	else {
		bx-=ax;	
		by-=ay;
		bx = abs(bx);
		by = abs(by);
		ll sum = bx + by + 2;
		ll g = __gcd(by, bx); 
		sum -= g + 2;
		cout << sum << '\n';
	}
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	
	int n, k, x=1, y=1, hasil;
	
	scanf("%d", &n);
	scanf("%d", &k);
	
	for(int i=0; i<n; i++){
		if(x*2<=x+k){
			x*=2;
		}
		else if(x*2>x+k){
			x+=k;
		}
	}
	
	printf("%d", x);
	return 0;
}

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

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    string s1 = "";
    string s2 = "";
    string as,bs;
    as = to_string(a);
    bs = to_string(b);
    for (int i = 0; i < b; i++)
    {
        s1 = s1 + as;
    }
    for (int i = 0; i < a; i++)
    {
        s2 = s2 + bs;
    }
    if (s1 < s2)
    {
        cout << s1 << endl;
    }
    else
    {
        cout << s2 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


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

    
    char a, b; cin >> a >> b;
    int c = a - '0';
    int d = b - '0';
    string s(d, a);
    string t(c, b);

    cout << min(s, t) << endl;
    

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python3

import array
from fractions import Fraction
import functools
import itertools
import math
import os
import sys


def main():
    N = read_int()
    X = read_ints()
    M = read_int()
    A = read_ints()
    print(*solve(N, X, M, A), sep='\n')


def solve(N, X, M, A):
    ar = [0] * 2020
    pos = [0] * (N + 1)
    for i, x in enumerate(X):
        ar[x] = i + 1
        pos[i + 1] = x

    for a in A:
        x = pos[a]
        if x != 2019 and ar[x + 1] == 0:
            ar[x] = 0
            ar[x + 1] = a
            pos[a] = x + 1

    return pos[1:]


###############################################################################
# AUXILIARY FUNCTIONS

DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


if __name__ == '__main__':
    main()



Measured memory_bytes: 6940
// g++ -std=c++14
#include<bits/stdc++.h>

typedef long long ll;
typedef long double lld;
using namespace std;

#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define endl "\n"
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(c) c.begin(),c.end()
#define LET(x, a)  __typeof(a) x(a)
#define foreach(it, v) for(LET(it, v.begin()); it != v.end(); it++)

#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename S, typename T>
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.fi<<", "<<p.se<<')';return out;}

template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
ll l=v.size();for(ll i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}

template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

int main(){
  _
  int a, b, c;
  cin >> a >> b >> c;
  cout << c << " " << a << " " << b << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()
 
typedef long long ll;


const int N = (int)1e5 + 5;
const int MOD = (int)1e9 + 7;
 
int f[N], rf[N];
 
int sum(int a, int b) {
    return (a + b) % MOD;
}
int sub(int a, int b) {
    return (a - b + MOD) % MOD;
}
int mult(int a, int b) {
    return (a * 1LL * b) % MOD;
}
int bin_pow(int a, int n) {
    int res = 1;
    for (; n; n >>= 1, a = mult(a, a))
        if (n & 1) res = mult(res, a);
    return res;
}
int inv(int a) {
    return bin_pow(a, MOD - 2);
}
 
int C(int n, int k) {
    if (k < 0 || k > n) return 0;
    return mult(f[n], mult(rf[k], rf[n - k]));
}


int solve(vector<int> a, int k) {
    int n = sz(a);
    int ans = 0;
    for (int i = k - 1; i < n; ++i) {
        ans = sum(ans, mult(a[i], C(i, k - 1)));
    }
    return ans;
}

int main()
{
    int n, k;
    scanf("%d %d", &n, &k);
    vector<int> a(n);
    for (int& x : a)
        scanf("%d", &x);
    sort(all(a));
    for (int& x : a)
        x = (x + MOD) % MOD;
    
    f[0] = 1;
    for (int i = 1; i <= n; ++i)
        f[i] = mult(f[i - 1], i);
    rf[n] = inv(f[n]);
    for (int i = n; i > 0; --i)
        rf[i - 1] = mult(rf[i], i);
        
    int ans = solve(a, k);
    reverse(all(a));
    ans = sub(ans, solve(a, k));
    printf("%d\n", ans);
}


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

long long mo=(long long)1e9+7;
long long cnt[2][1<<21];

int main(){
  int N;
  int a[21][21];
  std::cin>>N;
  for(int i=0;i<N;++i){
    for(int j=0;j<N;++j){
      std::cin>>a[i][j];
    }
  }
  for(int i=0;i<2;++i)
    for(int j=0;j<1<<N;++j)
      cnt[i][j]=0;
  cnt[0][0]=1;
  for(int i=0;i<N;++i){
    for(int s=0;s<1<<N;++s){
      if(__builtin_popcount(s)!=i)continue;
      for(int j=0;j<N;++j){
		if(a[i][j]==0)continue;
		if((s&(1<<j))==0){
	  	cnt[(i+1)%2][s|(1<<j)]+=cnt[i%2][s];
	  	cnt[(i+1)%2][s|(1<<j)]%=mo;
		}
      }
    }
    for(int s=0;s<1<<N;++s){
      cnt[i%2][s]=0;
    }
  }
  std::cout<<cnt[N%2][(1<<N)-1]<<std::endl;
  return 0;
}



Measured memory_bytes: 33024
#include<iostream>
using namespace std;
int main()
{
	int A,B;
	int C, D;
	cin >> A >> B >> C >> D;
	while (1) {
		C = C - B;
		if (C <= 0) {
			cout << "Yes" << endl;
			break;
		}
		A = A - D;
		if (A <= 0) {
			cout << "No" << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define pb push_back
#define fi first
#define se second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void chOut(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using v_bool = vector<bool>;
using v_Pii = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;



signed main(){

    int N, X, M; cin >> N >> X >> M;

    int now = X, ans = 0;
    v_bool used(100001, false);
    int i = 0;
    bool f = true;
    while(i < N){
        if(used[now] && f){
            int tmp = now, S = 0, cnt = 0;
            while(true){
                cnt++;
                S += tmp;
                tmp = (tmp * tmp) % M;
                if(tmp == now) break;
            }
            int nc = (N - i) / cnt;
            i += nc * cnt;
            ans += nc * S;
            f = false;
        }else{
            ans += now;
            used[now] = true;
            now = (now * now) % M;
            i++;
        }
    }
    Out(ans);

    return 0;
}


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

int main() {
  int N; cin>>N;
  vector<long long int> a(N);
  vector<long long int> b(N);
  long long int sum=0;
  long long int x = 1000000007;
  for(int i=0;i<N;i++){
    long long int y;
    cin>>y;
    a[i]=y;
    sum+=y;
    sum%=x;
    b[i]=sum;
  }
  sum=0;
  
  for(int i=N-1;i>0;i--){
    sum+= a[i]*b[i-1]%x;
    sum%=x;
  }
  
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 6412
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fr(i,j,n)   for(long long i=j;i<(n);++i)
#define bk(i,j,n)   for(long long i=j;i>=n;--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define MOD 1000000007
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define srt(x) sort(x.begin(),x.end());
#define run ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ordered_set tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>

typedef long long ll;
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}

ll dp[3005][3005];

int main()
{
    run;
    string s,t;
    cin>>s>>t;
    ll n1=s.length();
    ll n2=t.length();
    fr(i,0,n1)
    {
        fr(j,0,n2)
        {
            if(s[i]==t[j])
            {
                if(i&&j)
                dp[i][j]=1+dp[i-1][j-1];
                else
                    dp[i][j]=1;
                //max(dp[i-1][j],dp[i][j-1]);
            }
            if(i)
            dp[i][j]=max(dp[i-1][j],dp[i][j]);
            if(j)
            dp[i][j]=max(dp[i][j-1],dp[i][j]);
        }
    }

    ll len=dp[n1-1][n2-1];
    ll i=n1-1,j=n2-1;
    string u;
    while(len)
    {
        if(s[i]==t[j])
        {
            u.pb(s[i]);
            i--,j--,len--;
        }else if( i && j && dp[i-1][j]>dp[i][j-1] || !j)
        {
            i--;
        }else{
        j--;}
    }
    if(!u.length())
        return 0;
    bk(i,u.length()-1,0)
    {
        cout<<u[i];
    }

    //cout<<dp[n1-1][n2-1];




}


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


int main(){
  int h, w;
  cin >> h >> w;
  int count;
  int checkl[h], checkc[w];
  rep(i, h) checkl[i] = 0;
  rep(i, w) checkc[i] = 0;
  
  vector<vector<char>> grid(h, vector<char>(w));
  vector<vector<int>> ans(h, vector<int>(w, 0));
  
  rep(i, h){
    rep(j, w){
      cin >> grid.at(i).at(j);
    }
  }
  rep(i, h){
    count = 0;
    rep(j, w){
      if (grid.at(i).at(j) == '.'){
        count++;
      }
    }
    if (count == w) {
      checkl[i] = 1;
      
    }
    
  }
  rep(i, h) {
    if (checkl[i] == 1){
      rep(j, w){
        ans.at(i).at(j) = 1;
      }
    }
  }
  rep(i, w){ ///列の処理
    count = 0;
    rep(j, h){
      if (grid.at(j).at(i) == '.'){
        count++;
      }
    }
    
  
    if (count == h){
      checkc[i] = 1;
    }
    
  }
  rep(i, w){
    if(checkc[i] == 1){
      rep(j, h){
        ans.at(j).at(i) = 1;
      }
    }
  }
  
  rep(i, h){
    if(checkl[i] != 1){
    rep(j, w){
      if(ans.at(i).at(j) == 0){
        cout << grid.at(i).at(j) ;
      }
    }
    cout << endl;
  }
  }
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<S<<endl
using namespace std;

int main(){
	 while(1) {
		string c;
	    getline(cin, c);
	    if(c.size()==1 && c[0]=='.') break;
	    bool flag=true;
		stack<char> st;
		for(int i=0;c[i]!='.';i++){
			if((c[i]==')'||c[i]==']')&&st.empty()) {
				flag=false;
				break;
			}
			else if(c[i]=='('||c[i]=='[')			st.push(c[i]);
			else if(c[i]==')'&&st.top()=='(')	st.pop();
			else if(c[i]==']'&&st.top()=='[')	st.pop();
			else if(c[i]==']'||c[i]==')') {
				flag=false;
				break;
			}
		}

		if(flag&&st.empty()){
			p("yes");
		}else{
			p("no");
		}
	}

	return 0;
}

Measured memory_bytes: 3132
N,Q = map(int, input().split())
S = input()

AC = [0]*(N+1)
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        AC[i+2] += 1
for i in range(N):
    AC[i+1] += AC[i]

for _ in range(Q):
    l,r = map(int, input().split())
    print(AC[r]-AC[l])

Measured memory_bytes: 9332
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	string S;
	int K;
	cin >> S;
	cin >> K;
	set<string>V;
	for (int i = 0; i < S.size(); ++i) {
		for (int j = 1; i+j<=S.size(); ++j) {
			if (j <= 5) {
				V.insert(S.substr(i, j));
			}
		}
	}
	auto itr = V.begin();
	for (int i = 0; i < K-1; ++i) {
		++itr;
	}
	cout << *itr << endl;
    return 0;
}

Measured memory_bytes: 1664
#include<iostream>
using namespace std;
bool check(int, int);
int N, M;
char paper1[51][51], paper2[51][51];
int main() {
	cin >> N >> M;
	for (int y = 1; y <= N; ++y) {
		for (int x = 1; x <= N; ++x) {
			cin >> paper1[x][y];
		}
	}
	for (int y = 1; y <= M; ++y) {
		for (int x = 1; x <= M; ++x) {
			cin >> paper2[x][y];
		}
	}
	int slide = N - M + 1;
	for (int x = 1; x <= slide; ++x) {
		for (int y = 1; y <= slide; ++y) {
			if (check(x, y)) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

bool check(int x, int y) {
	for (int nx = 0; nx < M; ++nx) {
		for (int ny = 0; ny < M; ++ny) {
			if (paper2[nx + 1][ny + 1] != paper1[nx + x][ny + y]) {
				return false;
			}
		}
	}
	return true;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main() {
	int N, A, B, C;
	cin >> N >> A >> B >> C;
	vector<int> L(N);
	for (int i = 0; i < N; i++) cin >> L[i];
	int ans = 3000;
	for (int bit = 0; bit < pow(4, N); bit++) {
		int cost = 0;
		int a[3] = { 0,0,0 };
		int num[3] = { 0,0,0 };
		for (int i = 0; i < N; i++) {
			int n = bit % (int)pow(4, i + 1) / (int)pow(4, i);
			if (n < 3) {
				a[n] += L[i];
				num[n]++;
			}
		}
		if (num[0] == 0 || num[1] == 0 || num[2] == 0) continue;
		for (int i = 0; i < 3; i++) cost += 10 * (num[i] - 1);
		cost += abs(A - a[0]) + abs(B - a[1]) + abs(C - a[2]);
		ans = min(cost, ans);
	}
	cout << ans << endl;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
#define N 1000000007 // prime modulo value 

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, k,  m, y, q ;
string s, t, d;
ld w;

// <------------- Implement Functions Here ----------> //


// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> s ;
	cout<<string(s.length(),'x');
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n,k;cin>>n>>k;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    sort(ALL(a));
    int sum=0;
    rep(i,k) sum+=a[i];
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
signed main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0; i<n; i++)
	{
		cin>>a[i];
	}
	int dp[n]={0};
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for(int i=2; i<n; i++)
	{
		dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	}
	cout<<dp[n-1];
}

Measured memory_bytes: 1024
from itertools import *
from bisect import *
from math import *
from collections import *
from heapq import *
from random import *
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def MF(): return map(float, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LF(): return list(map(float, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

def main():
    def ok(m):
        s=0
        cnt=0
        while m:
            s+=m
            cnt+=1
            if s>k:return False
            if cnt==n:break
            m>>=1
        return True

    n,k=MI()
    l=0
    r=k+1
    while l+1<r:
        m=(l+r)//2
        if ok(m):l=m
        else:r=m
    print(l)

main()



Measured memory_bytes: 8176
N, K = map(int, input().split())
A = list(map(int, input().split()))
for _ in range(K):
    if len(set(A)) == 1 and A[0] == N:
        break
    work = [0] * (N + 1)
    for i in range(N):
        a = A[i]
        idx0 = max(0, i - a)
        idx1 = min(N, i + a + 1)
        work[idx0] += 1
        work[idx1] -= 1
    now = 0
    for i in range(N):
        now += work[i]
        A[i] = now
print(*A)

Measured memory_bytes: 152972
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>
#include <iomanip>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);

int main() {
    ll N,Z,W;
    cin >> N >> Z >> W;
    vector<ll> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }

    if(N>1){
        cout << max(llabs(A[N-2]-A[N-1]),llabs(A[N-1]-W)) << endl;
    }
    else cout << llabs(A[0]-W) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
	int t;
	while(cin >> t && t) {

		vector<int> v(t);
		rep(i, t) cin >> v[i];

		int n;
		cin >> n;

		vector<int> d(n), m(n);
		int dm[105], day = 0;
		rep(i, 105) dm[i] = INF;

		rep(i, n) {
			cin >> d[i] >> m[i];
			dm[d[i]-1] = min(dm[d[i]-1], m[i]);
			day = max(day, d[i]);
		}

		int dp[105][35];
		rep(i, 105) rep(j, 35) dp[i][j] = INF;

		dp[0][0] = 0;

		REP(i, 1, day) {
			rep(j, t) {
				if(j == 0) {
					rep(k, t) {
						dp[i][j] = min(dp[i][j], dp[i-1][k] + 1);
					}
					dp[i][j] = min(dp[i][j], dp[i-1][t-1]);
				} else {
					if(v[j] <= dm[i]) {
						dp[i][j] = min(dp[i][j], dp[i-1][j-1]);
					}
				}
			}
			// cout << " ------ i: " << i << " " << dm[i] << endl;
			// rep(j, t) cout << v[j] << " ";
			// cout << endl;
			// rep(j, day) {
			// 	rep(k, t) {
			// 		if(dp[j][k] == INF) cout << "X ";
			// 		else cout << dp[j][k] << " ";
			// 	}
			// 	cout << endl;
			// }
		}

		int ans = INF;
		rep(i, t) {
			ans = min(ans, dp[day-1][i]);
		}

		// rep(i, day+1) {
		// 	rep(j, t) {
		// 		if(dp[i][j] == INF) cout << "X ";
		// 		else cout << dp[i][j] << " ";
		// 	}
		// 	cout << endl;
		// }

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1208
class Dice:
    def __init__(self, default = [1, 2, 3, 4, 5, 6]):
        self.d = default

    def e(self):
        self.d[0], self.d[2], self.d[3], self.d[5] = self.d[3], self.d[0], self.d[5], self.d[2]

    def w(self):
        self.d[0], self.d[2], self.d[3], self.d[5] = self.d[2], self.d[5], self.d[0], self.d[3]

    def n(self):
        self.d[0], self.d[1], self.d[4], self.d[5] = self.d[1], self.d[5], self.d[0], self.d[4]

    def s(self):
        self.d[0], self.d[1], self.d[4], self.d[5] = self.d[4], self.d[0], self.d[5], self.d[1]

    def top(self):
        return self.d[0]


def main():
    dice = Dice([int(i) for i in input().split()])
    for o in input():
        if o == 'E':
            dice.e()
        elif o == 'W':
            dice.w()
        elif o == 'S':
            dice.s()
        else:
            dice.n()

    print(dice.top())


if __name__ == '__main__':
    main()







Measured memory_bytes: 5612
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



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

  ll N, K ; cin >> N >> K;
  vector<ll> A; 
  rep(i,N){
    ll inp; cin >> inp;
    if(inp == 0) continue;
    A.pb(inp);
  }
  sort(all(A));
  ll cf = A[0];
  rep(i,N)
    cf = gcd(cf, A[i]);

  for(ll i = cf; i <= A[A.size()-1]; i+=cf)
    if(i == K){cout << "POSSIBLE" << endl; return 0;}

  cout << "IMPOSSIBLE" << endl;
  
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


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

int main(){
    int ans=0;
    int a,b,c;
    cin >> a>>b>>c;

    ans = a+b+c+9*max(a,max(b,c));
    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

string s[100];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w;
    cin >> h >> w;
    for (int i = 0; i < h; ++i)
        cin >> s[i];


    for (int i = 0; i < 2 * h; ++i)
    {
        for (int j = 0; j < w; ++j)
            cout << s[i / 2][j];
        cout << '\n';
    }
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)
def FF(E, s, t):
    NN = H+W+2
    G = [[] for _ in range(NN)]
    for a, b, f in E:
        G[a].append([b, f, len(G[b])])
        G[b].append([a, 0, len(G[a])-1])
    
    def dfs(s, t, f):
        if s == t:
            return f
        used[s] = 1
        for i, (b, _f, r) in enumerate(G[s]):
            if used[b] or _f == 0: continue
            d = dfs(b, t, min(f, _f))
            if d > 0:
                G[s][i][1] -= d
                G[b][r][1] += d
                return d
        return 0
    
    flow = 0
    while 1:
        used = [0] * NN
        f = dfs(s, t, 10**100)
        if f == 0:
            return flow
        flow += f

E = []

H, W = map(int, input().split())
for i in range(H):
    A = input()
    for j in range(W):
        if A[j] == "o":
            E.append((i, j+H, 1))
            E.append((j+H, i, 1))
        elif A[j] == "S":
            S = (i, j+H)
        elif A[j] == "T":
            T = (i, j+H)
E.append((H+W, S[0], 10**6))
E.append((H+W, S[1], 10**6))
E.append((T[0], H+W+1, 10**6))
E.append((T[1], H+W+1, 10**6))

ff = FF(E, H+W, H+W+1)
print(ff if ff < 10**6 else -1)


Measured memory_bytes: 8820
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int>h(n);
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  sort(h.begin(),h.end());
    long long sum = 0;
  for(int i = 0;i<n-k;i++){
    sum += h[i];
  }
  if(n>k)cout << sum << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 5;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
char s[MAXN];
int main() {
	scanf("%s", s + 1);
	int n = strlen(s + 1);
	for (int i = 1; i <= n; i++)
		if (s[i] == '?') s[i] = 'D';
	printf("%s\n", s + 1);
	return 0;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
int F(int A,int B){
  int i=0,j=0;
  while(A>0){
    A/=10;
    i++;
  }
  while(B>0){
    B/=10;
    j++;
  }
  return max(i,j);
}
int main(){
  long long N;
  int mi=11;
  cin>>N;
  for(int i=sqrt(N)+1;i>0;i--){
    if(N%i==0){
      mi=min(mi,F(i,N/i));
      break;
    }
  }
  cout<<mi<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
	int n,k,x,y;
	cin >> n >> k >> x >> y;
	int ans = n>k ? x*k+y*(n-k) : x*n;
	cout << ans << '\n';
	
	return 0;
}


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

#define range 100005
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

int a[200000];

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("test.txt","r",stdin);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	a[0] = 0;
	int key =1;
	for(int i=1;i<=n;i++)
	{
		if(a[i]>a[i-1])
			a[i]-=1;
		if(a[i-1]>a[i])
		{
			key=0;
			break;
		}
	}
	if(key==1)
		cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 640
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N = int(readline())
    A = [int(i) for i in readline().split()]

    ans = []
    B = [0] * N
    for i in reversed(range(N)):
        s = sum(B[i::i+1])
        if s % 2 == A[i]:
            continue
        else:
            B[i] += 1
            ans.append(i+1)
    
    print(sum(B))

    if len(ans):
        print(*ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 14088
from itertools import product

A,B,C,D,E,F = map(int, input().split())
num_a = F // (100 * A)
num_b = F // (100 * B) 
num_c = int((F * E / (E + 100)) // C)
num_d = int((F * E / (E + 100)) // D)

def check_w(w_mizu, w_sato, F):
  return w_mizu + w_sato <= F

def check_tokeru(w_mizu, w_sato, E):
  return 100 * w_sato / (w_mizu + w_sato) <= 100 * E / (100 + E)

def culc_density(w_mizu, w_sato):
  return 100 * w_sato / (w_mizu + w_sato)

max = [100 * A, 0, 0]  # total, sato, density
for _a, _b,  in product(range(num_a + 1), range(num_b + 1)): 
  w_mizu = (A * _a + B * _b) * 100
  if w_mizu == 0 or w_mizu >= F:
    continue
    
  for _c, _d in product(range(num_c + 1), range(num_d + 1)):
    w_sato = (C * _c + D * _d)
    if w_sato == 0 or w_sato >= F or (w_mizu + w_sato) > F:
      continue
    
    density = culc_density(w_mizu, w_sato)
  
    if check_w(w_mizu, w_sato, F) and check_tokeru(w_mizu, w_sato, E):
      if max[2] < density:
        max[0] = w_mizu + w_sato
        max[1] = w_sato
        max[2] = density

if max[0]:
  print(max[0], max[1])



Measured memory_bytes: 9180
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

int main() {

	int d = 0;
	int n;

	cin >> n;

	REP(i, n) {
		int t;
		cin >> t;
		while (t % 2 == 0) {
			t /= 2;
			d++;
		}
	}

	cout << d NL;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

Ad = {}
for i in range(N):
    Ad[i] = A[i]

Ad_sorted = sorted(Ad.items(), key=lambda x:x[1])

ans = ''
for Adi in Ad_sorted:
    ans += ' ' + str(Adi[0] + 1)

print(ans.strip())

Measured memory_bytes: 26332
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        scan.close();
        String[] array = str.split(" ");
      String a = array[0];
      String b = array[1];
      Integer ai = Integer.parseInt(a);
      Integer bi = Integer.parseInt(b);
      if( ai*bi%2==0){
        System.out.println("Even")    ;
      }
      else{
        System.out.println("Odd")    ;
      }
    }
}


Measured memory_bytes: 21844
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
#include <climits>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter = " ") { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }


int main() {
    int x, n;
    cin >> x >> n;
    vector<bool> done(1000);
    rep(i, n) {
        int p;
        cin >> p;
        done[p] = true;
    }

    rep(d, 1000) {
        if (!done[x - d]) {
            cout << x - d << endl;
            return 0;
        }
        if (!done[x + d]) {
            cout << x + d << endl;
            return 0;
        }
    }
}

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

int main(){
	double xa,xb,ya,yb,ra,rb;
	int n;
	cin >> n;
	for( int i=0; i<n; i++ ){
		cin >> xa >> ya >> ra >> xb >> yb >> rb;
		double range = sqrt( (yb-ya)*(yb-ya)+(xb-xa)*(xb-xa) );
		int ret=1;
		if( rb > range+ra ){
			ret = -2;
		}else if( ra > range+rb ){
			ret = 2;
		}else if( range > ra+rb ){
			ret = 0;
		}
		cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

const int N=105;

int n,ans;
bool tag;
char s1[N],s2[N];

int main(){
	int i,j,k;
	scanf("%d",&n);
	scanf("%s",s1+1); scanf("%s",s2+1);
	ans=n+n;
	for (i=1;i<=n;i++){
		tag=1;
		for (j=1;j<=i;j++) if (s2[j]!=s1[n-i+j]){
			tag=0;
			break;
		}
		if (tag) ans=min(ans,n+n-i);
	}
	printf("%d\n",ans);
	return 0;
} 

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

int main() {

    int K, N;
    cin >> N >> K;

    vector<int> P(N);
    rep(i, N) cin >> P[i];

    sort(P.begin(), P.end());

    int sum = 0;
    rep(i, K) sum += P[i];

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3632
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
 
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+5;
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power((((a%mod)*(a%mod))%mod),b/2)%mod;
    else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
}

int32_t main()
{
    IOS
    
    
    
    int a,b,c;
    cin>>a>>b>>c;
    if(a-b>=c)
    {
        cout<<0;
    }
    else
    {
        cout<<-(a-b)+c;
    }
}



Measured memory_bytes: 256