akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)

void FIO()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
	FIO();
	int n; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	int ma = a[0];
	int cnt = 0;

	for (int i = 1; i < n; i++)
	{
		ma = max(ma, a[i]);
		cnt += (ma - a[i]);
	}
	cout << cnt << '\n';
	return 0;
}

Measured memory_bytes: 4712
#include <bits/stdc++.h>
using namespace std;
vector<int> sprime(int n) 
{ 
    
    bool prime[n+1]; vector<int>v;
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
      { if (prime[p]) 
          {
              v.push_back(p);
          }
      }
      return v;
} 
int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int x;cin>>x;
	if(x>=30)
	cout<<"Yes"<<"\n";
	else
	cout<<"No"<<"\n";
	  
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
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; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll n, maxv = 0, ans = 0; cin >> n;
    rep(i, n){
        ll in; cin >> in;
        chmax(maxv, in);
        ans += in;
    }
    ans -= maxv;
    if(maxv < ans) Yes();
    else No();
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100
#define M 100

int main(void)
{
	int n, m, i, j;
	int A[N][M] = {0};
	int b[M] = {0};
	int c[N] = {0};
	scanf("%d %d", &n, &m);
	for(i=0; i<n; i++){
		for(j=0; j<m; j++){
		scanf("%d", &A[i][j]);
		}
	}
	for(j=0; j<m; j++){
		scanf("%d", &b[j]);
	}
	for(i=0; i<n; i++){
		for(j=0; j<m; j++){
			c[i] += A[i][j] * b[j];
		}
		printf("%d\n", c[i]);
	}
	return 0;
}

Measured memory_bytes: 648
import sys

even = True
for s in sys.stdin:
    if even:
        even = False
        a = list(map(int, s.split()))
    else:
        even = True
        b = list(map(int, s.split()))
        hit = sum(a[i] == b[i] for i in range(4))
        blow = sum(b[i] in a for i in range(4)) - hit
        print(hit, blow)

Measured memory_bytes: 7648
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
int main(){
  ios::sync_with_stdio(0);  cin.tie(0); cout<<setprecision(3); cout<<fixed;
  #ifdef DEBUG
  freopen("ip.txt","r",stdin);
  clock_t tStart = clock();
  #endif

  int n,k,ans=1; cin>>n>>k;
  while(n--){
    if(ans<<1>ans+k) ans+=k;
    else ans<<=1;
  }
  cout<<ans;

  #ifdef DEBUG
	cout<<"\nExecution time: "<<(((double)clock() - tStart)/CLOCKS_PER_SEC)<<"s.\n";
	#endif
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "No" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl


const int MAX_N=200010;
int n,dat[4*MAX_N-1];
int Seg_init(int n_){
    n=1;
    while(n<n_)n*=2;
    for(int i=0;i<2*n-1;++i)dat[i]=0;
    return n;
}
int Seg_calc(int a,int b){
    //  b\a  0  1  2
    //   0   0  1  2
    //   1   1  2  0
    //   2   2  0  1
    return (a+b)%3;
}
void Seg_update(int k,int a){
    k+=n-1;
    dat[k]=a;
    while(k>0){
        k=(k-1)/2;
        dat[k]=Seg_calc(dat[2*k+1],dat[2*k+2]);
    }
}
int Seg_query(int a,int b,int k,int l,int r){
    //外からはSeg_query(a,b,0,0,n)で呼ぶ
    if(r<=a||b<=l)return 0;
    if(a<=l&&r<=b)return dat[k];
    int vl=Seg_query(a,b,2*k+1,l,(l+r)/2);
    int vr=Seg_query(a,b,2*k+2,(l+r)/2,r);
    return Seg_calc(vl,vr);
}


signed main(void){
    string S,T;
    int Q;
    int A[114514],B[114514],C[114514],D[114514];
    int G[114514],H[114514];
    
    cin >> S >> T;
    cin >> Q;
    REP(i,Q){
        cin >> A[i] >> B[i] >> C[i] >> D[i];
        A[i]--;B[i]--;C[i]--;D[i]--;
    }
    
    //Aを1、Bを2、O(=AB)を0と扱う
    
    //Sをセグる
    Seg_init(S.size());
    REP(i,S.size()){
        Seg_update(i,(S[i]=='A'?1:2));
    }
    REP(i,Q){
        G[i]=Seg_query(A[i],B[i]+1,0,0,n);
    }
    
    //Tをセグる
    Seg_init(T.size());
    REP(i,T.size()){
        Seg_update(i,(T[i]=='A'?1:2));
    }
    REP(i,Q){
        H[i]=Seg_query(C[i],D[i]+1,0,0,n);
    }
    
    //REP(i,Q){cout << G[i] MM H[i] << endl;}
    
    REP(i,Q){
        if(G[i]==H[i]){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 10240
while (line = gets)
  a, b, c = line.chomp.split(/[\+\=]/)
  #p [a, b, c]

  ans = -1

  min_x = 0
  if (a.length > 1 && a[0] == "X") ||
      (b.length > 1 && b[0] == "X") ||
      (c.length > 1 && c[0] == "X")
    min_x = 1
  end

  for x in (min_x..9)
    ax = a.gsub(/X/, x.to_s)
    bx = b.gsub(/X/, x.to_s)
    cx = c.gsub(/X/, x.to_s)
    #p [x, ax, bx, cx]

    if ax.to_i + bx.to_i == cx.to_i
      ans = x
      break
    end
  end

  puts (ans >= 0) ? ans : "NA"
end

Measured memory_bytes: 6244
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define rep(i,s,e) for (int64_t i=s; i<e; i++)
#define pi 3.14159265358979323846264338327950L
using namespace std;

int main() {
  int64_t N, T, ans=0;
  cin >> N >> T;
  vector<int64_t> t(N);
  rep(i,0,N) {
    cin >> t[i];
  }
  if (N==1) {
    ans=T;
  }
  else {
    rep(i,1,N) {
      ans+=min(T,(t[i]-t[i-1]));
    }
    ans+=T;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4832
#include<iostream>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)  REP(i,0,n)

#define NODE 301
const int INF = ( 1 << 21);

int table[2][NODE][NODE];
void solve(int n){
  rep(k,n)
    rep(i,n)
    rep(j,n)table[0][i][j]=min(table[0][i][j],table[0][i][k]+table[0][k][j]),
    table[1][i][j]=min(table[1][i][j],table[1][i][k]+table[1][k][j]);
}


main(){
  int n,m;
  while(cin>>m>>n && n){
    rep(i,n){
      rep(j,n)table[0][i][j]=table[1][i][j]=INF;
      table[0][i][i]=table[1][i][i]=0;
    }
    rep(i,m){
      int a,b,cost,time;
      cin>>a>>b>>cost>>time;
      a--,b--;
      table[0][a][b]=cost;table[0][b][a]=cost;
      table[1][a][b]=table[1][b][a]=time;
    }

    solve(n);
    int q;
    cin>>q;
    rep(i,q){
      int f,t,type;
      cin>>f>>t>>type;
      cout << table[type][f-1][t-1] << endl;
    }
    
  }
}

Measured memory_bytes: 1108
#include <cstdio>
#include <queue>
#include <cstring>
using namespace std;

typedef struct{
	int xx;
	int yy;
}zah;

int ix,iy;
zah ma,mb;
int maps[52][52]={};

typedef struct{
	int kyo;
	zah zaa;
	zah zab;
}forq;

zah muki[4]={
	{1,0},{0,1},{-1,0},{0,-1}
};
	
char me[50][50][50][50]={};
int main(void){
	int a,b,c,i,j;
	while(1){
		scanf("%d%d",&ix,&iy);
		if(ix==0)break;

		scanf("%d%d%d%d",&ma.xx,&ma.yy,&mb.xx,&mb.yy);
		memset(maps,-1,sizeof(maps));
		memset(me,0,sizeof(me));
		for(i=1;i<=iy;i++){
			for(j=1;j<=ix;j++){
				scanf("%d",&a);
				if(a==0)maps[j][i]=0;
				else maps[j][i]=-1;
			}
		}


		queue<forq> que;

		forq fa,fb;
		fa.kyo=0;
		fa.zaa=ma;
		fa.zab=mb;

		me[ma.xx-1][ma.yy-1][mb.xx-1][mb.yy-1]=1;
		que.push(fa);

		while(!que.empty()){
			fa=que.front();
			que.pop();

			//printf("%d %d %d %d %d\n",fa.kyo,fa.zaa.xx,fa.zaa.yy,fa.zab.xx,fa.zab.yy);
			if(fa.kyo>=100){
				printf("NA\n");
				goto nexq;
			}

			fb.kyo=fa.kyo+1;
			for(i=0;i<4;i++){
				if(maps[fa.zaa.xx+muki[i].xx][fa.zaa.yy+muki[i].yy]==0){
					fb.zaa.xx=fa.zaa.xx+muki[i].xx;
					fb.zaa.yy=fa.zaa.yy+muki[i].yy;
				}
				else{
					fb.zaa.xx=fa.zaa.xx;
					fb.zaa.yy=fa.zaa.yy;
				}

				if(maps[fa.zab.xx-muki[i].xx][fa.zab.yy-muki[i].yy]==0){
					fb.zab.xx=fa.zab.xx-muki[i].xx;
					fb.zab.yy=fa.zab.yy-muki[i].yy;
				}
				else{
					fb.zab.xx=fa.zab.xx;
					fb.zab.yy=fa.zab.yy;
				}

				if(fb.zaa.xx==fb.zab.xx && fb.zaa.yy==fb.zab.yy){
					printf("%d\n",fb.kyo);
					goto nexq;
				}
				if(me[fb.zaa.xx-1][fb.zaa.yy-1][fb.zab.xx-1][fb.zab.yy-1]!=1){
					me[fb.zaa.xx-1][fb.zaa.yy-1][fb.zab.xx-1][fb.zab.yy-1]=1;
					que.push(fb);
				}
			}
		}
		printf("NA\n");
		nexq:;
	}
return 0;
}

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

int main() {
    int N;
    cin >> N;
    if(N<1200){
      cout << "ABC" <<endl;
    } else if(N<2800){
      cout << "ARC" << endl;
    } else {
      cout << "AGC" << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static Scanner scanner = new Scanner(System.in);
    public static int[][] dp =  new int[3001][3001];
    public static void main(String[] args){
        String s = scanner.nextLine();
        String c = scanner.nextLine();
       System.out.println(solve(s , c));
    }

    public static int Lcslen(String s , String c , int i , int j){

        int slen = s.length();
        int clen = c.length();

        if( i >= slen || j >= clen){
            return 0;
        }
        if(dp[i][j] != -1){
            return dp[i][j];
        }

        if(s.charAt(i) == c.charAt(j) ){
            return dp[i][j] =  1 + Lcslen(s , c , i + 1 , j + 1);
        }
        else {
            return dp[i][j] = Math.max(Lcslen(s , c , i + 1 , j) , Lcslen(s , c , i , j + 1));

        }
    }
        public static String solve(String s , String c){
           for(int row[] : dp){
            Arrays.fill(row , -1);}
            int len = Lcslen(s , c , 0 , 0);
            return getLcs(s,c,len);
        }

        public static String getLcs(String s , String c , int len){
        int i = 0;
        int j = 0;
        String lcs = "";
        while(len > 0){
            if(s.charAt(i) == c.charAt(j)){
                lcs += s.charAt(i);
                i++;
                j++;
                len--;
            }
            else
            {
                if(dp[i][j + 1] > dp[i + 1][j])
                    j++;
                else
                    i++;
            }
        }
        return lcs;
        }
    }



Measured memory_bytes: 91292
/**
 *     author: qodjf
 *     created: 07.11.2020 14:16:14
 */
#include <bits/stdc++.h>
using namespace std;

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) res += ", ";
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifndef ONLINE_JUDGE
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) 42
#endif

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

#define mst(x, a) memset(x, a, sizeof(x))
#define all(a) begin(a), end(a)
#define rep(i, begin, end)                            \
  for (__typeof(end) i = (begin) - ((begin) > (end)); \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr ll LLINF = 0x3f3f3f3f3f3f3f3f;
constexpr ll MOD = 1e9 + 7;

vector<vector<pair<int, ll>>> g;
vector<ll> pos;

ll minPos, maxPos;

bool dfs(int x, ll px) {
  if (pos[x] != -LLINF) {
    return pos[x] == px;
  }
  pos[x] = px;
  chmin(minPos, px);
  chmax(maxPos, px);
  for (auto &child : g[x]) {
    if (!dfs(child.first, px + child.second)) {
      return false;
    }
  }
  return true;
}

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

  int N, M;
  cin >> N >> M;
  g.resize(N);
  rep(i, 0, M) {
    int L, R, D;
    cin >> L >> R >> D;
    L--;
    R--;
    g[L].emplace_back(R, D);
    g[R].emplace_back(L, -D);
  }
  pos = vector<ll>(N, -LLINF);
  rep(i, 0, N) {
    if (pos[i] == -LLINF) {
      minPos = LLINF;
      maxPos = -LLINF;
      if (!dfs(i, 0) || maxPos - minPos > 1e9) {
        puts("No");
        return 0;
      }
    }
  }
  puts("Yes");
}


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

int64_t cnt = 0;

//組織の大きさを返す
int find(int64_t i, vector<vector<int64_t>> &table, vector<int64_t> &finished){
    //組織の大きさ
    cnt++;
    //もう２度と同じところに来ないように
    finished.at(i) = 1;
    //iの友人
    for(auto x: table.at(i)){
        if(finished.at(x) == -1){
            find(x,table,finished);
        }
    }
    return 0;
}


int main(){
    int64_t N,M,A,B,ans;
    cin >> N >> M;
    vector<vector<int64_t>> table(N+1,vector<int64_t>(0));
    vector<int64_t> finished(N+1,-1);
    for(int64_t i = 0; i < M; i++){
        cin >> A >> B;
        table.at(A).push_back(B);
        table.at(B).push_back(A);
    }
    ans = 0;
    //スタートを探す
    for(int64_t i = 1;i < N+1; i++){
        if(finished.at(i) == -1){
            find(i,table,finished);
        }
        ans = max(ans,cnt);
        cnt = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 24972
from string import ascii_lowercase as alphabets


N = int(input())


def dfs(s, used):
    if len(s) == N:
        print(s)
        return
    for i in range(used+2):
        t = s
        t += alphabets[i]
        dfs(t, max(used, i))


dfs("a", 0)


Measured memory_bytes: 4960
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <functional>
using namespace std;

int n, m, h, k;
typedef pair<int, int> P;
typedef pair<int, P> PP;
vector<PP> v, w;
int s[1000], t[1000];

int main(){
	while(1){
		scanf("%d %d %d %d", &n, &m, &h, &k);
		if(n == 0) break;
		memset(s, 0, sizeof(s));
		for(int i=0; i<n; ++i) scanf("%d", &s[i]);
		for(int i=0; i<n; ++i) t[i] = i+1;

		v = w;
		for(int i=0; i<m; ++i){
			int a, b;
			scanf("%d %d", &a, &b);
			v.push_back(PP(b, P(a, i)));
		}
		sort(v.begin(), v.end());

		P x[100000], y[100000];
		for(int i=0; i<m; ++i){
			x[v[i].second.second] = P(t[v[i].second.first-1], t[v[i].second.first]);
			swap(t[v[i].second.first-1], t[v[i].second.first]);
		}
		sort(v.rbegin(), v.rend());
		for(int i=0; i<m; ++i){
			y[v[i].second.second] = P(s[v[i].second.first-1], s[v[i].second.first]);
			swap(s[v[i].second.first-1], s[v[i].second.first]);
		}
/*
		for(int i=0; i<m; ++i)
			printf("%d %d %d %d\n", x[i].first, x[i].second, y[i].first, y[i].second);
*/
		int ans = 0;
		for(int i=0; i<k; ++i) ans += s[i];
		int sum = ans;
		for(int i=0; i<m; ++i){
			if(x[i].first <= k && x[i].second > k){
				ans = min(ans, sum - y[i].second + y[i].first);
			}
		}

		printf("%d\n" , ans);
	}
}

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}
typedef pair<ll, ll> pll;

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	string s, t;
	cin >>s >>t;
	
	int tz = sz(t);
	string ans = "|";
	rep(i, sz(s)+1-tz){
		string cnd = s;
		bool ok=true;
		rep(j, tz){
			if(cnd[i+j] != t[j] && cnd[i+j] !='?') ok=false;
			cnd[i+j] = t[j];
		}
		if(!ok) continue;
		rep(j, sz(s)){
			if(cnd[j]=='?') cnd[j]='a';
		}
		ans = min(ans, cnd);
	}
	cout << (ans!="|"? ans:"UNRESTORABLE") <<"\n";
	return 0;
}


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

int main() {
  long n,t,ans=1000000;
  cin >> n >> t;
  for(long i=0;i<n;i++) {
    long a,b;
    cin >> a >> b;
    if(b<=t) ans=min(ans,a);
  }
  if(ans==1000000) cout << "TLE" << endl;
  else cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n;
  cin>>n;
  cout<<(1000-(n%1000))%1000<<newl;
  return 0;
}


Measured memory_bytes: 3636
n = int(input())
x = input().split()
y = []
for i in x:
  y.append(int(i))
y.sort(reverse=True)
a = 0
b = 0
for i in range(0, n):
  if i % 2 == 0:
    a += int(y[i])
  else:
    b += int(y[i])
print(a - b)

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

int main() {
  int n;
  long long ans = 0;
  
  cin >> n;
  
  long long A[n];
  
  for(int i=0;i<n;i++){
    cin >> A[i];
  }
  
  for(int j=0;j<n-1;j++){
    if(A[j]>A[j+1]){
      ans = ans + A[j] - A[j+1];
      A[j+1]=A[j];
    }
  }
  
    cout << ans << endl;
}


Measured memory_bytes: 5144
#include <algorithm>
#include <iterator>
#include <iostream>
#include <sstream>
#include <bitset>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <time.h>
#include <limits>
#include <math.h>
#include <climits>
#include <numeric>
#include <utility>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <functional>
#include<unordered_map>

using namespace std;
const double pi=acos(-1.0);
//memset ( a , 0 , n * sizeof(ll) ) ;

#define 	chut  		ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); // don't use if small inpts
#define 	endl 		'\n'
#define 	sl(n) 		scanf("%lld",&n)
#define		mp 			make_pair
#define 	pb 			push_back
#define 	ppb 		pop_back
#define 	fi 			first
#define 	se 			second
#define 	ll 			long long
#define 	ull 		unsigned long long
#define 	pii 		pair<int, int>
#define 	f(i,a,b) 	for(ll i = (ll)(a); i < (ll)(b); i++)
#define 	rf(i,a,b) 	for(ll i = (ll)(a); i > (ll)(b); i--)
#define 	ms(a,b) 	memset((a),(b),sizeof(a))
#define 	max(a,b) 	((a>b)?(a):(b))
#define 	min(a,b) 	((a<b)?(a):(b))
#define 	vec(g1) 	int temp;cin>>temp;g1,push_back(temp);
#define 	abs(x) 		((x<0)?(-(x)):(x))
#define 	MAX 		1000005
#define 	inf 		LLONG_MAX
#define 	MIN 		INT_MIN

//typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;


int mod = 1e9 + 7 ;
ll gcd(ll a , ll b){return b==0?a:gcd(b,a%b);}
ll powmod(ll a,ll b) {ll res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
// ll fac[200005];
// ll inverse(ll n){return powmod(n, mod-2);}
// ll nCr(ll n, ll r){return (fac[n] * inverse(fac[r]) % mod * inverse(fac[n-r]) % mod) % mod;}

int main(){
	int a,b,t;
	cin>>a>>b>>t;
	map<int,int> m1;
	m1[a]=b;
	int n= t/a +1;
	for(int i=1;i<=n;i++) m1[i*a]=m1[ (i-1)*a] + b;
    
    t=(int)t;
    t= t- t%a;

   cout<<m1[t]<<endl;

	

	return 0;
}

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

using namespace std;

typedef long long llint;

int n;
llint a, b;
vector<llint> h;

bool check(llint mid) {
  llint x = b * mid;
  llint y = (a - b);

  llint cnt = 0;
  for (int i = 0; i < n; i++) {
    llint d = h[i] - x;
    if (d <= 0) continue;
    cnt += (d + y - 1) / y;
  }
  return (cnt <= mid);
}

int main() {
  cin >> n >> a >> b;
  h.assign(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }

  llint ok = -1, ng = 1e10;
  while (ok + 1 < ng) {
    llint mid = (ok + ng) / 2;
    if (check(mid)) {
      ng = mid;
    } else {
      ok = mid;
    }
  }

  cout << ok + 1 << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

int H, W, N, sr, sc;
string S, T;

bool action(int i, int j, char a){
    if(a == 'L') return j <= (W + 1) / 2;
    else if(a == 'R') return W + 1 - j <= (W + 1) / 2;
    else if(a == 'U') return i <= (H + 1) / 2;
    else if(a == 'D') return H + 1 - i <= (H + 1) / 2;
}

signed main(){
    cin >> H >> W >> N >> sr >> sc;
    cin >> S >> T;
    int l = 1, r = W;
    for(int i = N - 1; i >= 0; i--){
        if(T[i] == 'L') r = min(r + 1, W);
        else if(T[i] == 'R') l = max(l - 1, 1);
        if(S[i] == 'L') l++;
        else if(S[i] == 'R') r--;
        if(l > r){
            PRINT("NO");
            return 0;
        }
    }
    if(sc < l || r < sc){
        PRINT("NO");
        return 0;
    }
    l = 1, r = H;
    for(int i = N - 1; i >= 0; i--){
        if(T[i] == 'U') r = min(r + 1, H);
        else if(T[i] == 'D') l = max(l - 1, 1);
        if(S[i] == 'U') l++;
        else if(S[i] == 'D') r--;
        if(l > r){
            PRINT("NO");
            return 0;
        }
    }
    if(sr < l || r < sr){
        PRINT("NO");
        return 0;
    }
    PRINT("YES");
    return 0;
}

Measured memory_bytes: 776
#include<cstdio>
#include<cstring>
using namespace std;

const int N=200100,M=67110100,INF=2e9;
char s[N]; int n,pre[N],f[N],g[M];

inline int min(int x,int y) {return x<y?x:y;}
int main()
{
	scanf("%s",&s[1]); n=strlen(s+1);
	for (int i=1; i<=n; ++i) pre[i]=pre[i-1]^(1<<(s[i]-'a'));
	for (int i=1; i<=n; ++i) f[i]=i; for (int i=1; i<=M; ++i) g[i]=INF;
	for (int i=1; i<=n; ++i)
	{
		for (int j=0; j<=25; ++j) f[i]=min(f[i],g[(1<<j)^pre[i]]+1);
		f[i]=min(f[i],g[pre[i]]+1); g[pre[i]]=min(g[pre[i]],f[i]);
	}
	printf("%d",f[n]);
	return 0;
}

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

using namespace std;


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

	int a, b, c;
	cin >> a >> b >> c;
	set<int> s;
	s.insert(a);
	s.insert(b);
	s.insert(c);

	cout << s.size() << endl;

	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
import java.util.Map.Entry;
import java.util.stream.IntStream;

public class Main {
    static ContestScanner in;
    static Writer out;
    public static void main(String[] args) {
        Main main = new Main();
        try {
            in = new ContestScanner();
            out = new Writer();
            main.solve();
            out.close();
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    void solve() throws IOException {
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        int g = gcd(a, b);
        System.out.println((c % g == 0) ? "YES" : "NO");
    }

    static int gcd(int a, int b){
        return b == 0 ? a : gcd(b, a % b);
    }
}


class Writer extends PrintWriter{
    public Writer(String filename)throws IOException
    {super(new BufferedWriter(new FileWriter(filename)));}
    public Writer()throws IOException{super(System.out);}
}
class ContestScanner implements Closeable{
    private BufferedReader in;private int c=-2;
    public ContestScanner()throws IOException
    {in=new BufferedReader(new InputStreamReader(System.in));}
    public ContestScanner(String filename)throws IOException
    {in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
    public String nextToken()throws IOException {
        StringBuilder sb=new StringBuilder();
        while((c=in.read())!=-1&&Character.isWhitespace(c));
        while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public String readLine()throws IOException{
        StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
        while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public long nextLong()throws IOException,NumberFormatException
    {return Long.parseLong(nextToken());}
    public int nextInt()throws NumberFormatException,IOException
    {return(int)nextLong();}
    public double nextDouble()throws NumberFormatException,IOException
    {return Double.parseDouble(nextToken());}
    public void close() throws IOException {in.close();}
}

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


int LCM(int a, int b){
    int g = __gcd(a, b);
    return a * b / g;
}

signed main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n; cin >> n;
    int a;
    int l = 1;
    rep(i,n){
        cin >> a;
        l = LCM(l,a);
    }
    cout << l << endl;
    return 0;
}


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

#define loop(i,n) for(int i=0;i<n;i++)
#define int long long
int n;
int d[102];
int num[21];
int mem[21];

signed main(){
  int v;
  cin>>n;
  n--;
  loop(i,n)cin>>d[i];
  cin>>v;
  loop(i,n){
    if(i==0){
      num[d[i]]=1;
      continue;
    }
    loop(j,21)mem[j]=0;
    loop(j,21){
      if(0<=j-d[i])mem[j-d[i]]+=num[j];
      if(j+d[i]<=20)mem[j+d[i]]+=num[j];
    }
    loop(j,21)num[j]=mem[j];
  }
  cout<<num[v]<<endl;
  return 0;
}

Measured memory_bytes: 3012
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;

const int nmax=8;
bool graph[nmax][nmax];

int dfs(int v, int N, bool visited[nmax]){
	bool all_visited=true;
	for(int i=0; i<N; i++){
		if(!visited[i]) all_visited=false;
	}
	if(all_visited) return 1;
	int ret=0;
	for(int i=0; i<N; i++){
		if(!graph[v][i]) continue;
		if(visited[i]) continue;
		visited[i]=true;
		ret+=dfs(i, N, visited);
		visited[i]=false;
	}
	return ret;
}

int main(){
	int N, M;
	cin >> N >> M;
	for(int i=0; i<M; i++){
		int A, B;
		cin >> A >> B;
		graph[A-1][B-1]=graph[B-1][A-1]=true;
	}
	bool visited[nmax];
	for(int i=0; i<N; i++) visited[i]=false;
	visited[0]=true;
	cout << dfs(0, N, visited) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

void print_ans(bool flag){
    if(flag){
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }   
}

int main(){
    int n, m;
    cin >> n >> m;
    int count[n+1];
    for(int i = 1; i <= n; i++){
        count[i] = 0;
    }
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        if(a == 1){
            count[b]++;
        } else if(b == n){
            count[a]++;            
        }
    }
    bool ans = false;
    for(int i = 2; i <= n-1; i++){
        if(count[i] == 2){
            ans = true;
            break;
        }
    }
    print_ans(ans);
    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#define MAX 100005
#define NIL -1

struct Node { int parent, left, right; };

Node T[MAX];
int n, D[MAX],H[MAX];

void setDepth(int u, int d){
	if( u == NIL ) return;
	D[u] =d;
	setDepth(T[u].left, d+1);
	setDepth(T[u].right, d+1);
}

int setHeight(int u){
	int h1 = 0, h2 = 0;
	if(T[u].left != NIL)
	h1 = setHeight(T[u].left) + 1;
	if(T[u].right != NIL)
	h2 = setHeight(T[u].right) + 1;
	return H[u] = ( h1 > h2 ? h1 : h2 );
}

//節点uの兄弟を返す
int getSibling(int u){
	if(T[u].parent == NIL ) return NIL;
	if(T[T[u].parent].left != u && T[T[u].parent].left != NIL)
	return T[T[u].parent].left;
	if(T[T[u].parent].right != u && T[T[u].parent].right != NIL)
	return T[T[u].parent].right;
	return NIL;
}

void print(int u){
	printf("node %d: ", u);
	printf("parent = %d, ", T[u].parent);
	printf("sibling = %d, ", getSibling(u));
	int deg = 0;
	if( T[u].left != NIL ) deg++;
	if( T[u].right != NIL ) deg++;
	printf("degree = %d, ", deg);
	printf("depth = %d, ", D[u]);
	printf("height = %d, ", H[u]);
	
	if(T[u].parent == NIL ){
		printf("root\n");
	}	else if( T[u].left == NIL && T[u].right == NIL ){
			printf("leaf\n");
	}	else{
		printf("internal node\n");
	}
}

int main(){
	int v, l, r, root =0,i;
	scanf("%d", &n);
	
	for( i = 0; i < n; i++) T[i].parent = NIL;
	
	for( i = 0; i < n; i++){
		scanf("%d %d %d", &v, &l, &r);
		T[v].left = l;
		T[v].right = r;
		if( l != NIL ) T[l].parent = v;
		if( r != NIL ) T[r].parent = v;
	}
	
	for( i = 0; i < n; i++) if(T[i].parent == NIL) root = i;
		
	setDepth(root, 0);
	setHeight(root);
		
		for( i = 0; i < n; i++) print(i);
		
		return 0;
}


Measured memory_bytes: 2684
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0), cin.tie(0)
#define RI(x) x = rit()
#define RII(a,b) a = rit(), b = rit()
#define RIII(a,b,c) a = rit(), b = rit(), c = rit()
#define REP(I, N) for(int I=0;I<(N);I++)
#define REPP(I, N) for(int I=1;I<=(N);I++)
#define SZ(x) (int)(x).size()
#define P pair<int, int>
#define F first
#define S second
#define PB(x) push_back(x)
#define endl "\n"
#define ll long long
//#define int long long

//===================================================//

#define N 100000
#define modn 1000000007

using namespace std;
inline int rit(){
    int f=0,key=1;
    char ch;
    do{
        ch = getchar();
        if(ch=='-') key=-1;
    }while(ch<'0'||ch>'9');
    do{
        f = f*10+ch-'0';
        ch = getchar();
    }while(ch>='0'&&ch<='9');
    return f*key;
}
int n, ans, L, R;
int32_t main(void){
    RI(n);
    REP(i,n){
        RII(L,R);
        ans+=R-L+1;
    }
    printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;

int N;
long A[300000];

int main(void) {
  cin >> N;
  REP(i, 0, N * 3) cin >> A[i];

  priority_queue< long, vector<long>, greater<long> > p;
  long sp = 0;
  vector<long> pm;
  REP(i, 0, N) {
    sp += A[i];
    p.push(A[i]);
  }
  pm.push_back(sp);
  REP(i, 0, N) {
    p.push(A[i + N]);
    sp += A[i + N] - p.top();
    p.pop();
    pm.push_back(sp);
  }

  priority_queue<long> q;
  long sq = 0;
  vector<long> qm;
  REP(i, 0, N) {
    sq += A[i + N * 2];
    q.push(A[i + N * 2]);
  }
  qm.push_back(sq);
  REP(i, 0, N) {
    q.push(A[N * 2 - i - 1]);
    sq += A[N * 2 - i - 1] - q.top();
    q.pop();
    qm.push_back(sq);
  }

  long ans = -1000000000000000000;
  REP(i, 0, pm.size()) ans = max(ans, pm[i] - qm[qm.size() - i - 1]);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6516
n = int(input())
x = list(map(int ,input().split()))

ans = 10 ** 99
ansp = 0

for i in range(100):
    for j in range(n):
        ansp += abs(x[j] - i)**2
    if ans > ansp:
         ans = ansp
    ansp = 0 
    
print(ans)

Measured memory_bytes: 38768
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif
#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define debug(x) cerr << #x << " = " << x << endl;
const int MO=1e9+7; 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" ";}
inline int powerexp(int a,int b,int m){int res=1;while(b){if(b&1)res=res*a%m;a=a*a%m,b>>=1;}return res%m;}
void solve(){
	string a,b;
	cin>>a>>b;
	reverse(all(a));
	cout<<(a==b?"YES":"NO")<<endl;
}
//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
    IOS;
    solve();
    #ifdef LOCAL_DEFINE
    cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
    #endif
}

Measured memory_bytes: 256
#![allow(dead_code)]
#![allow(unused_imports)]
use ascii::{AsciiChar, AsciiStr, AsciiString};
use indexmap::IndexMap;
use itertools::*;
use libm::*;
use num::*;
use ordered_float::OrderedFloat;
use permutohedron::LexicalPermutation;
use proconio::marker::{Bytes, Chars};
use proconio::{fastout, input};
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::mem::swap;

fn main() {
    input!(n:usize);
    println!("{}",(1..n+1).map(|x| n/x*(n/x+1)*x/2).sum::<usize>());
}


Measured memory_bytes: 2120
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

ll pow(ll a, ll x, ll p){
  	ll tmp=1;
  	while(x>0){
    	if(x%2 == 1){
          	tmp = (a*tmp)%p;
        }
      	a = (a*a)%p;
      	x /= 2;
    }
  	return(tmp);
}

ll inv(ll a, ll p){
  	return pow(a,p-2,p);
}

ll factorial(ll n, ll p){
  	ll res = 1;
  	for(ll i=1;i<=n;i++){
      	res = (res*i)%p;
    }
  	return res;
}

ll combination(ll n, ll r, ll p){
  ll ans = 1;
  if(r == 0){
      return ans;
  }
  for(ll i=1;i<=r;i++){
    ll x = (n+1-i)*inv(i,p) % p;
    ans = (ans * x) % p; 
  }
  return(ans);
}

ll f(ll r, ll c, ll p){
    ll ans;
    ans = combination(r+c,r,p) % p;
    return ans;
}

int main(){
    ll r1,c1,r2,c2;
    cin >> r1 >> c1 >> r2 >> c2;
  	
    ll ans = ( (f(r2+1,c2+1,mod)-f(0,c2,mod)) - (f(r1,c2+1,mod)-f(0,c2,mod))
                -(f(r2+1,c1,mod)-f(0,c1,mod)) + (f(r1,c1,mod)-f(0,c1,mod)) ) % mod;
    /*
    cout << (f(r2+1,c2+1,mod)-f(0,c2,mod)) << endl;
    cout << (f(r1,c2+1,mod)-f(0,c2,mod)) << endl;
    cout << (f(r2+1,c1,mod)-f(0,c1,mod)) << endl;
    cout << (f(r1,c1,mod)-f(0,c1,mod)) << endl;
    */
   
    if(ans < 0){
        ans = ans + mod;
    }
    
    cout << ans << endl;

    return(0);
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);

int main() {
    cin>>S;
    cout<<(S[1] == 'R' ? "ABC" : "ARC")<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_a_genius = 0; ngtkana_is_a_genius < int(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (int i = int(begin); (i) < int(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) 0;
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}


int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  std::string s; std::cin >> s;
  auto answer = [&] (int l, int r) {
    // debug(s.substr(l, r-l));
    std::cout << l+1 << " " << r << std::endl;
    exit(0);
  };
  int n = s.length();
  auto exec = [&] (char c) {
    std::vector< int > a(n);
    rep(i,0,n) a.at(i) = s.at(i) == c;
    std::partial_sum(all(a), a.begin());
    a.insert(a.begin(), 0);
    rep(i,0,n+1) {
      a.at(i) = i - 2 * a.at(i);
    }
    // debug(a);

    int prvi = 0, prv = a.at(0);
    rep(i,2,n+1) {
      if (prv > a.at(i)) answer(prvi, i);
      if (prv < a.at(i - 2)) {
        prvi = i - 2;
        prv = a.at(i-2);
      }
    }
  };
  rep(c,'a','z'+1) exec(c);
  std::cout << -1 << " " << -1 << std::endl;
  return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int; //任意長整数 
using Real32 = mp::number<mp::cpp_dec_float<32>>;
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
using Rat = boost::rational<Bint>;//有理数*/
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
ll mod = 1000000007;
ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
    ll n,l,pai,ans=INF,ansi;
    cin>>n>>l;
    pai=l*n + ((n-1)*n)/2;
    for(int i=0;i < n;i++)
    {
        ll sa=abs(pai-(pai-l-i));
        if(sa<ans){
            ans=sa;
            ansi=i;
        }
    }
    cout << pai-l-ansi << endl;
}


    

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<sstream>
using namespace std;
#define MOD 1000000007
const long long INF = 1LL << 60;

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

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};


int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

long long dp[100010];
int main() {
	for (int i = 0; i < 100010; ++i) dp[i] = INF;
	int n, k;
	cin >> n >> k;
	int *h = new int[n+1];
	for (int i = 1; i < n+1; i++) {
		cin >> h[i];
	}
	dp[1] = 0;
	for (int i = 2; i <= n; i++) {
		for (int j = 1; j <= k; j++) {
			if (i - j < 1)break;
			chmin(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
		}
	}
	cout << dp[n];



	return 0;
}


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

int main(){
	int n;
	cin >> n;
	for(int loop=0;loop<n;loop++){
		int housecount;
		int machine;

		cin >> housecount >> machine;
		int* house = new int[housecount];

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

		sort(house,house+housecount-1);

		int* ansdata = new int[housecount-1];
		for(int i=0;i<housecount-1;i++){
			ansdata[i] = house[i+1] - house[i];
		}

		sort(ansdata,ansdata+housecount-1);

		int ans = 0;
		for(int i=0;i<housecount-machine;i++){
			ans += ansdata[i];
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 0
/* ex3_3
        fmuacshai */
 
#include<stdio.h>
//math関数を導入
#include<math.h>
int main(void){
    //整数number、進数k、桁数mを整数定義
    int number,base_number,digits;
    //numberの入力
    scanf("%d",&number);
    //kの入力
    scanf("%d",&base_number);
    //mの初期設定
    digits=1;
    //(m+1)桁の最小の数字以上であるかチェック
    while(number>=pow(base_number,digits)){
        digits=digits+1;
    }
    //求めた桁数mの出力
    printf("%d\n",digits);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        String[] line = new Scanner(System.in).nextLine().split(" ", 4);
        int a = Integer.parseInt(line[0]);
        int b = Integer.parseInt(line[1]);
        int c = Integer.parseInt(line[2]);
        int d = Integer.parseInt(line[3]);

        int first = a * b;
        int second = c * d;
        if (first > second) {
            System.out.println(first);
        } else {
            System.out.println(second);
        }
    }
}


Measured memory_bytes: 21844
import numpy as np
cookies = np.array([int(x) for x in input().split()])

if any(cookies%2):
  ans = 0
elif cookies[0] == cookies[1] == cookies[2]:
  ans = -1
else:
  ans = 0
  while True:
    if not any(cookies%2):
      cookies = cookies//2
      ans += 1
      continue
    if all(cookies%2):
      ans += 1
    break
print(ans)

Measured memory_bytes: 18992
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

[<EntryPoint>]
let main _ =
    let N = read int

    let xs =
        [1 .. 50000]
        |> List.filter (fun x -> (float x * 1.08 |> int) = N)

    if List.isEmpty xs then
        printfn ":("
    else
        printfn "%i" (List.head xs)
    0

Measured memory_bytes: 14044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
//void chmin(int &a, int b) { if (a > b) a = b; }
//void chmax(int &a, int b) { if (a < b) a = b; }

const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

int main() {
    int n,r;
    cin >> n >> r;
    if(n >= 10){
        cout << r << endl;
    }else{
        cout << r+100*(10-n) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
    #include<cstdio>
    #include<cstring>
    using namespace std;
    typedef long long ll;
    const int N = 1000010;
    int ww[N];
    int main()
    {
    	int n,m;
    	int i;
    	scanf("%d%d",&n,&m);
    	for(i=0;i<N;i++)
    		ww[i] = 2*N;
    	for(i=0;i<m;i++)
    	{
    		int a,b;
    		scanf("%d%d",&a,&b);
    		ww[a] = min(ww[a],b);
    	}
    	int ans=0,w=0;
    	for(i=1;i<n;i++)
    	{
    		if(ww[i] == 2*N)
    			continue;
    		if(w < i)
    		{
    			ans ++;
    			w = ww[i]-1;
    		}
    		else if(ww[i]-1 < w)
    			w = ww[i]-1;
    	}
    	printf("%d\n",ans);
    	return 0;
    }

Measured memory_bytes: 4348
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;
struct n{
	int x;
	bool operator<(n other){
		return (10-x%10) % 10 < (10-other.x%10) % 10;
	};
}ar[5];

int main(){
	ios_base::sync_with_stdio(false);
	for(int i=0; i<5; i++) cin >> ar[i].x;
	sort(ar, ar+5);
	int res=0;
	for(int i=0; i<4; i++){
		res += (ar[i].x + ((10-(ar[i].x%10)) % 10));
	}
	res += ar[4].x;
	cout << res;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;


void solve(long long X){
    ll ans = X/500 * 1000;
    X %= 500;
    ans += X/5 * 5;
    cout<<ans<<endl;
}

int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void){
	int a,b,c,d,s=0;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if(a<b){
		s+=a;
	}else{
		s+=b;
	}
	if(c<d){
		s+=c;
	}else{
		s+=d;
	}
	printf("%d\n",s);
  	return 0;
}

Measured memory_bytes: 128