akhauriyash/Code-Regression huggingface dataset:
//
// author  : Abhishek
//
#include <bits/stdc++.h>

#define ll long long
#define db double
#define deb(x) cout<<#x<<": "<<x<<"\n"
#define all(x) x.begin(),x.end()
#define fo(i, n) for(i=0 ; i<n ; i++)
#define Fo(i, k, n) for(i=k ; i<n ; i++)

using namespace std;

const ll mod = 1000000007;
const ll N = 300005;  // array size
const ll inf = 10000000000000000;


void print(vector<ll> v) {
    ll i;
    fo(i, v.size())cout << v[i] << " ";
    cout << "\n";
}

vector<ll> read(ll n) {
    ll i;
    vector<ll> arr(n, 0);
    fo(i, n)cin >> arr[i];
    return arr;
}

vector<ll> read(ll n, ll k) {
    ll i;
    vector<ll> arr(n + k, 0);
    Fo(i, k, n + k)cin >> arr[i];
    return arr;
}

bool isEven(ll n) {
    return n % 2 == 0;
}

bool isOdd(ll n) {
    return n % 2 != 0;
}


void solve() {
    ll t;
    cin >> (t);
    while (t--) {

        ll i, j, k, n, m, p, q, x, y, a, b, l, r;


    }
}

int main() {

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

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll i, j, k, n, m, p, q, x, y, a, b, l, r;

    cin >> x >> y >> a;
    if (a + x + y >= 22) {
        cout << "bust\n";
    } else
        cout << "win";


    return 0;
}




Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
//#define ls (rt<<1)
//#define rs (rt<<1|1)
#define vi vector<int>
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a),i##end=(b);i<=i##end;i++)
#define fi first
#define se second
typedef long long ll;
const int maxn=205;
using namespace std;
ll a[maxn];
struct basis{
	ll a[64];
	void reset(){memset(a,0,sizeof(a));}
	void insert(ll x){
		for(int i=63;i>=0;i--){
			if(x&(1ll<<i)){
				if(!a[i]){
					a[i]=x;break;
				}
				x^=a[i];
			}
		}
	}
	bool exist(ll x){
		for(int i=63;i>=0;i--){
			if(x&(1ll<<i)){
				if(a[i])x^=a[i];
				else {return 0;}
			}
		}
		return 1;
	}
}t;
char s[maxn];
void solve(){
	int n;scanf("%d",&n);rep(i,1,n)scanf("%lld",&a[i]);
	scanf("%s",s+1);t.reset();
	if(s[n]=='1'){printf("1\n");return;}
	t.insert(a[n]);
	for(int i=n-1;i>=1;i--){
		if(s[i]=='0'){
			t.insert(a[i]);
		}
		else{
			if(!t.exist(a[i])){printf("1\n");return;}
		}
	}
	printf("0\n");
}
int main(){
	int t;scanf("%d",&t);
	while(t--)solve();
}


Measured memory_bytes: 3660
#include<stdio.h>

typedef struct{
        char name[11];
        int t;
}Pro;

#define len 100005

int main(){
        int total=0, q, i, n;
        scanf("%d %d", &n, &q);
        Pro pro[len];
        int max=n;

        for(i=0; i<n; i++){
                scanf("%s %d", pro[i].name, &pro[i].t);
        }

        int front=0, rear=n;
        do{
                if((pro[front].t-q)<=0){
                        total+=pro[front].t;
                        printf("%s %d\n", pro[front].name, total);
                        front=(front+1)%len;
                        max--;
                }else{
                        total+=q;
                        pro[front].t-=q;
                        pro[rear]=pro[front];
                        front=(front+1)%len; rear=(rear+1)%len;
                }
        }while(max!=0);

        return 0;
}



Measured memory_bytes: 3412
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		a,b,c,d,w,h,i,j,k,l,m,n,x,y,z;
	ll		ans = 0;
	string	s;
	cin >> n >> m;
	vector<ll>	aa(m+1);
	for(i=0;i<n;i++) {
		cin >> k;
		for(j=0;j<k;j++) {
			cin >> a;
			aa[a]++;
		}
	}
	for(i=1;i<=m;i++) {
		if (aa[i]==n) ans++;
	}

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


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	//min(a,b)...a,bの小さいほう
	//max(a,b)...     大きいほう
	int a;
	int b;
	//int c;
	//int d;
	int e;
	cin >> a >> b;
	//string s;
	//std::cin >> s;
	cout << b - a + b << "\n";
	std::cin >> e;
}

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

using namespace std;

int main()
{
	string S;
	int count = 0;
	const string ans = "CODEFESTIVAL2016";
	cin >> S;

	for (int i = 0; i < ans.size(); i++)
	{
		if (S[i] != ans[i])
			count++;
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
a = int(input())
b = 2#int(input())
x = list(map(int, input().split()))
dp = [0]+[10**10]*(a-1)
dp[1] = abs(x[1]-x[0])
for i,h in enumerate(x):
    if i>1:
        for di in range(1,b+1):
            dp[i] = min(dp[i],dp[i-di]+abs(h-x[i-di]))
print(dp[a-1])

Measured memory_bytes: 13976
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>
#include <cmath>

using namespace std;

void ARC080D()
{
	int H, W;
	cin >> H >> W;
	int N;
	cin >> N;
	vector<int> an(N);
	for (auto& x : an)
		cin >> x;

	vector<vector<int> > grid(H, vector<int>(W));
	int k = 0;
	int ct = 0;
	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j)
		{
			if (i % 2 == 0)
				grid[i][j] = k + 1;
			else
				grid[i][W - 1 - j] = k + 1;
			++ct;
			if (ct == an[k])
			{
				ct = 0;
				++k;
			}
		}
	}

	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j)
		{
			cout << grid[i][j];
			if (j < W - 1)
				cout << ' ';
		}
		cout << endl;
	}
}
int main()
{
	ARC080D();
	return 0;
}


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


int main(){
  long long n,m,i,j,sum;
  cin >> n >> m;
  priority_queue<long long,vector<long long>,greater<long long>> a;
  vector<long long> b(m),c(m);
  vector<pair<long long,long long>> bc(m);
  for(i=0;i<n;++i){
    long long z;
    cin >> z;
    a.push(z);
  }
  for(i=0;i<m;++i){
    cin >> b[i] >> c[i];
    bc[i]=make_pair(c[i],b[i]);
  }
  sort(bc.begin(),bc.end(),greater<>());

  for(i=0;i<m;++i){
    j=0;
    long long hi;
    hi=a.top();
    while(j<bc[i].second && hi<bc[i].first){
      a.pop();
      a.push(bc[i].first);
      hi=a.top();
      ++j;
    }
  }
  sum=0;
  while(!a.empty()){
    sum+=a.top();
    a.pop();
  }
  cout << sum << endl;
  return 0;

}


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

int main() {
  int N;
  cin >> N;
  vector<int> b(N);
  for (int i = 0; i < N; i ++ ){
    int a;
    cin >> b.at(i);
  }
  int c = 0;
  int j = 0;
  
  for (int i = 0; i < N; i ++ ){
    if (b.at(j) == 2){
      cout << c +1 <<endl;
      break;
    }
    else{
      j = b.at(j) - 1;
      c ++ ;
    }
    if (i == N -1 )
      cout << -1 <<endl;
  }
}

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

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

    int a,b,c;
    cin >> a >> b >> c;
    
    if(a + b + c >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
}


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

int main(){
  int h,w;
  cin >> h >> w;

  vector<string> s(h);
  for (int i = 0; i < h; i++)
  {
    cin >> s[i];
  }

  int l[h][w],r[h][w],t[h][w],d[h][w];
  // for (int i = 0; i < h; i++)
  // {
  //   for (int j = 0; j < w; j++)
  //   {
  //     l[h][w]=r[h][w]=t[h][w]=d[h][w]=0;
  //   }
  // }

  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
      if(s[i][j]=='#') l[i][j]=0;
      else{
        if(j==0) l[i][j]=1;
        else l[i][j]=l[i][j-1]+1;
      }
    }
  }

  for (int i = 0; i < h; i++)
  {
    for (int j = w-1; j >= 0; j--)
    {
      if(s[i][j]=='#') r[i][j]=0;
      else{
        if(j==w-1) r[i][j]=1;
        else r[i][j]=r[i][j+1]+1;
      }
    }
  }

  for (int j = 0; j < w; j++)
  {
    for (int i = 0; i < h; i++)
    {
      if(s[i][j]=='#') t[i][j]=0;
      else{
        if(i==0) t[i][j]=1;
        else t[i][j]=t[i-1][j]+1;
      }
    }
  }

  for (int j = 0; j < w; j++)
  {
    for (int i = h-1; i >= 0; i--)
    {
      if(s[i][j]=='#') d[i][j]=0;
      else{
        if(i==h-1) d[i][j]=1;
        else d[i][j]=d[i+1][j]+1;
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
      ans = max(ans,l[i][j]+r[i][j]+t[i][j]+d[i][j]-3);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 66816
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <cstdlib>
#include <math.h>

using namespace std;

typedef long long ll;
#define rep(i, n) for(long (i) = 0; (i) < (long) (n); (i)++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,a,b) for(long i=(a);i<(b);i++)
#define rrep1(i,a,b) for(long i=(a);i<=(b);i++)
#define rrrep(i,a,b) for(long i=(a);i>=(b);i--)
#define define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define X first
#define Y second
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int> >
#define vpl vector<pair<long, long> >
#define vppl vector<pair<long, pair<long, long> > >

const int INF = 100100100;
const long LONG_INF = 2147483647;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const ll LINF = 1e18;


int pow(int x) {
	if (x == 0) {
		return 1;
	}
	else {
		return pow(x - 1) * 2;
	}
}

int main(int argc, char const *argv[])
{
    int N,C;
    cin >> N >> C;
    int a[C][C];
    rep(i,C) {
        rep(j,C) {
            cin >> a[i][j];
        }
    }
    vi a1,a2,a3;
    rep(i,N){
        rep(j,N){
            int x;
            cin >> x;
            if ((i + j)%3==0) {
                a1.push_back(x);
            } else if ((i+j)%3==1)
            {
                a2.push_back(x);
            } else
            {
                a3.push_back(x);
            }
        }
    }
    vpl b1,b2,b3;
    rep(j,C){
        long total = 0;
        rep(i, a1.size()) {
            total += a[a1[i]-1][j];
        }
        b1.push_back(make_pair(total,j));
    }
    rep(j,C){
        long total = 0;
        rep(i, a2.size()) {
            total += a[a2[i]-1][j];
        }
        b2.push_back(make_pair(total,j));
    }
    rep(j,C){
        long total = 0;

        rep(i, a3.size()) {
            total += a[a3[i]-1][j];
        }
        b3.push_back(make_pair(total,j));
    }
    sort(ALL(b1));
    sort(ALL(b2));
    sort(ALL(b3));
    long min = 2147483647;
    if (N ==1) { // 1の場合パターンはb2, b3に値が入っていないためケア
        cout << b1[0].first << endl;
        return 0;
    }
    
    rep(i,3){
        rep(j,3){
            rep(k,3){
                if (b1[i].second == b2[j].second || b1[i].second == b3[k].second || b2[j].second == b3[k].second) {
                    continue;
                }
                int total = b1[i].first + b2[j].first + b3[k].first;
                if (total < min) {
                    min = total;
                }
            }
        }
    }

    cout << min;
    
    return 0;
}


Measured memory_bytes: 1520
s=input()
n=len(s)
s1=s[:n//2]
s2=s[n//2+1:]
test =True
if(s!=s[::-1]):
	test=False
if (s1!=s1[::-1]):
	test=False
if(s2!=s2[::-1]):
	test=False
if(test==True):
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3064
fun main(args: Array<String>) {
    val (n, t) = readLine()!!.split(" ").map { it.toInt() }
    val l = readLine()!!.split(" ").map { it.toInt() }
    var c = t
    for (i in 0 until n - 1) {
        c += if (l[i + 1] - l[i] < t) l[i + 1] - l[i] else t
    }
    println(c)
}


Measured memory_bytes: 80828
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;

long long T,n,i,j,k;
long long a,b,c,d;
long long ans;
map<long long,long long> H;

long long findnear(long long x,long long y,long long type)
{
	long long tt=y*(x/y);
	if (type==1) return tt;
	else return tt+y;
}

long long dg(long long x)
{
	long long s,t;
	if (x>1e18/d) s=1000000000000000000;
	else s=x*d;
	if (x==0) return 0;
	if (H[x]) return H[x];
	t=findnear(x,2,1);
	if (t/2!=x) s=min(s,dg(t/2)+a+d*abs(t-x));
	t=findnear(x,2,2);
	if (t/2!=x) s=min(s,dg(t/2)+a+d*abs(t-x));
	t=findnear(x,3,1);
	if (t/3!=x) s=min(s,dg(t/3)+b+d*abs(t-x));
	t=findnear(x,3,2);
	if (t/3!=x) s=min(s,dg(t/3)+b+d*abs(t-x));
	t=findnear(x,5,1);
	if (t/5!=x) s=min(s,dg(t/5)+c+d*abs(t-x));
	t=findnear(x,5,2);
	if (t/5!=x) s=min(s,dg(t/5)+c+d*abs(t-x));
	H[x]=s;
	return s;
}

int main()
{
//	freopen("read.in","r",stdin);
	scanf("%lld",&T);
	while (T--)
	{
		scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
		H.clear();
		ans=dg(n);
		printf("%lld\n",ans);
	}
}

Measured memory_bytes: 4436
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int N; string S[1 << 19];
map<string, int> M1, M2;
vector<string> vec;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> S[i];
		M1[S[i]]++;
	}
	int maxn = 0;
	for (int i = 0; i < N; i++) maxn = max(maxn, M1[S[i]]);
	for (int i = 0; i < N; i++) {
		if (M1[S[i]] == maxn) vec.push_back(S[i]);
	}
	sort(vec.begin(), vec.end());
	vec.erase(unique(vec.begin(), vec.end()), vec.end());

	for (int i = 0; i < vec.size(); i++) cout << vec[i] << endl;
	return 0;
}

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


int32_t main()
{

	
	int n; cin>>n;
	int arr[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>arr[i];
	}
	int ans=0;
	for (int i = 0; i < n; ++i)
	{
		for(int j=i+1;j<n;j++) ans+=arr[i]*arr[j];
	}


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

Measured memory_bytes: 256
//----------ACCIDENTAL COMPETITIVE PROGRAMMER---------------------

#include<bits/stdc++.h>

/*
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
*/
using namespace std;

#define LL long long
#define LD long double
#define PB push_back
#define MP make_pair


const LL MOD = (1e9) + 7 ;
const LD EPS = 0.0000001 ;

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

    string s; cin >> s;
    int ans1 = 0;
    int ans2 = 0;
    for (int i = 0; i < s.size(); i++){
    	int c = s[i] - '0';
    	if (i % 2){
    		if (c == 0){
    			ans1++;
    		} else {
    			ans2++;
    		}
    	} else {
    		if (c == 0){
    			ans2++;
    		} else {
    			ans1++;
    		}
    	}
    }
    cout << min(ans1, ans2) << endl;
	return 0;
}

Measured memory_bytes: 512
import sys

for s in sys.stdin:
    s = s[:-1]
    if s[::4] == "ooo" : print "o"; continue
    if s[::4] == "xxx" : print "x"; continue
    if s[2:8:2] == "ooo" : print "o"; continue
    if s[2:8:2] == "xxx" : print "x"; continue
    if s[0::3] == "ooo" : print "o"; continue
    if s[0::3] == "xxx" : print "x"; continue
    if s[0:3] == "ooo" : print "o"; continue
    if s[0:3] == "xxx" : print "x"; continue
    if s[3:6] == "ooo" : print "o"; continue
    if s[3:6] == "xxx" : print "x"; continue
    if s[6:9] == "ooo" : print "o"; continue
    if s[6:9] == "xxx" : print "x"; continue
    if s[0::3] == "ooo" : print "o"; continue
    if s[0::3] == "xxx" : print "x"; continue
    if s[1::3] == "ooo" : print "o"; continue
    if s[1::3] == "xxx" : print "x"; continue
    if s[2::3] == "ooo" : print "o"; continue
    if s[2::3] == "xxx" : print "x"; continue
    print "d"

Measured memory_bytes: 4276
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD =1e9+7;
using ll=long long;

int main() {
    string s;
    cin >> s;
    int l = s.size();
    for(int i=1; i<=s.size();i++){
        string S = s.substr(0,l-i);
        int n = S.size();
        if(n%2!=0) continue;
        string s1 = S.substr(0,n/2);
        string s2 = S.substr(n/2,n/2);
        if(s1 == s2) {
            cout << S.size() << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)){
			int len = sc.nextInt();
			String s = sc.next();
			int pointer = 0;
			int count = 0;
			while (pointer < len-1) {
				if (!s.substring(pointer,pointer+1).equals(s.substring(pointer+1,pointer+2))) {
					count++;
					pointer += 2;  //次の
				}
				else pointer++;
			}
			System.out.println(count);
		}
	}
}



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

using namespace std;

#define fRead(x)        freopen(x,"r",stdin)
#define fWrite(x)       freopen (x,"w",stdout)

#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define PI              acos(-1.0)
#define mk              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#pragma GCC target ("avx2")
#pragma GCC optimization ("O2")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(nullptr);
#ifdef VAMP
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cout << name << " = " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cout.write(names, comma - names) << " = " << arg1 <<" | ";
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif

int32_t main()
{
    #ifdef VAMP
        clock_t tStart = clock();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);

    #endif
    int x;
    cin >> x;
    int me = 0;
    for(int i = 1; ;i++){
        me += x;
        me %= 360;
        if(me == 0){
            cout << i << "\n";
            return 0;
        }
    }
    #ifdef VAMP
        fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    #endif
}


Measured memory_bytes: 3672
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>

using namespace std;

int main(){
	int w,a,b;
	cin >> w >> a >> b;
	int ans;
	if(b>a+w){
		ans=b-(a+w);
	}else if((a<=b && b <=a+w) || (a<=b+w && b+w <=a+w)){
		ans=0;
	}else{
		ans=a-(b+w);
	}
	cout << ans << endl;
	return 0;
	
}


Measured memory_bytes: 256
import collections
n = int(input())
list1 = list(map(int,input().split()))
list2n = list1[::2]
list2n_1 = list1[1::2]
c2n = collections.Counter(list2n)
c2n_1 = collections.Counter(list2n_1)
c2n_mc = c2n.most_common(2)
c2n_1_mc = c2n_1.most_common(2)

if c2n_mc[0][0] == c2n_1_mc[0][0]:
    if len(c2n_mc) == 1 and len(c2n_1_mc)==1:
        if c2n_mc[0][0] == c2n_1_mc[0][0]:
            ans = n//2
        else:
            ans = 0
    elif len(c2n_mc)==1 or len(c2n_1_mc)==1:
        if len(c2n_mc)==1:
            ans = n - c2n_mc[0][1] - c2n_1_mc[1][1]
        else:
            ans = n - c2n_1_mc[0][1] - c2n_mc[1][1]
    elif c2n_mc[1][1] <= c2n_1_mc[1][1]:
        ans = n - c2n_mc[0][1] - c2n_1_mc[1][1]
    else:
        ans = n - c2n_1_mc[0][1] - c2n_mc[1][1]
else:
    ans = n - c2n_mc[0][1] - c2n_1_mc[0][1]
print(ans)

Measured memory_bytes: 63596
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			int[] X = new int[N];
			int[] Y = new int[N];
			int[] V = new int[N];
			double x = 0;
			double y = 0;
			for (int i = 0; i < N; ++i) {
				X[i] = sc.nextInt();
				Y[i] = sc.nextInt();
				V[i] = sc.nextInt();
				x += X[i];
				y += Y[i];
			}
			x /= N;
			y /= N;
			double move = 0.01;
			for (int i = 0; i < 20; ++i) {
				for (int j = 0; j < 50000; ++j) {
					int mi = 0;
					double mt = 0;
					for (int k = 0; k < N; ++k) {
						double d = sq(X[k] - x) + sq(Y[k] - y);
						if (sq(mt * V[k]) < d) {
							mt = Math.sqrt(d) / V[k];
							mi = k;
						}
					}
					x += (X[mi] - x) * move;
					y += (Y[mi] - y) * move;
				}
				move *= 0.5;
			}
			double ans = 0;
			for (int k = 0; k < N; ++k) {
				ans = Math.max(ans, Math.sqrt(sq(X[k] - x) + sq(Y[k] - y)) / V[k]);
			}
			System.out.printf("%f\n", ans);
		}
	}

	static double sq(double v) {
		return v * v;
	}
}

Measured memory_bytes: 25876
#include <queue>
#include <string>
#include <iomanip>
#include <iostream>
#pragma warning(disable : 4996)
using namespace std;
struct state {
	int x, y; long double dist;
};
bool operator<(const state& s1, const state& s2) {
	return s1.dist < s2.dist;
}
int dir[4] = { 0, 1, 0, -1 };
int H, W, sx, sy; long double dist[555][555]; string s[555];
int main() {
	cin >> W >> H;
	for (int i = 0; i < H; i++) {
		cin >> s[i];
		if (s[i].find('s') != string::npos) {
			sx = i; sy = s[i].find('s');
		}
	}
	long double l = 0.0, r = 1.0e+10;
	for (int i = 0; i < 80; i++) {
		long double m = (l + r) * 0.5;
		priority_queue<state> que;
		for (int j = 0; j < H; j++) {
			for (int k = 0; k < W; k++) {
				dist[j][k] = 1.0e+15;
				if (s[j][k] == 'g') {
					dist[j][k] = 0.0;
					que.push(state{ j, k, 0.0 });
				}
				if (s[j][k] == '*') {
					dist[j][k] = m;
					que.push(state{ j, k, -m });
				}
			}
		}
		while (!que.empty()) {
			state u = que.top(); que.pop();
			for (int i = 0; i < 4; i++) {
				int tx = u.x + dir[i], ty = u.y + dir[i ^ 1];
				if (0 <= tx && tx < H && 0 <= ty && ty < W && s[tx][ty] != '#' && s[tx][ty] != '*' && dist[tx][ty] > dist[u.x][u.y] + 1.0L) {
					dist[tx][ty] = dist[u.x][u.y] + 1.0L;
					que.push(state{ tx, ty, -dist[tx][ty] });
				}
			}
		}
		long double sum = 0.0; int cnt = 0;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (s[i][j] == 's' || s[i][j] == '.') {
					sum += dist[i][j];
					cnt++;
				}
			}
		}
		if (sum < m * cnt) r = m;
		else l = m;
	}
	cout << fixed << setprecision(10) << dist[sx][sy] << endl;
	return 0;
}

Measured memory_bytes: 9948
#include<iostream>
#include<algorithm>
#include <iostream> 
#include <algorithm> 
#include<string>
#include<queue>
#include<utility>
#include<fstream>
#include<queue>
#include<set>
#include<stack>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 
 
typedef pair<int,int >P;
//////////////////////////
/////////////////////////



bool isPal(string a, int s, int e){
    string h;
    s--;
    e--;
    
    for(int i = e;i>=s;i--)h += a[i];
   // cout<<a<<h<<endl;
    string h1 = h;
    reverse(h1.begin(),h1.end());
    if(h==h1)return 1;
    return 0;
}

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

    int l = s.size();
    if(isPal(s, 1,l) && isPal(s,1, (l-1)/2)&& isPal(s, (l+3)/2, l)){
        cout<<"Yes"<<endl;

    }
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

constexpr long long inf = numeric_limits<long long>::max()/10;
struct edge{
    long long to,cost;
    edge(){}
    edge(long long to_,long long cost_) : to(to_),cost(cost_){}
};

vector<long long> dijkstra(int s,const vector<vector<edge>>& g){
    using P = pair<long long,long long>;
    long long V = g.size();
    vector<long long> d(V,inf);
    priority_queue<P,vector<P>,greater<P>> que;
    d[s] = 0;
    que.push(P(0,s));
    while(!que.empty()){
        P p=que.top();que.pop();
        long long v=p.second;
        if(d[v]<p.first) continue;
        for(int i=0;i<g[v].size();i++){
            edge e=g[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(P(d[e.to],e.to));
            }
        }
    }
    return d;
}

int N;
vector<vector<edge>> G;

int main(){
    cin >> N;
    G.resize(N);
    rep(i,N-1){
        ll u,v,w;
        cin >> u >> v >> w;
        u--;
        v--;
        if(w%2==0) w = 2;
        else w = 1;
        G[u].emplace_back(edge(v,w));
        G[v].emplace_back(edge(u,w));
    }

    auto dist = dijkstra(0,G);
    rep(i,N){
        if(dist[i] % 2 == 0) cout << 0 << endl;
        else cout << 1 << endl;
    }
}


Measured memory_bytes: 8704
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int X; 
  cin >> X;

  int now = 100;
  int ans = 0;
  while(now < X){
    now = now+now/100;
    ans++;
  }

  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;
	int main()
	{
		std::ios::sync_with_stdio(false);
		
		ll k,s;
		cin>>k>>s;
		
			ll count = 0;
			for(ll i=0; i<=k; i++) {
				for(ll j=0; j<=k; j++) {
					ll z = s - i - j;
					if(z>=0 && z<=k) {
						count++;
					}
				}
			}
			
			cout<<count<<endl;
			
		return 0;
	}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  
   int x,y,tmp;
   while(1){
    scanf("%d%d",&x,&y);
    if(x == 0 && y == 0){
     break;
    } else if(x > y){
      tmp = x; x = y; y = tmp;
    }
    printf("%d %d\n",x,y);
   }
  return 0 ;
} 



Measured memory_bytes: 1860
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>();
        for (int i=0;i<N;i++) {
            int a = sc.nextInt();
            if (map.containsKey(a)) map.put(a, map.get(a)+1);
            else map.put(a, 1);
        }

        boolean flag = false;
        ArrayList<Integer> key = new ArrayList<Integer>(map.keySet());
        ArrayList<Integer> val = new ArrayList<Integer>(map.values());
        int size = key.size();
        if (size==1 && ((val.get(0)-1)==key.get(0) || (long)2*key.get(0)<=val.get(0))) flag=true;
        // if (size==2 && key.get(1)-key.get(0)==1 &&  key.get(0)==val.get(0) && val.get(1)>1) flag=true;
        if (size==2 && key.get(1)-key.get(0)==1 &&  val.get(0)<key.get(1) && 2*(key.get(1)-val.get(0))<=val.get(1)) flag=true;

        if (flag) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 67464
a = []
b = []
n = []
while True:
    try:
        tmp = list(input().split())
        a.append(int(tmp[0]))
        b.append(int(tmp[1]))
        n.append(int(tmp[2]))
    except EOFError:
        break

for i in range(len(a)):
    s = 0
    for j in range(n[i]):
        f = a[i]*(10**(j+1))
        s += (f//b[i])%10
    print(s)

Measured memory_bytes: 7624
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
  int N;
  cin >> N;
  vector<int> s(N);
  int ans=0;
  for(int i=0; i<N; i++){
    cin >> s[i];
    ans += s[i];
  }
  sort(s.begin(), s.end());
  if(ans%10 != 0){
    cout << ans << endl;
    return 0;
  }
  for(int i=0; i<N; i++){
    if(s[i]%10 != 0){
      cout << ans-s[i] << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();

		long sum = 0;
		for (int i = 0; i < n; i++) {
			if (i % 2 == 0) {
				sum += a[i];
			} else {
				sum -= a[i];
			}
		}

		long[] ans = new long[n];
		ans[0] = sum;
		for (int i = 1; i < n; i++) {
			ans[i] = 2 * a[i - 1] - ans[i - 1];
		}

		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
			sb.append(ans[i]).append(' ');
		}
		sb.deleteCharAt(sb.length() - 1);
		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 57796
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    int N;
    read(N);

    vector<int> a(N + 1);
    vector<int> f(N + 1);
    reps(i, 1, N) {
        read(a[i]);
        if (a[i] == i) f[i] = 1;
    }

    i64 ans = 0;
    i64 cnt = 0;
    reps(i, 1, N) {
        if (f[i]) {
            ++cnt;
        } else {
            ans += (cnt + 1) / 2;
            cnt = 0;
        }
    }
    ans += (cnt + 1) / 2;

    print(ans);

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int X,Y;
    cin>>X>>Y;
    int ans=0;
    if(X==3){ans+=100000;}
    else if(X==2){ans+=200000;}
    else if(X==1){ans+=300000;}

    if(Y==3){ans+=100000;}
    else if(Y==2){ans+=200000;}
    else if(Y==1){ans+=300000;}

    if(X==1&&Y==1){ans+=400000;}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int N, K; cin >> N >> K;
  string S; cin >> S;
  if(S[K-1]=='A') S[K-1]='a';
  if(S[K-1]=='B') S[K-1]='b';
  if(S[K-1]=='C') S[K-1]='c';
  cout << S << endl;
  return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(1000)

def gcd(x, y):
    if x < y:
        x, y = y, x
    if x%y == 0:
        return y
    else:
        return gcd(y, x%y)

K = int(input())
ans = 0

for o in range(1, K + 1):
    for p in range(o, K + 1):
        temp_gcd = gcd(o, p)
        for q in range(p, K + 1):
            temp_ans = gcd(temp_gcd, q)
            if (o == p) and (p == q):
                ans += temp_ans
            elif (o == p) or (p == q) or (o == q):
                ans += temp_ans * 3
            else:
                ans += temp_ans * 6

print(ans)

Measured memory_bytes: 9224
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//const int MAX=;



int main(){
	string S;
	cin>>S;
	int l=sz(S);
	int a=-1,b=-1;
	rep(i,l-1){
		if(S[i]==S[i+1]){
			a=i+1;
			b=i+2;
			break;
		}
	}
	rep(i,l-2){
		if(S[i]==S[i+2]){
			a=i+1;
			b=i+3;
			break;
		}
	}
	
	cout<<a<<" "<<b<<endl;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < n - 1; i++) {
    cin >> c[i];
  }
  int res = 0;
  for (int i = 0; i < n; i++) {
    res += b[a[i]];
    if (i && a[i-1] == a[i] - 1) {
      res += c[a[i-1]];
    }
  }
  cout << res;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
long double a, b, c, d, e, f;
long double i, j, k, l, imax, jmax, kmax, lmax;
long long tot, sugar;
long double maxim=-1, total;

int main()
{
    cin>>a>>b>>c>>d>>e>>f;
    imax=f/(100*a)+5;
    jmax=f/(100*b)+5;
    for (i=0; i<=imax; i++)
    {
        for (j=0; j<=jmax; j++)
        {
            kmax=min((i*a+j*b)*e/c, (f-100*a*i-100*b*j)/c)+5;
            lmax=min((i*a+j*b)*e/d, (f-100*a*i-100*b*j)/d)+5;
            for (k=0; k<=kmax; k++)
            {
                for (l=0; l<=lmax; l++)
                {
                    total=i*100*a+j*100*b+k*c+l*d;
                    if (total==0) continue;
                    if (total<=f && k*c+l*d<=e*(i*a+j*b))
                    {
                        if (100*(k*c+l*d)/total>maxim)
                        {
                            maxim=100*(k*c+l*d)/total;
                            tot=total;
                            sugar=k*c+l*d;
                        }
                    }
                    else
                        break;
                }
            }
        }
    }
    cout<<tot<<" "<<sugar;
    return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

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

fun main() {
    val (H, W) = nextIntList()
    val A = Array(H) { nextIntList().toMutableList() }
    val ans = ArrayList<P>()
    for (y in 0 until H) {
        for (_x in 0 until W) {
            if (_x == W - 1 && y == H - 1) continue
            val inv = y % 2 == 1
            val x = if (inv) W - 1 - _x else _x
            if (A[y][x] % 2 == 0) continue
            val nx = if (inv) {
                if (x == 0) 0 else x - 1
            } else {
                if (x == W - 1) W - 1 else x + 1
            }
            val ny = if ((inv && x == 0) || (!inv && x == W - 1)) y + 1 else y
            A[ny][nx]++
            ans.add(P(x, y, nx, ny))
        }
    }
    println(ans.size)
    for (a in ans) {
        println("${a.y1 + 1} ${a.x1 + 1} ${a.y2 + 1} ${a.x2 + 1}")
    }
}

data class P(val x1: Int, val y1: Int, val x2: Int, val y2: Int)

Measured memory_bytes: 65168
#include<iostream>
#include<algorithm>
int main() {
	int W[10];
	int K[10];
	for (int i = 0; i < 20; ++i) {
		if (i <= 9) {
			std::cin >> W[i];
		}
		else if (i >= 10) {
			std::cin >> K[i - 10];
		}
	}
	std::sort(W, W + 10);
	std::sort(K, K + 10);
	std::cout << W[7] + W[8] + W[9] << " " << K[7] + K[8] + K[9] << std::endl;
	return 0;
}

Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define run(v) for(int k=head[v];k;k=e[k].ne)
#define v e[k].t
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<ll,ll> pa;
const int N=1e6+5,M=1e7+5,INF=1e9,mod=1e9+7;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("datax.out","w",stdout);}
il void gen(){freopen("data.in","w",stdout);}
int n,m,c[N],cc;
pa p[N],q[N];
int main(){//judge();
	read(n);
	ll mn=1e9,mx=-1e9,a1=-1e9,a2=1e9;
	rep(i,1,n){
		read(p[i].w1,p[i].w2);
		gmin(mn,p[i].w1);
		gmin(mn,p[i].w2);
		gmax(mx,p[i].w1);
		gmax(mx,p[i].w2);
		gmax(a1,min(p[i].w1,p[i].w2));
		gmin(a2,max(p[i].w1,p[i].w2));
		q[++m]=pa(p[i].w1,i);
		q[++m]=pa(p[i].w2,i);
	}
	ll r1=(a1-mn)*(mx-a2),r2=1e18;
	sort(q+1,q+1+m);
	ll r=0,tmp=1e9;
	while(r<m){
		r++;
		if(c[q[r].w2]==0)cc++;
		c[q[r].w2]++;
		if(cc==n)break;
	}
	rep(l,1,m){
		tmp=min(tmp,q[r].w1-q[l].w1);
		c[q[l].w2]--;
		while(c[q[l].w2]==0&&r+1<=m)c[q[r+1].w2]++,r++;
		if(c[q[l].w2]==0)break;
	}
	tmp*=(mx-mn);
	cout<<min(tmp,r1)<<endl;
}

Measured memory_bytes: 16640
n = int(input())
card = list(map(int,input().split()))

card.sort(reverse=True)
alice = []
bob = []

for i in range(len(card)):
    if i % 2 == 0:
        alice.append(card[i])
    else:
        bob.append(card[i])

print(sum(alice)-sum(bob))

Measured memory_bytes: 3060
N, M = map(int, input().split())
D = []
for _ in range(N):
  D.append(list(map(int, input().split())))

D.sort(key=lambda a: a[0])
ans = 0
num = 0
for price, n in D:
  if num + n >= M:
    ans += price * (M - num)
    break
  ans += price * n
  num += n
print(ans)

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

const int size = 51;
int A[size], B[size], C[size];

int main( void ) 
{
    int n, r;
    while ( cin >> n >> r ) {

        int as = 0, bs = 0, cs = 0;
        for ( int i = 0; i < n/2; i++ ) {
            B[bs] = i;
            bs++;
        }
        for ( int i = n/2; i < n; i++ ) {
            A[as] = i;
            as++;
        }

        for ( int ri = 0; ri < r; ri++ ) {
            int c;
            cin >> c;
            cs = 0;

            int ai = 0, bi = 0;
            bool at = true;
            while ( ai < as || bi < bs ) {
                if ( at ) {
                    for ( int i = 0; i < c && ai < as; i++ ) {
                        C[cs] = A[ai];
                        cs++;
                        ai++;
                    }
                } else {
                    for ( int i = 0; i < c && bi < bs; i++ ) {
                        C[cs] = B[bi];
                        cs++;
                        bi++;
                    }
                }
                at = !at;
            }

            as = bs = 0;
            for ( int i = 0; i < n/2; i++ ) {
                B[bs] = C[i];
                bs++;
            }
            for ( int i = n/2; i < n; i++ ) {
                A[as] = C[i];
                as++;
            }
        }

        cout << C[cs-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 0