akhauriyash/Code-Regression huggingface dataset:
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define mod 1000000007

int main() {
	string s;
	cin >> s;
	int ans[100000] = {};
	char now = s[0];
	int cnt = 1;
	int beforeRind = 0;
	int l = s.length();
	for (int i = 1; i < l; i++) {
		if (s[i] == now) {
			cnt++;
		} else {
			if (s[i] == 'R') {
				// RLLL ...LLRのとき
				// 奇数番目のLはbeforeRind + 1のLの位置に
				// 偶数番目のLはbeforeRindに存在
				ans[beforeRind + 1] += cnt / 2 + cnt % 2;
				ans[beforeRind] += cnt / 2;
			} else {
				// LRRR ... RRLのとき
				// 後ろから数えて奇数番目のRはi - 1に
				// 後ろから数えて偶数番目のRはiに存在
				ans[i - 1] += cnt / 2 + cnt % 2;
				ans[i] += cnt / 2;
			}
			now = s[i];
			cnt = 1;
		}
		// cout << i << " " << now << " " << cnt << endl;
		if (s[i] == 'R') beforeRind = i;
	}
	ans[beforeRind + 1] += cnt / 2 + cnt % 2;
	ans[beforeRind] += cnt / 2;

	for (int i = 0; i < l; i++) {
		cout << ans[i];
		if (i == l - 1)
			cout << endl;
		else
			cout << " ";
	}
}

Measured memory_bytes: 1024
from functools import reduce
from operator import xor

N = int(input())
AS = list(map(int, input().split()))
if N == 2:
    print(*AS, sep=" ")
    exit()
if N == 3:
    r0 = 0
    r1 = r0 ^ AS[2]
    r2 = r1 ^ AS[0]
    print(r0, r1, r2)
    exit()

"""
input
0b00000000000000000000000010100
0b00000000000000000000000001011
0b00000000000000000000000001001
0b00000000000000000000000011000

output
0b00000000000000000000000011010
0b00000000000000000000000000101
0b00000000000000000000000000111
0b00000000000000000000000010110

myanswer
0b00000000000000000000000000000
0b00000000000000000000000011111
0b00000000000000000000000011101
0b00000000000000000000000001100
"""
# for a in AS:
#     print(f"{a:#031b}")
r = [0] * N
for i in range(1, N):
    r[i] = r[i - 1] ^ AS[i - 1] ^ AS[i]

# for a in r:
#     print(f"{a:#031b}")

rest = reduce(xor, r[1:])
d = AS[0] ^ rest
for i in range(N):
    r[i] ^= d

print(*r)
# check
# total = reduce(xor, r)
# for i in range(N):
#     print(total ^ r[i] == AS[i])


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define DBGDO(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	vl a(n);
	FOR(i,0,n) cin >> a[i];
	
	ll res = 1;
	FOR(i,0,n) res *= 3;

	ll k = 1;
	FOR(i,0,n) if (a[i] % 2 == 0) k *= 2;

	cout << res-k << endl;


}



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

using namespace std;

long long gcd(long long a, long long b) { // Greatest Common Denominator - Euclidean Algorithm
	if (b == 0) return a;
	return gcd(b, a % b);
}

long long lcm(long long a, long long b) { // Lowest Common Multiple
	return (a * b) / gcd(a, b);
}

long long solve(long long x, long long c, long long d) { 
	return x - x / c - x / d + x / lcm(c, d);
}

int main() {
	
	long long A, B, C, D; 
	cin >> A >> B >> C >> D;

	long long b = B - B / C - B / D + B / lcm(C, D); 
	// // removes multiples of B and C and takes care of the duplicates for numbers <= A-1
	long long a =  A - 1 - (A - 1) / C - (A - 1) / D + (A - 1) / lcm(C, D);
	cout << b - a;
	// cout << solve(B, C, D) - solve(A - 1, C, D);
	return 0;
}


Measured memory_bytes: 256
use std::str::FromStr;
use std::io::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(&mut i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: &mut R, o: &mut W) {
    let mut i = AtRead::from(i);
    let (n, k) = i.read2::<usize, usize>();
    writeln!(o, "{}", solve(n, k)).unwrap();
}
fn solve(n: usize, k: usize) -> usize {
    let mut r = 0;
    for b in k + 1..n + 1 {
        r += (n / b) * (b - k);
        if k == 0 {
            r -= 1;
        }
        let m = n % b + 1;
        if m > k {
            r += m - k;
            if k == 0 && n < b {
                r -= 1;
            }
        }
    }
    return r;
}

struct AtRead<'a, R: BufRead + 'a> {
    r: &'a mut R,
    s: String,
}

macro_rules! fn_read {
        {$f:ident($($v:ident: $t:ident),*)} => {
            fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.next().split(' ');
                $(
                    let $v = next(i);
                )*
                ($($v),*)
            }
        };
    }

impl<'a, R: BufRead + 'a> AtRead<'a, R> {
    fn from(r: &'a mut R) -> Self {
        AtRead {
            r: r,
            s: String::new(),
        }
    }
    fn next(&mut self) -> &str {
        self.s.clear();
        self.r.read_line(&mut self.s).unwrap();
        self.s.trim()
    }

    fn_read! { read2(v1: T1, v2: T2) }
}

fn next<'a, T: FromStr, I: std::iter::Iterator<Item = &'a str>>(i: &mut I) -> T {
    i.next().unwrap().parse().ok().unwrap()
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

const int MAX_S = 300015000;

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin>>N;
    set<int> ans;
    if (N==3){
        cout<<"2 5 63\n";
        return 0;
    }
    if (N>=15000){
        FOR(i,1,30000)
            if (i%2==0||i%3==0) ans.ins(i);
        int rm = 20000-N;
        FOR(i,1,rm){
            ans.erase(i*6);
        }
        bool first=true;
        for(auto e:ans){
            if (!first) cout<<" ";
            else first=false;
            cout<<e;
        }cout<<"\n";
        return 0;
    }
    int sum=0;
    FOR(i,7,30000){
        if (i%2==0||i%3==0) ans.ins(i), sum+=i;
        if (ans.size()==N-2) break;
    }
    int t = sum%6;
    if (t==0) ans.ins(2), ans.ins(4);
    if (t==1) ans.ins(2), ans.ins(3);
    if (t==2) ans.ins(4), ans.ins(6);
    if (t==3) ans.ins(3), ans.ins(6);
    if (t==4) ans.ins(2), ans.ins(6);
    if (t==5) ans.ins(3), ans.ins(4);
    bool first=true;
    for(auto e:ans){
        if (!first) cout<<" ";
        else first=false;
        cout<<e;
    }cout<<"\n";
    return 0;
}


Measured memory_bytes: 4600
#include<bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <string>

int main(){
	int n;
	std::string s, t;
	std::cin >> n >> s >> t;
	for(int i=0; i<n; i++){
		std::cout << s[i];
		std::cout << t[i];
	}
	std::cout << std::endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] l = new int[n];
        for(int i = 0; i < n; i++){
            l[i] = Integer.parseInt(sc.next());
        }
        
        Arrays.sort(l);
        
        List<Integer> list = new ArrayList<>();
        for(int i = 0; i < n; i++){
            list.add(l[i]);
        }
        
        int ans = 0;
        for(int a = 0; a < n-2; a++){
            for(int b = a+1; b < n-1; b++){
                int x = lowerBound(list, b+1, n, l[a]+l[b]);
                ans += x - (b+1);
            }
        }
        
        System.out.println(ans);
    }
    
    private static int lowerBound(List<Integer> list, int from, int to, int key){
        
        Comparator<Integer> c = (Integer o1, Integer o2) -> {
            return (o1.compareTo(o2) >= 0) ? 1 : -1;
        };
        
        int index = ~Collections.binarySearch(list, key, c);
        if(index < from){
            index = from;
        }else if(index > to){
            index = to;
        }
        
        return index;
    }
}

Measured memory_bytes: 50976
s = input()

n = len(s)

stack = [ s[0] ]

rem = 0
# print(stack)

# 0 search

ss = len(stack)

for i in range(1,n):


    if ss==0 or stack[-1] == s[i]:

        stack.append(s[i])
        ss+=1
        
        continue


    if len(stack) > 0:
        stack.pop()
        ss -= 1

        i+=1
        rem +=2


print(rem)

        


Measured memory_bytes: 3956
from bisect import bisect_left
s = input()
t = input()

n = len(s)
s = s * 2


r = {}
for i, v in enumerate(s):
    if v in r.keys():
        r[v].append(i+1)
    else:
        r[v] = [i+1]

now = 0

lt = len(t)
for v in t:
    if v in r.keys():
        index = bisect_left(r[v], now % n + 1)
        tmp = r[v][index]
        now += tmp - now % n
    else:
        print(-1)
        exit()

print(now)

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

const int N=100005;
int C[N]={0};

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
       ll n;
       cin>>n;
       ll a[n];
       ll s=0;
       for(int i=0;i<n;i++)
       {
           cin>>a[i];
           C[a[i]]++;
           s+=a[i];
       }
       ll q;
       cin>>q;
       ll i=0;
       while(i<q)
       {
           ll b,c;
           cin>>b>>c;
           s=s+((c-b)*C[b]);
           C[c]+=C[b];
           C[b]=0;
           cout<<s<<endl;
           i++;
       }
    }
    return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

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

	string s, t;
	cin >> s >> t;

	vector<bool> letters(26, false);

	FOR(i, 0, s.size()){
		letters[s.at(i)-'a'] = true;
	}

	bool poss = true;
	FOR(i, 0, t.size()){
		if(!letters[t.at(i)-'a']){
			poss = false;
			break;
		}
	}

	if(!poss){
		cout << -1 << '\n';
		return EXIT_SUCCESS;
	}

	vvl dp(s.size(), vl(26, -1));
	FORD(i,0,s.size()){
		if(i < s.size()-1){
			FOR(j, 0, 26){
				dp[i][j] = dp[i+1][j];
			}
		}

		dp[i][s.at(i)-'a'] = i;
	}


	ll curPos = 0;
	ll jumps = 0;

	FOR(i, 0, t.size()){
		int next = dp[curPos][t.at(i)-'a'];
		if(next < 0){
			jumps++;
			curPos = dp[0][t.at(i)-'a'];
		}
		else{
			curPos = next;
		}
		curPos++;
		if(curPos >= s.size()){
			jumps++;
			curPos=0;
		}
	}

	cout << jumps*s.size()+curPos << '\n';

}


Measured memory_bytes: 24656
use std::io::stdin;
use std::cmp::min;

fn main() {
    let t: usize = {
        let mut line = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .last()
            .map(|s| s.parse().unwrap())
            .unwrap()
    };

    let ts: Vec<usize> = {
        let mut line = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace().map(|s| s.parse().unwrap()).collect()
    };

    println!("{}",
             ts.windows(2).map(|t2| min(t, t2[1] - t2[0])).sum::<usize>() + t);
}


Measured memory_bytes: 10492
def f(n,x):
    if n==0:return 0 if x<=0 else 1
    elif x<=1+a[n-1]:
        return f(n-1,x-1)
    else:
        return p[n-1]+1+f(n-1,x-2-a[n-1])


n,x=map(int,input().split())
a,p=[1],[1]

for i in range(n):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)

print(f(n,x))

Measured memory_bytes: 3064
player = ["A", "B", "C"]

cards = []
3.times do
    cards << gets.split(//)
end

i = 0
loop{
    name = cards[i][0]
    cards[i].delete_at(0)

    if cards[i].size == 0
        puts player[i]
        break
    end

    if name == "a"
        i = 0
    elsif name == "b"
        i = 1
    else
        i = 2
    end
}


Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1000003 ;

ll dp[110][310][110];//dp[index][weight][choose]

int main(){
  ll n,W;
  cin >> n >> W;
  ll w[n],v[n];
  rep(i,n){
    cin >> w[i] >> v[i];
  }
  ll x=w[0];
  rep(i,n)w[i]-=x;
  ll sum=0;
  rep(i,n)sum+=w[i];
  rep(i,n){
    rep(j,sum+1){
      rep(k,n){
        if(j-w[i]>=0){
          dp[i+1][j][k+1]=max(dp[i][j-w[i]][k]+v[i],dp[i][j][k+1]);
        }
        else{
          dp[i+1][j][k+1]=dp[i][j][k+1];
        }
      }
    }
  }
  ll ans=0;
  if(W-n*x>=sum){
    ll res=0;
    rep(i,n)res+=v[i];
    cout << res << endl;
    return 0;
  }
  for(ll i=1;i<=n && W-i*x>=0;i++){
    for(ll j=0;j<=min(W-i*x,300LL);j++){
      ll temp=dp[n][j][i];
      ans=max(ans,temp);
    }
  }
  cout << ans << endl;
return 0;}

Measured memory_bytes: 27904
#include<iostream>
#include<string.h>
using namespace std;
int a[100010];
int main(){
	string s;
	cin>>s;	
	int l=s.size();
	a[0]=1;
		for(int i=1;i<l;i++){
			a[i]=1;
//			cout<<a[i]<<"&&&&";
			if(s[i]==s[i-1]&&s[i]=='R'){
				a[i]+=a[i-1];
				a[i-1]=0;
//				cout<<"R:"<<a[i]<<" ";
			}	

		}
		for(int i=l-1;i>=0;i--){
			if(s[i-1]==s[i]&&s[i-1]=='L'){
				a[i-1]+=a[i];
				a[i]=0;
			}
			if(s[i]=='L'&&s[i-1]=='R'){

				if((a[i-1]+a[i])%2==0){
					a[i]=a[i-1]=(a[i-1]+a[i])/2;
				}
				else{
					if(a[i-1]%2!=0){
						a[i]=(a[i-1]+a[i])/2;
						a[i-1]=a[i]+1;
					}
					else{
						a[i-1]=(a[i-1]+a[i])/2;
						a[i]=a[i-1]+1;
					}
				}
			}
			
		}
		cout<<a[0];
		for(int i=1;i<l;i++){
			cout<<" "<<a[i];
		}
		cout<<endl;
	return 0;
}

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

#define deb(x) cerr<<"["#x<<" : "<<x<<" ]\n";

int main()
{
	int a, b;
	cin >> a >> b;
	if(a <= 8 and b <= 8) puts("Yay!");
	else puts(":(");
}


Measured memory_bytes: 3628
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define all(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
const int MAX = (int)2e5 + 5;

int main() {
	int sum = 0;
	bool dp[305] = {};
	dp[0] = true;
	rep(i, 3) {
		int v;
		cin >> v;
		sum += v;
		for (int j = 200; j > -1; j--) {
			if (dp[j]) dp[j + v] = true;
		}
	}
	if (sum % 2 == 0 && dp[sum / 2] == true) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

using namespace std;

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

    vector<char> ans;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == 'B') {
            if (ans.size() != 0) ans.pop_back();
        } else {
            ans.push_back(s[i]);
        }
    }


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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define debug(x) cout<<#x<<"="<<x<<endl;
using namespace std;

int main(void)
{
	LL n,K;
	scanf("%lld%lld",&n,&K);
	LL res=0;
	rep(i,0,n)
	{
		LL si;
		scanf("%lld",&si);
		LL a=abs(si);
		LL b=abs(si-K);
		//debug(a);debug(b);
		res+=(a<b?2ll*a:2ll*b);
	}
	printf("%lld",res);
	return 0;
}

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

ll mod=1000000007;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ll n,ans=1,i;
	cin>>n;
	for (i=1;i<=n;i++){
		ans=(ans*i)%mod;
	}
	cout<<ans;
	return 0;
}

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

int main(){
  string s;
  cin >> s;
  int counta = 0,countb = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == '0') {
      counta++;
    }
  }
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == '1') {
      countb++;
    }
  }
  cout << min(counta,countb)*2 << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
#include <queue>
#include <cstdlib>

using namespace std;

#define LL long long
#define INF 0x7fffffff
#define P 998244353

inline LL read(){
    LL x=0,f=1; char ch=getchar();
    while (ch<'0' || ch>'9') {if (ch=='-') f=-1; ch=getchar();}
    while (ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

struct Node{
	int x,y,d;
	Node (){}
	Node (int X,int Y,int D){
		x=X,y=Y,d=D;
	}
};

int visit[1010][1010],ans,dx[4]={0,0,-1,1},dy[4]={-1,1,0,0};
char mp[1010][1010];
int H,W,Sx,Sy;

inline bool check(int x,int y){
	if (x<1 || x>H) return 0;
	if (y<1 || y>W) return 0;
	if (visit[x][y]) return 0;
	return 1;
}
queue<Node>q;
inline void bfs(){
	
	while (!q.empty()){
		Node now = q.front(); q.pop();
		// printf("debug %d %d %d\n",now.x,now.y,now.d);
		for (int i=0; i<4; i++){
			int tx = now.x+dx[i], ty = now.y+dy[i], td = now.d+1;
			// printf("%d %d %d\n",tx,ty,td);
			if (!check(tx,ty)) continue;
			visit[tx][ty]=1;
			q.push(Node(tx,ty,td));
			
			ans = max(ans,td);
		}
	}
}

int main(){
	H=read(),W=read();
	for (int i=1; i<=H; i++){
		scanf("%s",mp[i]+1);
		for (int j=1; j<=W; j++){
			if (mp[i][j]=='#'){
				q.push(Node(i,j,0));
				visit[i][j]=1;
			}
		}
	}
	bfs();
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 17296
#include<stdio.h>
#include <iomanip>
#include <iostream>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include <random>
#include <chrono>

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

using namespace std;
int main() {
	int n,cnt=0;
	cin >> n;
	vector<int> l(n+1,INT_MAX);
	rep(i, n)cin >> l[i];
	sort(l.begin(), l.end());
	rep(i, n-2) {
		for (int j = i + 1; j < n-1 ; j++) {
			int k = j + 1;
			if (k == n) {
					break;
			}
			while (l[k] < l[i] + l[j]) {
				cnt++;
				k++;
				
			}
		}
	}
	cout << cnt;

}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <set>

int f(int n,int a,int b){
	int t = a-b;
	if(t<0)t+=n;
	if(t > n/2){
		return n-t;
	}else{
		return t;
	}
}

int main(){
	int n;
	while(true){
		std::cin >> n;
		if(n==0)break;
		std::set<int> nums;
		for(int i=1;i<n;i++){
			nums.insert((i*i)%n);
		}
		std::vector<int> buf(n/2,0);
		for(int a : nums){
			for(int b : nums){
				if(a!=b)buf[f(n,a,b)-1]++;
			}
		}
		for(int i=0;i<n/2;i++){
			std::cout << buf[i] << std::endl;
		}
	}
}

Measured memory_bytes: 1452
n,d=map(int,input().split())
xs = [list(map(int,input().split())) for i in range(n)]
ans=0
for i in range(n):
    for j in range(i+1,n):
        dist=0
        for k in range(d):
            dist+=(xs[i][k]-xs[j][k])**2
        for k in range(200):
            if dist == k*k:
                ans+=1
print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<bitset>
using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 1e+8
#define EPS 1e-8
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = (j); i < (k); i++)
int main(){
	int n;
	int change[] = {500,100,50,10,5,1};
	while(scanf("%d",&n),n){
		n = 1000-n;
		int ans = 0;
		while(n > 0){
			ans++;
			for(int i = 0; i < 6; i++){
				if(n - change[i] >= 0){
					n -= change[i];
					break;
				}
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1188
S = input()
T = input()

ans = "Yes"

def CheckDup(src, dest):
    dic = {}
    for i in range(len(src)):
        if src[i] in dic:
            if dic[src[i]] != dest[i]:
                return("No")
        else:
            dic[src[i]] = dest[i]
    return("Yes")

ans1 = CheckDup(S, T)
ans2 = CheckDup(T, S)

if ans1 == "No" or ans2 == "No":
    ans = "No"

print(ans)


Measured memory_bytes: 3632
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In,' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadLong;
            var A = cin.ReadLong;
            var B = cin.ReadLong;

            var ans1 = N / (A + B);
            ans1 *= A;
            var ans2 = N % (A + B) > A ? A : N % (A + B);

            WriteLine(ans1+ans2) ;
        }

    }


    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream,char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if(inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for(int i = 0;i < tmp.Length;i++)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }

        
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    string s; ll k; cin>>s>>k;
    rep(i,k){
        if(s[i]!='1'){
            cout<<s[i]<<endl;
            return 0;
        }
    }
    cout<<'1'<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
nm = len(str(N))-1
summ = 0
for i in range(nm):
    if i ==0:
      summ += 9
    elif i%2 ==0:
      summ += (10**(i+1)-10**(i))
if nm%2 == 0:
    summ += N-(10**nm)+1
print(summ)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int step[8][2] = {
    -1, -1,
    -1, 0,
    -1, 1,
    0, -1,
    0, 1,
    1, -1,
    1, 0,
    1, 1,
};
char matrix[50 + 5][50 + 5];
int main() {
    int h, w;
    while(cin >> h >> w) {
        for(int i = 1; i <= h; i++)
            for(int j = 1; j <= w; j++) {
                cin >> matrix[i][j];
                if(matrix[i][j] == '.')
                    matrix[i][j] = '0';
            }
        for(int i = 1; i <= h; i++)
            for(int j = 1; j <= w; j++)
                if(matrix[i][j] == '#')
                    for(int index = 0; index < 8; index++)
                        if(matrix[i + step[index][0]][j + step[index][1]] != '#')
                            matrix[i + step[index][0]][j + step[index][1]]++;
        for(int i = 1; i <= h; i++) {
            for(int j = 1; j <= w; j++)
                cout << matrix[i][j];
            cout << endl;
        }
    }
    return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin >> n >> m;
    n--;
    m--;
    cout << n*m << "\n";

    return 0;
}

Measured memory_bytes: 3600
def gu(n,a):
  ans=[0]*n
  for i in range(len(a)):
    ii=a[i]
    while True:
      if ii%2==0:
        ans[i]+=1
        ii=ii/2
      else:
        break
  return min(ans)
n=int(input())
a=list(map(int,input().split()))
print(gu(n,a))

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

int main(){
    int n,m,a;
    int day = 0;
    cin >> n >> m;
    rep(i,m){
       cin >> a;
       day += a;
    }
    if(n >= day){
        n -= day;
    }else{
        n = -1;
    }
    cout << n << endl;
}


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

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } initCpp;

i64 dp[100010][13];
const i64 M = 1000000007;
signed main() {
	string S;
	cin >> S;
	i64 k = 0;
	dp[0][0] = 1;
	REP(i, S.size()) {
		char c = S[i];
		if (c == '?') {
			REP(r, 13) {
				i64 s = 0;
				REP(j, 10) {
					s += dp[k][(j - r + 13) * 9 % 13];
				}
				dp[k + 1][r] = s % M;
			}
		} else {
			i64 d = c - '0';
			REP(r, 13) {
				i64 s = dp[k][(d - r + 13) * 9 % 13];
				dp[k + 1][r] = s % M;
			}
		}
		k += 1;
	}
	cout << dp[k][5] << endl;
}


Measured memory_bytes: 10704
#include <bits/stdc++.h>
using namespace std; 
using ll = long long;
#include <math.h>
double log10(double x);
int main() {
  int n;
  cin >> n;
  ll a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  ll ans = 1LL;
 /* for (int i = 0; i < n; i++) {
    if (a[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }*/
  for (int i = 0; i < n; i++) {
    //if (log10(a[i]) + log10(ans) > 18) {
    if (a[i] > 1000000000000000000LL / ans) {
      cout << -1 << endl;
      return 0;
    }
    ans *= a[i];
  }
  
  if (ans > 1000000000000000000LL /*|| ans < 0LL*/) {
    cout << -1 << endl;
  }
  else {
    cout << ans << endl;
  } 
  
} 
  



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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

struct scc{
    vector<vector<int>> graph,rgraph;
    vector<bool> done;
    vector<int> vs,cmp;
    const int size;
    int cnt;
    scc(vector<vector<int>> &graph):size(graph.size()),graph(graph),rgraph(graph.size()),done(graph.size()),cmp(graph.size()),cnt(0){
        //rep(v,0,size){
        for(int v=0; v<size; ++v){
            for(int u:graph[v]) rgraph[u].push_back(v);
        }
        //rep(v,0,size)
        for(int v=0; v<size; ++v){
            if(done[v]) continue;
            dfs(v);
        }
        fill(done.begin(),done.end(),false);
        for(int i=vs.size()-1; i>=0; --i){
            if(done[vs[i]]) continue;
            rdfs(vs[i],cnt);
            ++cnt;
        }
    }
    void dfs(int v){
        if(done[v]) return;
        done[v]=true;
        for(int u:graph[v]) dfs(u);
        vs.push_back(v);
    }
    void rdfs(int v,int k){
        if(done[v]) return;
        done[v]=true;
        cmp[v]=k;
        for(int u:rgraph[v]) rdfs(u,k);
    }
};

void solve(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> graph1(n);
    rep(i,0,m){
        int s,d;
        cin >> s >> d;
        --s;
        --d;
        graph1[s].push_back(d);
    }

    scc scc_(graph1);
    int cnt=scc_.cnt;
    vector<vector<int>> graph2(cnt);
    vector<int> cnt_in(cnt);
    rep(i,0,n) for(int j:graph1[i]){
        int a=scc_.cmp[i],b=scc_.cmp[j];
        if(a==b) continue;
        graph2[b].push_back(a);
        ++cnt_in[a];
    }

    ll mod=1000000007;
    vector<ll> memo(cnt);
    vector<bool> done(cnt);
    function<ll(int)> rec=[&](int v){
        ll &res=memo[v];
        if(done[v]) return res;
        done[v]=true;
        res=1;
        if(graph2[v].size()>0){
            ll tmp=1;
            for(int u:graph2[v]) tmp=tmp*(rec(u)+1)%mod;
            --tmp;
            res=(res+tmp)%mod;
        }
        return res;
    };
    rep(i,0,cnt) rec(i);
    ll ans=1;
    rep(i,0,cnt){
        if(cnt_in[i]>0) continue;
        ans=ans*(memo[i]+1)%mod;
    }
    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}

Measured memory_bytes: 3388
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;

int main(){
  ll n,k; cin >> n >> k;
  vector<int> l(n);
  rep(i,n){
     cin >> l[i];
  }
  sort(l.begin(),l.end(),greater<>());
  ll sum = 0;
  rep(i,k){
     sum += l[i];
     }
     print(sum);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()
template<class T> inline bool chmax(T &a, T b){
  if(a<b){a=b; return true;}
  return false;
}
template<class T> inline bool chmin(T &a, T b){
  if(a>b){a=b; return true;}
  return false;
}

int main(){
  ll N,W;
  cin >> N >> W;
  vector<ll> w(N);
  vector<ll> v(N);
  vector<vector<ll>> dp(N+1,vector<ll>(W+1,0));
  rep(i,0,N){
    cin >> w[i] >> v[i];
  }

  rep(i,0,N){
    rep(j,0,W+1){
      if(j>=w[i]){
        chmax(dp[i+1][j], dp[i][j-w[i]]+v[i]);
      }
      chmax(dp[i+1][j], dp[i][j]);
    }
  }
  cout << dp[N][W];
  
}


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

int main() {
  int N;
  cin >> N;
  
  if(N%10 == 7 || (N/10)%10 == 7 || (N/100)%10 == 7) {
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = LLONG_MAX/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

const ll N = 1e9+7;
const ll M = 2*1e5+5;
ll dp[M], invdp[M], inv[M];

ll modinv(ll a, ll m){
    ll b = m, u = 1, v = 0;
    while(b){
        ll t = a/b;
        a -= t * b; swap(a,b);
        u -= t * v; swap(u,v);
    }
    u %= m;
    if(u < 0) u += m;
    return u;

}

void expo(){
    dp[0] = 1;
    invdp[0] = 1;
    inv[0] = 1;
    rep(i,M){
        dp[i+1] = dp[i] * (i + 1) % N;
        inv[i+1] = N - inv[N%(i+1)] * (N/(i+1)) % N;
        invdp[i+1] = modinv(dp[i+1], N);
    }
}


ll comb(ll x, ll y){
    ll ans;
    if(y > 0) ans = dp[x] * (invdp[y] * invdp[x-y] %N) % N;
    else ans = 1;
    // cout << dp[x] << " " << invdp[y] << " " << invdp[x-y] << " " << ans << endl;
    return ans;
}


int main(){
    ll h,w; cin >> h >> w;
    ll a,b; cin >> a >> b;
    expo();
    vector<ll> dp(h-a);
    rep(i,h-a){
        dp[i] = comb(b+i-1, b-1);
    }
    ll res = 0;
    rep(i,h-a){
        ll temp = dp[i] * comb(w+h-b-2-i,w-b-1) % MOD;
        res = (res + temp) % MOD;
    }
    cout << res << endl;
}

Measured memory_bytes: 5632
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<char>> map(h, vector<char>(w));
    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++)
            cin >> map[i][j];
    int ans = 0;
    for (int i = 0; i < (1 << h); i++)
        for (int j = 0; j < (1 << w); j++) {
            vector<vector<char>> tmp(map);
            for (int x = 0; x < h; x++)
                if (i & (1 << x))
                    for (int y = 0; y < w; y++)
                        map[x][y] = '@';
            for (int y = 0; y < w; y++)
                if (j & (1 << y))
                    for (int x = 0; x < h; x++)
                        map[x][y] = '@';
            int cnt = 0;
            for (int x = 0; x < h; x++)
                for (int y = 0; y < w; y++)
                    if (map[x][y] == '#')
                        cnt++;
            /*cout << i << ' ' << j << ' ' << cnt << endl;
            for (int x = 0; x < h; x++) {
                for (int y = 0; y < w; y++)
                    cout << map[x][y];
                cout << endl;
            }*/
            if (cnt == k)
                ans++;
            map = tmp;
        }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n;
    cin>>n;
    int ans=0;
    int s2=0;
    int d[100];
    for(int i=0; i<n; i++){
        cin>>d[i];
        ans+=d[i];
        s2+=d[i]*d[i];
    }
    ans=(ans*ans-s2)/2;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lowbit(x) x & -x

using namespace std;

const int N = 2e5 + 10;

typedef long long LL;

LL n, k;
LL a[N], sum[N], c[N];

inline void insert(LL x) {
	for(; x <= n + 1; x += lowbit(x))
		c[x] += 1;
}

inline LL query(LL x) {
	LL ans = 0;
	for(; x; x -= lowbit(x)) 
		ans += c[x];
	return ans;
}

inline LL find(LL x) {
	LL mid, l = 1, r = n + 1;
	while(l <= r) {
		mid = l + ((r - l) >> 1);
		if(sum[mid] == x) return mid;
		else if(sum[mid] < x) l = mid + 1;
		else if(sum[mid] > x) r = mid - 1;
	}
	return mid;
}

int main() {
	cin >> n >> k;
	for(LL i = 1; i <= n; ++i) {
		cin >> a[i], a[i] -= k;
		sum[i] = sum[i - 1] + a[i];//记录前缀和 
		a[i] = sum[i];
	} 
	sum[n + 1] = 0;
	sort(sum + 1, sum + n + 2);
	LL ans = 0;
	for(LL i = 0; i <= n; ++i) {
		LL rk = find(a[i]);
		ans += query(rk);	
//		printf("rk = %d %d\n", a[i], query(rk));
		insert(rk);//更新要放在查询的后面 
	}
	printf("%lld", ans);
	return 0;
}

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

int main(){
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  if( a > b && a>c){
    for( int i =1 ;i<=k; i++){
      a *= 2;
    }
  }else if(b > a&&b>c){
    for( int i =1 ;i<=k; i++){
      b*= 2;
    }
  }else{
    for( int i =1 ;i<=k; i++){
      c *= 2;
    }
  }
  
  cout << a+b+c <<endl;
  return 0;
}


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

using namespace std;

int main()
{
    int a,b,c,n=0;
    cin >> a >> b >> c;
    for(int i = a; i<=b; i++)
    {
        if(c%i==0) { n++; }
    }

    cout << n << "\n";
    return 0;
}


Measured memory_bytes: 3104
#include "bits/stdc++.h"

using namespace std;


typedef long long ll;
typedef unsigned long long ull;
const int MOD=1e9+7;

struct RollingHash
{
    vector<ull> hash,pow;
    RollingHash(string s, ull _b=1000000007)
    {
        _b = _b;
        int sz = s.length();
        hash.assign(sz+1,0);
        pow.assign(sz+1,0);

        pow[0]=1;
        for(int i=0;i<sz;i++){
            pow[i+1]=pow[i]*_b;
        }
        for(int i=0;i<sz;i++){
            hash[i+1]=(hash[i]+s[i])*_b;
        }
    }
    ull get(int l,int r){
        return (hash[r]-hash[l]*pow[r-l]);
    }
};

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

    int n,m;cin>>n>>m;//??????n ?????¨???m
    string s;cin>>s;
    RollingHash hash1(s);
    set<ull> st;
    ll l=0,r=1;
    for(int i=0;i<m;i++){
        string q;cin>>q;
        if(q=="L++"){
            l++;
        }
        else if(q=="L--"){
            l--;
        }
        else if(q=="R++"){
            r++;
        }
        else{
            r--;
        }
        st.insert(hash1.get(l,r));
    }
    cout<<st.size()<<endl;
}

Measured memory_bytes: 21920
# -*- coding: utf-8 -*-
from itertools import accumulate
from bisect import bisect_left

N = int(input())
a = list(map(int, input().split()))

b = list(accumulate(a))

mi = bisect_left(b, b[N-1]/2)
m = max(min(b[mi-1], b[N-1] - b[mi-1]), min(b[mi],b[N-1] - b[mi]))
ans = b[N-1] - 2 * m
print(ans) 

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto x : v){cout << x << " ";} cout << endl
#define printVS(vs) for(auto x : vs){cout << x << endl;}
#define printVV(vv) for(auto v : vv){for(auto&& x : v){cout << x << " ";}cout << endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
typedef vector<vector<int>> Graph;
const int inf = 1e9;
const int mod = 1e9 + 7;

vector<string> getBoard(string s) {
    vector<string> t;
    stringstream ss(s);
    string line;
    while (getline(ss, line, '/')) {
        string temp = "";
        for (auto c : line) {
            if (c == 'b') {
                temp += 'b';
            } else {
                rep(i, c - '0') temp += '.';
            }
        }
        t.emplace_back(temp);
    }
    return t;
}

string make(vector<string> t) {
    string s = "";
    int cnt = 0;
    for (auto l : t) {
        cnt++;
        int n = 0;
        for (auto c : l) {
            if (c == 'b') {
                if (n > 0) {
                    s += n + '0';
                    n = 0;
                }
                s += 'b';
            } else {
                n++;
            }
        }
        if (n > 0) {
            s += n + '0';
            n = 0;
        }
        if (cnt < t.size()) s += '/';
    }

    return s;
}

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

    string s;
    while (cin >> s, s[0] != '#') {
        auto t = getBoard(s);

        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--, b--, c--, d--;
        swap(t[a][b], t[c][d]);

        cout << make(t) << endl;
    }

}

Measured memory_bytes: 3120
#include<stdio.h>

#define A(p1,p2) ((ps[p1].y-ps[p2].y)/(ps[p1].x-ps[p2].x))
#define C(p1,a) (ps[p1].y-a*ps[p1].x)

typedef struct{
  double x;
  double y;
}point;

int main(){
  double a,c,a1,c1;
  point ps[3],t;
  int i,comb[3][3]={{0,1,2},{1,2,0},{0,2,1}};
  while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",
	      &(ps[0].x),&(ps[0].y),&(ps[1].x),&(ps[1].y),
	      &(ps[2].x),&(ps[2].y),&(t.x),&(t.y))!=EOF){
    for(i=0;i<3;i++){
      ps[i].x-=t.x;
      ps[i].y-=t.y;
    }
    for(i=0;i<3;i++){
      if(ps[comb[i][0]].x*ps[comb[i][1]].x<0){
	a=A(comb[i][0],comb[i][1]);
	c=C(comb[i][0],a);
	if(ps[comb[i][0]].x*ps[comb[i][2]].x>0){
	  a1=A(comb[i][1],comb[i][2]);
	  c1=C(comb[i][1],a1);
	  printf("%s\n",(c1*c)<0?"YES":"NO");
	}else if(ps[comb[i][1]].x*ps[comb[i][2]].x>0){
	  a1=A(comb[i][0],comb[i][2]);
	  c1=C(comb[i][0],a1);
	  printf("%s\n",(c1*c)<0?"YES":"NO");
	}else{
	  printf("%s\n",c*ps[comb[i][2]].y<0?"YES":"NO");
	}
	break;
      }
    }
    if(i==3){
      printf("NO\n");
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
/*-*/

int main() {
	lnt N;
	std::cin >> N;
	lnt sq=1;
	for(;sq*sq<=N;sq++);
	std::vector<lnt> ans(N+1,0);
	for(int i=1;i<=sq;i++) for(int j=1;j<=sq;j++) for(int k=1;k<=sq;k++) {
		lnt x=i*i+j*j+k*k+i*j+j*k+k*i;
		if(x<=N) ans[x]++;
	}
	for(int i=1;i<=N;i++) {
		print(ans[i]);
	}
}


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;
typedef long long ll;

int ord[100010], low[100010];
int k;
vector<int> G[100010];
vector<pair<int, int>> bridge;
vector<int> articulation;
bool visit[100010] = {};

void dfs(int v, int p, int &k) {
    visit[v] = 1;
    ord[v] = k++;
    low[v] = ord[v];

    bool isArticulation = 0;
	int ct = 0;
    for (int i = 0; i < G[v].size(); i++) {
        if (!visit[G[v][i]]) {
            ct++;
            dfs(G[v][i], v, k);
            low[v] = min(low[v], low[G[v][i]]);
            if (~p && ord[v] <= low[G[v][i]]) isArticulation = 1;
            if (ord[v] < low[G[v][i]]) 
                bridge.emplace_back(min(v, G[v][i]), max(v, G[v][i]));
        }
        else if (G[v][i] != p) {
            low[v] = min(low[v], low[G[v][i]]);
        }
    }
    if (p == -1 && ct > 1) isArticulation = 1;
	if (isArticulation) articulation.push_back(v);
}

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int s, t;
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }

    int k = 0;
	for (int i = 0; i < n; i++){
		if (!visit[i]) dfs(i, -1, k);
	}
    sort(bridge.begin(), bridge.end());
	sort(articulation.begin(), articulation.end());

    for (int i = 0; i < bridge.size(); i++) {
        cout << bridge[i].first << " " << bridge[i].second << endl;
    }
    for (int i = 0; i < articulation.size(); i++) {
        //cout << articulation[i] << endl;
    }
}


Measured memory_bytes: 6988
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

const int CMax = 202;

int n, m, ti, ni, B[CMax][2];
long long A[CMax], teig, neig;

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

    for (int i = 0; i < n; i++) {
        cin >> A[i];
        if (A[i] > teig) {
            teig = A[i];
            ti = i;
        }
        if (A[i] < neig) {
            neig = A[i];
            ni = i;
        }
    }

    if (teig > abs(neig)) {
        for (int i = 1; i < n; i++) {
            while (A[i-1] > A[i]) {
                A[i] += teig;
                B[m][1] = i;
                B[m][0] = ti;
                if (A[i] > teig) {
                    teig = A[i];
                    ti = i;
                }
                m++;
            }
        }
    } else {
        for (int i = n-2; i >= 0; i--) {
            while (A[i+1] < A[i]) {
                A[i] += neig;
                B[m][1] = i;
                B[m][0] = ni;
                if (A[i] < neig) {
                    neig = A[i];
                    ni = i;
                }
                m++;
            }
        }
    }

    printf("%d\n", m);
    for (int i = 0; i < m; i++) {
        printf("%d %d\n", B[i][0] + 1, B[i][1] + 1);
    }
}



Measured memory_bytes: 256
import sys
alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
C = []
b = ""
for line in sys.stdin:
    a = line.lower()
    b += a
for i in range(len(alpha)):
    k = b.count(alpha[i])
    C.append(k)
for i in range(len(alpha)):
    print(alpha[i]+" :",C[i])


Measured memory_bytes: 5564
#include <iostream>
#include <vector>
#include <map>
using namespace std;

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

    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> cnt;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        ++cnt[a[i]];
    }
    int res = 0;
    int even = 0;
    for(auto elem: cnt){
        ++res;
        if(elem.second % 2 == 0) ++even;
    }

    if(even % 2 == 1) --res;

    cout << res << endl;


}

Measured memory_bytes: 8172