akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define N 1001

using namespace std;

long long M=1000000007;
long long tbl[N][N];
int main(){

    int h,w;
  char x;
     cin>>h>>w;
	  for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>x;
            if(i==1 && j==1) {
                tbl[i][j]=1;
                continue;
            }
            if(x=='#'){
                  tbl[i][j]=0;continue;
            }
            tbl[i][j]=((tbl[i-1][j]%M)+(tbl[i][j-1]%M)%M); 
         
          
        }
    }
  	cout << tbl[h][w]%M<<endl;
    return 0;
}

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

int main() {
  int n,k;
  cin>>n>>k;
  long long int ans=0,cnt=0;
  if(k%2==0){
    cnt=n/k;
    ans+=pow(cnt,3);
    cnt=(n+k/2)/k;
    ans+=pow(cnt,3);
  }
  
  else ans=pow(n/k,3);
  
  cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n, t;
	cin >> n >> t;
	int ans, bf;
	ans = t * n;
	rep(i, n){
		int in;
		cin >> in;
		if(i != 0 && in - bf < t){
			ans -= bf + t - in;
		}
		bf = in;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/*
Original problem: https://atcoder.jp/contests/dp/tasks/dp_z
Author: sammochen
*/

#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)

#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef vector<ll> VLL;
typedef vector<int> VI;

namespace SOLVE {
	struct line {
		ll m, c;
		ll ev(ll a) {
			return m * a + c;
		}
		db xint(line L) {
			return ((db)c - L.c) / (L.m - m);
		}
	};


    void main() {
		// convex hull. finding the minimum, gradient gets smaller every time
		ll n, c;
		cin >> n >> c;
		VLL h(n);
		REP(i,0,n) {
			cin >> h[i];
		}

		deque<line> dq;

		REP(i,0,n) {
			// while the first line isnt the lowest
			while (dq.size() >= 2 && dq[0].ev(h[i]) >= dq[1].ev(h[i])) {
				dq.pop_front();
			}
			
			// stores the current best value
			ll value;
			if (i == 0) {
				value = 0;
			} else {
				value = h[i] * h[i] + c + dq.front().ev(h[i]); 
			}
			line newline = {-2 * h[i], h[i] * h[i] + value};

			// cout << i << ' ' << h[i] << ' ' << value << endl;
			if (i == n - 1) {
				cout << value << endl;
			}

			// insert to the back i think!
			while (dq.size() >= 2 && newline.xint(dq.back()) <= dq[dq.size() - 2].xint(dq.back())) {
				dq.pop_back();
			}
			dq.push_back(newline);
		}
    }
}


signed main() {
	int t;
	t = 1;
	// cin >> t;
	while (t--) {
		SOLVE::main();
	}

	return 0;
}

Measured memory_bytes: 3968
#include<stdio.h>
 
int main(void)
{
int num,a,b;
scanf("%d",&num);
 
a = num/100;
b = num - a*100;
 
if(1<=a && a<=12)
{
  if(1<=b && b<=12)
  {
    printf("AMBIGUOUS");
  }
  else
  {
    printf("MMYY");
  }
}
else
{
  if(1<=b && b<=12)
  {
    printf("YYMM");
  }
  else
  {
    printf("NA");
  }
}
return(0);
}

Measured memory_bytes: 128
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int N, M;
vector<P> v;

void init()
{
}

#if 0
void solve()
{
    sort(ALL(v), greater<P>());
    int last = N+1;
    int ans = 0;
    for(P &p: v){
        cout << "[" << p.fi << ", " << p.se << "]" << endl;
        if(last >= p.fi){
            last = p.se;
            ans++;
            //cout << last << endl;
        }
    }
    cout << ans << endl;
}
#else
void solve()
{
    sort(ALL(v));
    int r = v[0].fi;
    int ans = 1;
    REP(i, v.size()){
        P &p = v[i];
        if(p.se >= r){
            r = p.fi;
            ans++;
        }
    }
    cout << ans << endl;
}
#endif

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    REP(i, M){
        int p, q;
        cin >> p >> q;
        p--; q--;
        v.pb(mp(q, p));
    }
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 1400
/* ***********************************************
Author        :yang12138
Created Time  :2018年07月01日 星期日 23时47分33秒
File Name     :E.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef pair<int,int>pii;
#define lson (root<<1)
#define rson (root<<1|1)

const int N=(1<<18)+10;
int a[N];

void solve(){

	int n;
	scanf("%d",&n);
	int all=(1<<n),ans=0;
	for(int i=0;i<all;i++) scanf("%d",a+i);
	for(int i=1;i<all;i++){
		int b=0,c=0;
		for(int j=i;j>=0;j--){
			j&=i;
			if(a[j]>b){
				c=b;
				b=a[j];
			}
			else if(a[j]>c){
				c=a[j];
			}
		}
		ans=max(ans,b+c);
		printf("%d\n",ans);
	}
}

int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    
	solve();
    return 0;
}


Measured memory_bytes: 4096
#include<stdio.h>
int main()
{
	int n,i,j,c=0,a=0;

	scanf("%d",&n);

	for(i=9;i<=n;i+=2){
		for(j=1;j<=i;j++)
			if(i%j==0)
				c++;
		if(c==8)
			a++;
		c=0;
	}
	printf("%d",a);
	return 0;
}

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

int main(){
  int N,A;
  double T,P,F=1e9+7;
  cin >> N >> T >> A;
  vector<double> H(N);
  rep(i,N){
    cin >> H.at(i);
  }
  rep(i,N){
    double num = T - H.at(i)*0.006;
    if(abs(A-num)<F){
      F = abs(A-num);
      P = i+1;
    }
  }
  cout << P << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i, l, r) for(register int i = l; i <= r; ++ i)
using namespace std;
const int N = 200010, mod = 1e9 + 7;
inline int read()
{
    register char cc = getchar(); register int cn(0), flus(1);
    while(cc < '0' || cc > '9') {if(cc == '-') flus = - flus; cc = getchar();}
    while(cc >= '0' && cc <= '9') {cn = cn * 10 + cc - '0'; cc = getchar();}
    return cn * flus;
}
signed main()
{
	int n = read(), k = read(), ans(0);
	rep(i, k, n + 1)
	{
		ans += ((2 * n - i + 1) * i / 2 - (i - 1) * i / 2 + 1);
		//ans += 1;
		ans %= mod;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3696
using AtCoderBeginnerContest119.Questions;
using AtCoderBeginnerContest119.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest119.Questions
{
    public class QuestionB : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var n = inputStream.ReadInt();
            decimal otoshidama = 0m;

            for (int i = 0; i < n; i++)
            {
                var xu = inputStream.ReadStringArray();
                var x = decimal.Parse(xu[0]);
                if (xu[1] == "JPY")
                {
                    otoshidama += x;
                }
                else
                {
                    otoshidama += x * 380000.0m;
                }
            }

            yield return otoshidama;
        }
    }
}


namespace AtCoderBeginnerContest119
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionB();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest119.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest119.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13140
// TOPSIC001_0

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef int _loop_int;
#define REP(i, n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i, a, b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i, a, b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a, b) a=min((a),(b))
#define CHMAX(a, b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a, b) (abs(a-b)<EPS)
typedef complex<Real> P;


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

    int ans = C - (A - B);
    if(ans < 0) ans = 0;


    cout << ans ;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a=getInt(sc);
		int b=getInt(sc);
		int c=getInt(sc);
		int d=getInt(sc);

		System.out.println(Math.min(a, b)+Math.min(c, d));

	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}

}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) (vec).begin(),(vec).end()
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n;
double val;
long long a,res;
int two,five;
map<pair<int,int>,int> cnt;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>val;
		a=llround(val*1e9);
		two=five=0;
		while(a%2==0){
			two++;
			a/=2;
		}
		while(a%5==0){
			five++;
			a/=5;
		}
		cnt[make_pair(two,five)]++;
	}
	for(auto p1:cnt){
		for(auto p2:cnt){
			if((p1.first.first+p2.first.first)>=18&&(p1.first.second+p2.first.second)>=18){
				if(p1==p2) res+=(long long)(p1.second)*(long long)(p1.second-1);
				else res+=(long long)(p1.second)*(long long)(p2.second);
			}
		}
	}
	cout<<res/2LL<<endl;
	return 0;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double W, H, x, y;
  cin >> W >> H >> x >> y;

  cout << W*H/2 << ' ';
  
  if(x==W/2 && y==H/2)
    cout << 1 << endl;
  else
    cout << 0 << endl;

}

Measured memory_bytes: 256
#include <stdio.h>

void putcross(int a){
    int i;
    for(i=0;i<a;i++)
        printf("#");
    printf("\n");
}

void putpoint(int a){
    int i;
      printf("#");
    for(i=0;i<a-2;i++)
          printf(".");
     printf("#\n");
}



void putframe(int a,int b){
    int i;
    putcross(b);
    for(i=0;i<a-2;i++)
        putpoint(b);
    putcross(b);
        




}

int main() {
    int a,b;
    while(1){
    scanf("%d%d",&a,&b);
        if(a==0,b==0)
            break;
    putframe(a,b);
        printf("\n");
    }
    return 0;
}




Measured memory_bytes: 2052
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
using namespace std;

char S[51][51];
int S2[51][51];

int count(int a, int b)
{
	int count = 0;
	if (S[a - 1][b - 1] == '#')
		count++;
	if (S[a - 1][b] == '#')
		count++;
	if (S[a - 1][b + 1] == '#')
		count++;
	if (S[a][b - 1] == '#')
		count++;
	if (S[a][b + 1] == '#')
		count++;
	if (S[a + 1][b - 1] == '#')
		count++;
	if (S[a + 1][b] == '#')
		count++;
	if (S[a + 1][b + 1] == '#')
		count++;
	return count;
}

int main()
{
	int H, W;

	cin >> H >> W;

	for (int i = 0; i < H; i++)
	{
		for (int i2 = 0; i2 < W; i2++)
		{
			cin >> S[i][i2];
		}
	}

	for (int i = 0; i < H; i++)
	{
		for (int i2 = 0; i2 < W; i2++)
		{
			if (S[i][i2] == '#')
				S2[i][i2] = -1;
			else if (S[i][i2] == '.')
				S2[i][i2] = count(i, i2);
		}
	}

	for (int i = 0; i < H; i++)
	{
		for (int i2 = 0; i2 < W; i2++)
		{
			if (S2[i][i2] == -1)
				cout << "#";
			else
				cout << S2[i][i2];
		}
		cout << endl;
	}

	return 0;
}

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

using namespace std;

#define Rep(b, e, i) for (ll i = b; i <= e; i++)
#define Repr(e, b, i) for (ll i = e; i >= b; i--)
#define rep(n, i) Rep(0, n - 1, i)
#define repr(n, i) Repr(n - 1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T, vector<T>, greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putbd cout << "---------------------------------------------" << endl;
#define putln(x) cout << x << endl;
#define debug(x) cerr << #x << "=" << x << endl;
#define ENJYU std::ios::sync_with_stdio(false) std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<vec> mat;
typedef vector<vecll> matll;
typedef vector<vecd> matd;

template <class T>
ostream &operator<<(ostream &o, const vector<T> &v)
{
	o << "{";
	for (int i = 0; i < (int)v.size(); i++)
		o << (i > 0 ? ", " : "") << v[i];
	o << "}";
	return o;
}

const int MAX = 1000010;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1 << 29;
const ll INFL = 1e18;
const ll MOD = 1e9+7;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//const int dx[]={-1,-1,-1,0,1,1,1,0},dy[]={-1,0,1,1,1,0,-1,-1};

//********************************template END****************************************//

void solve()
{
	int N, A, B;
	cin >> N >> A >> B;
	cout << min(A, B) << ' ' << max(0, A+B-N) << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
import java.lang.*;
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        
        int n = scan.nextInt();
        int limit = scan.nextInt();
        int min = Integer.MAX_VALUE;
        
        while(n-- > 0){
            int cost = scan.nextInt();
            int time = scan.nextInt();
            
            if(time <= limit)
                if(cost < min) min = cost;
        }
        
        if(min == Integer.MAX_VALUE) System.out.println("TLE");
        else System.out.println(min);
    }
}


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

int main()
{
    string a;
    cin >> a;
    int check = 0;
    for(int i = 0; i < a.length(); ++i)
    {
        if(a[i] == 'a')
        {
            ++check;
            break;
        }
    }
    for(int i = 0; i < a.length(); ++i)
    {
        if(a[i] == 'b')
        {
            ++check;
            break;
        }
    }
    for(int i = 0; i < a.length(); ++i)
    {
        if(a[i] == 'c')
        {
            ++check;
            break;
        }
    }

    if(check == 3)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
N = int(input())
*L, = map(int,input().split())

ans = 0
for a in range(N):
    la = L[a]
    for b in range(a+1,N):
        lb = L[b]
        if la==lb: continue
        for c in range(b+1,N):
            lc = L[c]
            if la==lc or lb==lc: continue
            if (lc < lb + la) and (lb < la + lc) and (la < lb + lc):
                ans += 1

print(ans)

Measured memory_bytes: 9200
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var sw = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var (s, w) = (sw[0], sw[1]);

        Console.WriteLine(s <= w ? "unsafe" : "safe");
    }
}


Measured memory_bytes: 27996
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

int main()
{
	string str = "";

	while (getline (cin, str ) ){

		double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
		stringstream ss(str);

		ss >> xa1 >> ya1 >> xa2 >> ya2 >> xb1 >> yb1 >> xb2 >> yb2;

		bool inter = true; 

		if ( max (xa1, xa2 ) < min (xb1, xb2 ) 
 		  || min (xa1, xa2 ) > max (xb1, xb2 ) ){
			inter = false;
		}else 
		if ( min (ya1, ya2 ) > max (yb1, yb2 ) 
		  || max (ya1, ya2 ) < min (yb1, yb2 ) ){
			inter = false;
		} // end if

		if (inter){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		} // end if
	} //  end while
		
	return 0;
}

Measured memory_bytes: 0
#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>
#include<stdio.h>
using namespace std;

int main(){
    while(1){
        int n,x;
        cin >> n >> x;
        if(n == 0 && x == 0){
            break;
        }else{
            int count = 0;
            int i,j,k;
            for(i =1;i<n;i++){
                for(j =i+1;j<n;j++){
                    for(k=j+1;k<=n;k++){
                        if ( i < j && j < k && i+j+k==x ){
                            count+=1;
                        }else{
                            continue;
                        }
                    }
                }
            }
            cout << count << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3068
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std;

typedef long long ll;

int v[100001];
int even[100001],odd[100001];
int a1,a2,b1,b2,na1,na2,nb1,nb2;

int main() {
  int n; cin >> n;
  for ( int i = 1; i <= n; i++ ) {
    cin >> v[i];
    if( i % 2 == 1 ) odd[v[i]]++;
    else even[v[i]]++;
  }

  for ( int i = 1; i <= 100000; i++ ) {
    if ( odd[i] > a1 ) {
      a2 = a1;
      a1 = odd[i];
      na2 = na1;
      na1 = i;
    } else if ( odd[i] > a2 ) {
      a2 = odd[i];
      na2 = i;
    }

    if ( even[i] > b1 ) {
      b2 = b1;
      b1 = even[i];
      nb2 = nb1;
      nb1 = i;
    } else if ( even[i] > b2 ) {
      b2 = even[i];
      nb2 = i;
    }

  }

  if ( na1 != nb1 ) cout << n-a1-b1 << endl;
  else cout << min(n-a1-b2,n-a2-b1);
  return 0;
}


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

int main(){

    int n, c;

    cin >> n >> c;

    vector<vector<int>> cost(c, vector<int>(c));

    for(int i = 0; i < c; ++i)
        for(int j = 0; j < c; ++j)
            cin >> cost[i][j];

    vector<vector<int>> color(n, vector<int>(n));

    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j){
            cin >> color[i][j];
            --color[i][j];
        }
    
    // sum[i][j]: (x+y)%3=iとなるような(x,y)の色を全てjにする時にかかる違和感の総和
    vector<vector<int>> sum(3, vector<int>(c, 0));

    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j)
            for(int k = 0; k < c; ++k)
                sum[(i+j)%3][k] += cost[color[i][j]][k];
    
    int answer = 1000000000;

    for(int i = 0; i < c; ++i)
        for(int j = 0; j < c; ++j)
            for(int k = 0; k < c; ++k)
                if(i != j && i != k && j != k)
                    answer = min(answer, sum[0][i] + sum[1][j] + sum[2][k]);

    cout << answer << endl;


    return 0;
}

Measured memory_bytes: 1280
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
5
0 3 2 3 3 1 1 2
1 2 0 2 3 4
2 3 0 3 3 1 4 1
3 4 2 1 0 1 1 4 4 3
4 2 2 1 3 3

output:
0 0
1 2
2 2
3 1
4 3
"""

import sys
import heapq as hp

WHITE, GRAY, BLACK = 0, 1, 2


def generate_adj_table(v_table):
    for each in v_table:
        v_index, v_adj_length, *v_adj_list = map(int, each)
        # assert len(v_adj_list) == v_adj_length * 2
        for pair in zip(v_adj_list[::2], v_adj_list[1::2]):
            init_adj_table[v_index][pair[0]] = pair[1]

    return init_adj_table


def dijkstra_path_heap():
    # path search init
    distance[init_vertex] = 0
    path_heap = []
    # heapq: rank by tuple[0], at here it's d[u]
    hp.heappush(path_heap, (0, init_vertex))

    while path_heap:
        current = hp.heappop(path_heap)[1]

        color[current] = BLACK

        for adj, cost in adj_table[current].items():
            if color[adj] is not BLACK:
                # alt: d[u] + w[u,v]
                alt_path = distance[current] + cost
                if alt_path < distance[adj]:
                    # update path_list
                    distance[adj] = alt_path
                    # update heap
                    hp.heappush(path_heap, (alt_path, adj))
                    color[adj] = GRAY
                    parents[adj] = current

    return distance


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices = int(_input[0])
    v_info = map(lambda x: x.split(), _input[1:])
    # assert len(init_vertices_table) == vertices_num

    distance = [float('inf')] * vertices
    parents = [-1] * vertices
    color = [WHITE] * vertices
    init_adj_table = tuple(dict() for _ in range(vertices))
    init_vertex = 0

    adj_table = generate_adj_table(v_info)
    ans = dijkstra_path_heap()
    for i, v in enumerate(ans):
        print(i, v)

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

int main()
{
    int t, k;
    bool ok = true;
    vector<int> v;
    cin>>k>>t;
    for(int i = 0; i< t; i++)
    {
        int x;
        cin>>x;
        v.push_back(x);
    }
    sort(v.begin(), v.end());
    if(k%2 == 0)
    {
        //cout<<v[t-1];
        if(v[t-1]>k/2)
        {
            ok = false;
        }
    }
    else
    {
        if(v[t-1]>(k/2+1))
        {
            ok = false;
        }
    }
    if(ok)
    {
        //cout<<"Aici";
        cout<<0;
        return 0;
    }
    cout<<(v[t-1] -1) - (k-v[t-1]);
    return 0;
}


Measured memory_bytes: 256
import itertools
N = int(input())
A = [int(x) for x in input().split()]
B = list(range(1,N+1))

def test(i,j):
  AA = A.copy()
  AA[i], AA[j] = AA[j], AA[i]
  return AA == B

bl = (A == B)
for i,j in itertools.combinations(range(N),2):
  if test(i,j):
    bl = True
answer = 'YES' if bl else 'NO'
print(answer)


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out)) {

      String[] lns = in.readLine().split(" ");
      int n = Integer.parseInt(lns[0]);
      int m = Integer.parseInt(lns[1]);
      // int cityP[] = new int[m];
      // int cityY[] = new int[m];
      City[] city = new City[m];
      City[] city2 = new City[m];
      int[] p = new int[n+1];

      int maxP = 0;
      int x,y;
      for(int i=0; i<m; i++) {
        lns = in.readLine().split(" ");
        x = Integer.parseInt(lns[0]);
        y = Integer.parseInt(lns[1]);
        city[i] = new City(x, y);
        city[i].s = i;
        city2[i] = city[i];
      }

      Arrays.parallelSort(city2, new Comparator<City>() {
        public int compare(City a, City b) {
          if(a.y == b.y) return 0;
          return a.y > b.y ? 1 : -1;
        }
      });

      Arrays.fill(p, 1);
      String no;
      for(int i=0; i<m; i++) {
        city2[i].no = p[city2[i].p]++;
      }

      // Arrays.parallelSort(city, new Comparator<City>() {
      //   public int compare(City a, City b) {
      //     return a.s - b.s;
      //   }
      // });
      
      for(int i=0; i<m; i++) {
        no = String.format("%06d%06d", city[i].p,city[i].no);
        out.println(no);
      }
      out.flush();
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
  class City {
    int s;
    int p;
    int y;
    int no;

    public City(int p, int y) {
      this.p = p;
      this.y = y;
    }
  }
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int A=in(),B=in(),C=in();
	out(A+B>=C ? "Yes" : "No");

	return 0;
}


Measured memory_bytes: 256
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n = ni()
a = na()

d = [0] * n
for i in range(n // 2, n):
    d[i] = a[i]

for i in range(n // 2 - 1, -1, -1):
    j = 1
    t = 0
    while j * (i + 1) <= n:
        t += d[j * (i + 1) - 1]
        j += 1
    if t % 2 != a[i]:
        d[i] = 1

m = sum(d)
cnt = 0
print(m)
for i in range(n):
    if d[i] == 1:
        if cnt >= 1:
            print(" ", end="")
        cnt += 1
        print(i + 1, end="")
print()

Measured memory_bytes: 7760
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		// 読み込み
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		
		int count = 0;
		for (int i = 0; i < S.length(); i++) {
			if(S.charAt(i) != T.charAt(i)) {
				count++;
			}
		}
		System.out.println(count);
	}
}


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

using namespace std;

#define ll long long
#define rep(i,n) for(int i=1;i<=(n);i++)
#define rep0(i,n) for(int i=0;i<(n);i++)

const ll INF=1e9+7;
ll n;
ll a,b,x,y,c,d,k;
int main()
{
	/*freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	cin>>n;
	cin>>a>>b;
	d=1;
	while(--n){
		x=a;
		y=b;
		cin>>a>>b;
		c=a+b;
		k=max(d*x/a,d*y/b);
		if(d*x>k*a||d*y>k*b){
			k++;
		}
		d=k;
	}
	cout<<d*(a+b);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
    #include<stdlib.h>
    int main(){
    int N,i;
    long long x,y,z;
    int a[200001];
    scanf("%d",&N);
    for(i=0;i<N;i++){
    scanf("%d",&a[i]);
    y+=a[i];
    }
    x=a[0];
    y-=a[0];
    z=llabs(x-y);
    for(i=1;i<N-1;i++){
    x+=a[i];
    y-=a[i];
    if(llabs(x-y)<z) z=llabs(x-y);
    }
    printf("%lld\n",z);
    return 0;
    }

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define substr(s,f,t) (s.substr(f-1,t-f+1))
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
};

class BIT{
  //0-indexed
public:
  static const ll MAX_N=220000;
  ll bit[MAX_N]={},n;
  BIT(ll num){
    n=num;
  }
  void add(ll i,ll value){
    i++;
    while(i<=n){
      bit[i]+=value;
      i += i & -i;
    }
  }
  ll sum(ll i){
    i++;
    ll ret=0;
    while(i>0){
      ret += bit[i];
      i -= i & -i;
    }
    return ret;
  }
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k;cin>>n>>k;
  vi a(n);
  BIT bit(n+10);
  vector<pair<ll,ll>> b;
  vi c(n+1);
  b.pb(mp(0,0));
  ll sum=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
    b.pb(mp(sum-k*(i+1),i+1));
  }
  sort(ALL(b));
  for(int i=0;i<n+1;i++){
    
    c[b[i].S]=i;
  }
  ll ans=0;
  for(int i=0;i<n+1;i++){
    ans+=bit.sum(c[i]);
    bit.add(c[i],1);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 11248
N = int(input())
x = list(map(int, input().split()))

x_ = [(x[i], i+1) for i in range(N)]
x_.sort(key=lambda s: s[0])
seq = [x_[i][1] for i in range(N)]
left = []
for s in seq:
    left.extend([s] * (s-1))
right = []
for s in reversed(seq):
    right.extend([s] * (N - s))
right.reverse()
ans_raw = left + right
ans_raw.reverse()

ans = [0] * (N**2)
for i, xi in enumerate(x):
    ans[xi-1] = -(i+1)
for i in range(N**2):
    if ans[i] == 0:
        ans[i] = ans_raw.pop()

cnt_list = [0] * (N+1)
for i in range(N**2):
    if ans[i] < 0:
        if cnt_list[-ans[i]] != -ans[i]-1:
            print('No')
            exit()
    else:
        cnt_list[ans[i]] += 1

print('Yes')
ans = list(map(abs, ans))
print(*ans)


Measured memory_bytes: 72744
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n;cin>>n;
  vector<string> s(n);rep(i,n)cin>>s[i];
  int name[5] = {0};
  rep(i,n){
    if(s[i][0] == 'M')name[0]++;
    if(s[i][0] == 'A')name[1]++;
    if(s[i][0] == 'R')name[2]++;
    if(s[i][0] == 'C')name[3]++;
    if(s[i][0] == 'H')name[4]++;
  }
  ll ans = 0;
  rep(i,1<<5){
    bitset<5> bs(i);
    int tmp = 0;
    rep(j,5)tmp += bs[j];
    if(tmp != 3)continue;

    ll temp = 1;
    rep(j,5){
      if(bs[j])temp *= name[j];
    }
    ans += temp;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 5760
N, M = map(int, input().split())
data = [[] for i in range(M)]
ans = [""] * M
num = [0] * N
for i in range(M):
    ken, year = map(int, input().split())
    data[i] = [ken, year, i]
    
data.sort(key=lambda x:x[1])

for p, y, i in data:
    num[p-1] += 1
    ans[i] = str(p).zfill(6) + str(num[p-1]).zfill(6)

for i in ans:
    print(i)

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

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

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  ll X,K,D;
  cin>>X>>K>>D;

  ll ans=LONG_MAX;

  X=abs(X);

  ll diff=X/D;


  ll ans1=X%D;
  ll d=(K-diff)%2;

  if(diff>K){
    cout<<X-K*D<<endl;
    return 0;
  }

  if(d){
    ans=min(ans,abs(ans1-D));
  }
  else{
    ans=min(ans,ans1);
  }

  ll ans2=abs(X%D-D);
  d=(K-diff-1)%2;
  if(diff+1>K){
    cout<<ans1<<endl;
    return 0;
  }

  if(d){
    ans=min(ans,abs(ans2+D));
  }
  else{
    ans=min(ans,ans2);
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3644
while True:
 
    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for k in range(W):
            if i == 0 or i == H-1 or k == 0 or k == W-1:
                print("#",end = "")
            else:
                print(".",end = "")
        print()
 
    print()


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

int main() {
  int n;
  cin>>n;
  long long ans=0;  
  vector<long long> s(n);
  vector<long long> p(n);
  
  for(int i=0; i<n; i++) {
    cin >> s[i];
    p[s[i]-1]++;
  }
  
  for(int i=0; i<n; i++){
    if(p[i] > 1) ans = ans + p[i]*(p[i]-1)/2;
  }
  
  for(int i=0; i<n; i++){
    if(p[s[i]-1] > 1){
      ans = ans - (p[s[i]-1] - 1);
      cout << ans << endl;
      ans = ans + (p[s[i]-1] - 1);
    }
    
    else cout << ans << endl;
  }
}

Measured memory_bytes: 5760
package main

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

type Node struct {
	id int
	edgesTo []*Node
	edgesCost []int
	isVisited bool
	cost int
	previousNode *Node
}

func (n *Node) connect(node *Node, cost int) {
	n.edgesTo = append(n.edgesTo, node)
	n.edgesCost = append(n.edgesCost, cost)
}

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	scanner.Split(bufio.ScanWords)
	n := nextInt()
	nodes := make([]*Node, n)
	for i := 0; i < n; i++ {
		nodes[i] = &Node{cost:-1}
	}
	for i := 0; i < n; i++ {
		u := nextInt()
		k := nextInt()
		nodes[i].id = u
		for j := 0; j < k;j++ {
			v := nextInt()
			c := nextInt()
			nodes[i].connect(nodes[v], c)
		}
	}

	nodes[0].cost = 0
	for {
		var processing *Node
		processing = nil
		for i := 0; i < len(nodes); i++ {
			node := nodes[i]
			if node.isVisited || node.cost < 0 {
				continue
			}
			if processing == nil {
				processing = node
				continue
			}
			if node.cost < processing.cost {
				processing = node
			}
		}
		if processing == nil {
			break
		}
		processing.isVisited = true
		for i := 0; i < len(processing.edgesTo); i++ {
			node := processing.edgesTo[i]
			cost := processing.cost + processing.edgesCost[i]
			if node.cost < 0 || node.cost > cost {
				node.cost = cost
				node.previousNode = processing
			}
		}
	}

	for _, n := range nodes {
		fmt.Printf("%d %d\n",n.id, n.cost)
	}

}


Measured memory_bytes: 14756
#include <iostream>
#include <set>

using namespace std;

int main(void) {
	int n;
	string id;
	set<string> sU;
	bool opened = false;
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> id;
		sU.insert(id);
	}
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> id;
		if(sU.find(id) == sU.end()) {
			cout << "Unknown " << id << endl;
		} else {
			cout << (opened ? "Closed by " : "Opened by ") << id << endl;
			opened = !opened;
		}
	}
	return 0;
}

Measured memory_bytes: 1232
people, sports = (int(n) for n in input().split(" "))
preference = []
for _ in range(people):
    pre = [int(n) - 1 for n in input().split(" ")]
    preference.append(pre)
answer = float("inf")
use_sports = {n for n in range(sports)}
for _ in range(sports):
    rank = [0 for n in range(sports)]
    for p in range(people):
        for s in (preference[p]):
            if s in use_sports:
                rank[s] += 1
                break
    answer = min(answer, max(rank))
    use_sports -= {rank.index(max(rank))}
print(answer)

Measured memory_bytes: 4212
N = int(input())
A = list(map(int,input().split()))
A.insert(0,0)
A.append(0)
ans = []
n = len(A)
S = 0
for i in range(1,n):
    S += abs(A[i]-A[i-1])

for i in range(1,n-1):
    sum = S + abs(A[i+1]-A[i-1])-abs(A[i-1]-A[i])-abs(A[i]-A[i+1])
    ans.append(sum)

for i in ans:
    print(i)

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

int main()
{
    int64_t A, B, K;
    cin >> A >> B >> K;
    int64_t Af, Bf;
    if (A + B < K)
    {
        Af = 0;
        Bf = 0;
    }
    else if (A < K)
    {
        Af = 0;
        Bf = A + B - K;
    }
    else
    {
        Af = A - K;
        Bf = B;
    }
    cout << Af << " " << Bf << endl;
}

Measured memory_bytes: 256
n = int(input())
s = input()
ans = s.count("R")*s.count("G")*s.count("B")
for i in range(n-2):
    for j in range(i+1,n-1):
        if 2*j-i <= n-1:
            if s[2*j-i] != s[i] and s[i] != s[j] and s[j] != s[2*j-i]:
                ans -= 1
print(ans)

Measured memory_bytes: 68164
#include<iostream>
#include <iostream>
#include <string>
using namespace std;
 
int main()
{
  string s[3];
  cin >> s[0] >> s[1] >> s[2];
  int turn = 0;
  while(1){
    if(s[turn].size() == 0){
      char ans = 'A' + turn;
      cout << ans << endl;
      break;
    }
    char next_turn = s[turn][0];
    s[turn].erase(s[turn].begin());
    turn = next_turn - 'a';
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int main(){

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

  vector<int> a(n);
  REP(i,n){
    scanf("%d", &a[i]);
  }

  sort(ALL(a));

  int ans = 0;
  REP(i,n){
    if(i == n - 1){
      if(x == a[i]) ans++;
      break;
    }

    if(x >= a[i]){
      x -= a[i];
      ans++;
    }else{
      break;
    }
  }

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 100005
#define lo long long
using namespace std;
int n,k;
vector< pair<int,int> > v;
int main(){
	scanf("%d %d",&n,&k);
	int gol=((n-1)*(n-2))/2;
	if(k>gol){
		printf("-1\n");
		return 0;
	}
	int sil=gol-k;
	for(int i=2;i<=n;i++){
		v.pb(mp(1,i));
	}
	int tas1=2;
	int tas2=3;
	for(int i=1;i<=sil;i++){
		v.pb(mp(tas1,tas2));
		tas2++;
		if(tas2==n+1){
			tas1++;
			tas2=tas1+1;
		}
	}
	printf("%d\n",(int)v.size());
	for(int i=0;i<(int)v.size();i++){
		printf("%d %d\n",v[i].fi,v[i].se);
	}
	return 0;
}




Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <ctype.h>
#include <stdlib.h>
using namespace std;

int main()
{
    int N,M,X;
    cin >> N >> M >> X;
    vector<int> A(M);
    for (int i = 0; i < M; i++)
    {
        /* code */
        cin >> A[i];
    }

    int leftCost = 0;
    int rightCost = 0;


    for (int i = 0; i < M; i++)
    {
        /* code */
        if(A[i] < X){
            leftCost++;
        }else{
            rightCost++;
        }
    }
    
    
    int ans = min(leftCost,rightCost);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
    return 0;
}



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

using namespace std;
const int maxn = 2e5+1000;

int s[maxn];

int main() {
    int n;
    long long sum=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s[i];
        sum+=s[i];
    }
    long long ans=999999999999;
    long long su=s[0];
    for(int i=1;i<n-1;i++){
        su+=s[i];
        ans=min(abs(sum-2*su),ans);
    }
    if(n==2){
        cout<<abs(s[0]-s[1])<<endl;
    }
    else
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#define ll long long
#define p pair<ll, ll>
#define INF 100000000000000000
#define mod 1000000007
using namespace std;

int main(){
  int x, a, b;
  cin >> x >> a >> b;
  if(abs(a-x) > abs(b-x)) cout << "B" << endl;
  else cout << "A" << endl;
  return 0;
}


Measured memory_bytes: 768
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#define reg register
using namespace std;
typedef long long ll;
const int N=2e5+5;
const ll inf=1e14;
int n,a[N];
ll sum[N],ans=inf;
inline int read()
{
	int x=0,w=1;
	char c=getchar();
	while (!isdigit(c)&&c!='-') c=getchar();
	if (c=='-') c=getchar(),w=-1;
	while (isdigit(c))
	{
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*w;
}
inline ll Max(ll a,ll b,ll c,ll d){return max(a,max(b,max(c,d)));}
inline ll Min(ll a,ll b,ll c,ll d){return min(a,min(b,min(c,d)));}
inline void Chk(ll &ans,ll a,ll b,ll c,ll d){ans=min(ans,Max(a,b,c,d)-Min(a,b,c,d));}
int main()
{
	n=read();
	for (reg int i=1;i<=n;i++) sum[i]=sum[i-1]+(a[i]=read());
	for (reg int i=2,l=1,r=3;i<n-1;i++)
	{
		while (l<i-1&&2*sum[l+1]<=sum[i]) ++l;
		while (r<n-1&&2*sum[r+1]-sum[i]<=sum[n]) ++r;
		ll s1=sum[l],s2=sum[i]-sum[l],s3=sum[r]-sum[i],s4=sum[n]-sum[r];
		Chk(ans,s1,s2,s3,s4);
		if (l<i-1) Chk(ans,s1+a[l+1],s2-a[l+1],s3,s4);
		if (r<n-1) Chk(ans,s1,s2,s3+a[r+1],s4-a[r+1]);
		if (l<i-1&&r<n-1) Chk(ans,s1+a[l+1],s2-a[l+1],s3+a[r+1],s4-a[r+1]);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2560
// Least common multiple
#include <stdio.h>

using namespace std;

long common_multi(long x, long y) {
    long a, b;
    if ( x > y ) {
        a = x;
        b = y;
    } else {
        a = y;
        b = x;
    }
    
    bool comp = true;
    long ans;
    long i = 1;
    while ( comp ) {
        long multi = a * i;
        if ( multi % b == 0 ) {
            comp = false;
            ans = multi;
        }
        i++;
    }
    return ans;
}

int main() {
    long x, y;
    long ans;

    scanf("%ld %ld", &x, &y);
    ans = common_multi(x, y);
    printf("%ld\n", ans);

    return 0;
}

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

using namespace std;

int l[300010];
int r[300010];

int idx[270000];
int bp;

void add(int x, int y, int v)
{
    if(y < x)
        return;
    x += bp;
    y += bp;
    while(x <= y)
    {
        if(x % 2 == 1)
            idx[x++] += v;
        if(y % 2 == 0)
            idx[y--] += v;
        x /= 2;
        y /= 2;
    }
}

int sum(int x)
{
    int r = 0;
    x += bp;
    while(x)
    {
        r += idx[x];
        x /= 2;
    }
    return r;
}

struct eve
{
    int t, x, v;
    bool operator <(const eve &a) const
    {
        return x != a.x ? x < a.x : t < a.t;
    }
};

int res[100010];

int main()
{
    //freopen("in", "r", stdin);
    //freopen("out", "w", stdout);

    int n, m, i;
    scanf("%d%d", &n, &m);
    for(i = 0; i < n; i++)
        scanf("%d%d", &l[i], &r[i]);

    for(bp = 1; bp <= m + 1; bp *= 2);

    vector<eve> v;
    for(i = 0; i < n; i++)
    {
        add(l[i], r[i], 1);
        v.push_back({ 0, l[i], r[i] });
    }

    for(i = 1; i <= m; i++)
    {
        int t = 0;
        while(t + i <= m + 1)
        {
            v.push_back({ i, t, t + i });
            t += i;
        }
    }

    sort(v.begin(), v.end());
    for(auto &e : v)
    {
        if(e.t == 0)
            add(e.x, e.v, -1);
        else
            res[e.t] += sum(e.v);
    }

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


Measured memory_bytes: 30056