akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;
struct Process {
    char name[11];
    int t;
};
int first = 0;
int last = 0;
#define SIZE 100000
Process a[SIZE];

void enqueue(Process p, int np){
    a[last] = p;
    last++;
    last = last % SIZE;
}

Process dequeue(int np){
    Process q = a[first];
    first++;
    first = first % SIZE;
    return q;
}

int main(){
    int np, q, cur = 0;
    scanf("%d %d", &np, &q);
    for(int i=0; i<np; i++){
        scanf("%s %d", a[i].name, &(a[i].t));
        enqueue(a[i], np);
    }
    while(first != last){
        Process p = dequeue(np);
        p.t -= q;
        cur += q;
        if(p.t <= 0){
            cur += p.t;
            cout << p.name << ' ' << cur << endl;
            continue;
        }
        enqueue(p, np);
    }
}

/**
 * 
5 100
p1 150
p2 80
p3 200
p4 350
p5 20
**/


Measured memory_bytes: 4796
import java.io.*
import java.util.*
import java.lang.*
import java.lang.Math.*


fun bsCondOpCl(A: LongArray, L: Int, R: Int, C: Int, K: Int): Int {
    val N = A.size
    fun isCondition(A: LongArray, m: Int): Boolean {
        var cnt = 1
        var i = 0
        var sum = 0
        var nt = A[0] + K
        while (i < N) {
            if (sum >= C || A[i] > nt) {
                cnt++
                sum = 0
                nt = A[i] + K
            }

            if (cnt > m) return false

            if (sum < C && A[i] <= nt) {
                sum++
                i++
            }
        }
        return true
    }
    var l = L; var r = R
    while (l+1 < r) {
        val m = (l + r) / 2
        if (isCondition(A, m)) {
            r = m
        } else {
            l = m
        }
    }
    return r
}


fun solve() {
    val (N, C, K) = rd.readIntArray()
    val T = rd.readLongColumn(N).sorted()

    val ans = bsCondOpCl(T.toLongArray(), 0, N, C, K)
    println(ans)
}


//val rd = debug.Reader("agc", "011", "a", "sample-2")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!! }
    catch (e: Exception) { throw e }
    finally { rd.close() }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
data class IntPair(val first: Int, val second: Int)
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
    val readIntColumn: (Int) -> IntArray = { N -> (0 until N).map { readInt() }.toIntArray() }
    val readLongColumn: (Int) -> LongArray = { N -> (0 until N).map { readLong() }.toLongArray() }
    val close: () -> Unit = { br.close() }
    protected fun finalize() { close() }
}


Measured memory_bytes: 59452
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <limits>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int solve()
{
    int N;
    std::cin >> N;

    vector<int> A(N);
    for (int i = 0; i < N; ++i)
        std::cin >> A[i];

    vector<int> B(N);
    for (int i = 0; i < N; ++i)
        std::cin >> B[i];

    vector<int> C(N);
    for (int i = 1; i < N; ++i)
        std::cin >> C[i];

    int prev = -1;
    int sum = 0;
    for (int i = 0; i < N; ++i)
    {
        sum += B[A[i] - 1];

        if (A[i] - prev == 1)
            sum += C[A[i] - 1];

        prev = A[i];
    }

    return sum;
}

int main()
{
    std::cout << solve() << std::endl;

    return 0;
}


Measured memory_bytes: 256
def linearSearch(S, key):
    i = 0
    S.append(key)
    while S[i] != key:
        i += 1
    if i == len(S)-1:
        return False
    return True

def main():
    n = int(raw_input())
    S = [int(_) for _ in raw_input().split()]
    q = int(raw_input())
    T = [int(_) for _ in raw_input().split()]
    Sum = 0
    for t in T:
        if linearSearch(S[:], t): Sum += 1
    print Sum
    return 0

main()

Measured memory_bytes: 6936
import heapq

maxd = float('inf')
nv, ne, r = [int(n) for n in input().split(' ')]
vertices = {k: {} for k in range(nv)}
for i in range(ne):
    s, t, w = [int(n) for n in input().split(' ')]
    vertices[s][t] = w

q = []
heapq.heappush(q, (0, r))

dist = {v: maxd for v in vertices}
dist[r] = 0

while len(q):
    u = heapq.heappop(q)[1]

    for v in vertices[u]:
        alt = dist[u] + vertices[u][v]
        if alt < dist[v]:
            dist[v] = alt
            heapq.heappush(q, (alt, v))

[print(d) if d < maxd else print("INF") for v, d in dist.items()]

Measured memory_bytes: 103644
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int n,match[21],dp[1<<21];
int main() {
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++) {
			int a;
			scanf("%d",&a);
			match[i]+=a<<j;
		}
	for(int i=0;i<n;i++)
		if(1<<i&match[0])
			dp[1<<i]=1;
	for(int i=1;i<n;i++)
		for(int mask=1;mask+1<1<<n;mask++)
			if(__builtin_popcount(mask)==i&&dp[mask])
				for(int j=0;j<n;j++)
					if(!(1<<j&mask)&&1<<j&match[i])
						dp[mask|1<<j]=(dp[mask|1<<j]+dp[mask])%mod;
	printf("%d\n",dp[(1<<n)-1]);
	return 0;
}

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

using namespace std;

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

bool isnum(char c) {
    return (c == '2' || c == '3' || c == '4' || c == '5' || c == '6' || c == '7' || c == '8' || c == '9');
}

int ctoi(char c) {
    switch(c) {
        case '1': return 1;
        case '2': return 2;
        case '3': return 3;
        case '4': return 4;
        case '5': return 5;
        case '6': return 6;
        case '7': return 7;
        case '8': return 8;
        case '9': return 9;
    }
    return -1;
}

int encode(string s) {
    int ret = 0;
    rep(i, s.size()) {
        int tmp = ctoi(s[i]);
        if(tmp>0) {
            if(s[i+1]=='m') ret += tmp * 1000;
            else if(s[i+1]=='c') ret += tmp * 100;
            else if(s[i+1]=='x') ret += tmp * 10;
            else if(s[i+1]=='i') ret += tmp;
            i++;
        } else {
            if(s[i]=='m') ret += 1000;
            else if(s[i]=='c') ret += 100;
            else if(s[i]=='x') ret += 10;
            else if(s[i]=='i') ret += 1;
        }
    }
    return ret;
}

string decode(int x) {
    string ret = "";
    string s = to_string(x);
    char symbol[] = "ixcm";
    for(int i=s.size()-1, j=0; i>=0; i--, j++) {
        if(s[i] != '0') {
            ret = symbol[j] + ret;
            if(s[i] != '1') ret = s[i] + ret;
        }
    }
    return ret;
}

int main() {
    int N; cin >> N;
    rep(i, N) {
        string s, t; cin >> s >> t;
        cout << decode(encode(s) + encode(t)) << endl;
    }
}



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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  vector<int> west(N); //西から数えてi番目までのWの数
  vector<int> east(N); //東から数えてi番目までのEの数
  if(S[0] == 'W'){
    west[0] = 1;
  }
  if(S[N-1] == 'E'){
    east[N-1] = 1;
  }
  rep(i,N-1){
    west[i+1] = west[i] + ((S[i+1] == 'W') ? 1 : 0);
    east[N-i-2] = east[N-i-1] + ((S[N-i-2] == 'E') ? 1 : 0);
  }
  vector<int> diff(N);
  diff[0] = east[1];
  diff[N-1] = west[N-2];
  rep(i,N-2){
    diff[i+1] = east[i+2]+west[i];
  }
  /*
  rep(i,N){
    cout << i << ":" << "W:" << west[i] << ", E:" << east[i] << ", diff:" << diff[i] << endl;
  }
  */
  sort(diff.begin(), diff.end());
  cout << diff[0] << endl;
  return 0;
}

Measured memory_bytes: 4228
#include<iostream>

using namespace std;

int main(){
        string osero;
        cin>>osero;
        char now=osero[0];
        int result=0;
        for(int i=0;i<osero.length();i++){
                if(now!=osero[i]){
                        result++;
                        now=osero[i];
                }
        }
        cout<<result<<endl;
        return 0;
}





Measured memory_bytes: 512
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)

mod = 10 ** 9 + 7
ans = 1

# 番兵を追加
A.append(-1)
B.append(-1)

s, t = 0, 0
for x in range(N * M, 0, -1):
    # 行・列両方から指定されtる
    if x == A[s] and x == B[t]:
        s += 1
        t += 1

    # 行から指定される
    elif x == A[s]:
        s += 1
        ans = (ans * t) % mod

    # 列から指定される
    elif x == B[t]:
        t += 1
        ans = (ans * s) % mod

    # 特に指定を受けない
    else:
        tmp = (s * t - (N * M - x))
        # 置き場所がない
        if tmp == 0:
            print(0)
            exit()
        ans = (ans * tmp) % mod

print(ans)


Measured memory_bytes: 3188
import sys
import itertools
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
k,n=map(int,input().split())

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

c=k-(a[n-1]-a[0])

for i in range(0,n-1):
	c=max(c,a[i+1]-a[i])
	

print(k-c)



Measured memory_bytes: 26444
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll l,r,d;
int32_t main(){
CODE_START;
ll ans=0;
cin>>l>>r>>d;
for(ll i=l;i<=r;i++)
{
    if(i%d==0){
        ans++;
    }
}
cout<<ans<<endl;
}




Measured memory_bytes: 3608
n=int(input())
b=list(map(int,input().split()))

a=[b[0] for i in range(n)]

for i in range(len(a)-1):
    if a[i] <= b[i]:
        a[i+1]=b[i]
        
    if a[i] > b[i]:
        a[i]=b[i]
        a[i+1]=b[i]
    
print(sum(a))

Measured memory_bytes: 3064
x,y,z,k = gets.chomp.split().map(&:to_i)

A = gets.chomp.split().map(&:to_i).sort.reverse
B = gets.chomp.split().map(&:to_i).sort.reverse
C = gets.chomp.split().map(&:to_i).sort.reverse

ab = Array.new(x*y)
cur = 0
A.each do |i|
  B.each do |j|
    ab[cur] = i + j
    cur += 1
  end
end

ab.sort!
ab.reverse!
ab = ab.slice(0,k)

ans = Array.new(ab.size * z)
cur = 0
ab.each do |i|
  C.each do |j|
    ans[cur] = i + j
    cur += 1
  end
end

ans.sort!
ans.reverse!
ans.slice(0,k).each do |e|
  puts e
end

Measured memory_bytes: 64528
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	int q;
	cin >> q;
	bool elf = false;//false -> sonomama
	deque<char> que;
	rep(i, s.size()) que.emplace_back(s[i]);
	int res = 0;
	rep(i, q) {
		int a; cin >> a;
		if (a == 1) {
			elf = elf ? false : true;
			res++;
		}
		else {
			int f; char c;
			cin >> f >> c;
			if (f == 1) {
				if (elf) que.emplace_back(c);
				else que.emplace_front(c);
			}
			else {
				if (elf) que.emplace_front(c);
				else que.emplace_back(c);
			}
		}
	}
	if (res % 2 != 0) reverse(all(que));
	for (auto& c : que) cout << c;
	cout << endl;
	return 0;
}

Measured memory_bytes: 976
#include <bits/stdc++.h>
using namespace std;
int x[102];
int main(){
    int n;
    scanf("%d", &n);
    for(int i=1;i<=n;i++) scanf("%d", &x[i]);
    int ans = 2e9;
    for(int i=1;i<=100;i++){
        int temp = 0;
        for(int j=1;j<=n;j++){
            temp += (x[j]-i)*(x[j]-i);
        }
        ans = min(ans, temp);
    }
    printf("%d\n", ans);   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n); for(ll i = 0; i < (ll)n; i++)
int facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
      sum *= i;
    return sum;
}


int main(){
  ll n; cin >> n;
  ll k = facctorialMethod(n);
  vector<int> v(n);
  rep(i, n)
    v[i] = i+1;
  
  vector<int> P(n),Q(n);
  rep(i, n) cin >> P[i];
  rep(i, n) cin >> Q[i];
  int p, q; 
 
  rep(i, k){
    if(P == v) {p = i+1; break;} 
    next_permutation(v.begin(),v.end());
  }
  rep(i, n)
    v[i] = i+1;
  
  rep(i, k){
    if(Q == v) {q = i+1; break;}
    next_permutation(v.begin(),v.end());
  }
  
  cout << abs(p-q) << endl;
}

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

#define INF INT_MAX
#define FF first.first
#define FS first.second
#define S second
typedef pair<int,int> P;
typedef pair<P,int> PP;

int main(void)
{
	int v,e,r;
	int s,t,d;
	int i,j;
	int leng[1000];
	int flg=0;
	int cnt=0;
	PP p[2000];
	
	cin>>v>>e>>r;
	for(i=0;i<e;i++){
		cin>>s>>t>>d;
		p[i] = PP(P(s,t),d);
	}
	
	//cout<<p[0].FF<<" "<<p[0].FS<<" "<<p[0].S<<endl;
	
	for(i=0;i<v;i++) leng[i]=INF;
	leng[r]=0;
	while(1){
		bool updete=false;
		for(i=0;i<e;i++){
			if(leng[p[i].FF]!=INF&&leng[p[i].FS]>leng[p[i].FF]+p[i].S){
				leng[p[i].FS]=leng[p[i].FF]+p[i].S;
				updete=true;
			}
		}
		if(!updete) break;
		if(cnt==v-1){
			flg=1;
			break;
		}
		cnt++;
	}
	
	for(i=0;i<v;i++){
		if(flg==1){
			cout<<"NEGATIVE CYCLE"<<endl;
			break;
		}
		else if(leng[i]==INF) cout<<"INF"<<endl;
		else cout<<leng[i]<<endl;
	}
		
	return 0;
}


Measured memory_bytes: 3164
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int size = scanner.nextInt();
		int[] heapArrays = new int[size + 1];
		for (int i = 1; i < size + 1; i++) {
			heapArrays[i] = scanner.nextInt();
		}
		
		for (int i = size / 2; i >= 1; i--) {
			maxHeapify(heapArrays, i, size);
		}
		StringBuilder stringBuilder = new StringBuilder();
		for (int i = 1; i < size + 1; i++) {
				stringBuilder.append(" ").append(heapArrays[i]);
		}
		System.out.println(stringBuilder.toString());
	}
	
	static void maxHeapify(int[] heapArrays, int point, int size) {
		int left = left(point, size);
		int right = right(point, size);
		int largest;
		
		if (left != -1 && heapArrays[left] > heapArrays[point]) {
			largest = left;
		} else {
			largest = point;
		}
		if (right != -1 && heapArrays[right] > heapArrays[largest]) {
			largest = right;
		}
		if (largest != point) {
			int tmp = heapArrays[point];
			heapArrays[point] = heapArrays[largest];
			heapArrays[largest] = tmp;
			maxHeapify(heapArrays, largest, size);
		}
	}
	
	int parent(int point) {
		if (point != 1) {
			return point / 2;
		} else {
			return -1;
		}
	}
	
	static int left(int point, int size) {
		if (point * 2 <= size) {
			return point * 2;
		} else {
			return -1;
		}
	}
	
	static int right(int point, int size) {
		if (point * 2 + 1 <= size) {
			return point * 2 + 1;
		} else {
			return -1;
		}
	}
}

Measured memory_bytes: 165224
#include<bits/stdc++.h>
using namespace std;
int main()
{
deque<char> a;
deque<char> b;
string s;
cin>>s;
int q;
cin>>q;
int t=0;
 deque <char> :: iterator it; 
for(int i=0;i<q;i++)
{
  //  cout<<"DQA";
    //cout<<"Q"<<i<<endl;
    int h;
    cin>>h;
    if(h==2)
    {
        int f;char c;
        cin>>f>>c;
        if(t%2==0)
        {
            if(f==1)
            {a.push_front(c);
        //    cout<<1<<endl;
            }else {
            b.push_back(c);
           // cout<<2<<endl;
      //          
            }
        }
        else
        {
            if(f==1)
          {  b.push_back(c);
           
             // cout<<3<<endl;
          } else{
            a.push_front(c);
          //cout<<4<<endl;
              
          }
        }
    }
    
    else
    t++;
}

    
if(t%2==0)
{
    for(it=a.begin();it!=a.end();it++)
    cout<<*it;
    cout<<s;
    for(it=b.begin();it!=b.end();it++)
    cout<<*it;
    
}


else{
    for(auto iit=b.rbegin();iit!=b.rend();++iit)
    cout<<*iit;
    for(int i=s.length()-1;i>=0;i--)
    cout<<s[i];
    for(auto iit=a.rbegin();iit!=a.rend();++iit)
    cout<<*iit;
    
    
    
    
    
}




return 0;
}

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

int main() {

    ll n; cin >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll ans = 0;
    for (ll i = 1; i < n; i++) {
        if (a[i - 1] > a[i]) {
            ans += a[i - 1] - a[i];
            a[i] = a[i - 1];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4832
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int N;
int INF = 2e+9;
int X[100000], L[100000];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N;
    vector<P> p;
    for(int i = 0; i < N; i++){
        cin >> X[i] >> L[i];
        p.push_back(P(X[i]+L[i], X[i]-L[i]));
    }
    sort(p.begin(), p.end());
    int cur = -INF;
    int ans = 0;
    for(int i = 0; i < N; i++){
        if(p[i].second >= cur){
            ans++;
            cur = p[i].first;
        }
    }
    cout << ans << endl;
}

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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

ll pre[1<<16];

ll dp[1<<16];

void solve(int idx, const vector<int>& notMarked, ll scoreSekarang, int maskTotal, int maskGroup) {
	if(idx == notMarked.size()) {
		dp[maskTotal] = max(dp[maskTotal], scoreSekarang + pre[maskGroup]);
		return;
	}
	solve(idx+1, notMarked, scoreSekarang, maskTotal, maskGroup);
	solve(idx+1, notMarked, scoreSekarang, maskTotal | (1<<notMarked[idx]), maskGroup | (1<<notMarked[idx]));
}

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

	ll a[n][n];
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			scanf("%lld",&a[i][j]);
		}
	}

	for(int mask = 0;mask < (1<<n);mask++){
		for(i=0;i<n;i++){
			if(mask & (1<<i)){
				for(j=i+1;j<n;j++){
					if(mask & (1<<j)){
						pre[mask] += a[i][j];
					}
				}
			}
		}
	}

	for(int mask = 0;mask < (1<<n);mask++){
		vector<int> notMarked;
		for(i=0;i<n;i++){
			if(!(mask & (1<<i))){notMarked.pb(i);}
		}
		solve(0, notMarked, dp[mask], mask, 0);
	}
	// for(int mask = 0;mask < (1<<n);mask++){
	// 	printf("dp[%d]: %lld\n",mask,dp[mask]);
	// }
	printf("%lld\n",dp[(1<<n) - 1]);

	return 0;
};

Measured memory_bytes: 1280
package main

import (
	"fmt"
)

func main() {
	var a string

	fmt.Scan(&a)
	if a[0:1] == a[1:2] && a[2:3] == a[1:2] && a[0:1] == "R" {
		fmt.Println(3)
	} else if a[1:2] == "R" {
		if a[0:1] == a[1:2] || a[2:3] == a[1:2] {
			fmt.Println(2)
		} else {
			fmt.Println(1)
		}

	} else if a[0:1] == "R" || a[1:2] == "R" || a[2:3] == "R" {
		fmt.Println(1)
	} else {
		fmt.Println(0)
	}
}


Measured memory_bytes: 1768
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

	ll n;
	cin >> n;
	double x;
	string u;

	double rate = 380000.0, res = 0;
	REP(i, n){
		cin >> x >> u;
		if(u == "JPY") res += x;
		else res += x * rate;
	}
	cout << fixed << setprecision(7) << res << endl;
    return 0;
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
//const int mod = 100000;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  map<int, int> mp;
  rep(i, n) ++mp[a[i]];
  if(mp.size() <= k) {
    cout << 0 << endl;
    return 0;
  }
  vector<int> vec;
  for(auto x : mp) vec.push_back(x.second);
  sort(ALL(vec));
  int ans = 0;
  rep(i, vec.size()-k) ans += vec[i];
  cout << ans << endl;
}


Measured memory_bytes: 14296
fn read1<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let s = read1::<String>().chars().collect::<Vec<char>>();

    let mut ans = "".to_string();
    for &c in s.iter() {
        if c == 'B'  {
            ans.pop();
        } else {
            ans.push(c);
        }
    }

    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define em3 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define F first
#define S second
#define X real()
#define Y imag()
#define cross(a, b) ((conj(a) * (b)).Y)
#define dot(a, b) ((conj(a) * (b)).X)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define EPS 1e-7
#define iof freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
long long mod = 1e9;
const int N = 1e9;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const double pi = acos(-1);
typedef complex <ll> point;
typedef tuple<int, int, int> line;
typedef vector<point> polygon;
ll n , x, y , ans;
vector<pair<ll,ll>> v;
int main()
{
    em3
    cin >> n;
    for(int i = 0 ; i < n ; i++)
    {
        cin >> x >> y;
        v.push_back({y , x});
    }
    sort(all(v));
    for(int i = 0 ; i < n ; i++)
    {
        if(ans + v[i].second <= v[i].first)
            ans += v[i].second;
        else
            return cout << "No" , 0;
    }
    cout << "Yes" ;


    return 0;
}



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

int main() {
  int A , B , C , D;
  cin >> A >> B >> C >> D;
  if( A+B > C+D) { cout << "Left" << endl ;
                 }
  else if (A+B==C+D) { cout << "Balanced"<< endl;
                    }
  else {cout << "Right" << endl;
       }
}
    

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <utility>
#include <queue>
#include <ios>
#include <iomanip>
#include <ctime>
#include <tuple>

#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; i++)
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 INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFF
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")

#define PInt pair<int, int>
#define PLL pair<long long, long long>
#define VInt vector<int>
#define VLL vector<long long>
#define MatrixInt vector<vector<int>>
#define MatrixLL vector<vector<long long>>

typedef long long ll;
using namespace std;

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

    cout << min(b / a, c) << endl;
    
}

Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>
int main(void){
    int n,m,a[50],b[50],c[50],d[50],ans,l;
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++){
        scanf("%d%d",&a[i],&b[i]);
    }
    for(int i=0;i<m;i++){
        scanf("%d%d",&c[i],&d[i]);
    }
    for(int i=0;i<n;i++){
        ans=abs(a[i]-c[0])+abs(b[i]-d[0]);l=1;
        for(int j=1;j<m;j++){
            if(abs(a[i]-c[j])+abs(b[i]-d[j])<ans){ans=abs(a[i]-c[j])+abs(b[i]-d[j]);l=j+1;}
        }
        printf("%d\n",l);
    }
    return 0;
}


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

int main() {
  string O, E;
  cin >> O >> E;
  if (O.length() == E.length()) {
    for (int i = 0; i < O.length(); i++) {
      cout << O[i] << E[i] << flush;
    }
  } else {
    for (int i = 0; i < O.length() - 1; i++) {
      cout << O[i] << E[i] << flush;
    }
    cout << O[O.size() - 1] << flush;
  }
  cout << endl;
}

Measured memory_bytes: 256
s = input()

previousword = []
length = len(s)
currentword = []
pointer = 0
separation = []
counter = 0
while(1):
    if pointer >= length:
        break
    currentword = []
    currentword.append(s[pointer])
    if currentword == previousword:
        pointer += 1
        if pointer >= length:
            break
        else:
            currentword.append(s[pointer])
    #separation.append(currentword)
    previousword = currentword
    counter += 1
    pointer += 1

#print(separation)
#print(len(separation))
print(counter)

Measured memory_bytes: 3500
#!/usr/bin/env python3

import sys, math, bisect
sys.setrecursionlimit(300000)


def solve(N: int, D: int, A: int, X: "List[int]", H: "List[int]"):
    p = []
    for i in range(N):
        p.append([X[i], H[i]])
    p.sort()
    ret = 0
    idx = []
    val = []
    nex = 0
    minus = 0
    l = 0
    for i in range(N):
        #print(i)
        #print(p[i])
        v = ret
        while l < i and idx[l] < i:
            minus = val[l]
            l += 1
        v -= minus
        p[i][1] = max(0, p[i][1] - v * A)
        tmp = math.ceil(p[i][1] / A)
        ret += tmp
        x = p[i][0] + D
        while nex < N and p[nex][0] <= x + D:
            nex += 1
        nex -= 1
        idx.append(nex)
        val.append(ret)
        #print(idx)
        #print(val)
        #print('tmp ', tmp)
        #print(ret)
        #print()
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    X = [int()] * (N)  # type: "List[int]"
    H = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        X[i] = int(next(tokens))
        H[i] = int(next(tokens))
    solve(N, D, A, X, H)

if __name__ == '__main__':
    main()


Measured memory_bytes: 124532
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    Scanner in = new Scanner(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    AGC005ASTring solver = new AGC005ASTring();
    solver.solve(1, in, out);
    out.close();
  }

  static class AGC005ASTring {

    public void solve(int testNumber, Scanner in, PrintWriter out) {
      String s = in.next();
      int res = 0;
      int sCnt = 0;
      // scnt = 0の状態でT -> res++;
      // 最後にscntを足す
      for (int i = 0; i < s.length(); i++) {
        if (s.charAt(i) == 'S') {
          sCnt++;
        } else {
          if (sCnt > 0) {
            sCnt--;
          } else {
            res++;
          }
        }
      }

      out.println(res + sCnt);
    }

  }
}



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

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

	if(d == 0 and n != 100) cout << n << endl;
	else if(d == 0 and n == 100) cout << 101 << endl;
	else if(d == 1 and n != 100) cout << 100 * n << endl;
	else if(d == 1 and n == 100) cout << 10100 << endl;
	else if(d == 2 and n == 100) cout << 1010000 << endl;
	else if(d == 2) cout << 10000 * n << endl;

	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt","r", stdin);
	freopen("output.txt","w", stdout);
	freopen("error.txt","w", stderr);
	#endif*/
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int n;
	cin>>n;
	ll ans = 0;
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= n; j++) {
			for(int k = 1; k <=n; k++) {
				ans += __gcd(__gcd(i,j),k);
			}
		}
	}
	cout<<ans;
	return 0;
}


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

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int a,b;
    cin>>a>>b;
    if(a==1 || b==1)
    {
        cout<<1<<"\n";
        return 0;
    }
    long long int ans = (a*b)/2;
    if((a*b)%2!=0)
    ans++;
    cout<<ans<<"\n";
    
}

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int calc(string s) {
  int res = 0;
  for (int i = 0; i < s.size(); i++) res += s[i] - '0';
  return res;
}

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

  string s;
  cin >> s;

  int sz = s.size();
  int ans = calc(s);
  for (int i = 0; i < sz; i++) {
    string t = s;
    if (t[i] != '0') {
      t[i] = s[i] - 1;
      for (int j = i + 1; j < sz; j++) {
        t[j] = '9';
      }
    }
    ans = max(ans, calc(t));
  }
  cout << ans << endl;

  return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector <int> d(n);
    for (int tsumugi = 0; tsumugi < n; tsumugi++){
        cin >> d[tsumugi];
    }

    long long ans = 0;
    for (int karen = 0; karen < n - 1; karen++){
        for (int kaede = karen + 1; kaede < n; kaede++){
            ans += d[karen] * d[kaede];
        }
    }

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
  int n;cin>>n;
  vector<int> a(n);
  int sm=0;
  rep(i,n){
    cin>>a[i];
    sm=sm^a[i];
  }
  rep(i,n){
    int res=sm^a[i];
    cout<<res<<" ";
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 4048
using System;

namespace Contest148
{
	class Program
	{
		static void Main(string[] args)
		{
			int num = int.Parse(Console.ReadLine());
			string[] str = Console.ReadLine().Split(' ');
			string newStr = "";

			for(int i = 0; i < num; i++)
			{
				newStr += str[0].Substring(i, 1);
				newStr += str[1].Substring(i, 1);
			}

			Console.WriteLine(newStr);
		}
	}
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int N;
map<char, int> mp;

int main(void){
    
    scanf("%d", &N);
    for(int i = 0; i < N; ++i){
        string s; cin >> s;
        if(s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H') ++mp[s[0]];
    }
    
    if(mp.size() < 3) { printf("0\n"); return 0; }
    
    vector<int> p;
    for(auto m : mp) p.push_back(m.second); 
    vector<bool> v(mp.size());
    fill(v.end() - 3, v.end(), true);
	
	ll ans = 0;
    do{
        ll sum = 1;
        for(int i = 0; i < mp.size(); ++i){
            if(v[i]) sum *= p[i]; 
        }
		ans += sum;
    }while(next_permutation(v.begin(), v.end()));
    printf("%lld\n", ans);
    
    return 0;
}


Measured memory_bytes: 256
/*
    じょえチャンネルです！
    https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
    チャンネル登録と高評価お願いします！
    最新の動画：
    【競プロ】チーム対抗！目隠しABC早解き対決 https://youtu.be/gPFr7q7eLL8
*/

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

template <typename T>
T pow(T a, long long n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}

template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }

    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }

    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};

using mint = ModInt<1000000007>;

constexpr int MAX_FACTORIAL = 202020;

mint fact[MAX_FACTORIAL];
mint factinv[MAX_FACTORIAL];

void init() {
    fact[0] = 1;
    for (int i = 1; i < MAX_FACTORIAL; i++) {
        fact[i] = fact[i - 1] * i;
    }
    factinv[MAX_FACTORIAL - 1] = fact[MAX_FACTORIAL - 1].inv();
    for (int i = MAX_FACTORIAL - 2; i >= 0; i--) {
        factinv[i] = factinv[i + 1] * (i + 1);
    }
    assert(factinv[0] == 1);
}

mint ncr(int n, int r) { return fact[n] * factinv[r] * factinv[n - r]; }

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

    int n, a, b;
    cin >> n >> a >> b;

    mint ans = pow(mint(2), n) - 1;
    mint hoge = 1;
    if (a > b) swap(a, b);
    for (int i = 0; i < a; i++) {
        hoge *= n - i;
        hoge /= 1 + i;
    }
    ans -= hoge;
    // cout << hoge << endl;
    for (int i = a; i < b; i++) {
        hoge *= n - i;
        hoge /= 1 + i;
    }
    // cout << hoge << endl;
    ans -= hoge;

    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

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() {
	int N; cin >> N;
	vector<int> h(N),dp(N,0);
	for (int i = 0; i < N; i++)cin >> h[i];
	dp[1] = abs(h[0] - h[1]);
	for (int i = 2; i < N; i++) {
		dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]));
	}
	cout << dp[N - 1] << endl;
}





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

int main() {
  int A, B;
  cin >> A >> B;
  if (A > B){
    cout << A * 2 - 1 << endl;
  }
  else if (A == B){
    cout << A * 2 << endl;
  }
  else{
    cout << B * 2 - 1 << endl;
  }
}


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

def num2alpha(num):
    if num <= 26:
        return chr(64 + num)
    elif num % 26 == 0:
        return num2alpha(num // 26 - 1) + chr(90)
    else:
        return num2alpha(num // 26) + chr(64 + num % 26)

print(num2alpha(n).lower())

Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define line cout<<"----------------------------------"<<endl
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
const ll mx=200009;
int cnt[mx]; 
int main()
{
    int n,a,b;
    cin>>n>>a>>b; 
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            int dis=min(fabs(i-j),fabs(i-a)+1+fabs(j-b));
            cnt[dis]++; 
        }
    }
    for(int i=1;i<n;i++) cout<<cnt[i]<<endl; 
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN = 107;
int dp[MAXN][MAXN * 3], w[MAXN], v[MAXN];
int main()
{
    int n, W; scanf("%d%d", &n, &W); 
    for (int i = 1; i <= n; i++) scanf("%d%d", &w[i], &v[i]);
    int ww = w[1];
    for (int i = 1; i <= n; i++) w[i] -= ww;
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        for (int j = i; j >= 1; j--)
            for (int r = 3 * i; r >= w[i]; r--)
            {
                dp[j][r] = max(dp[j][r], dp[j - 1][r - w[i]] + v[i]);
                if ((ll)j * ww + r <= W) ans = max(ans, dp[j][r]);
            }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 384
def x(a):
	m=-10**9
	for c in N:
		p=[0]*n 
		for e in range(c,n):
			for r in N:
				p[r]+=a[r][e]
			m=max(P(p),m)
	return m
def P(a):
	m,c=-10**5,0
	for i in N:
		c+=a[i]
		m=max(c,m)
		if c<0:c=0
	return m
n = input()
N = range(n)
print x([map(int, raw_input().split()) for i in N])

Measured memory_bytes: 4564
#include <bits/stdc++.h>
#include<iostream>
#include<cmath>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll=long long;
using P=pair<int,int>;
const int INF=1001001001;

int main(){
   //前の値よりも大きいorイコールであればよい
   //1引いても上記の条件に当てはまれば引いておく
   int n; cin>>n;
   vector<int> a(n);
   rep(i,n) cin>>a[i];
   int pre=0;
   rep(i,n){
      if(pre<=a[i]-1) pre=a[i]-1;
      else if(pre<=a[i]) pre=a[i];
      //単調非増加にならない
      else{
         cout<<"No"<<endl;
         return 0;
      }
   }
   cout<<"Yes"<<endl;
   return 0;
}


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

int main(){
  int N, K;
  cin >> N >> K;
  
  vector<int> vec(N);
  for (int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  
  int sum=0;
  for (int i=N-1; i>N-1-K; i--){
    sum+=vec.at(i);
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int64_t> l = { 2,1 };
	for (int i = 2; i <= n; i++) {
		l.push_back(l.at(i - 2) + l.at(i - 1));
	}
	cout << l.at(n) << endl;
}

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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	string s; cin >> s;
	int n=s.length();
	int ans = 0;
	for(int i=0; i<=(n-1)/2; i++){
		if(s[i]!=s[n-1-i])ans++;
	}
	cout << ans << endl;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 256
implicit none
integer :: a,b,c,d,e,f,n_a,i,j,k,l,S,T
double precision :: youeki, yousitu,noudo,Li

read(5,*) a,b,c,d,e,f
youeki=0
yousitu=0
noudo=0
S=0
T=0
Li=0
n_a=int(f/(100*a))

do i=0, 2+n_a
do j=0, 2+int((f-100*i*a)/(100*b))
do k=0, 2+int((f-100*i*a-100*j*b-k*c)/d)
do l=0, 2+int((f-100*i*a-100*j*b-k*c)/d)
    S=100*a*i+100*b*j+c*k+d*l
    T=c*k+d*l
    if (S/=0) then
        Li=100.0*T/S
    endif
    if (S<=f .and. Li<=100.0*e/(100.0+e) .and. Li>=noudo) then
        noudo=Li
        youeki=S
        yousitu=T
    endif


end do
end do
end do
end do

write(6,'(i0," "i0)') int(youeki),int(yousitu)
end 



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c;
    return 0;
    
}

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

bool check(const vector<int>& know, const vector<int>& flowed){
    for(int i=0 ; i < flowed.size(); i++){
        bool match = false;
        for(int j=0; j < know.size(); j++){
            if(flowed[i] == know[j]){
                match = true;
                break;
            }
        }
        if(match == false)
            return false;
    }
    return true;
}

int main(void){
    int N;
    while(cin >> N, N){
        int M;
        vector< vector<int> > know;
        vector<int> flowed;
        vector<int> suspended;
        for(int i = 0; i < N; i++){
            cin >> M;
            know.push_back(vector<int>(0));
            for(int j=0; j < M; j++){
                int tmp; cin >> tmp;
                know[i].push_back(tmp);
            }
        }

        int K; cin >> K;
        for(int i=0 ; i < K; i++){
            int tmp; cin >> tmp;
            flowed.push_back(tmp);
        }

        for(int q=0; q < know.size(); q++){
            if(check(know[q], flowed)){
                suspended.push_back(q);
            }
        }

        if(suspended.size() == 1){
            cout << suspended[0] + 1 << endl;
        }else{
            cout << -1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1272