akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define ld long double
#define pii pair<int,int>
#define fi first
#define se second
#define mex 1000005
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//vector<int> adj[mex];
//a+b=a^b+2*(a&b)

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS

int main(){
	fast
	int t;
	cin>>t;
	while(t--){
		int n;
		cin>>n;
		int k[n],l[n],r[n];
		for(int i=0;i<n;i++)
		 cin>>k[i]>>l[i]>>r[i];
		
		priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>> > p1,p2;
		ll s=0;
		vector<pair<ll,ll>> v1,v2;
		for(int i=0;i<n;i++){
			if(l[i]>=r[i]){
				s=s+r[i];
				v1.push_back({k[i],l[i]-r[i]});
			}
		}
		sort(v1.begin(),v1.end());
		for(int i=0;i<v1.size();i++){
			p1.push({v1[i].se,v1[i].fi});
			if(p1.size()>v1[i].fi)
			 p1.pop();
		}
		while(!p1.empty()){
			s=s+p1.top().fi;
			//cout<<(p1.top().fi)<<endl;
			p1.pop();
		}
		//cout<<s<<endl;
		for(int i=0;i<n;i++){
			if(r[i]>l[i]){
				s=s+l[i];
				v2.push_back({k[i],r[i]-l[i]});
			}
		}
		sort(v2.rbegin(),v2.rend());
		for(int i=0;i<v2.size();i++){
			p2.push({v2[i].se,v2[i].fi});
			if(p2.size()>n-v2[i].fi)
			 p2.pop();
		 }
		 while(!p2.empty()){
			 s=s+p2.top().fi;
			 p2.pop();
		 }
		 cout<<s<<endl;
	 }
			 
}


Measured memory_bytes: 13448
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
 
using namespace std;
 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
 
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
 
	int i;
	vector<int> red(a);
	vector<int> green(b);
	vector<int> colorless(c);
	priority_queue<int, vector <int>, greater<int>> ans;
 
	for (i = 0; i < a; i++)
		cin >> red[i];
 
	for (i = 0; i < b; i++)
		cin >> green[i];
 
	for (i = 0; i < c; i++)
		cin >> colorless[i];

	sort(red.begin(), red.end(), greater<int>());
	sort(green.begin(), green.end(), greater<int>());
	sort(colorless.begin(), colorless.end(), greater<int>());
 
	for (i = 0; i < x; i++)
		ans.push(red[i]);
 
	for (i = 0; i < y; i++)
		ans.push(green[i]);

	for (auto item:colorless)
		if (ans.top() < item)
		{
			ans.pop();
			ans.push(item);
		}
 
	long long sum = 0;
	while(!ans.empty())
	{
		sum += ans.top();
		ans.pop();
	}
 
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 2552
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    k = II()
    a, b = MII()
    for i in range(a,b+1):
        if i%k == 0:
            print('OK')
            return None
    print('NG')

if __name__ == '__main__':
    main()

Measured memory_bytes: 9504
A,B,C,X,Y=list(map(int,input().split()))
ans=0
if (A+B)/2>=C:
    ans+=2*C*min(X,Y)
else:
    ans+=(A+B)*min(X,Y)

if X>=Y and A>=2*C:
    ans+=2*C*abs(X-Y)
elif X>=Y:
    ans+=A*abs(X-Y)
elif X<Y and B>=2*C:
    ans+=2*C*abs(X-Y)
else:
    ans+=B*abs(X-Y)
print(ans)


Measured memory_bytes: 3064
package main

import (
    "fmt"
)

func main() {
    var o, e string
    fmt.Scan(&o, &e) 

    size := len(o) + len(e)
    pass := make([]byte, size)
    for i := range pass {
        if i%2 == 0 { 
            pass[i] = o[i/2]
        } else {
            pass[i] = e[(i-1)/2]
        }   
    }   

    fmt.Println(string(pass))
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
#include<stack>
#include<iomanip>
double Z(string s){
	if(s.size()==1){
		if(s[0]=='+')return 0.1;
		if(s[0]=='-')return 0.2;
		if(s[0]=='*')return 0.3;
		if(s[0]=='/')return 0.4;
		return s[0]-'0'+0.0;
	}
	double tmp=(s[0]=='-'?0:s[0]-'0')+0.0;
	for(int i=1;i<s.size();i++){
		tmp*=10;
		if(tmp<=0)tmp-=s[i]-'0'+0.0;
		else tmp+=s[i]-'0'+0.0;
	}
	return tmp;
}
int main(){
	string s;
	while(getline(cin,s)){
		stack<double> st;
		s.push_back(' ');
	int left=0;
	for(int i=0;i<s.size();i++){
		if(s[i]==' '){
			double tmp=Z(s.substr(left,i-left));
			if(0<tmp&&tmp<1){
				double b=st.top();st.pop();
				double a=st.top();st.pop();
				if(tmp==0.1)st.push(a+b);
				if(tmp==0.2)st.push(a-b);
				if(tmp==0.3)st.push(a*b);
				if(tmp==0.4)st.push(a/b);
			}
			else st.push(tmp);
			left=i+1;
		}
	}
	cout<<fixed<<setprecision(10)<<st.top()<<endl;
	}
	return 0;
}

Measured memory_bytes: 3184
import sys
input = sys.stdin.readline
H,W=map(int,input().split())
n=int(input())
ans=[[0]*W for _ in range(H)]

A=list(map(int,input().split()))
cnt=0
for a,num in enumerate(A):
    #print(a,num)
    for i in range(num):
        h=cnt//W
        w=cnt %W
        if h%2==1:
            w=w*(-1)-1
        ans[h][w]=a+1
        cnt+=1
for a in ans:
    print(*a)


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

int main(){
	int N;
  	cin >> N;
    
  	vector<int> A(N);
  	for(int i = 0;i < N;i++){
    	cin >> A.at(i);
    }
    
  	sort(A.begin(),A.end());
 	
  	string ans = "YES";
	for(int i = 0;i < N - 1;i++){
    	if(A.at(i) == A.at(i + 1)){
          ans = "NO";
          break;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
	int n;
	int money = 100000;
	
	scanf("%d", &n);
	for(int i=0 ; i<n ; ++i){
		money += (int)ceil(money * 0.05 / 1000.0) * 1000;
	}
	
	printf("%d\n", money);
	return 0;
}

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

int main() {
    
    int k;
    cin>>k;
    string s;
    cin>>s;
    if(s.length()<=k) cout<<s<<endl;
    else
    {
        for(int i=0;i<k;i++) cout<<s[i];
        cout<<"..."<<endl;
    }
    
    
    	return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

int main() {
    int A, B; cin >> A >> B;

    cout << (A + B + 1) / 2 << endl;
    return 0;
}


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

int main(){
	int a, b;
	int c[101];
	memset(c, 0, sizeof(c));
	
	while(cin >> a >> b){
		if(a==0 && b==0){
			int odd=0;
			for(int i=3; i<=100; ++i){
				if(c[i]%2==1) odd++;	
			}
			
			bool ans=false;
			if(c[1]%2==1 && c[2]%2==1 && odd==0) ans=true;
			
			if(ans) printf("OK\n");
			else printf("NG\n");
			
			memset(c, 0, sizeof(c));			
		}
		else{
			c[a]++;
			c[b]++;	
		}
	}
}

Measured memory_bytes: 1116
#include<stdio.h>
int main(void){
	int a[20000],b[20000],i;
	char op[20000];
	for(i=0;i<20000;i++){
		scanf("%d %c %d",&a[i],&op[i],&b[i]);
		if(op[i]=='?'){
			break;
		}
	}
	for(i=0;i<20000;i++){
		if(op[i]=='?'){
			break;
		}else if(op[i]=='+'){
			printf("%d\n",a[i]+b[i]);
		}else if(op[i]=='-'){
			printf("%d\n",a[i]-b[i]);
		}else if(op[i]=='*'){
			printf("%d\n",a[i]*b[i]);
		}else if(op[i]=='/'){
			printf("%d\n",a[i]/b[i]);
		}
	}
	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long



#if 1
const int MOD = 998244353;

inline int lgput(int a, int b) {
    int ans = 1;
    while(b > 0) {
        if(b & 1) ans = (1LL * ans * a) % MOD;
        b >>= 1;
        a = (1LL * a * a) % MOD;
    }
    return ans;
}

inline void mod(int &x) {
    if(x >= MOD)
        x -= MOD;
}

inline void add(int &x, int y) {
    x += y;
    mod(x);
}

inline void sub(int &x, int y) {
    x += MOD - y;
    mod(x);
}

inline void mul(int &x, int y) {
    x = (1LL * x * y) % MOD;
}

inline int inv(int x) {
    return lgput(x, MOD - 2);
}
#endif

#if 0
int fact[], invfact[];

inline void prec(int n) {
    fact[0] = 1;
    for(int i = 1; i <= n; i++) {
        fact[i] = (1LL * fact[i - 1] * i) % MOD;
    }
    invfact[n] = lgput(fact[n], MOD - 2);
    for(int i = n - 1; i >= 0; i--) {
        invfact[i] = (1LL * invfact[i + 1] * (i + 1)) % MOD;
    }
}

inline int comb(int n, int k) {
    if(n < k) return 0;
    return (1LL * fact[n] * (1LL * invfact[k] * invfact[n - k] % MOD)) % MOD;
}
#endif

using namespace std;



int main() {
#if HOME
    ifstream cin("B.in");
    ofstream cout("B.out");
#endif
    int i, n;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> n;

    int ans = lgput(3, n);
    int bad = 0, cmb = 1;
    for(i = 1; i <= n / 2; i++) {
        mul(cmb, n - i + 1);
        mul(cmb, inv(i));
    }
    for(i = n / 2 + 1; i <= n; i++) {
        int cur = lgput(2, n - i);
        // comb(n, i) = n! / i! * (n - i)!
        // comb(n, i - 1) = n! / (i - 1)! * (n - i + 1)!
        mul(cmb, n - i + 1);
        mul(cmb, inv(i));
        mul(cur, cmb);
        add(bad, cur);
    }

    mul(bad, 2);
    sub(ans, bad);

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
using graph = vector<vector<int>>;

int main(){
    ll a, b; cin >> a >> b;
    for(ll i=0; i<10001; ++i){
        ll aa = i * 8 / 100;
        ll bb = i * 10 / 100;
        if(aa==a && bb==b){
            cout << i << endl; 
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

typedef pair<double, double> XY;

XY koch(XY p, XY q, double dist) {
    if (q.first > p.first) { // when you draw from left to right
        switch ((int)round(180.0 / acos(-1) * atan((p.second - q.second) / (p.first - q.first)))) {
            case 0:
                return make_pair((p.first + q.first) / 2, p.second + sqrt(3) / 2 * dist);
                break;
            case 60:
                return make_pair(p.first * 2 - q.first, q.second);
                break;
            case -60:
                return make_pair(q.first * 2 - p.first, p.second);
                break;
            default:
                break;
        }
    }else {
        switch ((int)round(180.0 / acos(-1) * atan((p.second - q.second) / (p.first - q.first)))) {
            case 0:
                return make_pair((p.first + q.first) / 2, p.second - sqrt(3) / 2 * dist);
                break;
            case 60:
                return make_pair(p.first * 2 - q.first, q.second);
                break;
            case -60:
                return make_pair(q.first * 2 - p.first, p.second);
                break;
            default:
                break;
        }
    }
    return make_pair(-1, -1);
}

void grow(vector<XY> &v, double dist) {
    for(int i = v.size()-1; i >= 1; i--) {
        XY p = v[i];
        XY q = v[i-1];
        XY pp, qq;
        pp = make_pair((p.first * 2 + q.first) / 3, (p.second * 2 + q.second) / 3);
        qq = make_pair((p.first + q.first * 2) / 3, (p.second + q.second * 2) / 3);
        XY pq = koch(qq, pp, dist);
        v.insert(v.begin() + i, pp);
        v.insert(v.begin() + i, pq);
        v.insert(v.begin() + i, qq);
    }
}

void printXY(vector<XY> v) {
    REP(i,v.size()) {
        printf("%.8f %.8f\n", v[i].first, v[i].second);
    }
}

int main() {
    int n;
    cin >> n;
    vector<XY> v;
    v.push_back(make_pair(0, 0));
    v.push_back(make_pair(100, 0));
    double dist = 100/3.;
    REP(i,n) {
        grow(v, dist);
        dist /= 3;
    }
    printXY(v);
    return 0;
}

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

using namespace std;

#define pb push_back
#define eb emplace_back
#define ll long long
#define pii pair < int, int >
#define fr first
#define sc second
#define mk make_pair

const int N = (int)1e5 + 7;
const int inf = (int)1e9 + 7;
const double pi = acos(-1.0);

struct point {
  double x, y;
  int i;
  point() {};
  point(double _x, double _y, int _i) {
    x = _x; y = _y; i = _i;
  }
};

bool cmp(point a, point b) {
  if (a.x < b.x) return 1;
  else if (a.x == b.x) return a.y < b.y;
  return 0;
}

bool cw(point a, point b, point c) {
  return a.x * (b.y - c.y) + b.x * (c.y - a.y) + c.x * (a.y - b.y) < 0;
}

bool ccw(point a, point b, point c) {
  return a.x * (b.y - c.y) + b.x * (c.y - a.y) + c.x * (a.y - b.y) > 0;
}

double ang(point a, point o, point b) {
  a.x -= o.x;
  b.x -= o.x;
  a.y -= o.y;
  b.y -= o.y;
  return abs(atan2(a.x * b.y - b.x * a.y, a.x * b.x + a.y * b.y));
}

void convexhull(vector < point > &a) {
  sort(a.begin(), a.end(), &cmp);
  point p1 = a[0];
  point p2 = a.back();
  vector < point > up, down;
  up.pb(p1);
  down.pb(p1);
  for (int i = 1; i < a.size(); i++) {
    if (i == a.size() - 1 || cw(p1, a[i], p2)) {
      while (up.size() > 1 && !cw(up[up.size() - 2], up.back(), a[i])) {
        up.pop_back();
      }
      up.pb(a[i]);
    }
    if (i == a.size() - 1 || ccw(p1, a[i], p2)) {
      while(down.size() > 1 && !ccw(down[down.size() - 2], down.back(), a[i])) {
        down.pop_back();
      }
      down.pb(a[i]);
    }
  }
  a.clear();
  for (auto to : up) {
    a.pb(to);
  }
  for (int i = down.size() - 2; i > 0; i--) {
    a.pb(down[i]);
  }
}

double ans[123];

main() {
  int n;
  scanf("%d", &n);
  vector < point > a;
  for (int i = 1; i <= n; i++) {
    double x, y;
    cin >> x >> y;
    a.pb(point(x, y, i));
  }
  convexhull(a);
  for (int i = 0; i < a.size(); i++) {
    ans[a[i].i] = (pi - ang(a[(i - 1 + a.size()) % a.size()], a[i], a[(i + 1) % a.size()])) / (pi * 2);
  }
  cout << fixed << setprecision(12);
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 256
/*Hatsune Miku 4ever!*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _for(i,a,b) for(int i = (a);i < b;i ++)
#define _rep(i,a,b) for(int i = (a);i > b;i --)
#define INF 0x3f3f3f3f
#define lowbit(x) ((x)&(-x))
#define pb push_back
#define MIKU 39
#define Design ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define debug() printf("Miku Check OK!\n")
#define maxn 200039

int n;
int a[maxn], b[maxn];
int main()
{
	scanf("%d",&n);
	_for(i,1,n+1)
		scanf("%d",&a[i]);
	_for(i,1,n+1)
		scanf("%d",&b[i]);
	
	sort(b+1,b+1+n,greater<int>());

	int l = -1, r = -1;
	int val = -1;
	_for(i,1,n+1)
	{
		if(a[i]==b[i] && l==-1)
		{
			val = a[i];
			l = i;
		}
		if(a[i]!=b[i] && l!=-1 && r==-1)
			r = i-1;
	}
	if(r==-1 && l!=-1)
		r = n;
	int ptr = 1;
	int solvecnt = 0;
	
	if(r!=-1)
	_for(i,l,r+1)
	{
		while(ptr <= n && (a[ptr]==val || b[ptr]==val))
			ptr ++;
		if(ptr > n)
			break;
		swap(b[ptr],b[i]);
		solvecnt ++;
	}
	
	if(r==-1 || solvecnt==r-l+1)
	{
		printf("Yes\n");
		_for(i,1,n+1)
			printf("%d ",b[i]);
	}
	else
		printf("No");
	return 0;
}

Measured memory_bytes: 5392
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
#include<assert.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")
#define charsize 100005 //10^5+5

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a= c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod_MOD1(ll n){n+= n<0?((-n)/MOD1+1)*MOD1:0; return n%=MOD1;}
ll mod_p(ll n ,ll p){n+= n<0?((-n)/p+1)*p:0; return n%=p;}
ll change_into_num(char s[] , ll len, ll p){ return !p ? 0 : POW(10,p-1)*(s[len-p]-'0') + change_into_num(s,len,p-1); }

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

int main(void){
    // char ;
    ll n,k;
    ll ans=0;
    scanf("%lld%lld",&n,&k);
    // ll [n];
    ans=k;
    rep(i,1,n){
        ans*=(k-1);
    }

    
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3
import sys
import numpy as np
input = sys.stdin.readline
n=int(input())
A =  list(map(int,input().split()))
B = []
ans = A[0]
for i in range(1,n):
    ans = ans ^ A[i]


for i in range(n):
    B.append(ans ^ A[i])
L=[str(a) for a in B]
L=" ".join(L)
print(L)

Measured memory_bytes: 58748
#include<iostream>
#include <string.h>
#include<stdio.h>
#include <math.h>
using namespace std;

int main() {
	int N, ans = 0;
	string S;

	cin >> N >> S;

	for (int i = 0; i < N; i++) {
		if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') {
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
using ld = long double;
 
// ------------------------------------------------------------------------------------------------

ll n, k, l;
vll a, b;
map<pll, ll> cnt;

ll find(ll x, vll &p) {
    if (p[x] != x) {
        p[x] = find(p[x], p);
    }
    return p[x];
}

void unify(ll x, ll y, vll &p) {
    ll px = find(x, p), py = find(y, p);
    p[py] = px;
}

int main() {
    fast_io; cout_precision;
    cin >> n >> k >> l;
    a.resize(n + 1); b.resize(n + 1);
    for (ll i = 1; i <= n; i++) {
        a[i] = i; b[i] = i;
    }
    for (ll i = 0, p, q; i < k; i++) {
        cin >> p >> q;
        unify(p, q, a);
    }
    for (ll i = 0, r, s; i < l; i++) {
        cin >> r >> s;
        unify(r, s, b);
    }
    for (ll i = 1; i <= n; i++) {
        cnt[{find(i, a), find(i, b)}]++;
    }
    for (ll i = 1; i <= n; i++) {
        cout << cnt[{find(i, a), find(i, b)}] << ' ';
    }
    cout << endl;
}

Measured memory_bytes: 15104
n = int(input())  # ���l
v = input().split()  # �󔒋�؂�Ń��X�g��
c = input().split()  # �󔒋�؂�Ń��X�g��

ans = 0
for i in range(n):
    if int(v[i]) > int(c[i]):
        ans += int(v[i]) - int(c[i])
print(ans)


Measured memory_bytes: 2940
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mp make_pair
#define f first
#define s second
#define pb push_back

const int N = 3e4 + 5;
const int M = 1e6 + 5;
const int Q = 2e5 + 5;
const int OO = 1e9;
const int mod = 1e9 + 7;

ll a,b,k;

int main() {

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

    cin >> a >> b >> k;

    ll f = min(a,k);

    a -= f, k -= f;

    f = min(b,k);

    b -= f;

    cout << a << ' ' << b << '\n';

    return 0;
}

Measured memory_bytes: 256
import itertools

N = int(input())
P = "".join(list(map(str,input().split())))
Q = "".join(list(map(str,input().split())))

tmp = [i for i in range(1,N+1)]
nums = []
for i in itertools.permutations(tmp):
    _ = []
    for j in i:
        _.append(str(j))
    nums.append("".join(_))

print(abs(nums.index(P) - nums.index(Q)))

Measured memory_bytes: 6040
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int x;
    cin >> x;
    n -= x;
  }
  n = max(n, -1);
  cout << n << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}




Measured memory_bytes: 3668
// ~maqsat~
/*
*/

// #pragma GCC target ("avx2")
// #pragma GCC optimization ("Ofast")
// #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")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define in insert
#define pb push_back
#define eb emplace_back
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define count1 __builtin_popcountl
#define debug(x) cerr << (#x) << " = " << (x) << "\n"
#define ACCELERATE ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> inline void cmin(T &a, T b) { a = min(a, b); }
template <class T> inline void cmax(T &a, T b) { a = max(a, b); }

const int oo = 0x3f3f3f3f;
const ll N = 1e5 + 345;
const ll MOD = 1e9 + 7;
const ll INF = 1e10 + 9;
const db EPS = 1e-9;
const db PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

int main() {
    fre("");
    ACCELERATE;

    int n;
    cin >> n;

    pair<double, double> a[n+5];
    for(int i = 0; i < n; i++) cin >> a[i].F >> a[i].S;

    vector<int> v(n);
    iota(all(v), 0);

    double cnt = 0;
    double sum = 0;
    do {
    	cnt++;
    	double tot = 0;
    	for(int j = 0; j < n-1; j++) {
    		int i = v[j];
    		int k = v[j+1];
    		double dis = (a[i].F - a[k].F) * (a[i].F - a[k].F) + (a[i].S - a[k].S) * (a[i].S - a[k].S);
    		dis = sqrt(dis);
    		tot += dis;
    	}
    	sum += tot;
    } while(next_permutation(all(v)));


    cout << fixed << setprecision(6);
	cout << sum / cnt << '\n';

    return 0;
}
/*
 
*/


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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    int N, W;
    cin >> N >> W;
    int v[101], w[101];
    for(int i=1;i<=N;i++) cin >> v[i] >> w[i];

    static int dp[101][10001];
    for(int n=1;n<=N;n++){
        for(int we=1;we<=W;we++){
            if(we >= w[n]) dp[n][we] = max(dp[n-1][we], dp[n-1][we-w[n]]+v[n]);
            else dp[n][we] = dp[n-1][we];
        }
    }

    cout << dp[N][W] << endl;
    
    return 0;
}


Measured memory_bytes: 7104
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();

        int[][] dp = new int[s.length()+1][t.length()+1];


        for(int i = 1 ; i <= s.length();i++)
        {
            for(int j = 1 ; j <= t.length() ;j++)
            {
                if(s.charAt(i-1) == t.charAt(j-1))
                {
                    dp[i][j] = dp[i-1][j-1]+1;
                }else
                {
                    dp[i][j] = Math.max(dp[i-1][j],dp[i][j-1]);
                }
            }
        }
        int i = s.length();
        int j = t.length();
        char[] lcs = new char[dp[i][j]];
        int index = lcs.length;
        while (i > 0 && j > 0)
        {
            // If current character in X[] and Y are same, then
            // current character is part of LCS
            if (s.charAt(i-1) == t.charAt(j-1))
            {
                // Put current character in result
                lcs[index-1] = s.charAt(i-1);

                // reduce values of i, j and index
                i--;
                j--;
                index--;
            }
            // If not same, then find the larger of two and
            // go in the direction of larger value
            else if (dp[i-1][j] > dp[i][j-1])
                i--;
            else
                j--;
        }
        StringBuilder b = new StringBuilder();
        for(i  = 0 ; i < lcs.length ;i++)
        {
            b.append(lcs[i]);
        }
        System.out.println(b);

    }
}


Measured memory_bytes: 81100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
#define ci(n,a)   vi a(n); rep(i,(n)) cin>>a[i];
#define rep(i,n)  for(ll i = 0; i < (n); ++i)
#define red(i,n)  for(ll i = (n)-1; i >= 0; --i)
#define all(a)    begin(a),end(a)
#define pb(a)     push_back(a)
#define mp(a,b)   make_pair(a,b)
#define yn(a)     cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll INF = 1e9+7, LINF = 1e18;


int main(int argc,char* argv[])
{
    ll n,q,l,r;
    string s;
    cin>>n>>q>>s;
    ll a[n]={0};
    rep(i,n-1)a[i+1]=a[i]+(s.substr(i,2)=="AC"); 
    rep(i,q){
        cin>>l>>r;
        cout<<a[r-1]-a[l-1]<<"\n";
    }
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
string s;
int ans=1<<30;
int main()
{
	cin>>s;
	for(int i=1;i<s.length();i++)
		if(s[i]!=s[i-1])
			ans=min(ans,max(i,int(s.length())-i));
	cout<<min(ans,int(s.length()))<<endl;
	return 0;
}

Measured memory_bytes: 512
//Max Profit Algorithm 2

import java.util.Scanner;

public class Main {
	public int min_val;
	public int[] max_profits;
	
	public Main(int n){
		max_profits = new int[n];
		min_val = 0;
		max_profits[0] = -99999;
	}
	
	int maxprofit(int n, int[] arr) {
		int max_profit ;
		this.min_val = arr[0];
                max_profit = arr[1] - this.min_val;
		
		for(int i = 1; i < n; i++) {
			this.max_profits[i] = arr[i] - this.min_val;
			
			if(arr[i] < this.min_val) {
				this.min_val = arr[i];
			}
			
			if(max_profits[i] > max_profit) {
				max_profit = max_profits[i];
			}
			
		}
		
		return max_profit;
		
	}
	
	



	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] arr = new int[n];
		Main m = new Main(n);
		
		for(int i = 0; i < n; i++) {
			arr[i] = in.nextInt();
		}
		
		System.out.println(m.maxprofit(n,arr));

	}

}


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

using namespace std;

typedef long long ll;

const int nax = 1e7+7;
const int MOD = 1e9+7;

void printarr(vector<int> &v){
    for(int x: v){
        cout<<x<<" ";
    }
    cout<<endl;
}

int main(){
    int n, m; cin>>n>>m;

    vector<int> switch_counts(m);

    vector<vector<int> > switches(m);

    vector<int> p(m);

    for(int i=0; i<m; i++){
        cin>>switch_counts[i];
        for(int sw=0; sw<switch_counts[i]; sw++){
            int x; cin>>x;
            x--;
            switches[i].push_back(x);
        }
    }

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

    int ans = 0;

    // n switches ... so 2^n states of switches
    for(int mask=0; mask < (1<<n); mask++){
        vector<int> curr_switches(n, 0);
        for(int i=0; i<n; i++){
            // if(mask>>i & 1)
            if(mask & (1<<i)){
                curr_switches[i] = 1;
            }
        }

        // cout<<"mask: "<<mask<<"  switches-> ";
        // printarr(curr_switches);

        int satis = 0;
        for(int bulb=0; bulb<m; bulb++){
            int cnt = 0;
            for(int sw=0; sw<switch_counts[bulb]; sw++){
                if(curr_switches[switches[bulb][sw]] > 0){
                    cnt++;
                }
            }
            if(cnt%2==p[bulb]){
                satis++;
            }
        }
        if(satis==m){
            // cout<<"mask: "<<mask<<endl;
            ans++;
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3636
/**
 *    author:  math2do
 *    created: 18.01.2020 20:59:26
**/

#include <bits/stdc++.h>

using namespace std;

class Graph {
private:
  int V;
  int E;
  vector <vector <int>> adj;
  int Dfs(int u, vector <int> &dp);
public:
  Graph(int n, int m);
  inline void addEdge(int src, int dst);
  int solve();
};

Graph::Graph(int n, int m) {
  this->V = n;
  this->E = m;
  adj.resize(n);
}

inline void Graph::addEdge(int src, int dst) {
  adj[src].push_back(dst);
}

const int ninf = - (1U << 31);

int Graph::Dfs(int u, vector <int> &dp) {
  if (dp[u] != -1) {
    return dp[u];
  }
  int age = 0;
  for (int v: adj[u]) {
    age = max(age, Dfs(v, dp));
  }
  return dp[u] = age + 1;
}


int Graph::solve() {
  vector <int> dp(V, -1);
  for (int i = 0; i < V; i++) {
    Dfs(i, dp);
  }

  int ans = ninf;
  for (int i = 0; i < V; i++) {
    ans = max(ans, dp[i]);
  }
  return ans - 1; 
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  Graph g(n, m);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    g.addEdge(x, y);
  }

  cout << g.solve() << '\n';
  return 0;
}


Measured memory_bytes: 8832
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

const int maxn = 2e5 + 7;

int n;
long long a[maxn], b[maxn];

void sort(long long *a, long long md) {
    int pos = n;
    for (int i = 0; i < n; i ++) {
        if (pos == n && a[i] >= md) pos = i;
        a[i] = a[i] & (md - 1);
    }
    inplace_merge(a, a + pos, a + n);
}

bool solve(long long limit) {
    long long ans = 0;
    int that = n - 1;
    for (int i = 0; i < n; i ++) {
        while (that >= 0 && a[i] + b[that] >= limit) that --;
        ans += n - 1 - that;
    }
    return ans & 1;
}
int main() {
#ifndef ONLINE_JUDGE
//    freopen("in.txt", "r", stdin);
#endif // ONLINE_JUDGE
        cin >> n;
        for (int i = 0; i < n; i ++) {
            scanf("%I64d", a + i);
        }
        for (int i = 0; i < n; i ++) {
            scanf("%I64d", b + i);
        }
        sort(a, a + n);
        sort(b, b + n);
        long long ans = 0;
        for (int i = 61; i >= 0; i --) {
            sort(a, (long long)2 << i);
            sort(b, (long long)2 << i);
            long long res =
                solve((long long)1 << i) ^
                solve((long long)2 << i) ^
                solve((long long)3 << i);
            ans |= res << i;
        }
        printf("%I64d\n", ans);
    return 0;
}


Measured memory_bytes: 4212
/*ॐॐ*/
/* I have already deleted My old account because somebody stole my code
and i have no idea how. If you are copying this code atleast make it look different.
Change variable names or change some Data structres or anything just make sure MOSS do not
Detect Anything.
Yours Faithfully
Shobhit Yadav */

/* I do not fear this new challenge. Rather like a true warrior I will rise to meet it. 
                                       -Prince Vegeta  */

 /* “Strength is the only thing that matters in this world. Everything else is just a delusion for the weak.” – Vegeta */

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

ll K,N;
/*ll freq[200005];*/
void solve(){
   /*memset(freq,0,sizeof(freq));*/
  cin>>N;
  bool flag = false;

  for(ll temp = N ; temp != 0 ; temp /= 10){
     
     if(temp%10 == 7){
      flag = true;
      break;
     }

  }


  if(flag)
    cout<<"Yes"<<'\n';


  else
    cout<<"No"<<'\n';

   

}



int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  
   solve();

  return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<string>
#include<cstdlib>
using namespace std;
int a,b;
int main(){
	cin>>a>>b;
	if(a==0&&b==0) cout<<"0\n";
	else cout<<(a-1)*(b-1);
 	return 0;
}

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

int main(){
    vector<int> v(3);
    rep(i,3) cin >> v[i];
    int maxv=0;
    int ans=0;
    rep(i,3) maxv=max(maxv,v[i]);
    rep(i,3){
        int y=(maxv-v[i])/2;
        ans+=y;
        v[i]+=2*y;
    }
    int count=0;
    rep(i,3){
        if(maxv==v[i]) count++;
    }
    if(count==1) ans++;
    if(count==2) ans=ans+2;
    
    cout << ans << endl;
    
    return 0;
}





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

int main()
{
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  while(A > 0 && C > 0){
    C -= B;
    if(C <= 0) break;
    A -= D;
  }
  if(C <= 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3556
n, m = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

import bisect
def is_ok(x):
    cnt = 0
    for i, a in enumerate(A):
        j = bisect.bisect_left(A, x-a)
        cnt += n-j
    if cnt >= m:
        return True
    else:
        return False

l = 0
r = 2*10**5+1
while l+1 < r:
    c = (l+r)//2
    if is_ok(c):
        l = c
    else:
        r = c

from itertools import accumulate
B = [0]+A
B = list(accumulate(B))
ans = 0
cnt = 0
for a in A:
    j = bisect.bisect_left(A, l-a)
    cnt += (n-j)
    ans += B[-1]-B[j]+a*(n-j)
ans -= (cnt-m)*l
print(ans)

Measured memory_bytes: 60748
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
int B[MAX_N][2];
ll dp[MAX_N][2];

void solve() {
	cin >> N;
	rep(i, 1, N + 1) {
		ll a; cin >> a;
		int cnt = 0;
		while((1 << (cnt + 1)) <= a) cnt++;
		if((1 << cnt) == a) {
			B[i][0] = cnt; B[i][1] = cnt;
		}
		else {
			B[i][0] = cnt; B[i][1] = cnt + 1;
		}
	}
	// rep(i, 0, N + 1) debug(pi(B[i][0], B[i][1]));
	rep(i, 1, N + 1)  {
		dp[i][0] = inf;
		dp[i][1] = inf;
	}
	rep(i, 1, N + 1) {
		dp[i][0] = min(dp[i - 1][0] + abs(B[i][1] - B[i - 1][0]), dp[i - 1][1] + abs(B[i][1] - B[i - 1][1]));
		dp[i][1] = min(dp[i - 1][0] + abs(B[i][0] - B[i - 1][0]), dp[i - 1][1] + abs(B[i][0] - B[i - 1][1]));
		if(B[i][0] != B[i][1]) {
			dp[i][0]++;
			dp[i][1]++;
		}
		// debug(i, dp[i][0], dp[i][1]);
	}
	cout << min(dp[N][0] + B[N][0], dp[N][1] + B[N][1]) / 2 << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 3840
#include<iostream>
#include<string>
 
using namespace std;
 
#define NMAX 1000
 
int main(){
 
    int n;
    string sqs[NMAX+1];
    int sqi[NMAX+1][NMAX+1];
    int sqw[NMAX+1][NMAX+1];
    int max;
 
    while(1){
 
        cin>>n;
        if(n==0) break;
 
        for(int i=0;i<=n;i++){
            for(int j=0;j<=n;j++){
                sqi[i][j]=0;
                sqw[i][j]=0;
            }
        }
 
        for(int i=0;i<n;i++){
            cin>>sqs[i];
        }
 
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                if(sqs[i-1][j-1]=='.') sqi[i][j]=1;
                else sqi[i][j]=0;
            }
        }
 
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                sqw[i][j]=sqi[j][i]+sqw[i-1][j]+sqw[i][j-1]-sqw[i-1][j-1];
            }
        }
 
        max=0;
 
        for(int i=1;i<=n;i++){
	  if(i+max-1>n) continue;
            for(int j=1;j<=n;j++){
	      if(j+max-1>n) continue;
          for(int k=max;i+k<=n&&j+k<=n;k++){
                    if((k+1)*(k+1)==sqw[i+k][j+k]-sqw[i+k][j-1]-sqw[i-1][j+k]+sqw[i-1][j-1]){
                        if(max<k+1) max=k+1;
                    }
            else break;
                }
            }
        }
        cout<<max<<endl;
    }
 
}

Measured memory_bytes: 10080
#include <bits/stdc++.h>
using namespace std;
#define M 30005
#define N 1005
int n,m,mi=100,i,j,pos,dpos;
int sp[105],num[26];

int main()
{

    string s;
    cin>>s;
    n=s.size();
    for(i=1;i<=n;i++)
        sp[i]=s[i-1]-'a';
    for(j=0;j<26;j++){
       for(i=1;i<=n;i++)
       if(sp[i]==j){dpos=i-1;
       pos=i;
       break;
       }
       for(i=pos;i<=n;i++)
       {
           if(sp[i]==j)
           {
               dpos=max(i-pos-1,dpos);
               pos=i;
           }
       }
       dpos=max(dpos,n-pos);
    mi=min(dpos,mi);
    }
    cout<<mi;
        return 0;
    }


Measured memory_bytes: 256
n = gets.to_i
a = gets.chomp.split.map(&:to_i)
a.sort!
res = Array.new(2)

res[0] = a.pop
a.sort_by! {|x| [(x - res[0] / 2).abs, (x - (res[0] + 1) / 2).abs].min }
res[1] = a[0]
puts res.join(" ")

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

using namespace std;
using ll = long long;

int main() {
  int n, m; ll k;
  cin >> n >> m >> k;
  int a[n], b[m];
  for(int i = 0; i < n; ++i) cin >> a[i];
  for(int i = 0; i < m; ++i) cin >> b[i];  
  long long pre_b[m], pre_a[n];
  pre_b[0] = b[0];
  pre_a[0] = a[0];
  for(int i = 1; i < m; ++i) {
    pre_b[i] = (ll)pre_b[i - 1] + (ll)b[i];
  }
  for(int i = 1; i < n; ++i) {
    pre_a[i] = (ll)pre_a[i - 1] + (ll)a[i];
  }  
  int answer = 0;
  for(int count = 0; count <= n; ++count) {
    long long check = (count == 0 ? 0 : pre_a[count - 1]);
    if(k >= check) {
      long long left = k - check;
      //find max number of books u can read with k == left;
      int pos = 0;
      if(pre_b[0] > left) {        
      } else if(pre_b[m - 1] <= left) {
        pos = m;
      } else {
        int L = 0;
        int R = m - 1;
        while(L <= R) {
          int mid = (L + R) / 2;          
          if(pre_b[mid] <= left) {
            if(mid < (m - 1) && pre_b[mid + 1] > left) {
              pos = mid + 1;
            }
            L = mid + 1;
          } else {
            if(mid > 0 && pre_b[mid - 1] <= left) {
              pos = mid;
            }
            R = mid - 1;
          }
        }
      }
      pos += count;
      answer = max(answer, pos);
    }
  }
  cout << answer << '\n';
  return 0;
}


Measured memory_bytes: 8228
N = int(input())
inputs = []
for i in range(N):
  s = input().split()
  inputs.append([i, s[0], int(s[1])])

inputs.sort(key=lambda x: x[2], reverse=True)
inputs.sort(key=lambda x: x[1])
for x in inputs:
  print(x[0] + 1)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
const int maxN=2e5+10;
int N;
long long A[maxN],presum[maxN],ans=0LL;
map<long long,long long> cnt;
int main()
{
	cin>>N;
	for(int i=1;i<=N;i++) cin>>A[i];
	for(int i=1;i<=N;i++) presum[i]=presum[i-1]+A[i];
	for(int i=1;i<=N;i++) cnt[presum[i]]++;
	for(int i=N;i>=1;i--)
	{
		ans+=cnt[presum[i]]-1LL;
		if(presum[i]==0LL) ans++;
		cnt[presum[i]]--;
	}
	cout<<ans<<endl;
	return 0;
}
/*
6
1 3 -4 2 2 -2
Output:3

7
1 -1 1 -1 1 -1 1
Output:12

5
1 -2 3 -4 5
Output:0

3
0 0 0
Output:6

5
1 -1 2 -2 3
Output:3
*/

Measured memory_bytes: 15872
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
inline void YES(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr ll BIGP = 1000000007L;
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> L(N);
    rep(i, N) cin >> L[i];
    sort(L);
    //
    ll ans = 0;
    for(int i=0;i<N;++i)
    {
        for (int j = i+1; j < N; ++j)
        {
            for (int k = j+1; k < N; ++k)
            {
                //
                auto arr = std::array<ll,3>({ L[i],L[j] ,L[k] });
                sort(arr);
                bool valid = arr[0] != arr[1] && arr[0] != arr[2] && arr[1] != arr[2];
                if (valid && (arr[2] < arr[0] + arr[1]))
                {
                    ++ans;
                }
            }
        }
    }
    cout << ans;
    //

    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <queue>
using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

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

    cout << N*(N-1)/2 + M*(M-1)/2 << endl;

    return 0;
}


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

int main() {
    string a , b;
    cin>>a>>b;
    int result =0;
    for (int i =0 ; i<a.size(); i++){
     if (a[i] != b[i]){
         result ++;
     }   
    }
    cout<<result<<endl;
	return 0;
}

Measured memory_bytes: 3852
n=int(input())

def divisore(n):
    divisors=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

d=divisore(n)

ans=0
for i in d[1:]:
  cand=i-1
  if n//cand==n%cand:
    ans+=cand

print(ans)

Measured memory_bytes: 66376
#include<stdio.h>

struct Card{
  char suit;
  char value;
};

void sum(struct Card xu[], int n){
  int i, j;
  struct Card t;
  for ( i = 0; i < n; i++ ){
    for ( j = n-1; j >= i+1; j-- ){
      if ( xu[j].value < xu[j-1].value ){
	t = xu[j]; xu[j] = xu[j-1]; xu[j-1] = t;
      }
    }
  }
}

void num(struct Card xu[], int n){
  int i, j, min;
  struct Card t;
  for ( i = 0; i < n; i++ ){
    min = i;
    for ( j = i; j < n; j++ ){
      if ( xu[j].value < xu[min].value ) min = j;
    }
    t = xu[i];xu[i] = xu[min]; xu[min] = t;
  }
}

void tum(struct Card xu[], int n){
  int i;
  for ( i = 0; i < n; i++ ){
    if ( i ) printf(" ");
    printf("%c%c", xu[i].suit, xu[i].value);
  }
  printf("\n");
}

int rum(struct Card fan[], struct Card malon[], int n){
  int i;
  for ( i = 0; i < n; i++ ){
    if ( fan[i].suit != malon[i].suit ) return 0;
  }
  return 1;
}

#define N 110
int main(){
  struct Card fan[N], malon[N];
  int n, i;
  char ch;

  scanf("%d%c", &n, &ch);
 for ( i = 0; i < n; i++ ){
    scanf("%c%c%c", &fan[i].suit, &fan[i].value, &ch);
  }

  for ( i = 0; i < n; i++ ) malon[i] = fan[i];

  sum(fan, n);
  num(malon, n);

  tum(fan, n);
  printf("Stable\n");
  tum(malon, n);
  if ( rum(fan, malon, n) ){
    printf("Stable\n");
  } else {
    printf("Not stable\n");
  }

  return 0;
}



Measured memory_bytes: 2036