akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>
#include <stack>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using Graph = std::vector<std::vector<int> >;
const int INF = 1e17;
/* libraries */

int LIS(std::vector<int> a) {
	std::vector<int> dp(a.size()+1,INF);
	for(auto i:a) {
		auto lb = std::lower_bound(all(dp),i);
		if(*lb>i) *lb = i;
	}
	int len = 0;
	while(dp[len]!=INF) len++;
	return len;
}


signed main() {
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	rep(i,n) std::cin >> a[i];
	Graph g(n);
	rep(i,n-1) {
		int u,v;
		std::cin >> u >> v;
		u--;v--;
		g[u].emplace_back(v);
		g[v].emplace_back(u);
	}
	std::vector<int> ans(n,1);
	std::vector<std::multiset<int> > dp(n+1);
	auto dfs = [&] (auto f, int i, int par) -> void {
			int l=-1,r=n+1;
			while(r-l>1) {
				int o=(r+l)>>1;
				if(dp[o].empty() || *(dp[o].begin())>=a[i]) r=o;
				else l=o;
			}
			auto ins = dp[r].emplace(a[i]);
			int rr=r;
		{
			int l=-1,r=n+1;
			while(r-l>1) {
				int o=(r+l)>>1;
				if(dp[o].empty()) r=o;
				else l=o;
			}
			ans[i]=r;
		}
		for(auto to:g[i]) {
			if(to==par) continue;
			f(f,to,i);
		}
		dp[rr].erase(ins);
	};
	dfs(dfs,0,-1);
	rep(i,n) print(ans[i]);
	return 0;
}


Measured memory_bytes: 58368
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

#define MAX_N 100001
#define INF   1000000000
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
char c[MAX_N];

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

    ll N, K, R, S, P;
    string T;
    cin >> N >> K;
    cin >> R >> S >> P;
    cin >> T;
    
    //for(ll i = 0; i < N; i++) cin >> a[i];
    //fill(a, a + MAX_N, '');
    
    ll score = 0;
    
    for(ll i = 0; i < N; i++){
      if(T[i] == 'r')      {c[i] = 'p'; score += P;}
      else if(T[i] == 's') {c[i] = 'r'; score += R;}
      else if(T[i] == 'p') {c[i] = 's'; score += S;}
    }


    for(ll i = 0; i < N; i++){
      if(i - K >= 0) {
	if(c[i-K] == c[i]) {
	  if(c[i] == 'r')      {score -= R; c[i] = 'n';}
	  else if(c[i] == 's') {score -= S; c[i] = 'n';}
	  else if(c[i] == 'p') {score -= P; c[i] = 'n';}
	}
      }
    }
    
    cout << score << endl;
    
    return 0;
}
    


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

using namespace std;

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

  cout << vc.back() - vc.front() << "\n";
  
}


Measured memory_bytes: 384
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;

class select1{
	public:
		int i;
		int j;
		int k;
		long sum;
	select1(int i,int j,int k,long sum){
		this->i=i;
		this->j=j;
		this->k=k;
		this->sum=sum;
	}
};

bool operator< (const select1 &s1,const select1 &s2){
	return s1.sum<s2.sum;
};

bool operator> (const select1 &s1,const select1 &s2){
	return s1.sum>s2.sum;
};

bool operator== (const select1 &s1,const select1 &s2){
	return s1.i==s2.i && s1.j==s2.j && s1.k==s2.k;
}

int main(){
	long X,Y,Z;
	long K;
	cin>>X>>Y>>Z>>K;
	vector<long>A,B,C;
	long tmp;
	for(int i=0;i<X;++i){
		cin>>tmp;
		A.push_back(tmp);
	}
	for(int i=0;i<Y;++i){
		cin>>tmp;
		B.push_back(tmp);
	}
	for(int i=0;i<Z;++i){
		cin>>tmp;
		C.push_back(tmp);
	}
	sort(A.begin(),A.end(),greater<long>());
	sort(B.begin(),B.end(),greater<long>());
	sort(C.begin(),C.end(),greater<long>());
	select1 status(0,0,0,A[0]+B[0]+C[0]);
	priority_queue<select1>q;
	q.push(status);
	vector<select1>statusarr;
	vector<long>ans;
	while(true){
		status=q.top();
		//cout<<status.i<<" "<<status.j<<" "<<status.k<<endl;
		q.pop();
		int tmp=0;
		for(int i=0;i<statusarr.size();++i){
			if(statusarr[i]==status)tmp=1;
		}
		if(tmp==1)continue;
		statusarr.push_back(status);
		ans.push_back(status.sum);
		if(ans.size()==K)break;
		if(status.i<X-1){
			status.i++;
			status.sum+=-A[status.i-1]+A[status.i];
			q.push(status);
			status.i--;
			status.sum+=-A[status.i+1]+A[status.i];
		}
		if(status.j<Y-1){
			status.j++;
			status.sum+=-B[status.j-1]+B[status.j];
			q.push(status);
			status.j--;
			status.sum+=-B[status.j+1]+B[status.j];
		}
		if(status.k<Z-1){
			status.k++;
			status.sum+=-C[status.k-1]+C[status.k];
			q.push(status);
			status.k--;
			status.sum+=-C[status.k+1]+C[status.k];
		}
	}
	for(int i=0;i<ans.size();++i){
		cout<<ans[i]<<endl;
	}
}


Measured memory_bytes: 768
import math
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    xy = [tuple(map(int, input().split())) for _ in range(n)]
    checked = [[None for _ in range(n)] for _ in range(n)]
    sum_v = 0
    p = 1
    for i in range(n):
        p *= i + 1
        for j in range(n):
            if i == j or checked[i][j] is not None:
                continue
            checked[i][j] = 1
            checked[j][i] = 1
            sum_v += math.sqrt((xy[i][0] - xy[j][0]) ** 2 + (xy[i][1] - xy[j][1]) ** 2)
    print(sum_v * 2 / n)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;

int main(){
   int n,k,q;
   cin>>n>>k>>q;

   vector<int> a(n,k);

   rep(i,q){
      int b;
      cin>>b;
      a[b-1]++;
   }
   rep(i,n){
      a[i]-=q;

      (a[i]>0)? cout<<"Yes"<<endl:cout<<"No"<<endl;
   }
   


return 0;
}



Measured memory_bytes: 1024
#include<stdio.h>

int main(void){
  int flag,i,n,a[100],count=0,temp,j;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&a[i]);
  flag=1;
  j=0;
  while(flag){
    flag=0;
    for(i=n-1;i>=j+1;i--){
      if(a[i]<a[i-1]){
	temp=a[i];
	a[i]=a[i-1];
	a[i-1]=temp;
	count++;
	flag=1;
      }
    }
    j++;
  }
  for(i=0;i<n;i++){
    if(i==n-1) printf("%d\n",a[i]);
    else printf("%d ",a[i]);
  }
  printf("%d\n",count);
  return  0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int xv[]={1,0,-1,0},yv[]={0,-1,0,1};
    int r,c,x,y,b=0;
    char in;
    cin>>r>>c;
    vector<vector<int>> tl(r+2,vector<int>(c+2,-1));
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            cin>>in;
            if(in=='.')tl[i+1][j+1]=9999999;
            else b++;
        }
    }
    queue<pair<int,int>> q;
    if(tl[1][1]==9999999){
        q.push(make_pair(1,1));
        tl[1][1]=1;
    }
    while(!q.empty()){
        y=q.front().first;
        x=q.front().second;
        q.pop();
        for(int i=0;i<4;i++){
            if(tl[y+yv[i]][x+xv[i]]!=-1&&tl[y][x]+1<tl[y+yv[i]][x+xv[i]]){
                tl[y+yv[i]][x+xv[i]]=tl[y][x]+1;
                q.push(make_pair(y+yv[i],x+xv[i]));
            }
        }
    }
    if(tl[r][c]==9999999)cout<<-1<<endl;
    else{
        cout<<r*c-tl[r][c]-b<<endl;;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string a,b;
  cin>>a;
  cin>>b;
  int ans =0;
  if(a[0]==b[0]){
    ans++;
  }
  if(a[1]==b[1]){
    ans++;
  }
  if(a[2]==b[2]){
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}

  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define randome_generate srand(std::chrono::high_resolution_clock::now().time_since_epoch().count())
using namespace std;
int n;
int a[200100];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	int sch=1;
	for(int i=1;i<=n;i++){
		if(a[i]==sch){
			sch++;
		}
	}
	sch--;
	if(sch){
		cout<<n-sch<<endl;
	}
	else{
		cout<<-1<<endl;
	}
	return 0;
}


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

using namespace std;

#define all(v) (v).begin(), (v).end()

using li = long long;
using ld = long double;

void solve(bool);

int main() {
#ifdef YA
    auto s = clock();
    assert(freopen("input.txt", "r", stdin));
    // assert(freopen("output.txt", "w", stdout));
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif

    cout << fixed << setprecision(20);

    solve(true);
    
#ifdef YA1
    while (true) solve(false);
#endif

#ifdef YA
    cout << endl << endl << "time = " << (clock() - s) / (double)CLOCKS_PER_SEC << endl;
#endif

    return 0;
}

const int maxn = 4e5 + 555;

li n, k;
int a[maxn], pos[maxn], nxt[maxn];
li len[maxn];
bool used[maxn];

void solve(bool __attribute__((unused)) read) {
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = n; i < 2 * n; ++i) {
        a[i] = a[i - n]; 
    }
    memset(pos, -1, sizeof pos);
    for (int i = 2 * n - 1; i >= 0; --i) {
        nxt[i] = pos[a[i]];
        if (nxt[i] != -1) {
            len[i] = nxt[i] - i + 1;
            nxt[i] = (nxt[i] + 1) % n;
        }
        pos[a[i]] = i;
    }
    memset(used, 0, sizeof used);
    vector <int> g = {0};
    vector <li> pref = {0};
    int v = 0;
    while (!used[v]) {
        used[v] = 1;
        pref.push_back(pref.back() + len[v]);
        v = nxt[v];
        g.push_back(v);
    }
    int pos0 = -1;
    for (int i = 0; i < (int)g.size(); ++i) {
        if (g[i] == v) {
            pos0 = i;
            break;
        }
    }
    assert(pos0 != -1);
    li L = n * k;
    li l = 0;
    int x = -1;
    if (pref[pos0] > L) {
        for (int i = 0; i < (int)g.size(); ++i) {
            if (pref[i] > L) {
                l = pref[i - 1];
                x = g[i - 1];
                break;
            }
        }
    } else {
        l = pref[pos0];
        li c = (L - l) / (pref.back() - pref[pos0]);
        l += c * (pref.back() - pref[pos0]);
        for (int i = pos0; i < (int)g.size(); ++i) {
            if (pref[i] - pref[pos0] + l > L) {
                l += pref[i - 1] - pref[pos0];
                x = g[i - 1];
                break;
            }
        }
    }
    assert(x != -1);
    memset(used, 0, sizeof used);
    vector <int> s;
    while (l < L) {
        ++l;
        if (used[a[x]]) {
            while (used[a[x]]) {
                used[s.back()] = 0;
                s.pop_back();
            }
        } else {
            used[a[x]] = 1;
            s.push_back(a[x]);
        }
        x = (x + 1) % n;
    }

    for (int x : s) {
        cout << x << " ";
    }
    cout << "\n";
}


Measured memory_bytes: 13808
n, k = map(int, input().split())
x = list(map(int, input().split()))
ans = 10 ** 16
for i in range(n-k+1):
    if x[i] * x[i+k-1] < 0:
        dis = min(abs(x[i]), abs(x[i+k-1])) * 2 + max(abs(x[i]), abs(x[i+k-1]))
    else:
        dis = max(abs(x[i]), abs(x[i+k-1]))
    ans = min(ans, dis)
print(ans)

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

int main()
{
  string word , sen;
  int count = 0;
  
  cin >> word;
  
  while( cin >> sen )
    {
  for( int i = 0; i < sen.size(); i++ )
    {
 
      if( isupper(sen[i]) )
         sen[i] = tolower(sen[i]); 
    }
      if( sen == "END_OF_TEXT" ) break;
      else if( sen == word ) count++;
    }
  cout << count << "\n";
  
  return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_multiset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
//find_by_order(k) - k is the kth element of the multiset
//order_of_key(k) - Number of elements striclty samller than k
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll a[n],b[n];
    multiset< pair<ll,ll> > mst;
    for(int i=0;i<n;i++)
    {
        cin>>a[i]>>b[i];
        mst.insert(mp(b[i],a[i]));
    }
    ll sum=0;
    multiset< pair<ll,ll> >::iterator itr;
    for(itr=mst.begin();itr!=mst.end();++itr)
    {
        if(sum+itr->second<=itr->first)
        {
            sum+=itr->second;
            continue;
        }
        else
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 15872
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define REV(i, a) for (int i = (a); i >= 0; --i)
#define CLR(a) memset((a), 0, sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (3e15)

using namespace std;

int N, T;
int t[200005];

signed main() {
    cin >> N >> T;
    REP(i, N) cin >> t[i];

    int ans = 0;
    FOR(i, 0, N - 1) { ans += min(T, t[i + 1] - t[i]); }
    ans += T;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
import sys

def solve(n, l, ls_s):
    sl = sorted(ls_s)
    s = ''
    for i in sl:
        s += i
    print(s)


def readQuestion():
    ws = sys.stdin.readline().strip().split()
    n = int(ws[0])
    l = int(ws[1])
    ls_s = [sys.stdin.readline().strip().split()[0] for j in range(n)]
    return (n, l, ls_s,)

def main():
    solve(*readQuestion())

main()

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

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

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

const int MAX = 1e6 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

map<int, int> prime_factor(int n) {
    map<int, int> res;
    for (int i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            ++res[i];
            n /= i;
        }
    }
    if (n != 1) res[n] = 1;
    return res;
}

ll mod_pow(ll x, ll y) {
    ll res = 1;
    while (y > 0) {
        if (y & 1) res = res * x % MOD;
        x = x * x % MOD;
        y >>= 1;
    }
    return res;
}

ll inv[MAX];

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

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

    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    }

    map<int, int> mp;
    for (auto &a : A) {
        for (auto &p : prime_factor(a)) {
            mp[p.first] = max(mp[p.first], p.second);
        }
    }

    ll lcm = 1;
    for (auto p : mp) {
        lcm *= mod_pow(p.first, p.second);
        lcm %= MOD;
    }

    ll ans = 0;
    for (auto &a : A) {
        ans += lcm * inv[a];
        ans %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 8576
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int a, b;
  cin >> a >> b;
  if (a < b) {
    rep(i,b) cout << a;
  }
  else {
    rep(i,a) cout << b;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3192
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    StringBuilder ans = new StringBuilder();;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        String s = sc.next();
        if ("snuke".equals(s)) {
          ans.append((char)('A'+j)).append(i+1); 
        }
      }
    }
    System.out.println(ans.toString());
  }
}

Measured memory_bytes: 22228
#include <iostream>
#include <algorithm>
#include <stack>
#include <cstdio>
using namespace std;
// int a[10];
// bool ans;
// void dfs(int i,int r,int l){
// 	if(i==10)ans=1;
// 	if(ans)return;
// 	if(a[i]<r&&a[i]<l)return;
// 	if(r<a[i])dfs(i+1,a[i],l);
// 	if(l<a[i])dfs(i+1,r,a[i]);

// }
// int main(){
// 	int t;
// 	cin>>t;
// 	while(t--){
// 		ans=0;
// 		for(int i=0;i<10;i++)cin>>a[i];
// 		dfs(0,0,0);
// 		if(ans)cout<<"YES"<<endl;
// 		else cout<<"NO"<<endl;
// 	}
// }

int main(){
	for(int i=1;i<=9;i++)
		for(int j=1;j<=9;j++)printf("%dx%d=%d\n",i,j,i*j);
	return 0;
}

Measured memory_bytes: 1096
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>  //for bool
#include <stdlib.h> // abs,labs,llabs
#include <limits.h>
#include <ctype.h>

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld; //%Lf

int main(void) {
  int n;
  scanf("%d", &n);
  printf("%d\n", (n * n * n));
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
using namespace std;

int main()
{
    const int N = 999999;

    vector<int> num1(N+1, -1);
    vector<int> num2(N+1, -1);
    num1[0] = 0;
    num2[0] = 0;
    for(int i=1; ; ++i){
        int tmp = i*(i+1)*(i+2)/6;
        if(tmp > N)
            break;
        for(int j=0; j+tmp<=N; ++j){
            if(num1[j] >= 0 && (num1[j+tmp] == -1 || num1[j]+1 < num1[j+tmp])){
                num1[j+tmp] = num1[j]+1;
            }
        }
        if(tmp % 2 == 1){
            for(int j=0; j+tmp<=N; ++j){
                if(num2[j] >= 0 && (num2[j+tmp] == -1 || num2[j]+1 < num2[j+tmp])){
                    num2[j+tmp] = num2[j]+1;
                }
            }
        }
    }

    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            break;
        cout << num1[n] << ' ' << num2[n] << endl;
    }

    return 0;
}

Measured memory_bytes: 8596
// ABC096_B
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    
    // calculation
    cout << A+B+C + max({A, B, C})*((ll)pow(2, K)) - max({A, B, C}) << "\n";
    
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int mod = 1e9 + 7;
const int N = 2e5 + 5;
int a[N];
void solve(){
    int n;
    cin >> n;
    for (int i = 1; i < n; ++i) {
        int x;
        cin >> x;
        a[x]++;
    }
    for (int i = 1; i <= n; ++i) cout << a[i] << '\n';
}
int main(){
    speed;
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; ++i) {
        solve();
    }
}

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

using ll = long long;

const int MAXN = 3e5;
int N; ll C;
ll X[MAXN], V[MAXN];

ll cw[MAXN], ccw[MAXN];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N >> C;
	for (int i = 0; i < N; i++) {
		cin >> X[i] >> V[i];
	}

	ll ans = 0;
	for (int z = 0; z < 2; z++) {
		assert(is_sorted(X, X + N));

		cw[0] = 0;
		ll s = 0;
		for (int i = 0; i < N; i++) {
			s += V[i];
			cw[i+1] = max(cw[i], s - 2 * X[i]);
		}

		s = 0;
		ccw[0] = 0;
		for (int i = N-1; i >= 0; i--) {
			s += V[i];
			ccw[N-i] = max(ccw[N-i-1], s - (C - X[i]));
		}

		for (int i = 0; i <= N; i++) {
			ans = max(ans, cw[i] + ccw[N-i]);
		}

		for (int i = 0; i < N; i++) {
			X[i] = C - X[i];
		}
		reverse(X, X + N);
		reverse(V, V + N);
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 7168
#include<bits/stdc++.h>
 
using namespace std;
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<long long , long long>
#define pb push_back
#define ll long long
#define ld long double
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define fill(a,b) memset((a),(b),sizeof((a)))
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
ll power(ll x,ll y,ll m){ll r=1;for(;y;y>>=1){if(y&1)r=r*x%m;x=x*x%m;}return r;}
const ll mod = 1e9 + 7;
const ld pi = 3.14159265358979;
 
int run_test(){
      ll n;
      cin >> n;
      map<ll, ll> mp;
      ll sum = 0;
      for(int i=0; i<n; i++){
            ll a;
            cin >> a;
            sum += a;
            mp[a]++;
      }
      ll q;
      cin >> q;
      for(ll i=0; i<q; i++){
            ll b, c;
            cin >> b >> c;
            sum -= b * mp[b];
            sum += c * mp[b];
            cout << sum << "\n";
            mp[c] += mp[b];
            mp[b] = 0;
      }
      return 0;
}
 
int main(){
    FAST;
    ll t;
    t = 1;
 
    while(t--){
        run_test();
    }
}

Measured memory_bytes: 9388
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/
const int MAXN = 220000;

int p[MAXN];
int ps[MAXN];
int n;

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> p[i];
		--p[i];
		ps[p[i]] = i;
	}
	int ans = n;
	int now = 0;
	for (int i = 0; i < n; ++i) {
		now = max(now, i + 1);
		while (now < n && ps[now] > ps[now - 1])
			++now;
		ans = min(ans, n - (now - i));
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 2428
#include <stdio.h>

int main() {
  int i, j, n, max;
  int number[1000000] = {0};

  number[0] = 1;
  number[1] = 1;
  for(i = 2; i < 1000000; i++) {
    if(number[i] == 1) continue;;
    for(j = i+i; j < 1000000; j += i) {
      number[j] = 1;
    }
  }
  
  while ( scanf("%d", &n) != EOF) {
    max = 0;

    for(i = 2; i < n; i++) {
      if(number[i] == 0) {
	if(max < i) max = i;
      }
    }
    printf("%d ", max);
    i++;
    while(1) {
      if(number[i] == 0) {
	printf("%d\n", i);
	break;
      }
      i++;
    }
  }
  
  return 0;
}

Measured memory_bytes: 4508
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y, ll z){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2,z);
        if(y%2==0)
         return (p*p)%z;
        else
        return (x*((p*p)%z))%z;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
ll po(ll x)
{
    ll c=0;
    while(x>0)
    {
        x=x&(x-1);
        c++;
    }
    return c;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    ll n;
    cin>>n;
    ll a[n],s=0,c=0,ans=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        s=s+a[i];
        s=s%hell;
    }
    c=s;
    for(int i=0;i<n-1;i++)
    {
        ans=(ans+a[i]*(c-a[i]+hell))%hell;
        c=(c-a[i]+hell)%hell;
        
    }
    cout<<ans;}

Measured memory_bytes: 5168
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

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


    int n;
    cin>>n;
    int c[n];
    vector<vector<int>> v(200005);
    for(int i=0;i<n;i++){
        cin>>c[i];
        v[c[i]].push_back(i);
    }
    ll mod=1e9+7;
    ll ans=0;
    vector<pair<int,int>> p;
    for(int i=0;i<200005;i++){
        if(v[i].size()>1){
            int a=v[i][0];
            for(int j=1;j<v[i].size();j++){
                int b=v[i][j];
                if(a+1!=b) p.push_back(make_pair(b,a));
                a=b;
            }
        }
    }
    sort(p.begin(),p.end());
    ll dp[n+1]={};
    dp[0]=1;
    int r=0;
    for(int i=0;i<n;i++){
        dp[i+1]+=dp[i];
        dp[i+1]%=mod;
        if(r<p.size() && i==p[r].first){
            dp[i+1]+=dp[p[r].second+1];
            dp[i+1]%=mod;
            r++;
        }
    }
    cout<<dp[n]<<endl;    
    
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;


int main(){
    
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    
    vector<int> ans(n);
    rep(i,n){
        ans[a[i]-1] = i+1;
        
        
    }
    
    rep(i,n){
        cout << ans[i] << endl;
        
    }
    
    
    
    
}


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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

int main(int argc, char **argv)
{
	ll N; cin >> N;
	vector<ll> A(N); REP(i, N) cin >> A[i];
	sort(ALL(A));

	vector<pair<ll, ll>> res;
	vector<ll> plus, minus;
	for (auto &e : A)
	{
		if (e < 0) minus.push_back(e);
		else if (e > 0) plus.push_back(e);
		else
		{
			if (A.front() >= 0)
			{
				minus.push_back(0);
			}
			else
			{
				plus.push_back(0);
			}
		}
	}

	sort(ALL(minus)); // -3, -2, -1
	sort(ALL(plus), greater<ll>()); // 3, 2, 1

	if (plus.empty())
	{
		ll m1 = minus.back();
		minus.pop_back();
		ll m2 = minus.back();
		minus.pop_back();

		res.emplace_back(pair<ll, ll>(m2, m1));
		plus.push_back(m2 - m1);
	}
	else if (minus.empty())
	{
		ll p1 = plus.back();
		plus.pop_back();
		ll p2 = plus.back();
		plus.pop_back();

		res.emplace_back(pair<ll, ll>(p1, p2));
		minus.push_back(p1 - p2);
	}

	while (plus.size() != 1)
	{
		ll p = plus.back();
		plus.pop_back();
		ll m = minus.back();
		minus.pop_back();

		res.emplace_back(pair<ll, ll>(m, p));
		minus.push_back(m-p);
	}

	ll resM{-INF};
	while (!minus.empty())
	{
		ll m = minus.back();
		ll p = plus.back();
		minus.pop_back();
		plus.pop_back();

		res.emplace_back(pair<ll, ll>(p, m));
		resM = max(resM, p-m);
		plus.push_back(p-m);
	}

	std::cout << resM<< std::endl;
	for (auto &e : res)
	{
		std::cout << e.first << " " << e.second << std::endl;
	}
}


Measured memory_bytes: 5872
#include<iostream>
using namespace std;
int main()
{
int n;
cin >> n;
int a[n+1];
for(int i=1;i<=n;i++)
cin >> a[i];
int cnt=0;
for(int i=1;i<=n;i++){
if(i%2==1  &&  a[i]%2==1)
cnt++;
}
cout << cnt << endl;
return 0;
}

Measured memory_bytes: 3632
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //b
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      ans += a[i] * a[j];
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	long long n,k;
	cin >> n;
	vector<long long>d(n);
	for (long long i = 0; i < n; i++) {
		cin >> d[i];
	}
	sort(d.begin(), d.end());
	k = d[n / 2] - d[n / 2 - 1];
	cout << k << endl;
} 

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
    int x, y, z;
    while(1){
        cin >> x >> y;
        if(x == 0 && y == 0) break;
        if(x>y){
            z = x;
            x = y;
            y = z;
        }
        cout << x << " " << y << endl;
    }
    return 0;
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<ll> A(X), B(Y), C(Z);
    REP(i, X) cin >> A[i];
    REP(i, Y) cin >> B[i];
    REP(i, Z) cin >> C[i];
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    vector<ll> sumBC;
    REP(i, Y) REP(j, Z) sumBC.push_back(B[i] + C[j]);
    sort(sumBC.rbegin(), sumBC.rend());
    vector<int> maxSumIndex(X, 0);
    REP(i, K)
    {
        ll sumMax = -1;
        int argMaxIndex;
        REP(j, X)
        {
            if (maxSumIndex[j] < Y * Z)
            {
                if (A[j] + sumBC[maxSumIndex[j]] > sumMax)
                {
                    sumMax = A[j] + sumBC[maxSumIndex[j]];
                    argMaxIndex = j;
                }  
            }
        }
        cout << sumMax << endl;
        maxSumIndex[argMaxIndex]++;
    }
}


Measured memory_bytes: 10608
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<string> a(n), b(m);
    FOR(i, 0, n)
        cin >> a[i];
    FOR(i, 0, m)
        cin >> b[i];

    bool flag = false;
    FOR(y, 0, n) {
        FOR(x, 0, n) {
            int cnt = 0;
            FOR(i, 0, m) {
                FOR(j, 0, m) {
                    int ti = y + i, tj = x + j;
                    if (ti < 0 || ti >= n || tj < 0 || tj >= n || a[ti][tj] != b[i][j])
                        break;
                    cnt++;

                }
            }
            if (cnt == m*m) {
                flag = true;
                break;
            }
        }
        if (flag)
            break;
    }

    cout << (flag ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<numeric>
#include<algorithm>
#include <sstream>
#include<cstring>
#include<cmath>
#include<iterator>
#include<utility>
#include<array>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<forward_list>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define pa(a) cout<<a<<endl;
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;

int main()
{
#ifdef RAHUL
    freopen("input.txt","r",stdin);
#endif
ll a,b;
cin>>a>>b;

int first=a+b;
int second=a-b;
int third=a*b;

int max2=max(first,second);
int max1=max(max2,third);

cout<<max1<<endl;

}




Measured memory_bytes: 256
using System;
using System.Collections.Generic;
 
namespace Sample
{
  class Sample1
  {
    static void Main()
    {
		string[] line = Console.ReadLine().Trim().Split(' ');
      if(line[0] == line[1]){
      Console.WriteLine("Yes");
      }else{
      Console.WriteLine("No");
      }
            
		}
	}
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  int sum=0;
  
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='o'){
      sum++;
    }
  }
  cout<<700+100*sum<<endl;
}

    

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int x , n;
  scanf("%d %d",&x ,&n);

  int p[200] = {0} , a;
  for(int i = 0;i < n;i ++){
    scanf("%d",&a);
    p[a] ++;
  }

  int ans;
  for(int i = 0;i <= 101;i ++){
    if(x-i >= -101){
      if(x-i == -1){
        ans = -1;
        i += 1000;
      }
      else if(p[x-i] == 0){
        ans = x-i;
        i += 1000;
      }
      if(i <= 101){
      if(p[x+i] == 0){
        ans = x+i;
        i += 1000;
      }
      }
    }
  }

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

  return 0;
}

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

using ll = long long;

int main() {
    int Q;
    cin >> Q;
    while(Q--) {
        string s;
        cin >> s;
        int n = 0;
        for(int i=0; i<8; ++i) {
            n <<= 4;
            if(isdigit(s[i])) {
                n += s[i] - '0';
            } else {
                n += s[i] - 'a' + 10;
            }
        }
        double res = 0;
        double d = 1;
        {
            int t = n & ((1LL << 31) - 1);
            res += (t >> 7);
        }
        int cnt = 1;
        for(int i=6; i>=0; --i) {
            d /= 2;
            if(n & (1 << i)) {
                res += d;
                cnt = 6 - i + 1;
            }
        }
        cout << fixed << setprecision(cnt);
        if(n & (1 << 31)) {
            cout << -res << endl;
        } else {
            cout << res << endl;
        }
    }
}

Measured memory_bytes: 3260
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int N;
string S;


void input()
{
    cin>>N;
    cin>>S;
}


void solve()
{

    input();
    int half=N/2;

    if(N%2==0 && S.substr(0,half)==S.substr(half,half))
    {

       cout<<"Yes";

    }
    else{

        cout<<"No";

    }
}

int main()
{

    solve();


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include<string.h>
int main(void){
while(1){
    char a[1001];
    scanf("%s",a);
    if(a[0]=='0')
    break;
    
    int i=0,j;
    for(j=0;j<strlen(a);j++){
        i+=(int)a[j];
        i-=48;
    }
    printf("%d\n",i);
}


    return 0;
}

Measured memory_bytes: 2676
#include<bits/stdc++.h>
#define ll long long
#define sr(v) sort(v.begin(),v.end())
using namespace std;


int main(){
    ll n,a,ans = 0,value;
    vector <ll> v;

        cin>> n >> a;
            while(n--){
                cin>>value;
                v.push_back(value);
            }
            sort(v.begin(),v.end());
            n = v.size();
            for(int i=0;i<n-a;i++){
                ans += v[i];
            }
                cout<< ans <<endl;


    return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int V = 1e5;

int dp[105][V + 5];

signed main() {
	int n, m; cin >> n >> m;
	vector<int> w(n + 1), v(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> w[i] >> v[i];
	}
	memset(dp, 0x3f, sizeof(dp));
	for (int i = 0; i <= n; i++) dp[i][0] = 0;
	for (int i = 1; i <= n; i++)
	for (int j = 1; j <= V; j++) {
		if (j < v[i]) dp[i][j] = dp[i - 1][j];
		else dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v[i]] + w[i]);
	}
	int i = V; while (dp[n][i] > m) i--;
	cout << i << '\n';
}

Measured memory_bytes: 82304
import sys
input = sys.stdin.readline

import bisect
left = bisect.bisect_left
right = bisect.bisect_right 

n, q = list(map(int, input().split()))
s = input()
lr = [list(map(int, input().split())) for i in range(q)]
a = [i for i in range(n-1) if s[i:i+2]=="AC"]

for i in range(q):
  left_index = left(a, lr[i][0]-1)      
  right_index = right(a, lr[i][1]-2)  
  print(right_index - left_index)



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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



string s,t;
void solve(){
	cin >> s >> t;
	int n = s.size();
	s += s;
	for(int i = 0; i < n*2; i++){
		if(s.substr(i,n) == t){
			cout << "Yes" << endl;
			return;
		}
	}
	cout << "No" << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 256
from math import *
S = input()
ans = [0] * len(S)
cur_r = True
l, s = 0, 0
for i in range(len(S)):
    if(cur_r):
        if S[i] == 'R': l += 1
        else:
            ans[i - 1] += ceil(l / 2)
            ans[i] += floor(l / 2)
            l, s = 1, i
            cur_r = False
    else:
        if(S[i] == 'L'): l += 1
        else:
            ans[s] += ceil(l / 2)
            ans[s - 1] += floor(l / 2)
            l, s = 1, i
            cur_r = True
ans[s] += ceil(l / 2)
ans[s - 1] += floor(l / 2)
print(' '.join(str(n) for n in ans))


Measured memory_bytes: 10508
import java.util.Scanner

object Main {
  def main (args: Array[String]) = {
    val in = new Scanner(System.in)
    val W = in.nextInt
    val H = in.nextInt
    val x = in.nextInt
    val y = in.nextInt
    val r = in.nextInt

    val wIn = (0 <= (x - r)) && (W >= (x + r))
    val hIn = (0 <= (y - r)) && (H >= (y + r))
    val result = if(wIn && hIn) "Yes" else "No"

    println(result)

  }
}

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

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

  int tmp;
  if(a > b){
    swap(a,b);
  }
  if(b > c){
    swap(b,c);
  }
  if(a > b){
    swap(a,b);
  }

  cout << a << ' ' << b << ' ' << c << endl;

  return 0;
}

void swap(int &a, int &b){
  int tmp;
  tmp = a;
  a = b;
  b = tmp;
}

Measured memory_bytes: 3080
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    l,r=pin()
    L=l%2019
    R=r%2019
    #print(L,R)
    if r-l>=2019:R+=2019


    t=20192019
    for i in range(L,R):
        for j in range(i+1,R+1):
            t=min(t,(i*j)%2019)
    print(t)
#%%submit!
resolve()

Measured memory_bytes: 38896
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    std::vector<int> B(N-1);
    for(int i=0;i<N-1;i++){
        cin>>B[i];
    }
    long long sum=0;
    sum+=B[0];
    for(int i=1;i<N-1;i++){
        sum+=min(B[i],B[i-1]);
    }
    if(N-1!=0){
        sum+=B[N-2];
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

const INF int = 10000000

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

type Point struct {
	pos int
	d   bool
}

func add(m map[int][]Point, ind int, pos int, d bool) {
	list, ok := m[ind]
	if !ok {
		list = make([]Point, 0)
	}
	m[ind] = append(list, Point{pos, d})
}

type SortArray struct {
	orig []Point
}

func (sa *SortArray) Len() int {
	return len(sa.orig)
}

func (sa *SortArray) Less(i, j int) bool {
	return sa.orig[i].pos < sa.orig[j].pos
}

func (sa *SortArray) Swap(i, j int) {
	sa.orig[i], sa.orig[j] = sa.orig[j], sa.orig[i]
}

func solve(list []Point) int {
	sa := SortArray{list}
	sort.Sort(&sa)

	pos_max := -INF
	min_t := INF
	var t int
	for _, p := range sa.orig {
		if p.d {
			pos_max = p.pos
		} else {
			if pos_max > -INF {
				t = p.pos - pos_max
				if t < min_t {
					min_t = t
				}
			}
		}
	}
	return min_t
}

func find(m map[int][]Point) int {
	min_t := INF
	var t int
	for _, list := range m {
		t = solve(list)
		if t < min_t {
			min_t = t
		}
	}
	return min_t
}

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	N := nextInt()

	dl := make(map[int][]Point)
	ur := make(map[int][]Point)
	ul := make(map[int][]Point)
	dr := make(map[int][]Point)
	ud := make(map[int][]Point)
	lr := make(map[int][]Point)

	var X, Y int
	var d string
	for i := 0; i < N; i++ {
		X, Y = nextInt(), nextInt()
		d = next()
		if d == "U" {
			add(ur, X+Y, X*2, false)
			add(ul, X-Y, X*2, true)
			add(ud, X, Y, true)
		} else if d == "D" {
			add(dr, X-Y, X*2, false)
			add(dl, X+Y, X*2, true)
			add(ud, X, Y, false)
		} else if d == "R" {
			add(ur, X+Y, X*2, true)
			add(dr, X-Y, X*2, true)
			add(lr, Y, X, true)
		} else if d == "L" {
			add(ul, X-Y, X*2, false)
			add(dl, X+Y, X*2, false)
			add(lr, Y, X, false)
		}
	}

	min_t := INF
	ts := make([]int, 6)
	ts[0] = find(dl)
	ts[1] = find(ur)
	ts[2] = find(ul)
	ts[3] = find(dr)
	ts[4] = find(ud)
	ts[5] = find(lr)

	for _, t := range ts {
		if t < min_t {
			min_t = t
		}
	}

	if min_t == INF {
		fmt.Fprintln(out, "SAFE")
	} else {
		fmt.Fprintln(out, min_t*5)
	}
}


Measured memory_bytes: 80928
H, W = map(int, input().split())

def f():
    if H % 3 == 0:
        return 0
    else:
        r = W
    
    for i in range(1, H):
        s1 = i * W
        if W % 2 == 0:
            s2 = s3 = (H - i) * (W // 2)
        else:
            s2 = (H - i) * (W // 2)
            s3 = (H - i) * (W - W // 2)
        r = min(r, max(s1, s2, s3) - min(s1, s2, s3))
    
    return r

res = f()
H, W = W, H
res = min(res, f())
print(res)


Measured memory_bytes: 9120
# D - We Like AGC

import itertools, copy

N = int(input())
MOD = 10**9+7

if N == 3:
    print(4**3-3)
    exit()

# AGCそれ自体を含むか、1箇所入れ替えてAGCができてしまうような4文字
out_letters_4 = set()
for x in ["A", "C", "G", "T"]:
    out_letters_4.add("A" + x + "GC")
    out_letters_4.add("AG" + x + "C")
    for y in ["AGC", "GAC", "ACG"]:
        out_letters_4.add(x + y)
        out_letters_4.add(y + x)

# 全4文字辞書
tmp = list(itertools.product(["A", "C", "G", "T"], repeat = 4))
all_letters_4 = set()
for x in tmp:
    tmp2 = ""
    for y in x:
        tmp2 += y
    all_letters_4.add(tmp2)

possible_letters_4 = all_letters_4 - out_letters_4

# 文字を末尾に追加する前の末尾の4文字(key)、文字追加後の末尾の4文字(value)の辞書
trans_letters_4_dict = dict.fromkeys(possible_letters_4, -1)
for key in trans_letters_4_dict.keys():
    for x in ["A", "C", "G", "T"]:
        tmp = (key + x)[1:]
        if tmp in trans_letters_4_dict.keys():
            if trans_letters_4_dict[key] == -1:
                trans_letters_4_dict[key] = [tmp]
            else:
                trans_letters_4_dict[key].append(tmp)

n_pattern = dict.fromkeys(possible_letters_4, 1)

for _ in range(N-4):
    next_n_pattern = dict.fromkeys(possible_letters_4, 0)
    for former_key in possible_letters_4:
        for to_key in trans_letters_4_dict[former_key]:
            next_n_pattern[to_key] += n_pattern[former_key]
    n_pattern = copy.deepcopy(next_n_pattern)

print(sum(n_pattern.values()) % MOD)

Measured memory_bytes: 3696
#include <cstdio>
#include <string>
#include <iostream>
#include <cstring>
#include <map>
#define LL long long
using namespace std;
int arr[100005][26];
int n;

int main() {
    scanf("%d",&n);
    char str[20];
    memset(arr, 0, sizeof(arr));
    map<string, int> m;
    for (int i = 0; i < n; i++) {
        scanf("%s",str);
        for (int j = 0; j < 10; j++) {
            arr[i][str[j]-'a']++;
        }
        string s = "";
        for (int j = 0; j < 26; j++) {
            char c = arr[i][j] + '0';
            s = s + c;
            //s.append(arr[i][j]+'0');
        }
        //cout<<s<<endl;
        m[s]++;
    }
    long long ans = 0;
    for (map<string,int>::iterator it = m.begin(); it != m.end(); it++) {
        long long a = it->second;
        ans += a*(a-1)/2;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 22912
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Contest.D
{
	class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			Scanner cin = new Scanner();
			int n = cin.nextInt();
			int k = cin.nextInt();
			string s = cin.next();
			int d = 0;
			for (int i = 0; i < n-1; i++)
			{
				if (s[i] != s[i + 1]) d++;
			}
			int now = n - d - 1;
			int ans = now + Math.Min(d, 2 * k);
			Console.WriteLine(ans);

			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return next();
			i = 0;
			return s[i++];
		}

		public int nextInt()
		{
			return int.Parse(next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextInt() + add;
			}
			return Array;
		}

		public long nextLong()
		{
			return long.Parse(next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextLong() + add;
			}
			return Array;
		}

		public double nextDouble()
		{
			return double.Parse(next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextDouble() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 27928
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<pair<int, int>> a(N);
	for (int i = 0; i < N; ++ i) cin >> a[i].first >> a[i].second;
	set<pair<int, int>> b(a.begin(), a.end());
	int r = N;
	for (int i = 0; i < N; ++ i) for (int j = 0; j < N; ++ j) if (i != j) {
		int p = a[i].first - a[j].first;
		int q = a[i].second - a[j].second;
		int rr = 0;
		for (auto x : a) {
			if (!b.count({x.first - p, x.second - q})) ++ rr;
		}
		r = min(r, rr);
	}
	cout << r << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <iostream>
#include <math.h>
#include <map>
#include <set>
using namespace std;
int main ()
{
	char s[101],t[101];
	scanf("%s%s",&s,&t);
	int a,b;
	scanf("%i%i",&a,&b);
	char u[101];
	scanf("%s",&u);
	int sb=0;
	for(int i=0;i<=strlen(s);i++)
	{
		if(u[i]!=s[i])
		{
			sb=1;
			break;
		}
	}
	if(sb==1)
	{
		b--;
	}
	else	a--;
	printf("%i %i",a,b);
	return 0;
}


Measured memory_bytes: 256