akhauriyash/Code-Regression huggingface dataset:
import java.io.*
import java.util.*

fun solve(A: Long, B: Long){
    println((A-1L)*(B-1L))
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val A = sc.next().toLong()
    val B = sc.next().toLong()
    solve(A, B)
}



Measured memory_bytes: 29600
N=int(input())
alist=list(map(int,input().split()))

slist=[0]
for a in alist:
  slist.append(slist[-1]+a)  
#print(slist)

answer=float("inf")
for i in range(N+1):
  s1=slist[i]
  s2=slist[-1]-s1
  answer=min(answer,abs(s1-s2))
  
print(answer)

Measured memory_bytes: 31700
#include <stdio.h>
 
int main(void)
{
    int total;
    int book;
    int i;
     
    while (1){
        scanf("%d", &total);
        if (total == 0){
            break;
        }
         
        for (i = 0; i < 9; i++){
            scanf("%d", &book);
            total -= book;
        }
        printf("%d\n", total);
    }
     
    return (0);
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;  // 1e9+7
const int INF = 100100100;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << '\n'

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int ans = 0;
  FOR(i, 1, N + 1) {
    if (to_string(i).size() % 2 == 1) {
      ans++;
    }
  }

  cout << ans << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);

// #ifndef ONLINE_JUDGE
// 	freopen("input.txt" , "r" , stdin);
// 	freopen("output.txt" , "w" , stdout);
// #endif


	string s, t;
	cin >> s >> t;
	int f = 0;
	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] != t[i])
		{
			f = 1;
			break;
		}
	}
	if (f)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

// graph template
template<typename T>
class Edge{
    public:
        int src, to; T cost;

        Edge(int to, T cost): src(-1), to(to), cost(cost){}
        Edge(int src, int to, T cost): src(src), to(to), cost(cost){}
};
template<typename T>
using Edges = vector<Edge<T>>;
template<typename T>
using AdjacencyList = vector<Edges<T>>;
template<typename T>
using Matrix = vector<vector<T>>;

template<typename T>
vector<T> dijkstra(AdjacencyList<T> &g, int s){
    const auto INF = numeric_limits<T>::max();
    vector<T> dist(g.size(), INF);

    using Pr = pair<T, int>;
    priority_queue<Pr, vector<Pr>, greater<Pr>> que;
    dist[s] = 0;
    que.emplace(dist[s], s);

    while(not que.empty()){
        T cost; int v;
        tie(cost, v) = que.top(); que.pop();
        if(dist[v] < cost) continue;

        for(auto &e: g[v]){
            if(dist[e.to] > dist[v] + e.cost){
                dist[e.to] = dist[v] + e.cost;
                que.emplace(dist[e.to], e.to);
            }
        }
    }

    return dist;
}

int main(void){
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--; t--;

    AdjacencyList<ll> g1(n), g2(n);
    for(int i = 0; i < m; i++){
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--; v--;
        g1[u].push_back(Edge<ll>(v, a));
        g1[v].push_back(Edge<ll>(u, a));
        g2[u].push_back(Edge<ll>(v, b));
        g2[v].push_back(Edge<ll>(u, b));
    }

    vector<ll> vec1 = dijkstra(g1, s);
    vector<ll> vec2 = dijkstra(g2, t);

    vector<ll> vec(n);
    vec[n-1] = (ll)1e15 - vec1[n-1] - vec2[n-1];
    for(int i = n-1; i >= 1; i--){
        vec[i-1] = max(vec[i], (ll)1e15 - vec1[i-1] - vec2[i-1]);
    }

    for(auto res: vec) cout << res << '\n';

    return 0;
}

Measured memory_bytes: 19012
#include <bits/stdc++.h>
#define PI acos(-1.0)
#define mem(a,b) memset((a),b,sizeof(a))
#define TS printf("!!!\n")
#define pb push_back
//std::ios::sync_with_stdio(false);
using namespace std;
//priority_queue<int,vector<int>,greater<int>> que;
const double EPS = 1.0e-8;
typedef pair<int, int> pairint;
typedef long long ll;
typedef unsigned long long ull;
const int  maxn = 2e5 + 100;
const int  maxm = 300;
int a[maxn];
int main()
{
        int n;
        cin >> n;
        int now;
        for(int i=1;i<=n;i++)
        {
        scanf("%d",&now);
        a[now]++;
        a[now+1]++;
        a[now-1]++;
        }
        int anser=0;
        for(int i=0;i<=maxn;i++)
        anser=max(anser,a[i]);
        cout<<anser<<endl;

}


Measured memory_bytes: 640
def main():
    MOD = 998244353

    A, B, H, W = map(int, input().split())

    dp = [[0] * (W + 1) for _ in range(H + 1)]
    dp[A][B] = 1

    for h in range(A, H + 1):
        for w in range(B, W + 1):
            if h == A and w == B: continue
            t = 0
            if h > A:
                t += dp[h - 1][w] * w
            if w > B:
                t += dp[h][w - 1] * h
            if h > A and w > B:
                t -= dp[h - 1][w - 1] * (h - 1) * (w - 1)
            dp[h][w] = t % MOD

    print(dp[H][W])


if __name__ == '__main__':
    main()


Measured memory_bytes: 144024
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>
#include<sstream>
#include<cctype>
#include<cstdlib>
#include<cstring>
#include<ctime>
using namespace std;

int main()
{
    int k, a, b;
    cin >> k >> a >> b;
    cout << (a % k == 0 || b % k == 0 || a / k < b / k ? "OK" : "NG") << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

vector<string> V;
string T("AKIHABARA");

void dfs(string K,int n) {
	if (n == T.size()) V.push_back(K);
	else {
		if (T[n] != 'A') {
			K.push_back(T[n]);
			dfs(K, n + 1);
		}
		else {
			dfs(K, n + 1);
			K.push_back(T[n]);
			dfs(K, n + 1);
		}
	}
}

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

	string S; cin >> S;
	string K;
	dfs(K, 0);

	bool flag = false;
	for (int i = 0; i < V.size(); i++) {
		if (S == V[i]) flag = true;
	}

	if (flag) cout << "YES" << endl;
	else cout << "NO" << endl;
	

	
}

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

int main(){
  int a, b;
  int d, r;
  cin >> a >> b;

  double f;

  d = a / b;
  r = a % b;
  f = (double)a/b;

  printf("%d %d %lf\n", d, r, f);
}



Measured memory_bytes: 3224
/******************************************
*******************************************
*******************************************
	PREPARED BY - SOMESH AWASTHI 
	CHANDIGARH UNIVERSITY
*******************************************
*******************************************
*******************************************/

#include<bits/stdc++.h>
using namespace std;
#define fr(i,a,b) for(long long i=a;i<b;i++)
#define io ios::sync_with_stdio(false);cin.tie(NULL);
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
long int mod=1000000007;
vector<pll> arr;
ll n;

ll findMax(ll w) {
	ll mat[n + 1][w + 1] = {0};
	fr(i, 0, n + 1) {
		fr(j, 0, w + 1) {
			if(i == 0 || j == 0) {
				mat[i][j] = 0;
			}
			else if(arr[i - 1].first <= j) {
				// cout << mat[i - 1][j] << ' ' << arr[i - 1].second + mat[i - 1][j - arr[i - 1].first] << " "<< i <<"\n";
				mat[i][j] = max(mat[i - 1][j], arr[i - 1].second + mat[i - 1][j - arr[i - 1].first]);
				// cout << mat[i][j] << endl;
			}
			else {
				mat[i][j] = mat[i - 1][j];
			}
		}
	}
	return mat[n][w];
}

int main()
{
	io
	#ifdef SOMU
		clock_t startTime = clock();
		freopen("input.txt","r",stdin);
	#endif

	ll w;
	cin >> n >> w;
	arr.resize(n);
	fr(i, 0, n) {
		cin >> arr[i].first >> arr[i].second;
		// cout << arr[i].first << " " << arr[i].second << endl;
	}
	sort(arr.begin(), arr.end());
	// fr(i, 0, n) {
	// 	cout << arr[i].first << " " << arr[i].second << '\n';
	// }
	ll ans = findMax(w);	
	cout << ans;

	#ifdef SOMU
		cout << endl <<setprecision(20)<< double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;
	#endif
	return 0;
}

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

int n, m;
string s[200], t[200];
int res = 0;

int main(){
  cin >> n;
  rep(i, n) cin >> s[i];
  cin >> m;
  rep(i, m) cin >> t[i];
  rep(i, n){
    int sum = 0;
    string u = s[i];
    rep(j, n){
      if(u == s[j]){
        sum++;
      }
    }
    rep(j, m){
      if(u == t[j] && sum > 0){
        sum--;
      }
    }
    res = max(sum, res);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>


int num,line[105],line1[105],i;
  
double d(int p){

    int i;
    double D;

    for(D=0.0,i=0;i<num;i++){
        if(p==4)D=D>abs(line[i]-line1[i])?D:abs(line[i]-line1[i]);
        else D+=pow(abs(line[i]-line1[i]),p);
    }
    return p==4?D:pow((double)D,1.0/p);
}
  
int main(void){

    scanf("%d",&num);
    for(i=0;i<num;i++)
        scanf("%d",&line[i]);
    for(i=0;i<num;i++)
        scanf("%d",&line1[i]);
    for(i=1;i<5;i++)
        printf("%lf\n",d(i));

    return 0;
}

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

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int n;
	scanf("%d",&n);
	printf("%s", n <= 999 ? "ABC" : "ABD");
	return 0;
}


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

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

    rep(i, s.size())
        cout << 'x';
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i=0;i<(n);i++)
using namespace std;
typedef long long ll;
ll lcm(ll x, ll y) {
    return x/__gcd(x, y)*y;
}
int main(){
  int n;
  ll ans=1;
  cin >> n;
  ll t[n];
  rep(i,n){
    cin >> t[i];
  }
  rep(i,n){
    ans = lcm(ans,t[i]);
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
#define min(a,b) ((a<b)?a:b)
#define LL long long

vector<LL> length;
//vector<LL> f;
int n;
int a,b;
int main()
{
    length.clear();
    cin>>n>>a>>b;
    //f.resize(n+2,2147483647);
    length.push_back(0);
    for (int i=1;i<=n;i++)
    {
     LL temp;
     cin>>temp;
     length.push_back(temp);
    }
   /* f[0]=0;
    f[1]=0;*/
    LL ans=0;
    for (int i=2;i<=n;i++)
    {
     //for (int j=0;j<i;j++)
       ans+=min((length[i]-length[i-1])*a,b);
      //cout<<f[i]<<' ';
    }
  // cout<<endl;

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


Measured memory_bytes: 1400
#include <iostream>
#include <complex>
#include <vector>

using namespace std;

typedef complex<double> P;

const double EPS = 1e-8;

double cross(P a, P b) { return imag(conj(a)*b); }

vector<P> convexCut(const vector<P> &vp, P p, P q){
	vector<P> res;
	int n = vp.size();
	for(int i=0;i<n;i++){
		P A(vp[i]), B(vp[(i+1)%n]);
		double p1 = cross(q-p,A-p);
		double p2 = cross(q-p,B-p);
		if(p1 > -EPS) res.push_back(A);
		if(p1*p2 < -EPS)
			res.push_back(A+cross(q-p,q-A)/cross(q-p,B-A)*(B-A));
	}
	return res;
}

int main(){
	int n;
	while(cin >> n, n){
		vector<P> vp(n);
		for(int i=0;i<n;i++){
			double x, y; cin >> x >> y;
			vp[i] = P(x,y);
		}
		vector<P> see = vp;
		for(int i=0;i<n;i++)
			see = convexCut(see, vp[i], vp[(i+1)%n]);
		puts(see.empty()?"0":"1");
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
const double PI=3.141592;
vector<double> f(double a,double b){
    a=a/180.0*PI;
    b=b/180.0*PI;
    vector<double>ret(3);
    ret[0]=cos(a)*sin(b);
    ret[1]=sin(a);
    ret[2]=cos(a)*cos(b);

    return ret;
}

int main(){
    while(true){
        double a1,b1,a2,b2;
        scanf("%lf%lf%lf%lf",&a1,&b1,&a2,&b2);
        if(a1==-1&&b1==-1&&a2==-1&&b2==-1)break;

        vector<double>v1,v2;

        v1=f(a1,b1);
        v2=f(a2,b2);

        double dot=0;
        for(int i=0;i<3;i++)dot+=v1[i]*v2[i];
        double rad=acos(dot);
        rad*=6378.1;
        printf("%d\n",(int)(rad+0.5));
    }
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define forn(i,a,b) for (int i = a; i < b; i++)
#define w(t) while(t --)
int main()
{
    int n,k;
    cin>>n>>k;
    double ans=0.0f;
    forn(i,1,n+1)
    {
        int p=(k%i==0)? k/i : k/i+1;
        int x=ceil(log2(p));
        //cout<<x<<"\n";
        ans+=(1/(double)(n))*pow(0.5,x);
    }
    cout<<setprecision(12)<<ans;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;
const int N_MAX = 100001;
const int modint = 1000000007;

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }

// int main() {
//   ll n;
//   cin >> n;
//   ll ans = n * (n-1) % modint;

//   rep(i,n-2){
//     ans = (ans * 8) % modint;
//   }
//   cout << ans << endl;
// }

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

  if(s[s.length()-1] == 's')s.append("es");
  else {
    s.append("s");
  }
  cout << s << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int n,a[3333];
long long int memo[3333][3333][2];
long long int dp(int x,int y,int z){
  if(memo[x][y][z]!=-1) return memo[x][y][z];
  if(x>y) return 0;
  if(z==0) return memo[x][y][z]=max(dp(x+1,y,1)+a[x],dp(x,y-1,1)+a[y]);
  if(z==1) return memo[x][y][z]=min(dp(x+1,y,0)-a[x],dp(x,y-1,0)-a[y]);
}
int main(){
  memset(memo,-1,sizeof(memo));
  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i];
  cout<<dp(0,n-1,0)<<endl;
  return(0);
}


Measured memory_bytes: 173952
#include<math.h>
#include<stdio.h>
#include<stdlib.h>
typedef long long int lli;

void solve(){
    long long int a,b;
    scanf("%lld%lld",&a,&b);
    printf("%lld\n",a*b);
}

int main(){
    int t;
    // scanf("%d",&t);
    // while(t--){
        solve();
    // }
    // return 0;
}

Measured memory_bytes: 1728
#include<bits/stdc++.h>
#define LL long long
#define M 1000005 
using namespace std;
const int P=1e9+7;
int C[2005][2005];
int main(){ 
	
	int n,k;
	cin>>n>>k;
	for(int i=0;i<=n;i++)
		for(int j=0;j<=i;j++){
			if(j==0||j==i)C[i][j]=1;
			else C[i][j]=(C[i-1][j-1]+C[i-1][j])%P;
		}
	for(int i=1;i<=k;i++){
		int ans=1LL*C[k-1][i-1]*C[n-k+1][i]%P;
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,count=0;
	string str;
	cin >> n >> str;
	for(i=0;i<n-2;)
	{
		if(str[i]=='A' && str[i+1]=='B' && str[i+2]=='C')
		{
			count++;
			i+=3;
		}
		else
			i++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
k, q = map(int, input().split())
d = list(map(int, input().split()))
for _ in range(q):
    n, x, m = map(int, input().split())
    cum = [0]*(k+1)
    cnt = [0]*(k+1)
    for i in range(k):
        cum[i] = cum[i-1]+d[i]%m
        cnt[i] = cnt[i-1]
        if d[i]%m == 0:
            cnt[i]+=1
    res = x%m+cum[k-1]*((n-1)//k)+cum[(n-1)%k-1]
    s = res//m
    print(n-1-s-cnt[k-1]*((n-1)//k)-cnt[(n-1)%k-1])


Measured memory_bytes: 56488
n, y = map(int, input().split())
for i in range(n + 1):
    for j in range(n + 1 - i):
        total = 10000 * i + 5000 * j + 1000 * (n - i - j)
        if total == y:
            print(i, j, n - i -j)
            exit()
print('-1 -1 -1')

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin >> n;
    vector<ll> A(n);
    REP(i, n) cin >> A[i];
    ll ans = 0;
    REP(i, n) {
        ans += A[i]/2;
        A[i] %= 2;
        if (i < n-1) {
            ll a = min(A[i], A[i+1]);
            A[i] -= a;
            A[i+1] -= a;
            ans += a;
        }
    }
    cout << ans << endl;
}


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

using namespace std;

#define to first
#define cost second

const int N = 3000;
vector<pair<int , int> > adj[N];
vector<int> rev[N];
int cycle[N] , cnt[N];
int vis[N];

void reach (int node) {
    cnt[node]++;
    vis[node] = 1;
    for (auto &e : adj[node])
        if (!vis[e.to])
            reach(e.to);
}

void reach2 (int node) {
    cnt[node]++;
    vis[node] = 2;
    for (int child : rev[node])
        if (vis[child] != 2)
            reach2(child);
}

int main() {
    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
#ifdef LOCAL
    freopen("input.in" , "r" , stdin);
#endif
    int n , m , p;
    cin >> n >> m >> p;

    while (m--) {
        int a , b , c;
        cin >> a >> b >> c;
        adj[a].push_back({b , c - p});
        rev[b].push_back(a);
    }

    vector<int> dp(n + 1 , -1e9);
    dp[1] = 0;

    for (int j = 1 ;j <= n ;j++) {
        for (int i = 1 ;i <= n ;i++) {
            for (auto &e : adj[i]) {
                if (dp[e.to] < dp[i] + e.cost) {
                    dp[e.to] = dp[i] + e.cost;
                    if (j == n)
                        cycle[e.to] = 1;
                }
            }
        }
    }

    reach(1);
    reach2(n);

    for (int i = 1 ;i <= n ;i++) {
        if (cnt[i] == 2 && cycle[i]) {
            cout << -1;
            return 0;
        }
    }

    cout << max(0 , dp[n]);
}


Measured memory_bytes: 3988
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
ll x[1010],y[1010],a,b,t1,t2;
int main() {
	//freopen("1.txt","r",stdin);
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%lld %lld",&x[i],&y[i]);
	a=x[1]; b=y[1];
	for (int i=2;i<=n;i++) {
		if (a%x[i]==0) t1=a/x[i]; else t1=a/x[i]+1;
		if (b%y[i]==0) t2=b/y[i]; else t2=b/y[i]+1;
		a=x[i]*max(t1,t2); b=y[i]*max(t1,t2);
	}
	printf("%lld\n",a+b);
	return 0;
}

Measured memory_bytes: 256
n = int(input())
v = list(map(int,input().split(" ")))
c = list(map(int,input().split(" ")))
m = []
for i in range(n):
    m.append(v[i]-c[i])
ans = 0
for i in range(n):
    if m[i] > 0:
        ans += m[i]
print(ans)

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

vector<int>pre,in,post;

int n;
int pos;
void rec(int l,int r){
    if(l>=r) return;
    int root=pre[pos++];
    vector<int>::iterator dist=find(in.begin(),in.end(),root);
    int m=distance(in.begin(),dist);
    rec(l,m);
    rec(m+1,r);
    post.push_back(root);
}


void solve(){
    pos=0;
    rec(0,pre.size());
    for(int i=0;i<n;i++){
        if(i) cout<<" ";
        cout<<post[i];
    }

    cout<<endl;
}

int main(){
   // freopen("data.in","r",stdin);
    cin>>n;
    int k;
    for(int i=0;i<n;i++) {
        cin>>k;
        pre.push_back(k);
    }
    for( int i=0;i<n;i++){
        cin>>k;
        in.push_back(k);
    }


    solve();
    return 0;
}

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

int main(){
  int n, sum;
  while(cin >> n, n){
    int N = n;
    sum = 1;
    for(int i = 1; i <= n; i++){
      if(n % i == 0) {
	  int j = 1, temp = 1;
	  while(n % i == 0 && i != 1){
	    n /= i;
	    temp += (int)pow(i,j++);
	  }
	  //	  cout <<"temp"<< temp << endl;
	  sum *= temp;
      }
    }
    sum -= N;
    //        cout << sum << endl;
    if(sum > N) cout << "abundant number" << endl;
    else if(sum < N) cout << "deficient number" << endl;
    else cout << "perfect number" << endl;

    
  }
  return 0;
}

Measured memory_bytes: 1200
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
//#include <vector>
//#include <string>
//#include <list>
//#include <deque>
//#include <unordered_map>
typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 200100
//#define NIL -1

int main() {
    LL n;
    LL y;

    cin >> n >> y;
    LL tmp;
    LL k;
    LL ans_i=-1;
    LL ans_j=-1;
    LL ans_k=-1;


    for(LL i=0; i<=n; i++){
        for(LL j=0; j<=n-i; j++){
            k=n-i-j;
            tmp=10000*i+5000*j+1000*k;
            if(tmp==y){
                ans_i=i;
                ans_j=j;
                ans_k=k;
            }
        }
    }

    cout << ans_i << " " << ans_j << " " << ans_k << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i,n) for (int i = 0; i < (n); ++i)


void solve(std::string S){
    ll ans = 0;
    ll j = S.size() - 1;
    rep(i,S.size()){
        if(S[i] != S[j]) ans++;
        j--;
    }
    cout << ans/2 << endl;

}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll n,k;
  cin >> n>> k;
  ll a[n+1];
  for(ll i=1;i<=n;i++)cin >> a[i];

  for(ll i=k+1;i<=n;i++){
    if(a[i]>a[i-k])cout << "Yes" << endl;
    else cout << "No" << endl;
  }

}

Measured memory_bytes: 5192
#include<bits/stdc++.h>
#define maxn 10005
using namespace std;
char sl[maxn][maxn];
int main()
{
	int m,n;
	cin>>m>>n;
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=n;j++)
		{
		cin>>sl[i][j];
		}
	}
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(sl[i][j]=='#')
			{
				continue;
			}
			sl[i][j]='0';
			if(sl[i-1][j-1]=='#')
			{
				sl[i][j]++;
			}
			if(sl[i][j-1]=='#')
			{
				sl[i][j]++;
			}
			if(sl[i+1][j-1]=='#')
			{
				sl[i][j]++;
			}
			if(sl[i-1][j]=='#')
			{
				sl[i][j]++;
			}
			if(sl[i+1][j]=='#')
			{
				sl[i][j]++;
			}
			if(sl[i-1][j+1]=='#')
			{
				sl[i][j]++;
			}
			if(sl[i][j+1]=='#')
			{
				sl[i][j]++;
			}
			if(sl[i+1][j+1]=='#')
			{
				sl[i][j]++;
			}
		}
	}
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=n;j++)
		{
			cout<<sl[i][j];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 512
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val n = nextInt()

    var sum = 0.0
    repeat(n) {
        val (x, u) = listOfString()
        if (u == "JPY") {
            sum += x.toFloat()
        } else if (u == "BTC") {
            sum += x.toFloat() * 380000.0
        }
    }

    println(sum)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 37928
n = int(input())
res = []
for k in range(1,n+1):
 for s in range(1,n+1):
  for b in range(1,n+1):
    #print(k,s,b)
    resn = str(k) + str(s) + str(b)
    #print(resn)
    resn = int(resn)
    res.append(resn)
print(len(res))

Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<string>
using namespace std;
#define ll long long
#define ull unsigned long long
#define l long
#define xx 1000000007
#define max 1000
int main()
{ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin>>n;
int a[n];
for(int i=1;i<=n;i++)cin>>a[i];
//for(int i=1;i<=n;i++)cout<<a[i]<<" ";
int sum[n];
sum[1]=0;
sum[2]=abs(a[2]-a[1]);
sum[3]=min((sum[2]+abs(a[3]-a[2])),abs(a[3]-a[1]));
//cout<<sum[2]<<" "<<sum[3]<<" ";
for(int i=4;i<=n;i++)
{
int x=sum[i-2]+abs(a[i]-a[i-2]),y=sum[i-1]+abs(a[i]-a[i-1]);
sum[i]=min(x,y);
//cout<<sum[i]<<" ";
}cout<<sum[n];

}


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

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

    vector<long> dp(n+1, LONG_MAX);
    dp[1]=0;
    for(int i=1; i<n; ++i) {
        dp[i+1]=min(dp[i+1], dp[i]+abs(h[i]-h[i+1]));
        if (i+2<=n) dp[i+2]=min(dp[i+2], dp[i]+abs(h[i]-h[i+2]));
    }
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 1408
{-# LANGUAGE RankNTypes #-}
import Control.Monad.State
import Control.Monad.ST
import Data.Array.ST
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector as V

main :: IO ()
main = readContents 2 >>= print . solve

solve :: [[Int]] -> Int
solve [[n], hs] = runST (initialize >>= evalMemo calc 0)
    where
        vs = V.fromList hs
        initialize :: ST s (Table s Int Int)
        initialize = newListArray (0, n - 1) $ repeat Nothing
        calc :: forall s. Memo s Int Int -> Memo s Int Int 
        calc f i 
            | i < n - 2 = min <$> a <*> b
            | i < n - 1 = a 
            | otherwise = return 0
            where
                a = (+ da) <$> f (i + 1)
                b = (+ db) <$> f (i + 2)
                da = abs $ vs V.! i - vs V.! (i + 1)
                db = abs $ vs V.! i - vs V.! (i + 2)

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

type Table s a b = STArray s a (Maybe b)
type Memo s a b = a -> StateT (Table s a b) (ST s) b

evalMemo :: (Ix a) => (forall s. Memo s a b -> Memo s a b) -> a -> Table s a b -> ST s b
evalMemo f k = evalStateT (memoizeFix f k)

memoizeFix :: (Ix a) => (forall s. Memo s a b -> Memo s a b) -> forall s. Memo s a b
memoizeFix f k = get >>= (\arr -> lift (readArray arr k) >>= maybe (f (memoizeFix f) k >>= ((<$) <*> (lift . writeArray arr k . Just))) return)

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

int main(void){
	int n,k;
	scanf("%d%d",&n,&k);
	if(k==1){
		printf("%d\n",0);
	}else{
		n-=k;
		printf("%d\n",n);
	}
	return 0;
}


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

#define FOR(i, j, n) for (int i(j); i < n; ++i)
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define dbg(x) std::cerr<<#x<<" = " << (x) << std::endl
#define pnl(x) std::cout << x << "\n"

typedef	std::vector<int>	vi;
typedef std::pair<int,int>	ii;
typedef std::vector<std::string>	vs;
typedef std::vector<ii>	vii;
typedef std::vector<long long>	vl;
typedef	long long ll;


const int	NB_D = 4;
const int	DY[] = {-1, 1, 0, 0};
const int	DX[] = {0, 0, -1, 1};

int		main(void)
{
	std::ios_base::sync_with_stdio(false);
	int		N, A;
	std::cin >> N >> A;

	N %= 500;
	if (N <= A)
		std::cout << "Yes\n";
	else
		pnl("No");
}



Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <limits>
#include <sstream>

using namespace std;

int main (void)
{
	for (int u = 0; u < 100; u++)
	{
		int t = 0,n = 0;

		cin >> t;
		if (t == 0)
		{
			break;
		}
		cin >> n;

		int a[11],b[11];

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

		int p = 0;

		for (int i = 0; i < n; i++)
		{
			p += b[i] - a[i];
		}

		if (t <= p)
		{
			cout << "OK" << endl;
		}
		else
		{
			cout << t - p << endl;
		}
	}
}


Measured memory_bytes: 3076
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;

    int gcd = M/N;
    while (true) {
        if (M%gcd == 0) {
            cout << gcd << endl;
            return 0;
        }
        gcd--;
    }

    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BHomework solver = new BHomework();
        solver.solve(1, in, out);
        out.close();
    }

    static class BHomework {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            int n = s.nextInt(), m = s.nextInt();
            int sum = 0;
            for (int i = 0; i < m; i++) sum += s.nextInt();
            w.println(Math.max(-1, n - sum));
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 26292
n,m = map(int,input().split())
ks = []
for i in range(m):
    ks.append(list(map(int,input().split())))
p = list(map(int,input().split()))

ans = 0

def tekito(swit):
    for i in range(m):
        judge_kun = 0
        for s in ks[i][1:]:
            judge_kun += swit[s-1]
        if judge_kun % 2 == (1-p[i]):
            return False
    return True

import itertools
for swit in itertools.product([0, 1], repeat=n):
    if tekito(swit):
        ans+=1


print(ans)

Measured memory_bytes: 3064
N, M = map(int,input().split())
p = [list(map(int,input().split())) for i in range(M)]
lmax, rmin = 0, 10**7
for l, r in p:
    lmax = max(lmax, l)
    rmin = min(rmin, r)
if lmax <= rmin:
    print(rmin-lmax+1)
else:
    print(0)

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

int main(void)
{
  int a,b,res=0;

  scanf("%d%d",&a,&b);

  if(a*b%2)
  {
    printf("Odd");
    return 0;
  }
     

  printf("Even");
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N;
    cin >> N;
    vector<ll> A(N),B(N);
    rep(i,N){
        cin >> A[i] >> B[i];
    }
    ll cnt = 0;
    for(int i=N-1;i>=0;i--){
        ll tmp = (A[i]+cnt)%B[i];
        if(tmp==0) continue;
        cnt += B[i] - tmp; 
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1792
use v5.18;
use warnings;
use Math::BigInt;
use List::Util 'reduce';

my ($n, $e, $f) = split / /, <STDIN>;
my $MOD = 1e9 + 7;

sub combination {
  my ($n, $k) = @_;
  my $c = reduce {$a * $b % $MOD} (($n-$k+1)..$n);
  my $d = reduce {$a * $b % $MOD} (1..$k);

  $c * Math::BigInt->new($d)->bmodinv($MOD) % $MOD;
}
my $ans = Math::BigInt->new(2)->bmodpow($n, $MOD) - 1;
$ans += $MOD - combination($n, $e);
$ans += $MOD - combination($n, $f);
say $ans % $MOD;

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 N; cin >> N;
    vector<i64> A(N);
    REP(i, N) cin >> A[i];

    auto solve = [&](bool pos) {
        i64 cnt = 0;
        i64 a = A[0];
        if (pos && A[0] <= 0) a = 1;
        if (!pos && A[0] >= 0) a = -1;

        cnt += abs(A[0] - a);
        i64 cum = a;
        REPS(i, N - 1) {
            i64 nc = cum + A[i];
            if (cum > 0 && nc >= 0) nc = -1;
            if (cum < 0 && nc <= 0) nc = 1;
            cnt += abs(cum + A[i] - nc);
            cum = nc;
        }
        return cnt;
    };

    cout << min(solve(true), solve(false)) << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstring>

using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
    
    unsigned long long a,b = 0;
    int k;
    cin  >> a >> b >> k;
    
    for(unsigned long long i = a; i <= b; i++){
        if (i < a + k || i > b - k) cout << i << endl;
        else{
            i = b - k;
        }
    }
    
//    cout << result << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    int n,m,s,c,i;
    scanf("%d%d",&n,&m);
    int num[n];
    int ans=0;

    for(i=0;i<n;i++)
        num[i] = -1;

    for(i=0;i<m;i++){
        scanf("%d%d",&s,&c);
        if(num[s-1] == -1 || num[s-1] == c)
            num[s-1] = c;
        else ans = -1;
    }

    if(n==1){
        if(num[0]==-1)
            num[0] = 0;
        if(ans == -1)
            printf("-1");
        else 
            printf("%d",num[0]);
    }
    
    if(n==2){
        if(num[0]==0)
            ans=-1;
        if(num[0]==-1)
            num[0]=1;
        if(ans == -1)
            printf("-1");
        else{
            for(i=0;i<n;i++){
                if(num[i] == -1)
                    printf("0");
                else
                    printf("%d",num[i]);
            }
        }
    }

    if(n==3){

        if(num[0] == 0)
            ans = -1;
        if(num[0] == -1)
            num[0] = 1;

        if(ans == -1)
            printf("-1");
    
        else{
            for(i=0;i<n;i++){
                if(num[i] == -1)
                    printf("0");
                else
                    printf("%d",num[i]);
            }
        }   
    }
    return 0;

}

Measured memory_bytes: 128
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define msi map<string,int>
#define mii map<int,int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define po pop_back
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
//	#ifndef ONLINE_JUDGE
  //  	freopen("input.txt", "r", stdin);
    //	freopen("output.txt", "w", stdout);
	//#endif
	int h,w,n;
	cin>>h>>w>>n;
	int max1 = max(h,w);
	int ans = n/max1;
	if(n%max1 != 0){
		ans++;
	}
	cout<<ans;

	return 0;
}

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

using namespace std;

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int64_t a, b;
  std::cin >> a >> b;
  std::cout << (a - b + 1) << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <string>
using namespace std;
#define ll long long
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
	int n;
	cin>>n;
	string com;
	int key;
	list<ll> lst;
	list<ll>::iterator it,i=lst.end();
	while(n--){
		cin>>com;
		if(com=="insert"){
			cin>>key;
			lst.push_front(key);
		}
		else if(com=="delete"){
			cin>>key;
			for(it=lst.begin();it!=i;it++){
				if(*it==key){
					lst.erase(it);
					break;
				}
			}
		}
		else if(com=="deleteFirst")	lst.pop_front();
		else 						lst.pop_back();
		
	}
	i--;
	for(it=lst.begin();it!=i;it++)	cout<<*it<<" ";
	cout<<*i<<"\n";
	return 0;
}

Measured memory_bytes: 32472
#include <stdio.h>
#include <iostream>
#include <string.h>
using namespace std;
char a[200010];
int main(){
	int i,n,tmp=0;
	long long ans=0;
	scanf("%s",a+1);
	n=strlen(a+1);
	for(i=1;i<=n;i++){
		if(a[i]=='B') tmp++;
		else ans+=tmp;
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>
#include <map>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint>> que;
//priority_queue<llint> q;

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

int n,k;
string s;
vector<int>v;

void solve(){
  cin >> n >> k;
  cin >> s;
  char pre='0';
  int cnt=0;
  for(int i=0;i<n;i++){
    if(pre!=s[i]){
      v.push_back(cnt);
      cnt=1;
    }
    else cnt++;
    pre=s[i];
  }
  v.push_back(cnt);
  if(pre=='1')v.push_back(0);
  if(v.size() == 1){
		cout << v[0] << endl;
		return;
	}
  int sum=0;
  int x=0;
  for(int i=0;i<v.size();i++){
    sum+=v[i];
    if(i%2)x=max(sum,x);
    if(i-2*k>=0) sum-=v[i-2*k];
  }
  int ans=x;
  reverse(v.begin(),v.end());
  sum=0;
  x=0;
  for(int i=0;i<v.size();i++){
    sum+=v[i];
    if(i%2)x=max(sum,x);
    if(i-2*k>=0) sum-=v[i-2*k];
  }
  ans=max(ans,x);
  cout << ans << endl;
}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


Measured memory_bytes: 1020
/* Alohomora */
#include<bits/stdc++.h>
#define ll         long long
#define fl(i,n)    for(i=0;i<n;i++)
#define fld(i,a,b) for(i=a;i>b;i--)
#define fli(i,a,n) for(i=a;i<n;i++)
#define inp(i,a,n) for(i=0;i<n;i++) {cin>>a[i];}
#define op(i,a,n)  for(i=0;i<n;i++) {cout<<a[i]<<" ";}
#define pb         push_back
#define mp         make_pair
#define F          first 
#define S          second
#define mod        1000000007
#define all(x)     x.begin(),x.end()  
#define speedup    ios_base::sync_with_stdio(false),cin.tie(0)
using namespace std;
void comp() {
  ll i,j,k,l,m,n,r;
  cin>>n;
  ll sum=0;
  fli(i,1,n+1) {
  	if(i%3 && i%5) sum+=i;
  }
  cout<<sum<<endl;
}

int main() {
    speedup;
    ll i=0,t;
    //cin>>t;
    t=1;
    while(t--) {
        comp();
    }
    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;
double kai(int n) {
	int a = 1;
	for (int i = 1; i <= n; i++) {
		a = a * i;
	}
	return a;
}

int main() {
	int N;
	double sum = 0;
	cin >> N;
	vector<double> x(N);
	vector<double> y(N);
	vector<double> v(N);
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i];
		v[i] = i;
	}
	 do{
		for (int i = 0; i < N-1; i++) {
			sum = sum + sqrt(pow(x[v[i]] - x[v[i + 1]], 2) + pow(y[v[i]] - y[v[i + 1]], 2));
		}
	 } while (next_permutation(v.begin(), v.end()));
	cout << setprecision(12) <<  sum / kai(N) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long l,r;
    scanf("%lld%lld",&l,&r);
    r=min(r,l+5000);
    long long ans=2018;
    for(long long i=l;i<=r;i++)
        for(long long j=i+1;j<=r;j++)
    {
        ans=min(ans,i*j%2019);
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int MAX = 305;
const int NIL = -1;
const ll LINF = 1LL << 50;
/* global variables */
/* funciton */
/* main */
int main() {
    int N;
    cin >> N;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];

    vector<vector<ll>> dp(N+1, vector<ll>(N+1));

    for (int i = 0; i <= N; i++) dp[i][i] = 0;
    for (int len = 1; len <= N; len++) {
        for (int x = 0; x <= N - len; x++) {
            int y = x + len;
            if ((N-len) % 2 == 0) {
                dp[x][y] = max(dp[x+1][y] + a[x], dp[x][y-1] + a[y-1]);
            }
            else {
                dp[x][y] = min(dp[x+1][y] - a[x], dp[x][y-1] - a[y-1]);
            }
        }
    }
    cout << dp[0][N] << '\n';
}

Measured memory_bytes: 73628
// ------------------------------------
// Date:2018/ 3/27
// Problem:B - Sports b.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 300;

int N, M;
int A[MAX_N][MAX_N];

struct Data {
  int type;
  int num;
};

int solve(vector< int > p)
{
  int ans = N;
  int maxNum;
  int loopCnt = p.size();
  while (loopCnt--){
    
    map< int, int > m;
    
    REP(ni, N) {
      REP(mi, M) {
	if (binary_search(ALL(p), A[ni][mi])) {
	  m[A[ni][mi]]++;
	  break;
	}
      }
    }

    int tmp = 0;
    EACH(mi, m) {
      if (tmp < mi.second) {
	maxNum = mi.first;
	tmp = mi.second;
      }
    }

    REP(ni, N) {
      REP(mi, M) {
	if (A[ni][mi] == p[maxNum - 1]) A[ni][mi] = 0;
      }
    }
    
    // debug(ans);
    ans = min(ans, tmp);
  }

  return ans;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  cin >> N >> M;
  REP(hi, N)
    REP(wi, M) cin >> A[hi][wi];
  
  vector< int > p(M);
  iota(ALL(p), 1);

  int ans = solve(p);
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
using namespace std;

void solve4() {
	string s;
	cin >> s;
	if (s.size() == 2 && s[0] == s[1]) {
		cout << 1 << " " << 2 << endl;
		return;
	}
	for (int i = 0; i+2 < s.size(); i++)
	{
		if (s[i] == s[i + 2] || s[i] == s[i + 1] || s[i + 1] == s[i + 2])
		{
			cout << i+1 << " " << i + 3 << endl;
			return;
		}
	}
	cout << -1 << " " << -1 << endl;
}
int main() {
	solve4();
	return 0;
}

Measured memory_bytes: 512
import java.io.*;
  
class Main{
	public static void main(String[] args) throws IOException{

		double x,men,shu;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		x = Double.parseDouble(str);

		men = x * x * Math.PI;
		shu = 2 * Math.PI * x;

		System.out.printf("%1.6f %1.6f", men, shu);
    	}
}

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

void solve() {
	int N, Q; cin >> N >> Q;
	string str; cin >> str;

	vector<int> s(N + 1, 0);
	for (int i = 0; i < N - 1; i++) {
		if (str[i] == 'A' && str[i + 1] == 'C') s[i + 1] = s[i] + 1;
		else s[i + 1] = s[i];
	}

	int l, r;
	rep(q, Q) {
		cin >> l >> r;
		l--; r--;
		cout << s[r] - s[l] << endl;
	}
}

int main(void) {
	solve();

	return 0;
}

Measured memory_bytes: 1408
N,K=map(int,input().split())
A=list(map(int,input().split()))
a=A[:]
for _ in range(K):
    t=[0]*(N+1)
    for i in range(N):
        ti=a[i]
        t[max(0,i-ti)]+=1
        t[min(N,i+ti+1)]-=1
    for i in range(N):
        t[i+1]+=t[i]
    a=t[:N]
    if min(a)==N:
        break
print(*a)

Measured memory_bytes: 170064