akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <sstream>
#include <vector>
#include <string>
#include <iomanip>
#include <bitset>
#define INF	100000000
#define pb	push_back
#define fi first
#define sec second
#define SS stringstream
using namespace std;
typedef pair<int, int> P;
typedef long long int	ll;

string str;
char num[10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
int t[10];

int main(){
	while(cin >> str){
		vector<int> ans;
		for(int i = 0; i < 10; i++) t[i] = 0;
		for(int i = 0; i < str.size(); i++){
			for(int j = 1; j < 10; j++){
				if(str[i] == num[j]){
					t[j]++;
					break;
				}
			}
		}
		bool flag = false;
		for(int i = 1; i < 10; i++){
			if(t[i] > 4){
				cout << "0" << endl;
				flag = true;
				break;
			}
		}
		if(flag == true) continue;
		for(int i = 1; i < 10; i++){
			if(t[i] == 4) continue;
			t[i]++;
			for(int j = 1; j < 10; j++){
				if(t[j] >= 2){
					int temp[10];
					for(int k = 0; k < 10; k++) temp[k] = t[k];
					t[j] -= 2;
					for(int l = 1; l < 10; l++){
						if(t[l] >= 3){
							t[l] -= 3;
						}
						if(t[l] == 1 || t[l] == 2){
							if(l > 7) break;
							if(t[l+1] < t[l] || t[l+2] < t[l]) break;
							else{
								t[l+1] -= t[l];
								t[l+2] -= t[l];
								t[l] = 0;
							}
						}
					}
					bool hata = false;
					for(int k = 0; k < 10; k++){
						if(t[k] != 0) break;
						if(k == 9){
							ans.pb(i);
							hata = true;
						}
					}
					for(int k = 0; k < 10; k++) t[k] = temp[k];
					if(hata == true) break;
				}
			}
			t[i]--;
		}
		if(ans.size() == 0) cout << "0" << endl;
		else{
			cout << ans[0];
			for(int i = 1; i < ans.size(); i++){
				cout << " " << ans[i];
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 1204
#include <stdio.h>
#include <math.h>
//f(a,b)a,bで桁の大きい方
int min(int a,int b){
    if(a<b)return a;
    else return b;
}
int main(void){
    int x;
    long long int n;
    scanf("%d",&x);
     int i,j;
    int t=1;
    while(0.5*t*(t+1)<x){
        t++;
    }
    printf("%d\n",t);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<vector<int>> vvi;
#define clr(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define frpn(x) freopen(#x ".in","r",stdin);freopen(#x ".out","w",stdout);
#define all(a) a.begin(), a.end()
#define mkp make_pair
#define forn(i, n) for(int i=0; i<(int)(n); ++i)
#define forab(i, a, b) for(int i=(int)(a); i<=(int)(b); ++i)
#define fornd(i, n) for(int i=(int)(n-1); i>=0; --i)

//const int NAX = (int)3e5+5;
const int MOD = (int)1e9+7;

template <class T>
inline void rem(T &n){
   n = (-MOD <= n && n <= MOD) ? n : n%MOD ;
  if(n < 0) n += MOD; 
}
//modular inverse
//inv(a,m) - inverse of a mod m
template <class T>
inline T inv(T a, T m){
 return 1<a ? m - inv(m%a, a)*m/a : 1;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a, b; 
    cin >> a >> b;
    int res = 0;
    int sk = 1, c = 1;
    while(sk < b) {
       sk += a - 1;
       ++c;
       ++res;
    }
    cout<< res << "\n";
    return 0;
}


Measured memory_bytes: 256
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
2
---+/

void main(string[] args) {
  const N = readln.chomp.to!long;
  (N.pow(3)).writeln;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
struct node{char op;int x,y,z;};
int now=199999,p[63],a[31],b[31],tmp;
int New(){return now--;}
vector<node>ans;
int Add(int x,int y){
    int p=New();ans.pb(node{'+',x,y,p});
    return p;
}
void Shift(int x,int y){
    for(int i=0;i<y;i++)
        ans.pb(node{'+',x,x,x});
}
int cmp(int x,int y){
    int p=New();ans.pb(node{'<',x,y,p});
    return p;
}
int main(){
    // freopen("data.txt","w",stdout);
    p[0]=cmp(2,Add(0,1));
    ans.pb(node{'+',0,p[0],0});
    ans.pb(node{'+',1,p[0],1});
    for(int i=1;i<31;i++)p[i]=Add(p[i-1],p[i-1]);
    tmp=New();
    for(int i=30;~i;i--){
        a[i]=cmp(Add(tmp,p[i]),0);
        int q=cmp(Add(tmp,p[i]),0);
        Shift(q,i);ans.pb(node{'+',tmp,q,tmp});
    }
    tmp=New();
    for(int i=30;~i;i--){
        b[i]=cmp(Add(tmp,p[i]),1);
        int q=cmp(Add(tmp,p[i]),1);
        Shift(q,i);ans.pb(node{'+',tmp,q,tmp});
    }
    for(int i=60;~i;i--){
        ans.pb(node{'+',2,2,2});
        for(int j=0;j<=i;j++){
            int k=i-j;
            if(j<=30&&k<=30)
                ans.pb(node{'+',2,cmp(p[0],Add(a[j],b[k])),2});
        }
    }
    printf("%d\n",ans.size());
    for(int i=0;i<ans.size();i++)
        printf("%c %d %d %d\n",ans[i].op,ans[i].x,ans[i].y,ans[i].z);
    return 0;
}

Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;
const int N=2e5+5;

ll a[N];
ll sum;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	ll ans=1e18;
	ll now=0;
	for(int i=1;i<n;i++)
	{
		now+=a[i];
		if(abs(sum-now-now)<ans) ans=abs(sum-now-now);
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

#define MOD_BIG 1000000007
#define MOD_BIG2 998244353
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using std::vector;

#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

//////////////////////////////////////


//////////////////////////////////////

int main() {
    
    int N;
    cin >> N;
    vector<int> ps;
    int num = 2;
    for (num = 2; num < 1e6; num++) {
        bool warikire = false;
        double rtnm = sqrt(num);
        for(int i = 0; i < ps.size(); i++) {
            if (num % ps[i] == 0) {
                warikire = true;
                break;
            }
            if (ps[i] > rtnm) {
                break;
            }
        }
        if (!warikire) {
            ps.push_back(num);
            if (N <= num) {
                cout << num << endl;
                break;
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 384
#!/usr/bin/env python3
import sys


def solve(K: int, S: str):
    if len(S)<=K:
        print(S)
    else:
        print(S[:K]+"...")
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(K, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9180
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,A,B,C,D,E;
	while(cin>>N>>A>>B>>C>>D>>E) {
		ll m = min({A,B,C,D,E});
		ll ans = 5 + (N+m-1)/m - 1;
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
 
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};
 
 
int main(void){
  string S;
  int score=0,lest=0;

  cin>>S;
  REP(i,(int)S.length()){
    if(S[i]=='g'){
      if(lest>=1){
	lest--;
	score++;
      }else{
	lest++;
      }
    }else{
      if(lest>=1){
	lest--;
      }else{
	score--;
	lest++;
      }
    }	
  }
  print(score);
  return 0;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

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

	if (S == "SUN") {
		cout << 7 << endl;
	}
	else if (S == "MON") {
		cout << 6 << endl;
	}
	else if (S == "TUE") {
		cout << 5 << endl;
	}
	else if (S == "WED") {
		cout << 4 << endl;
	}
	else if (S == "THU") {
		cout << 3 << endl;
	}
	else if (S == "FRI") {
		cout << 2 << endl;
	}
	else if (S == "SAT") {
		cout << 1 << endl;
	}
}





Measured memory_bytes: 3620
/*
khoi orz, go check out his algo
-normie-
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define FILE_IN "robot.inp"
#define FILE_OUT "robot.out"
#define ofile freopen(FILE_IN,"r",stdin);freopen(FILE_OUT,"w",stdout)
#define fio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define nfio cin.tie(0);cout.tie(0)
#define max(x,y) (((x)>(y))?(x):(y))
#define min(x,y) (((x)<(y))?(x):(y))
#define ord(a,b,c) ((a>=b)and(b>=c))
#define MOD (ll(1000000007))
#define MAX 300001
#define mag 1048576
#define fi first
#define se second
#define pow2(x) (ll(1)<<x)
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plll pair<ll,pll>
#define For(i,__,___) for(int i=__;i<=___;i++)
#define Rep(i,__,___) for(int i=__;i>=___;i--)
#define ordered_set tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update>
#define endl "\n"
#define bi BigInt
#define ll long long
#define pi 3.1415926535897
//------START-----------//
struct node
{
	int match;
	int gt[2];
	node()
	{
		match=0;
		gt[0]=-1; gt[1]=-1;
	}
};
//------END-----------//
ll n,m,k,t,t1,i,j,a,b, res=-1,resi,resj;
vector<node> trie(1);
vector<ll> v;
void pus (ll k)
{
	ll cur=0, bt[64];
	for (ll i=63;i>=0;i--)
	{
		bt[i]=k%2; k/=2;
	}
	for (ll i=0;i<64;i++)
	{
		if (trie[cur].gt[bt[i]]==-1)
		{
			trie.push_back(node());
			trie[cur].gt[bt[i]]=trie.size()-1;
		}
		cur=trie[cur].gt[bt[i]];
		trie[cur].match++;
	}
}
int main()
{
//	ofile;
	fio;
	cin>>n>>m;
	for (i=0;i<n;i++)
	{
		cin>>a;
		v.push_back(a);
		k=0;
		for (j=i;j>=0;j--)
		{
			k+=v[j];
			pus(k);
		}
	}
	vector<ll> vn,vn2;
	vn.push_back(0);
	res=0;
	for (i=0;i<64;i++)
	{
		vn2.clear();
		res*=2;
		ll cnt=0;
		for (ll g:vn) 
		{
			ll nxt=trie[g].gt[1];
			if (nxt>0) cnt+=trie[nxt].match;
			if (nxt>0) vn2.push_back(nxt);
		}
		if (cnt>=m) res++;
		else
		for (ll g:vn) 
		{
			ll nxt=trie[g].gt[0];
			if (nxt>0) vn2.push_back(nxt);
		}
		vn=vn2;
	}
	cout<<res;
}

Measured memory_bytes: 198876
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int

ll max(ll a,ll b)
{
    if(a>b)
    {
        return a;
    }
    return b;
}

ll min(ll a,ll b)
{
    if(a<b)
    {
        return a;
    }
    return b;
}

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

ll lcm(ll a, ll b)
{
    return (a*b)/gcd(a, b);
}


int main() {

int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
{
    cin>>a[i];
}
int mi=a[0];
int c=1;
for(int i=1;i<n;i++)
    {
        if(a[i]<=mi)
        {
            mi=a[i];
            c++;
        }
    }
cout<<c;
    return 0;
}

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

using namespace std;
using ll = long long;
using IP = pair<int, int>;

const ll linf = 1LL << 62;
const int inf = 99999999;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };
const ll atcoder = 1e9 + 7;

#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define rep(i,n) for(int i= 0;i<n;i++)

ll gcd(ll a, ll b) {//最大公約数
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	return (a / gcd(a, b))*b;
}

int main(){

	int n, a, b;
	cin >> n >> a >> b;

	if (n == 2)pr("Borys");
	else {
		if((b-a)%2 == 1)pr("Borys");
		else pr("Alice");
	}

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans,n;
    cin >>n;
    ll cnt[n];
    ans=1;
    for(int i=0;i<n;i++){
        cnt[i]=0;
        int a;
        cin >>a;
        if (a==0){
            ans=(ans*(3-cnt[a]))%MAX;
        }else ans=(ans*(cnt[a-1]-cnt[a]))%MAX;
        cnt[a]++;
    }
    

    cout <<ans<<endl;

    return 0;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

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; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);

/**
 * 二次元累積和を求める s[x][y] := [0, x) x [0, y) の長方形の区間の和
 * @param [in] base 元となる二次元データ (h * w)
 * @param [out] base を元に計算された累積和 ((h+1) * (w+1))
 */
vector<vector<int>> create_2d_cumulative_sum(const vector<vector<int>>& base) {
  int h = base.size();
  int w = base[0].size();
  vector<vector<int>> s(h+1, vector<int>(w+1, 0));
  rep(i, h) rep(j, w) {
    s[i+1][j+1] = s[i][j+1] + s[i+1][j] - s[i][j] + base[i][j];
  }
  return s;
}

/**
 * 二次元累積和から指定された区間 [x1, x2) [y1, y2) の和を求める
 */
int get_value(const int& x1, const int& y1, const int& x2, const int& y2, const vector<vector<int>>& s) {
  return s[x2][y2] - s[x1][y2] - s[x2][y1] + s[x1][y1];
}

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

  int n, m, q;
  cin >> n >> m >> q;

  vector<vector<int>> base(n, vector<int>(n, 0));
  rep(i, m) {
    int l, r; cin >> l >> r; l--; r--;
    base[l][r]++;
  }

  vector<vector<int>> w = create_2d_cumulative_sum(base);

  rep(i, q) {
    int l, r; cin >> l >> r; l--; r--;
    cout << get_value(l, l, r+1, r+1, w) << endl;
  }

  return 0;
}


Measured memory_bytes: 2944
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int q = Integer.parseInt(sc.next());
		int h = Math.min(Integer.parseInt(sc.next()), q * 2);
		int s = Math.min(Integer.parseInt(sc.next()), h * 2);
		int d = Integer.parseInt(sc.next());
		long n = Integer.parseInt(sc.next());
		if (s * 2 <= d) {
			System.out.println(s * n);
		}
		else if (n % 2 == 0) {
			System.out.println(d * n / 2);
		}
		else {
			System.out.println(d * (n / 2) + s);
		}
	}
}

Measured memory_bytes: 23124
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define LL long long
using namespace std;
LL n,m,dp[1000001],v[101],w[101],sum,ans; 
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&w[i],&v[i]);
		sum+=v[i];
	}
	memset(dp,127/3,sizeof dp);
	dp[0]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=sum;j>=v[i];j--)
		  dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
	}
	for(int i=sum;;i--)
	{
		if(dp[i]<=m){
			ans=i;break;
		}
	}
	cout<<ans;
	return 0;
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }
// ll comb(ll n, ll k) { ll v=1; for(ll i=1; i<=k; i++) v = DIV(MUL(v, n-i+1),i); return v; }
//

void solve(int W, int H) {
    rep(i,H) putchar('U');
    rep(i,W) putchar('R');
    rep(i,H) putchar('D');
    rep(i,W) putchar('L');

    putchar('L');
    rep(i,H+1) putchar('U');
    rep(i,W+1) putchar('R');
    putchar('D');
    putchar('R');
    rep(i,H+1) putchar('D');
    rep(i,W+1) putchar('L');
    putchar('U');
    putchar('\n');
}

int main() {
    int sx,sy,tx,ty; cin >>sx>>sy>>tx>>ty;
    solve(tx-sx, ty-sy);
    // cout << (solve(N,a) ? "Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    while(1){
        int n; cin >> n;
        if(n==0)break;
        vector<int> a(n);
        for(int i=0;i<n;i++){
            cin >> a[i];
        }
        string s; cin >> s;
        for(int i=0;i<s.size();i++){
            for(int j=0;j<a[i%n];j++){
                if(s[i]=='a')s[i]='Z';
                else if(s[i]=='A')s[i]='z';
                else s[i]--;
            }
        }
        cout << s << endl; 
    }
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <functional>
#include <set>
#include <tuple>
#include <map>
#include <numeric>

using namespace std;
#define PI 3.14159265359
#define ll long long int

int main(void)
{
    ll N;
    cin >> N;
    vector<ll> P(N), Q(N), R(N);
    for(ll i = 1; i <= N; i++){
        ll p;
        cin >> p;
        P.push_back(p);
        R.push_back(i);
    }

    for(ll i = 0; i < N; i++){
        ll q;
        cin >> q;
        Q.push_back(q);
    }

    ll a, b;
    ll i = 0;
    do{
        if(P == R) a = i;
        if(Q == R) b = i;
        if(R > max(P, Q)) break;
        i++;
    }while(next_permutation(R.begin(), R.end()));

    cout << abs(a - b) << endl;
}

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

using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N, Q;
    cin >> N >> Q;

    string S;
    cin >> S;

    vector<int> l(Q), r(Q);
    for (int i = 0; i < Q; i++) {
        cin >> l[i] >> r[i];
        l[i]--;
    }

    vector<int> AC;
    for (int i = 0; i < N - 1; i++) {
        if (S.substr(i, 2) == "AC") {
            AC.push_back(i);
        }
    }

    for (int i = 0; i < Q; i++) {
        cout << upper_bound(AC.begin(), AC.end(), r[i] - 2) - lower_bound(AC.begin(), AC.end(), l[i]) << endl;
    }

    return 0;
}

Measured memory_bytes: 1996
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define srt(x) sort((x).begin(), (x).end())
#define rsrt(x) sort((x).rbegin(), (x).rend())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<long long>;
using vllvll = vector<vll>;
using vc = vector<char>;
using vs = vector<string>;
using um = unordered_map<long long, long long>;
template<class T>void print(T x) { cout << '\n' << "== " << x << " ==" << '\n'; }
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T>void precise(T x) { cout << setprecision(21) << x << '\n'; }
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; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long double doublepi = M_PI * 2.0;
const long double halfpi = M_PI / 2.0;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long MOD = 1e9 + 7;

ld gete(ll n)
{
    return (n+1) / 2.0;
}

int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ld> acc(N+1, 0);
    vll p(N);
    rep(i, 0, N) {
        cin >> p[i];
    }

    rep(i, 0, N) {
        acc[i+1] = acc[i] + gete(p[i]);
    }

    ld mx = -1;
     rep(i, 0, N-K+1) {
         chmax(mx, acc[i+K] - acc[i]);
     }
     cout << setprecision(21) <<  mx << endl;
}

Measured memory_bytes: 4992
import bisect

N, M, Q = map(int, input().split())
trains = [list(map(int, input().split())) for i in range(M)]
queries = [list(map(int, input().split())) for i in range(Q)]

A  =[[0] * N for _ in range(N)] #A[i][j] = (i + 1) -> (j+1)なる列車の本数
for train in trains:
    li, ri = train
    A[li - 1][ri - 1] += 1
dp = [[0] * N for _ in range(N)]
reached = [[False] * N for _ in range(N)]
def ans(left, right):
    if reached[left][right]:
        return dp[left][right]
    elif left > right:
        return 0
    elif left == right:
        dp[left][right] = A[left][right]
        reached[left][right] = True
        return A[left][right]
    else:
        dp[left][right] = ans(left, right-1) + ans(left + 1, right) + A[left][right] - ans(left + 1, right - 1)
        reached[left][right] = True
        return dp[left][right]

for q in range(Q):
    pi, qi = queries[q]
    print(ans(pi - 1, qi - 1))



Measured memory_bytes: 77460
#include <bits/stdc++.h>
#include <cstdio>
#include <string>

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

const int MAX_N = 100;

int N;
int X[MAX_N], Y[MAX_N], H[MAX_N];

signed main()
{
    int N, T;
    cin >> N >> T;
    int ans = INF;
    for(int i = 0; i < N; i++) {
        int a,b; cin >> a >> b;
        if(b <= T) {
            ans = min(ans, a);
        }
    }

    if(ans == INF) {
        cout << "TLE" << endl;
        return 0;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
A = list(input())
B = list(input())
C = list(input())
D = {"a":A, "b":B, "c":C}


st=A[0]
for i in range(len(A+B+C)):
    if len(D[st])>0:
        st = D[st].pop(0)
    else:
        print(st.upper())
        break


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

int main (){
    int n;
    cin >> n;
    for(int i=0;i<7;i++){
        if(pow(2,i)<=n&&n<pow(2,i+1)){
            cout << pow(2,i) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE FlexibleContexts #-}
import Control.Applicative
import Control.Monad.ST
import Control.Monad
import Control.Monad.State
import Control.Monad.List
import Data.Array.ST
import Data.STRef
import Data.List
import Data.Tuple
import Data.Maybe
import Debug.Trace

modifyArray arr i f = readArray arr i >>= \x -> writeArray arr i (f x)
listToTuple2 [a,b] = (a,b)

bridge n edges = runST $ do
  ord <- newArray (1,n) (-1) :: ST s (STArray s Int Int)
  low <- newArray (1,n) (-1) :: ST s (STArray s Int Int)

  order <- newSTRef 0 :: ST s (STRef s Int)
  
  let
    dfs cur par order es = do
      let (connected, others) = partition ((==cur) . fst) es
      readSTRef order >>= \x -> writeArray ord cur x >> writeArray low cur x
      modifySTRef order (+1)
      
      forM_ connected $ \(_,next) -> do
        nextOrder <- readArray ord next
        when (next /= par) $ do
          if nextOrder == -1 then do
            dfs next cur order others
            readArray low next >>= \x -> modifyArray low cur (\y -> min y x)
            else
            readArray ord next >>= \x -> modifyArray low cur (\y -> min y x)

  dfs 1 (-1) order edges

  res <- forM edges $ \(u,v) -> do
    a <- readArray ord u
    b <- readArray low v
    return $ if a<b then Just (u,v) else Nothing
  return $ catMaybes res

main = do
  (n,m) <- listToTuple2 . map read . words <$> getLine :: IO (Int,Int)
  edges <- map (listToTuple2 . map read . words) . lines <$> getContents :: IO [(Int,Int)]

  print $ length $ bridge n (edges ++ (map swap edges))


Measured memory_bytes: 1020
N = int(input())

if N<0:
  negative = True
elif N==0:
  print(0)
  exit()
else:
  negative = False

N = abs(N)

a = bin(N)
a = a[2:]
a = [int(i) for i in a]
a.reverse()
a.extend([0,0,0,0,0,0])

for i,num in enumerate(a[-2::-1]):
  digit = len(a)-2-i
  if digit % 2:
    a[digit+1] += num

if negative:
  for i,num in enumerate(a[-2::-1]):
    digit = len(a)-2-i
    a[digit+1] += num


for i,num in enumerate(a):
  while a[i]>1:
    a[i] -= 2
    if a[i+1]:
      a[i+1] -= 1
    else:
      a[i+1] += 1
      a[i+2] += 1

flag = 0
for i in a[::-1]:
  if i == 1:
    flag = i
  if flag:
    print(i,end='')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define endl "\n"
#define ENGZ ios::sync_with_stdio(0);ios_base::sync_with_stdio(0);cin.tie(0) , cout.tie(0) ;
#define mod (ll)(1e9+7)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define F first
#define S second
#define PB push_back
#define pb pop_back()
#define MP make_pair
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rREP(i,a,b) for(int i=a;i>=b;i--)
#define MAX 500002
#define MOD 1000003
#define EPS 1e-6
#define PI 3.1415926535
using namespace std;

typedef long long ll;
typedef unsigned long long ull ;
typedef vector<int> vi;
typedef pair<int,int> pi;


int main(){
    ENGZ
    int n ;
    double arr[105] ;
    cin >> n ;
    REP(i,0,n)
        cin >> arr[i] ;

    double sum = 0 ;
    REP(i,0,n){
        sum += 1.0/arr[i] ;
    }
    sum = 1.0 / sum ;
    cout << sum << endl;
    return 0;
}


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

int main(){
  double res;
  int n,d;
  cin >> n >> d;
  int ans = 0;
  while(n--){
  	double x,y; cin >> x >> y;
    res = sqrt(x*x + y*y);
    if(res <= (double)d)
      ans++;
  }
  cout << ans << endl;
}

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

int main() {
	// your code goes here
	int n,i,sa=0,sb=0;
	cin>>n;
	int a[n];
	for(i=0;i<n;i++)
	cin>>a[i];
	sort(a,a+n);
	for(i=0;i<n;i++)
	{
	    if(i%2==0)
	    sa+=a[i];
	    else
	    sb+=a[i];
	}
	int k=abs(sa-sb);
	cout<<k<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lb long double
#define N 100010
using namespace std;
struct Po{int x,y;}a[N];
int n,nst,st[N];
void get(Po &x){scanf("%d %d",&x.x,&x.y);}
bool comp(const Po &x,const Po &y){if (x.y!=y.y)return x.y<y.y;return x.x<y.x;}
Po operator -(Po x,Po y){return (Po){x.x-y.x,x.y-y.y};}
int operator *(Po x,Po y){return x.x*y.y-x.y*y.x;}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) get(a[i]);
	sort(a+1,a+n+1,comp);
	for (int i=1;i<=n;i++){
		while (nst>=2&&(a[i]-a[st[nst]])*(a[st[nst-1]]-a[st[nst]])<0)nst--;
		st[++nst]=i;		
	}
	for (int i=n-1;i>=1;i--){
		while (nst>=2&&(a[i]-a[st[nst]])*(a[st[nst-1]]-a[st[nst]])<0)nst--;
		st[++nst]=i;
	}
	printf("%d\n",nst-1);
	for (int i=1;i<nst;i++)printf("%d %d\n",a[st[i]].x,a[st[i]].y); 
	return 0;
}


Measured memory_bytes: 4172
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        int[] arr = new int[5];
        for (var i = 0; i < 5; i++) {
            arr[i] = int.Parse(Console.ReadLine());
        }
        var k = int.Parse(Console.ReadLine());

        var flg = 0;
        for (var i = 0; i < 4; i++) {
            for (var j = i+1; j < 5; j++) {
                var a = arr[j] - arr[i];
                if (a > k) {
                    flg = 1;
                    break;
                }
            }
        }
        
        if (flg == 0) {
            Console.WriteLine("Yay!");
        } else {
            Console.WriteLine(":(");
        }
    }
}


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

using namespace std;

const int MAXN=2e5+5;
int n;
int a[MAXN];
int xor_sum[MAXN];
int dp[MAXN];
long long sum[MAXN];

inline int bin_chop(int rp){
	int l=1,r=rp;
	while(l<=r){
		int mid=l+r>>1;
		if((xor_sum[mid-1]^xor_sum[rp])==sum[rp]-sum[mid-1])
			r=mid-1;
		else l=mid+1;
	}
	return l;
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		sum[i]=sum[i-1]+a[i];
		xor_sum[i]=xor_sum[i-1]^a[i];
	}
	for(int i=1;i<=n;++i)
		dp[i]=bin_chop(i);
	long long ans=0;
	for(int i=1;i<=n;++i)
		ans+=i-dp[i]+1;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, 0, n) cin >> a[i];
	int sum = 0;
	rep(i, 0, n) sum += a[i];
	rep(i, 0, n) a[i] *= n;
	int ans = 0;
	rep(i, 0, n){
		if(abs(sum - a[i]) < abs(sum - a[ans])){
			ans = i;
		}
	}
	cout << ans << endl;
}

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

#define loop(n) for(int i = 0;i < (int)(n);++i)
#define rep(i,n) for(int i = 0;i < (int)(n);++i)
#define all(vec) (vec).begin(),(vec).end()
#define Sort(vec) sort(all(vec))
#define Rev(vec) reverse(all(vec))

using Graph = vector<vector<int>>;

namespace Input
{
                
    void input(){return;}
    template<typename First,typename... Rest> void input(First &first,Rest&... rest){
    std::cin >> first;
    input(rest...);
}
    
    void inputVec(){return;}
    template<typename First,typename... Rest> void inputVec(vector<First> &first,Rest&... rest){
        int N = first.size();
        for(int i = 0;i < N;i++){
            cin >> first[i];
        }
        inputVec(rest...);
    }
    
    template<typename First,typename Second> void inputTwoVec(vector<First> &first,vector<Second>& second){
        int N = first.size();
        for(int i = 0;i < N;i++){
            cin >> first[i] >> second[i];
        }
    }

    void inputGraph(Graph &g,int path_num,bool isdirected){
        for(int i = 0;i < path_num;i++){
            int a,b;
            cin >> a >> b;
            a--;b--;
            if(isdirected){
                g[a].push_back(b);
            }
            else{
                g[a].push_back(b);
                g[b].push_back(a);
            }
        }
    }
}

void calculate(){
    int N,M;
    Input::input(N,M);
    Graph city(N);
    Input::inputGraph(city,M,false);
    rep(i,N){
        cout << city[i].size() << '\n';
    }
}

int main(int,char**){
    calculate();    
}




Measured memory_bytes: 256
n, m, l = [int (x) for x in input().split(' ')]
a = [[0 for i in range(m)] for j in range(n)]
b = [[0 for i in range(l)] for j in range(m)]
c = [[0 for i in range(l)] for j in range(n)]
for s in range(0,n):
    a[s] = [int (x) for x in input().split(' ')]
for s in range(0,m):
    b[s] = [int (x) for x in input().split(' ')]

for i in range(0,n):
    for k in range(0,l):
        result = 0
        for j in range(0,m):
            result += a[i][j] * b[j][k]
        c[i][k] = result

for i in range(0,n):
    c[i] = [str(c[i][j]) for j in range(0,l)]
    print(' '.join(c[i]))

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

const int N = 2e5 + 5;
int a[N];

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

    int n; std::cin >> n;
    long long sum0 = 0, sum1 = 0;
    for (int i = 0; i < n; ++ i) {
        std::cin >> a[i]; sum1 += a[i];
    }

    long long ans = 1e16;
    for (int i = 0; i < n - 1; ++ i) {
        sum0 += a[i]; sum1 -= a[i];
        ans = std::min(ans, std::abs(sum0 - sum1));
    }

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


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;


void go_karatsuba(auto a, auto b, auto ret, size_t n){
	if(n<8){
		fill(ret, ret+n*2-1, 0);
		for(size_t i=0; i<n; ++i)
		for(size_t j=0; j<n; ++j) ret[i+j] += a[i]*b[j];
	}else
	if(n&1){
		go_karatsuba(a,b,ret,n-1);
		ret[n*2-3] = 0;
		for(size_t i=0; i<n-1; ++i) ret[i+n-1] += a[i]*b[n-1] + b[i]*a[n-1];
		ret[n*2-2] = a[n-1]*b[n-1];
	}else{
		auto 	ar = a, al = a+n/2, 
				br = b, bl = b+n/2,
				asum = ret+n*5, bsum = asum+n/2,
				x1 = ret, x2 = x1+n, x3 = x2+n;
		for(size_t i=0; i<n/2; ++i){
			asum[i] = al[i] + ar[i];
			bsum[i] = bl[i] + br[i];
		}
		go_karatsuba(ar, br, x1, n/2);
		go_karatsuba(al, bl, x2, n/2);
		go_karatsuba(asum, bsum, x3, n/2);
		for(size_t i=0; i<n; ++i) x3[i] -= x1[i]+x2[i];
		for(size_t i=0; i<n; ++i) ret[i+n/2]+=x3[i];
	}
	ret[n*2-1] = 0;
}

template<class T>
vector<T> mul(const vector<T> &_a, const vector<T> &_b){
	auto n = max(size(_a), size(_b));
	vector<T> a(n), b(n);
	copy(ALL(_a), begin(a));
	copy(ALL(_b), begin(b));
	vector<T> ret(n*6);
	go_karatsuba(begin(a), begin(b), begin(ret), n);
	return vector<T>(begin(ret), begin(ret)+size(_a)+size(_b)-1);
} 


int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	const int P = 2e5+3;
	const int g = 2;
	
	vector<int> f(P);
	for(int x=1,i=0;i<P-1;++i){
		f[x] = i;
		x = 1LL*x*g %P;
	}
	
	int n;
	cin>>n;
	
	vector<int> a(n);
	for(auto &_ : a) cin>>_;
	//ll answer = 0;
	//for(int i=0;i<n;++i) for(int j=0;j<n;++j) answer+=1LL*a[i]*a[j]%P;
	
	vector<ll> cnt(P-1);
	for(int x : a){
		x%=P;
		if(x) cnt[f[x]]++;
		//cerr<<x<<' '<<f[x]<<endl;
	}
	
	//for(int i=0;i<P;++i) cout<<cnt[i]<<' '; cout<<endl;
	
	auto m = mul(cnt,cnt);
	//for(auto x : m) cout<<x<<' '; cout<<endl;
	for(int i=P-1;i<size(m);++i) m[i%(P-1)]+=m[i];
	m.resize(P-1);
	//for(auto x : m) cout<<x<<' '; cout<<endl;
	
	ll ans = 0;
	for(int i=0,x=1; i<P-1; ++i, x=1LL*x*g%P) ans+=m[i]*x;
	
	for(int x:a) ans-=1LL*x*x%P;
	ans/=2;
	
	cout<<ans<<endl;
	
	//cout<<answer<<endl;
	
	return 0;
}


Measured memory_bytes: 21904
S = input()
N = len(S)

round = lambda x:int((x*2+1)//2)
ans = []
r, l = 0, 0
for i in range(N):
    if i == N-1 or S[i:i+2] == 'LR':
        l += 1
        ans.append([0] * (r-1) + [round(r/2) + l//2, round(l/2) + r//2] + [0] * (l-1))
        r, l = 0, 0
    else:
        if S[i] == 'R':
            r += 1
        elif S[i] == 'L':
            l += 1

print(' '.join(' '.join(str(e) for e in elem) for elem in ans))


Measured memory_bytes: 11692
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <unordered_map>
#include <unordered_set>

using namespace std;
#define ll long long
#define ld long double

int main() {
	int a, b;
	cin >> a >> b;
	for (int i = 0; i <= a; i++) {
		if (i * 2 + (a - i) * 4 == b) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

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

int main() {
    int H, N; cin >> H >> N;
    int sum = 0;
    for(int i=0; i<N; ++i) {
        int a; cin >> a;
        sum += a;
    }
    cout << (sum >= H ? "Yes\n" : "No\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, length) for (int var = (begin); i < (length); i++)
#define RFOR(var, length, end) for (int var = (length) - 1; i >= (end); i--)
#define REP(var, length) FOR(var, 0, length)
#define RREP(var, length) RFOR(var, length, 0)
#define SORT(vector) sort(vector.begin(), vector.end())

const ll MOD = 1e9 + 7;

void solve(istream& cin, ostream& cout) {
  string s;
  cin >> s;

  int n0 = 0, n1 = 0;
  for (auto c : s) {
    if (c == '0') {
      n0++;
    }
    if (c == '1') {
      n1++;
    }
  }

  cout << 2 * min(n0, n1) << endl;
}

#ifndef TEST
int main() {
  solve(cin, cout);
}
#endif


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

int main() {
	int n, x;
	char y;
	bool S[14]={false}, H[14]={false}, C[14]={false}, D[14]={false};
	
	cin >> n;

	for (int i=0; i<n; i++) {
		cin >> y >> x;
		switch (y) {
			case 'S':
				S[x] = true;
				break;
			case 'H':
				H[x] = true;
				break;
			case 'C':
				C[x] = true;
				break;
			case 'D':
				D[x] = true;
				break;				
		}
	}
	
	for (int i=1; i<=13; i++) {
		if (!S[i])
			cout << "S " << i << endl;
	}
	for (int i=1; i<=13; i++) {
		if (!H[i])
			cout << "H " << i << endl;
	}
	for (int i=1; i<=13; i++) {
		if (!C[i])
			cout << "C " << i << endl;
	}
	for (int i=1; i<=13; i++) {
		if (!D[i])
			cout << "D " << i << endl;
	}

	return 0;
}


Measured memory_bytes: 3016
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();

		int[] a = new int[n];
		for(int i =0 ; i<n;i++) {
			a[i] = sc.nextInt();
		}

		int[][] dual = new int[20][n+1];
		for(int i=0;i<20;i++) {
			dual[i][0]=0;
		}
		for(int i = 0;i<n;i++) {
			for(int j = 0;j<20;j++) {
				if(Math.pow(2, 19-j)<=a[i]) {
					dual[j][i+1]=1;
					a[i]-=Math.pow(2, 19-j);
				}else {
					dual[j][i+1]=0;
				}
			}
		}
		for(int i = 1;i<n+1;i++) {
			for(int j = 0;j<20;j++) {
				dual[j][i]+= dual[j][i-1];
			}
		}

		long counter  =0;
		boolean flag  =true;
		int[] holder = new int[20];
		
		
		for(int i =0; i<20;i++) {
			holder[i]=0;
			for(int j=0;j<n+1;j++) {
				flag = true;
				for(int k=holder[i];k<n+1;k++ ) {
					if((dual[i][k]-dual[i][j])>1) {
						dual[i][j]=k;
						holder[i]=k;
						flag=false;
						break;
					}

				}
				if(flag) {
					dual[i][j]= n+1;
					holder[i]=n+1;
				}
			}
		}

		for(int i =0;i<n;i++) {
			int currentBest = 200002;
			for(int j=0;j<20;j++) {
				if(currentBest>dual[j][i]) {
					currentBest=dual[j][i];
				}
			}
			counter= counter+currentBest-i-1;
		}
		System.out.println(counter);
	}
}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/

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

int main(){
  int a[3][3],b[3][3],n,x,i,j,k,bingo=0;
  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      cin>>a[i][j];
      b[i][j]=0;
    }
  }
  cin>>n;
  for(k=0;k<n;k++){
    cin>>x;
    for(i=0;i<3;i++){
      for(j=0;j<3;j++){
        if(a[i][j]==x){
          b[i][j]=1;
        }
      }
    }
  }
  for(i=0;i<3;i++){
    if(b[i][0]*b[i][1]*b[i][2]==1){
      bingo=1;
    }
  }
  for(i=0;i<3;i++){
    if(b[0][i]*b[1][i]*b[2][i]==1){
      bingo=1;
    }
  }
  if(b[0][0]*b[1][1]*b[2][2]==1){
    bingo=1;
  }
  if(b[0][2]*b[1][1]*b[2][0]==1){
    bingo=1;
  }
  if(bingo){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
using namespace std;
using ll = long long;

int main(){
  string S;
  cin >> S;
  int N=S.size();
  if(S[N-1]=='s'){
    S+="es";
    cout << S << endl;
    return 0;
  }
  else{
    S+="s";
    cout << S << endl;
    return 0;
  }
}

Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;




int main() {
	int a[4][2] = {};
	double b[2];
	while (cin >> b[0] >> b[1]) {
		rep(i, 2) {
			if (b[i] >= 1.1)a[0][i]++;
			else if (b[i] >= 0.6)a[1][i]++;
			else if (b[i] >= 0.2)a[2][i]++;
			else a[3][i]++;
		}
	}
	rep(i, 4) {
		cout << a[i][0] << " " << a[i][1] << endl;
	}
}

Measured memory_bytes: 1224