akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define LOCAL
#pragma region Macros
typedef long long ll;
#define ALL(x) (x).begin(),(x).end()
const long long MOD=1e9+7;
// const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    cout << '(' << p.first << ',' << p.second << ')';
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const map<T,U> &m){
    os << '{';
    for (auto itr=m.begin();itr!=m.end();++itr){
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr!=m.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const set<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();++itr){
        os << *itr;
        if (++itr!=s.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}

void debug_out(){cerr << '\n';}
template<class Head,class... Tail>
void debug_out(Head&& head,Tail&&... tail){
    cerr << head;
    if (sizeof...(Tail)>0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...) cerr << " ";\
cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n';\
cerr << " ";\
debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<typename T> T gcd(T x,T y){return y!=0?gcd(y,x%y):x;}
template<typename T> T lcm(T x,T y){return x/gcd(x,y)*y;}

template<class T1,class T2> inline bool chmin(T1 &a,T2 b){
    if (a>b){a=b; return true;} return false;
}
template<class T1,class T2> inline bool chmax(T1 &a,T2 b){
    if (a<b){a=b; return true;} return false;
}
#pragma endregion

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M; cin >> N >> M;
    vector<int> L;
    vector<vector<int>> R(M+2);
    for (int i=0;i<N;++i){
        int l,r; cin >> l >> r;
        L.emplace_back(l);
        R[l].emplace_back(M+1-r);
    }
    sort(L.begin(),L.end());
    int now=0;
    for (int i=0;i<N;++i){
        if (now<M&&now<L[i]) ++now;
    }
    priority_queue<int,vector<int>,greater<int>> pq;
    priority_queue<int> removed;
    for (int i=M;i>=0;--i){
        for (int r:R[i]) pq.emplace(r);
        if (i&&i<=now){
            removed.emplace(pq.top());
            pq.pop();
        }
    }
    int ans=0,Max=0;
    vector<int> use;
    while(!pq.empty()){
        while(!pq.empty()&&pq.top()<=Max) pq.pop();
        if (!pq.empty()){
            use.emplace_back(pq.top());
            pq.pop(); ++Max;
        }
    }
    cout << N-min(M,(now+Max)) << '\n';
}

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

int main()
{
    int h, w;
    while (1) {
        cin >> h >> w;
        if (!h && !w) break;
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                cout << "#";
            }
            cout << '\n';
        }
        cout << '\n';
    }

    return 0;
}

Measured memory_bytes: 3048
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll A, B;
    char op;
    cin >> A >> op >> B;
    if (op == '+')
    {
        cout << A + B << endl;
    }
    else
    {
        cout << A - B << endl;
    }
}

Measured memory_bytes: 3648
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N, T;
	cin >> N >> T;

	int ans = N * T;
	int t;
	int pt = 0;
	rep(i, 0, N)
	{
		cin >> t;
		if (i > 0)
		{
			ans -= max(0LL, T - (t - pt));
		}
		pt = t;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
 
  public static void main(String[] args)
  {
     
   Scanner s=new Scanner(System.in);
    int n=s.nextInt();
    int totalWt=s.nextInt();
    int wt[]=new int[n];
    long profit[]=new long[n];
    
    for(int i=0;i<n;i++ )
    {
    	wt[i]=s.nextInt();
    	profit[i]=s.nextLong();
    }
    
    long dp[]=new long[totalWt+1];
    long dp1[]=new long[totalWt+1];
    
   
    
     for(int i=wt[0];i<=totalWt;i++)
     {
    	dp[i]=profit[0];
     }
     
     for(int i=1;i<n;i++)
     {
    	for(int j=0;j<=totalWt;j++)
    	{
           		if(j-wt[i]>=0)
           		{
           			dp1[j]=Math.max(profit[i]+dp[j-wt[i]], dp[j]);
           		}
           		else
           			dp1[j]=dp[j];
    	}
    	dp=dp1;
    	dp1=new long[totalWt+1];
    }
    
    
   
     System.out.println(dp[totalWt]);
     
     s.close();
    
  }
  }

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

using namespace std;
typedef long long int ll;

int main() {
  int N;
  cin>>N;
  vector<int> v,w;
  for(int i = 0;i<N;i++){
    int x;
    cin>>x;
    v.push_back(x);
  }
  w=v;
  sort(v.begin(),v.end());


  for(int i = 0;i<N;i++){
    if(w[i]<=v[v.size()/2-1]){
      cout<<v[v.size()/2]<<endl;
    }else{
      cout<<v[v.size()/2-1]<<endl;
    }
  }


  return 0;
}


Measured memory_bytes: 3828
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <algorithm>

int main(){
    int N, L;
    std::cin >> N >> L;
    std::string str[100] = {};

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

    sort(str, str+N);

    for(int i=0;i<N;i++){
        std::cout << str[i];
    }

    std::cout << std::endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int N; cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    multiset<int> s;
    rep(i,N){
        auto d = s.lower_bound(A[i]);
        if(d == s.begin()){
            s.insert(A[i]);
        }
        else{
            d--;
            s.erase(d);
            s.insert(A[i]);
        }
    }
    cout << s.size() << endl;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int N;
    cin >> N;
    
    map<int, int> mp;

    vector<int> a(N);
    REP(i, N) {
        cin >> a[i];
        mp[a[i]]++;
    }

    ll ans = 0;
    for (auto t : mp) {
        if (t.first > t.second) ans += t.second;
        if (t.first < t.second) ans += (t.second - t.first);
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 5120
#include<stdio.h>
#include<string.h>
int main(void)
{
  char str[21];
  int i,n;

  scanf("%s",str);
  //  n=strlen(str);
  //  printf("%d\n", n);

  for(i=strlen(str)-1;i>=0;i--)
    printf("%c",str[i]);
  printf("\n");

  return 0;
}

Measured memory_bytes: 524
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
   int N; cin >> N;
   vector<int> a(N);
   bool ok = false;
   rep(i,N){
       cin >> a[i];
       if(a[i]&1) ok = true;
   }
   cout << (ok ? "first" : "second") << endl;
}



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

int H,W;
const int MOD=1e9+7;
char arr[1005][1005];
int dp[1005][1005];

int solve(int i,int j)
{
    int &ret=dp[i][j];
    if(ret!=-1)return ret;
    if(i==H-1 && j== W-1)return 1;
    if(i>=H || j>=W)return 0;
    ret=0;
    if(arr[i+1][j]!='#'){
        ret=ret+solve(i+1,j);
        ret%=MOD;
    }
    if(arr[i][j+1]!='#'){
        ret=ret+solve(i,j+1);
        ret%=MOD;
    }
    return ret;

}

int main()
{
    cin>>H>>W;
    for(int i=0;i<H;i++)
        cin>>arr[i];
    memset(dp,-1,sizeof(dp));
    cout<<solve(0,0);
}


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

long long int knapsack(long long int n,long long int w,long long int wt[],long long int val[])
{
   long long int dp[n+1][w+1];
   for(int i=0;i<=n;i++)
   {
      dp[i][0]=0;
   }
   for(int i=0;i<=w;i++)
   {
     dp[0][i]=0;
   }
   for(int i=1;i<=n;i++)
   {
     for(int j=1;j<=w;j++)
     {
        if(wt[i-1]<=j)
        {
           dp[i][j]=max(dp[i-1][j],val[i-1]+dp[i-1][j-wt[i-1]]);
        }
        else
        {
           dp[i][j]=dp[i-1][j];
        }
     }
   }
   return dp[n][w];
}
int main()
{
  long long int n,w;
  cin>>n>>w;
  long long int wt[n];
  long long int val[n];
  for(int i=0;i<n;i++)
  {
     cin>>wt[i]>>val[i];
  }
  long long int x=knapsack(n,w,wt,val);
  cout<<x<<"\n";
  return 0;
}

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

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

const int N = 1e5 + 1;
int n, mx1[2], mx2[2], idx[2];
map<int, int> cnt[2];

int main() {
  scanf("%d", &n);
  for (int i = 0, a, b = 0; i < n; ++i, b ^= 1) {
    scanf("%d", &a);
    ++cnt[b][a];
  }

  for (int b = 0; b <= 1; ++b) {
    for (auto it : cnt[b]) {
      if (it.second > mx2[b]) {
        mx2[b] = it.second;
        if (mx2[b] > mx1[b]) {
          swap(mx1[b], mx2[b]);
          idx[b] = it.first;
        }
      }
    }
  }

  if (idx[0] != idx[1]) {
    printf("%d\n", n - mx1[0] - mx1[1]);
  } else {
    printf("%d\n", n - max(mx1[0] + mx2[1], mx1[1] + mx2[0]));
  }

  return 0;
}


Measured memory_bytes: 8380
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<fstream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

int main() {
	int n, d;
	cin >> n >> d;
	vector<int> X(n*d);
	for (auto& elem : X)
		cin >> elem;
	int cont = 0;

	for (auto i = 0; i < n-1; i++) {
		for (auto k = i+1; k < n ; k++) {
			int sum = 0;
			for (auto j = 0; j < d; j++) {
				sum += pow((X[i*d + j] - X[k*d + j]), 2);
			}
			// cout << sum << endl;
			double judge = sqrt(sum);
			if (ceil(judge) == floor(judge))
				cont++;
		}
	}
	cout << cont << endl;
}


Measured memory_bytes: 256
N = int(input())
A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))
C_list = list(map(int, input().split()))

manzoku = 0
before_A = 0
for A in A_list:
    manzoku += B_list[A-1]
    if before_A == 0:
        before_A = A
    elif A == before_A + 1:
        manzoku += C_list[before_A-1]
        before_A = A
    else:
        before_A = A
print(manzoku)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
  int n,m;
  cin >>n>>m;
  int p[110000],y[110000];
  vector<int> yd[110000];
  rep(i,m){
  cin>>p[i]>>y[i];
  yd[p[i]].push_back(y[i]);
  }
  rep(i,n){
    sort(yd[i+1].begin(),yd[i+1].end());
  }

  rep(i,m){
    printf("%012lld\n",ll(p[i])*1000000+int(lower_bound(yd[p[i]].begin(),yd[p[i]].end(),y[i]) -yd[p[i]].begin())+1);
  }



}


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

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

void mainmain(){
	int a,b,c,d,e;
	while(cin>>a>>b>>c>>d>>e,a){
		int na,nb,nc;
		vint v;
		cin>>na>>nb>>nc;
		rep(i,na){
			v.PB(a);
		}
		rep(i,nb){
			v.PB(b);
		}
		rep(i,nc){
			v.PB(c);
		}
		sort(ALL(v));
		int t=na+nb+nc;
		int ans=na*a+nb*b+nc*c;
		if(t<d){
			if(ans>d*e) ans=d*e;
		}
		else{
			int tmp=0;
			rep(i,d){
				tmp+=v[v.size()-1-i];
			}
			if(tmp>=d*e){
				rep(i,v.size()){
					if(e<v[i]){
						v[i]=e;
					}
				}
				rep(i,d){
					v[v.size()-1-i]=e;
				}
			}
			ans=0;
			rep(i,v.size()){
				ans+=v[i];
			}
		}
		cout<<ans<<endl;
	}
}



}
main() try{


    mainmain();
}
catch(...){
}

Measured memory_bytes: 4240
N = int(input())
A = list(map(int,input().split()))
#A.reverse()
ans = [0 for _ in range(N)]
for i in reversed(range(N-1)):
  #今i番目(0index)の社員
  boss = A[i]-1 #0index
  ans[boss] += 1
  #print(ans,i,boss)
for x in ans:
  print(x)

Measured memory_bytes: 32132
#include <iostream>
using namespace std;
 
int N;
int A[201];
 
int main(){
  cin >> N;
  for(int i=0; i < N; ++i) cin >> A[i];
  
  int res=0;
  
  while(true){
    bool exist_odd = false;
    for(int i=0;i<N;++i){
      if(A[i]%2 != 0) exist_odd=true;
    }
    
    if(exist_odd) break;
    
    for(int i=0;i<N;++i){
      A[i] /= 2;
    }
    ++res;
  }
    
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		String s=scn.next();
		 String t =scn.next();
		 long count=0;
		 for(int i=0;i<s.length();i++){
			 if(s.charAt(i)!=t.charAt(i)){
				 count++;
			 }
		 }
		 System.out.println(count);

	}

}

Measured memory_bytes: 41092
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
using namespace std;
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;

int main()
{
    ll n, m,ac=0,wa=0;
    cin>>n>>m;
    vector<bool> b(n+1,false);
    vector<ll> wav(n+1);
    
    for (ll i = 0; i < m;i++){
        ll p;
        string s;
        cin >> p >> s;
        if(!b[p]&&s=="WA"){
            wav[p]++;
        }
        else if(!b[p]&&s=="AC"){
            ac++;
            b[p] = true;
        }
    }
    for (ll i = 1; i <= n;i++){
        if(b[i]){
            wa += wav[i];
        }
    }
    cout << ac << " " << wa << endl;

}


Measured memory_bytes: 1024
dpa = [-float('inf') for _ in range(100010)]
dpb = [-float('inf') for _ in range(100010)]
dpc = [-float('inf') for _ in range(100010)]


N = int(input())
a = []
b = []
c = []

for i in range(N):
    a1,b1,c1 = map(int,input().split())
    a.append(a1)
    b.append(b1)
    c.append(c1)

#もらうDP
dpa[0] = a[0]
dpb[0] = b[0]
dpc[0] = c[0]

#i日にAを実施。i-1日目にBもしくはC。
for i in range(1,N):
    dpa[i] = max(dpb[i-1]+a[i],dpc[i-1]+a[i])
    dpb[i] = max(dpa[i-1]+b[i],dpc[i-1]+b[i])
    dpc[i] = max(dpa[i-1]+c[i],dpb[i-1]+c[i])

print(max(dpa[N-1],dpb[N-1],dpc[N-1]))
    



Measured memory_bytes: 79100
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourd; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, cnt, sum, ans, dp[2000][2000], a[210000], b[210000];
string str, ss;
bool f[210000];
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
vector<Edge>vec[200000];
vector<LL>v[26];
struct cll {
	char first;
	LL second, thrid;
};
vector<cll>S;
map<string, LL>ma;
multiset<LL>st;

void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


int main() {
	cin >> str;
	cin >> ss;
	dp[0][0] = 1;
	rep(j, ss.size()) {
		rep(i, str.size()) {
			if (i)
				dp[i][j] += dp[i - 1][j];
			dp[i][j] %= MOD;
			if (str[i] == ss[j]) {
				dp[i + 1][j + 1] += dp[i][j];
				dp[i + 1][j + 1] %= MOD;
			}

		}
	}
	rep(i, str.size()+1)ans += dp[i][ss.size()];
	cout << ans %MOD << endl;
	return 0;
}



Measured memory_bytes: 19656
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    for(int j=1; j<10; j++){
        for(int i=1; i<10; i++){
            if(i*j==N){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
from sys import stdin, exit

N = int(stdin.readline().rstrip())
H = [int(x) for x in stdin.readline().rstrip().split()]
drop = 0

if N == 1:
    print('Yes')
    exit()

if N == 2:
    if H[0] - H[1] > 1:
        print('No')
        exit()
    else:
        print('Yes')
        exit()

for i in range(N - 2, -1, -1):
    if H[i] - H[i + 1] > 1:
        print('No')
        exit()
    if H[i] - H[i + 1] == 1:
        H[i] -= 1
print('Yes')


Measured memory_bytes: 63984
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		int n = Integer.parseInt(bf.readLine());
 		int k = n%10;
 		if (k == 3)
 			out.println("bon");
 		else if (k == 0 || k == 1 || k == 6 || k == 8)
 			out.println("pon");
 		else
 			out.println("hon");
 		out.close();
 		
 		
 		
 	}
}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

 		
 		
 		
 		
	




Measured memory_bytes: 25368
#include <bits/stdc++.h>
using namespace std;
bool dp[100005];
bool helper(vector<int> &v,int k,int n)
{
    //base case;
    if(k<=0)
    {
        return false;
    }
    if(dp[k]!=-1)
    {
        return dp[k];
    }
    bool ans=false;
    for(int i=0;i<n;i++)
    {

        if(v[i]==k)
        {
            return true;
        }
        if(k>=v[i])
        {
            ans=ans || !helper(v,k-v[i],n);
        }
    }
    return dp[k]=ans;
}
int main() {
    int n,k;
    cin>>n>>k;
    vector<int> v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    memset(dp,false,sizeof(dp));
    for(int i=0;i<n;i++)
    {
        dp[v[i]]=true;
    }

    for(int i=1;i<=k;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(v[j]<=i)
            {
                dp[i]=dp[i] || !dp[i-v[j]];
            }
        }
    }

    if(dp[k])
    {
        cout<<"First\n";
    }
    else
    {
        cout<<"Second\n";
    }
    return 0;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, k;
	cin >> n >> k;
	int arr[n];
	for (int i = 0; i < n; i++)cin >> arr[i];
	bool dp[k + 1];
	memset(dp, false, sizeof(dp));

	for(int i=1;i<=k;i++)
	{
		for(int num : arr)
		{
			if(num>i)break;

			if(!dp[i-num])
			{
				dp[i]=true;
				break;
			}

		}
	}
	if(dp[k])cout << "First";
	else cout << "Second";

	return 0;
}

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

int main() {
	int n, k;
	cin >> n >> k;
	int ans = 1;
	while (true){
		if (pow(k, ans)>n) break;
		ans++;
	} 
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4112
package main

import "fmt"

func main() {
	var n string
	fmt.Scan(&n)
	switch n {
	case "A":
		fmt.Println("T")
	case "T":
		fmt.Println("A")
	case "G":
		fmt.Println("C")
	default:
		fmt.Println("G")
	}
}

Measured memory_bytes: 512
inputs = [int(input()) for i in range(4)]

use_num = inputs[0]
sell_start_num = inputs[1]
basic_price = inputs[2]
sell_price = inputs[3]
price_sum = 0

for i in range(use_num):
    if i >= sell_start_num:
        price_sum += sell_price
    else:
        price_sum += basic_price

print(price_sum)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int N,K,X,Y;
    cin >> N >> K>>X>>Y;
    int ans=0;
    if(N<=K){
        ans+=N*X;
    }else{
        ans+=K*X+(N-K)*Y;
    } 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    string s; cin >> s;
    ll ans = 0;
    vector<int> dp(2030);
    rep(i,s.size()) {
        vector<int> dp2(2030, 0);
        int a = s[i]-'0';
        rep(j,2019) {
            dp2[(j*10+a)%2019] = dp[j];
        }
        dp2[a]++;
        ans += dp2[0];
        swap(dp, dp2);
        // cout << ans << endl;
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

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

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using DoP = pair<double, double>;

const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 45;
const int mod = 1000000007;
//const int mod = 10007;

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  map<string, int> m;
  m["SUN"] = 7;
  m["MON"] = 6;
  m["TUE"] = 5;
  m["WED"] = 4;
  m["THU"] = 3;
  m["FRI"] = 2;
  m["SAT"] = 1;
  string s; cin >> s;
  cout << m[s] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
main(){
    int dp[20][20];
    int W,H,N;
    cin >> W >> H;
    while(W){
        cin >> N;
        fill(dp[0],dp[20],0);
        for(int i = 0;i < N;i++){
            int a,b;
            cin >> a >> b;
            dp[b-1][a-1] = -1;
        }
        dp[0][0] = 1;
        for(int i = 0;i < H;i++){
            for(int j = 0;j < W;j++){
                if(i && j && dp[i-1][j] == -1 && dp[i][j-1]  == -1 || (!i && !j) || dp[i][j] == -1)continue;
                      if(!i || dp[i-1][j] == -1){
                    dp[i][j] = dp[i][j-1];
                }else if(!j || dp[i][j-1] == -1){
                    dp[i][j] = dp[i-1][j];
                }else{
                    dp[i][j] = dp[i][j-1] + dp[i-1][j];
                }
            }
        }
        if(dp[H-1][W-1] == -1)dp[H-1][W-1] = 0;
        cout << dp[H-1][W-1] << endl;
        cin >> W >> H;
    }
}

Measured memory_bytes: 3088
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int ll;
int main()
{
	string s;
	cin >> s;
	int s_len=s.length();
	int ans = 999;
	int tmp = 0;

	for(int i=0; i<=s_len-3; i++){
		tmp = (s.at(i)-'0')*100+(s.at(i+1)-'0')*10+(s.at(i+2)-'0');
		if(abs(753-tmp)<ans){
			ans=abs(753-tmp);
		}
	}

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

int a[100000];

int func(int i, int cnt)
{
    if (a[i] == 0) return -1;
    if (i == 2) return cnt;
    int aa = a[i];
    a[i] = 0;
    return func(aa, cnt + 1);
}

int main()
{
    int n;

    cin >> n;

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

    cout << func(1, 0) << endl;

    return 0;
}

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

int main() {
  int n;
  cin>>n;
  int a=1000-n%1000;
  cout<<a%1000<<endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<double> v(n);
  for(int i=0; i<n; i++) cin >> v[i];
  sort(v.begin(),v.end());
  double ans=0;
  ans = (v[0] + v[1])/2;
  for(int i=2; i<n; i++){
    ans = (ans + v[i])/2.0;
  }
  cout << ans << endl;
}

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

const int N = 100000 + 10;

int n;
char ss[N];

int main() {
	scanf( "%s", ss + 1 );
	n = (int)strlen( ss + 1 );
	int tot = 0;
	for( int i = 1, j; i <= n; i = j + 1 ) {
		for( j = i; j + 1 <= n && ss[j+1] == ss[i]; j++ );
		tot++;
	}
	printf( "%d\n", tot - 1 );
}



Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>

const long long gosencho = 5000000000000000;

int main (void)
{
    char s[101];
    char *p = s;
    long long k;
    double digit = 0;

    scanf("%s", s);
    scanf("%lld", &k);

    while (*p) {
        digit += pow((double)(*p - '0'), (double)gosencho);
        if (digit >= k) {
            putchar(*p);
            puts("");
            return 0;
        }
        ++p;
    }

    return 0;
}


Measured memory_bytes: 128
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn print_evens(mut b: i64, m: i64) {
    let mut l = b / 2;
    let mut r = l + 1;
    for i in 0..m {
        println!("{} {}", l, r);
        l -= 1;
        r += 1;
    }
}

fn print_odds(mut b: i64, offset: i64, m: i64) {
    let mut l = b / 2;
    let mut r = l + 2;
    for i in 0..m {
        println!("{} {}", l + offset, r + offset);
        l -= 1;
        r += 1;
    }
}

fn main() {
    let v = read_vec::<i64>();
    let (mut n, m) = (v[0], v[1] as i64);
    if n == 4 {
        println!("1 2");
        return;
    }
    let mut assigned = n / 2;
    if assigned % 2 == 1 && n % 2 == 1 {
        assigned += 1;
    } else if assigned % 2 == 1 {
        assigned -= 1;
    }
    let m1 = min(m, assigned / 2);
    debug!(m, assigned);
    print_evens(assigned, min(m, m1));
    if n % 2 == 1 {
        let m = m - min(m, m1);
        print_odds(n - assigned, assigned, m);
    } else {
        let m = m - min(m, m1);
        print_odds(n - assigned, assigned, m);
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

const int MAX_N = 1e+5 + 1;

bool is_used[MAX_N];
vector<int> graph[MAX_N];
vector<int> tsorted;
int dp[MAX_N];

void dfs(int node) {
    if (is_used[node]) return;
    is_used[node] = true;
    for (int i = 0; i < graph[node].size(); i++) dfs(graph[node][i]);
    tsorted.push_back(node);
}

int main() {
    int N, M;
    cin >> N >> M;
    int x, y;
    for (int i = 0; i < M; i++) {
        cin >> x >> y;
        x--, y--;
        graph[x].push_back(y);
    }
    for (int i = 0; i < N; i++) {
        if (!is_used[i]) dfs(i);
    }
    for (int i = tsorted.size() - 1; i >= 0; i--) {
        for (int j = 0; j < graph[tsorted[i]].size(); j++) {
            dp[graph[tsorted[i]][j]] = max(dp[graph[tsorted[i]][j]], dp[tsorted[i]] + 1);
        }
    }
    int ans = 0;
    for (int i = 0; i < N; i++) ans = max(ans, dp[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8056
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repA(a,i,n) for(int i=a;i<n;i++)
#define trav(a,x)for(auto &a: x)
#define fll(a) memset(a,0,sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define itr(it,x) for(auto it=x.begin();it!=x.end();it++)
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
typedef vector<int>vi;
typedef map<int,int>ma;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
void fopen()
{
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);	
}
int BFS(vector <int> edges[], int u, 
                              int v, int n) 
{  
    vector<bool> visited(n, 0); 
  
    vector<int> distance(n, 0); 
  
    // queue to do BFS. 
    queue <int> Q; 
    distance[u] = 0; 
  
    Q.push(u); 
    visited[u] = true; 
    while (!Q.empty()) 
    { 
        int x = Q.front(); 
        Q.pop(); 
  
        for (int i=0; i<edges[x].size(); i++) 
        { 
            if (visited[edges[x][i]]) 
                continue; 
  
      
            distance[edges[x][i]] = distance[x] + 1; 
            Q.push(edges[x][i]); 
            visited[edges[x][i]] = 1; 
        } 
    } 
    return distance[v]; 
}
int main()
{
	//fopen();
	int h,w;
	cin>>h>>w;
	char c[h][w];
	vector<int>v[h*w];
	rep(i,h)
	{
		rep(j,w){
			cin>>c[i][j];
		//	cout<<c[i][j]<<" ";
		}
		//cout<<endl;
	}
	rep(i,h)
	{
		rep(j,w)
		{
			if(c[i][j]=='.'){
			if(i+1<h && c[i+1][j]=='.'){v[i*w+j].pb((i+1)*w+j);v[(i+1)*w+j].pb(i*w+j);}
			if(j+1<w && c[i][j+1]=='.'){v[i*w+j].pb(i*w+j+1);v[i*w+j+1].pb(i*w+j);}	}
		}
	}
	int m=0;
	rep(i,h*w-1)
	{
		repA(i+1,j,h*w)
		{
			m=max(m,BFS(v,i,j,h*w));
			//cout<<BFS(v,i,j,h*w)<<" "<<i<<" "<<j<<endl;
		}
	}
	cout<<m;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
template<long long mod = 1000000007>
struct modint{
	long long a;

	modint() : a(0){}
	modint(long long t){
		a = t % mod;
		if(a < 0) a += mod;
	}

	operator long long() const{ return a; }

	bool operator==(const modint &x) const{ return a == x.a; }
	bool operator!=(const modint &x) const{ return a != x.a; }

	modint operator-() const{ return modint(a ? (mod - a) : 0); }
	modint operator~() const{ return pow(mod - 2); }

	modint operator+(const modint &x) const{ return modint(*this) += x; }
	modint operator-(const modint &x) const{ return modint(*this) -= x; }
	modint operator*(const modint &x) const{ return modint(*this) *= x; }
	modint operator/(const modint &x) const{ return modint(*this) /= x; }

	modint &operator+=(const modint &x){
		a += x.a;
		if(a >= mod) a -= mod;
		return *this;
	}
	modint &operator-=(const modint &x){
		a -= x.a;
		if(a < 0) a += mod;
		return *this;
	}
	modint &operator*=(const modint &x){
		a = a * x.a % mod;
		return *this;
	}
	modint &operator/=(const modint &x){
		a = a * (~x).a % mod; 
		return *this;
	}

	friend ostream &operator<<(ostream &os,const modint &x){
		return os << x.a;
	}
	friend istream &operator>>(istream &is,modint &x){
		long long t;
		is >> t;
		x = modint(t);
		return is;
	}

	modint pow(long long x) const{
		modint ret = 1,tmp = a;
		for(;x;tmp *= tmp,x >>= 1){
			if(x & 1) ret *= tmp;
		}
		return ret;
	}
};

signed main(){
	int n;
	modint<> a[200010],sum(0),ans(0);
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		sum += a[i];
	}
	for(int i = 0;i < n;i++){
		sum -= a[i];
		ans += sum * a[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 5196
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define MAX 100100
#define ll long long
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int n,m,a[MAX<<1];
bool chk(int mid)
{
	for(int l=mid*2-1,r=n+n;l<=r;++l,--r)
		if(a[l]+a[r]<m)return false;
	return true;
}
int main()
{
	n=read();m=read();
	for(int i=1;i<=n+n;++i)a[i]=read();
	sort(&a[1],&a[n+n+1]);
	int l=1,r=n,ret=n+1;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(chk(mid))ret=mid,r=mid-1;
		else l=mid+1;
	}
	int ans=0;
	for(int l=1,r=ret*2-2;l<=r;++l,--r)ans=max(ans,(a[l]+a[r])%m);
	for(int l=ret*2-1,r=n+n;l<=r;++l,--r)ans=max(ans,(a[l]+a[r])%m);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,0,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;

signed main(){
    int N;cin>>N;
    vector<int>A(3*N);
    REP(i,3*N)cin>>A[i];
    sort(A.rbegin(),A.rend());
    int ans=0;
    REP(i,N){
        ans+=A[2*i+1];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2560
n=int(input())
a=list(map(int, input().split()))
def gcd(x, y):
    while y:
        x, y = y, x % y
    return x
def lcm(i,j):
    return i*j//gcd(i,j)
k=1
for t in a:
    k=lcm(k,t)
k-=1
ans=0
for t in a:
    ans+=k%t
print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	char X[2],Y[2];

	scanf("%s %s",X,Y);

	if(X[0] == Y[0]){

		printf("=\n");

	}else if(X[0] < Y[0]){

		printf("<\n");
	}else{

		printf(">\n");
	}

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int selectionSort(int A[], int N);

int main(){
  int N,i,cnt;
  int A[100];
  scanf("%d",&N);
  for(i=0;i<N;i++) scanf("%d",&A[i]);

  cnt=selectionSort(A,N);

  for(i=0;i<N;i++){
    if(i>0 && i<N) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",cnt);
  
  return 0;
}

int selectionSort(int A[],int N){
  int i,j,a,minj,cnt=0;
  for(i=0;i<N-1;i++){
    minj=i;
    for(j=i;j<N;j++){
      if(A[j]<A[minj]) minj=j;
    }
    a=A[i];
    A[i]=A[minj];
    A[minj]=a;
    if(i!=minj) cnt++;
  }
  return cnt;
}



Measured memory_bytes: 2144
#include<iostream>
#include<string>

int N, t[50], res,r;

std::string s[50], X;

int main() {

	std::cin >> N;

	for (int i = 0; i < N; i++) {
		std::cin >> s[i] >> t[i];
		r += t[i];
	}

	std::cin >> X;

	for (int i = 0; i < N; i++) {
		res += t[i];
		if (X == s[i])break;
	}

	std::cout << r-res << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi			first
#define se			second
#define fz(i,a,b)	for(int i=a;i<=b;i++)
#define fd(i,a,b)	for(int i=a;i>=b;i--)
#define foreach(it,v) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define all(a)		a.begin(),a.end()
#define giveup(...) return printf(__VA_ARGS__),0;
#define fill0(a)	memset(a,0,sizeof(a))
#define fill1(a)	memset(a,-1,sizeof(a))
#define fillbig(a)	memset(a,0x3f,sizeof(a))
#define fillsmall(a) memset(a,0xcf,sizeof(a))
#define mask(a)		(1ll<<(a))
#define maskx(a,x)	((a)<<(x))
#define _bit(a,x)	(((a)>>(x))&1)
#define _sz(a)		((int)(a).size())
#define filei(a)	freopen(a,"r",stdin);
#define fileo(a)	freopen(a,"w",stdout);
#define fileio(a) 	freopen(a".in","r",stdin);freopen(a".out","w",stdout)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define put(x)		putchar(x)
#define eoln        put('\n')
#define space		put(' ')
#define y1			y_chenxiaoyan_1
#define y0			y_chenxiaoyan_0
#define int long long
typedef pair<int,int> pii;
inline int read(){
	int x=0,neg=1;char c=getchar();
	while(!isdigit(c)){
		if(c=='-')	neg=-1;
		c=getchar();
	}
	while(isdigit(c))	x=x*10+c-'0',c=getchar();
	return x*neg;
}
inline void print(int x){
	if(x<0){
		putchar('-');
		print(abs(x));
		return;
	}
	if(x<=9)	putchar(x+'0');
	else{
		print(x/10);
		putchar(x%10+'0');
	}
}
inline int qpow(int x,int e,int _MOD){
	int ans=1;
	while(e){
		if(e&1)	ans=ans*x%_MOD;
		x=x*x%_MOD;
		e>>=1;
	}
	return ans;
}
int a=read(),b=read(),n=read(),ans=0;
signed main(){
	fz(i,max(min(n,b-1)-100000000,0ll),min(n,b-1)){
		ans=max(ans,(int)(1.0*a*i)/b);
//		cout<<i<<" "<<(int)(1.0*a*i/b)-a*(int)(1.0*i/b)<<endl;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

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

	int q; cin >> q;

	int64_t bsum = 0;
	int64_t asum = 0;

	multiset<int> lefts;
	multiset<int> rights;

	int count = 0;
	FOR_LT(i, 0, q) {
		int m; cin >> m;
		if (m == 1) {
			count++;

			int a, b; cin >> a >> b;
			bsum += b;

			if (count == 1) {
				lefts.insert(a);
				rights.insert(a);
			}
			else {
				int64_t diff = 0;
				if (a < *lefts.rbegin() || *rights.begin() < a) {
					diff = min(abs(a - *lefts.rbegin()), abs(a - *rights.begin()));
				}
				asum += diff;

				if (a < *lefts.rbegin()) {
					lefts.insert(a);
					lefts.insert(a);
					rights.insert(*lefts.rbegin());
					auto end_it = lefts.end();
					end_it--;
					lefts.erase(end_it);
				}
				else if (*rights.begin() < a) {
					rights.insert(a);
					rights.insert(a);
					lefts.insert(*rights.begin());
					rights.erase(rights.begin());
				}
				else {
					lefts.insert(a);
					rights.insert(a);
				}
			}
		}
		else {
			cout << (*lefts.rbegin()) << " " << (bsum + asum) << endl;
		}
	}

	return 0;
}

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


ans = []
while n > 0:
    #print(n, n%26)
    if n % 26 == 0:
        ans.append(26)
        n = (n-1) // 26
    else:
        ans.append(n % 26)
        n = n // 26


#print(ans[::-1])
print(''.join(map(lambda x: chr(ord('a')+x-1), ans[::-1])))




Measured memory_bytes: 9164
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector<int> in(n);
  for (int i = 0; i < n; i++) {
    cin >> in[i];
  }
  vector<int> ans;
  while (in.size()) {
    int i;
    for (i = (int) in.size() - 1; i >= 0; i--) {
      if (i + 1 == in[i]) {
        ans.push_back(in[i]);
        break;
      }
    }
    if (i < 0) {
      cout << -1 << endl;
      return 0;
    }
    in.erase(in.begin() + i);
  }
  reverse(ans.begin(), ans.end());
  for (int i : ans) {
    cout << i << endl;
  }
  return 0;
}

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

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

  long long sum=0 , i;

  for(i=0 ; i<s.length() ; i++)
  {
      if(s[i]=='0') sum=sum+0;
    else if(s[i]=='1') sum=sum+1;
    else if(s[i]=='2') sum=sum+2;
    else if(s[i]=='3') sum=sum+3;
    else if(s[i]=='4') sum=sum+4;
    else if(s[i]=='5') sum=sum+5;
    else if(s[i]=='6') sum=sum+6;
    else if(s[i]=='7') sum=sum+7;
    else if(s[i]=='8') sum=sum+8;
    else if(s[i]=='9') sum=sum+9;
}
if(sum%9==0) cout<<"Yes";
else cout<<"No";

}


Measured memory_bytes: 3688