akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

const int MAXD = 303;
const int MOD = 1e9+7;
int D, S;
int l[MAXD];
int dp[MAXD][MAXD*MAXD][2];

ll mod_pow(ll x, ll p, int MOD) {
	if (x == 0) return 0;
    ll a = 1;
    while (p) {
        if (p%2) a = a*x%MOD;
        x = x*x%MOD;
        p/=2;
    }
    return a;
}

int dfs(int d, int rest, int flag) {
	int& ret = dp[d][rest][flag];
	if (ret >= 0) return ret;
	if (d == D) {
		ret = mod_pow(rest, D, MOD);
		if (flag) ret = -ret;
		ret = (ret%MOD+MOD)%MOD;
	} else {
		ret = dfs(d+1, rest, flag);
		if (rest >= l[d]) {
			ret += dfs(d+1, rest-l[d], flag^1);
		}
		ret %= MOD;
	}

	return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
	cin >> D;
	for (int i = 0; i < D; i++)
		cin >> l[i];
	cin >> S;
	memset(dp, -1, sizeof(dp));
	cout << dfs(0, S, 0) << endl;
    return 0;
}

Measured memory_bytes: 220580
#include<stdio.h>

int main(void){
int a,b,c;
int i;
int d;
int e=0;
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);
for(i=1;i<101;i++){
d=i*b+c;
if(d%a==0){
e=1;
break;
}
}
if(e==1){printf("YES");}
else{printf("NO");}
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  string S;
  cin >> S;
  int cnt = 0;
  int N = S.size();
  for (int i = 0; i < N / 2; ++i) {
    if (S[i] != S[N - 1 - i]) ++cnt;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

		var inputArray = retreiveLongArray();
			var inputCount = 2;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];
			long M = inputArray[1];

			long TimeForOnce = 1900 * M + 100 * (N - M);
			long averageChallengeNum = (long)Math.Pow(2, M);


			//答えの出力
			var ans = TimeForOnce * averageChallengeNum;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}

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

int main(){
    int a, b;
    cin >> a >> b;
    if(a%3 == 0 || b%3 == 0 || (a+b)%3 == 0){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
int main(int argc, char *argv[])
{
	int n;
	while(cin>>n)
	{
		string s;
		char last;
		map<string,int>m;
		bool t=true;
		for(int i=0;i<n;i++)
		{
			cin>>s;
			m[s]++;
			if(m[s]>1||(i!=0&&s[0]!=last))
				t=false;
			last=s[s.length()-1];
		}
		if(t)
			printf("Yes\n");
		else
			printf("No\n");	
	}
	return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/23  Problem: 004_agc_b / Link: https://agc004.contest.atcoder.jp/tasks/agc004_b?lang=en  ----- */
/* ------問題------

高橋君は異世界に住んでいます。 この世界には N 色のスライムがいます。 最初、高橋君はどの色のスライムも飼っていません。 高橋君の目標は、全色のスライムを一緒に飼うことです。
高橋君は次の 2 種類の操作を行えます。
今飼っていないスライムの色 i (1≤i≤N) をひとつ選ぶ。 色 i のスライムを捕まえて飼う。 この操作には ai 秒掛かる。
魔法を唱える。 すると、今飼っている各スライムについて、色 i (1≤i≤N−1) のスライムは色 i+1 へ変色する。 ただし、色 N のスライムは色 1 へ変色する。 この操作には x 秒掛かる。
高橋君が全色のスライムを一緒に飼うためには、最短で合計何秒掛かるかを求めてください。

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

template<typename type>
struct SegTree {
	type INIT_VAL = INT_MAX;
	inline type merge(type a, type b) {
		return min(a, b);
	}
	int N;	vector<type> dat;

	SegTree(int _N) {
		N = 1;
		while (N < _N)N *= 2;
		dat = vector<type>(N * 2 - 1, INIT_VAL);
	}
	~SegTree() { vector<type>().swap(dat); }

	void update(int k, type val) {
		k += N - 1;
		dat[k] = val;
		while (k) {
			k = (k - 1) / 2;
			dat[k] = merge(dat[k * 2 + 1], dat[k * 2 + 2]);
		}
	}
	type query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l)return INIT_VAL;
		if (a <= l&&b >= r)return dat[k];
		type v1 = query(a, b, k * 2 + 1, l, (l + r) / 2);
		type v2 = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return merge(v1, v2);
	}

	inline type query(int a, int b) {
		return query(a, b, 0, 0, N);
	}
};

LL N, X;

LL ans = 0LL;

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

	cin >> N >> X;
	VL a(N);
	FOR(i, 0, N) {
		cin >> a[i];
	}
	SegTree<LL>seg(2 * N);
	FOR(i, 0, N) {
		seg.update(i, a[i]);
		seg.update(N + i, a[i]);
	}

	ans = LINF;
	FOR(k, 0, N) {
		LL ret = X*k;
		FOR(i, 0, N) {
			ret += seg.query(i - k + N, i + N + 1);
		}
		ans = min(ans, ret);
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n,a,b; cin>>n>>a>>b;
    for(int i=a;i<=b;i++){
        if(i%n==0){
            cout<<"OK"; return 0;
        }
    }
    cout<<"NG";
    return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<string>
#include<vector>
#include<float.h>
#include<iomanip>
using  ll = long long;
using namespace std;

int main(){
  int x; cin >> x;
  int ans = 0;
  if(x == 1){
    cout << 1 << endl;
    return 0;
  } else { 
    for(int i = 2; i <= sqrt(x); i++){
      for(int j = 2; pow(i, j) <= x; j++){
        if(ans < pow(i, j)){
          ans = pow(i, j);
        }
      }
    }
    cout << ans << endl;
  }
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;

template<typename A,typename B> inline void chmin(A &a,B b){if(a>b) a=b;}
template<typename A,typename B> inline void chmax(A &a,B b){if(a<b) a=b;}
//-----------------------------------------------------------------------

const int N=1e6;
bool isPrime[N+5];

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

    for(int i=2;i<=N;i++) isPrime[i]=true;
    for(int i=2;i<=N;i++){
        if(!isPrime[i]) continue;
        for(int j=i*2;j<=N;j+=i){
            isPrime[j]=false;
        }
    }

    int a,d,n;
    while(cin>>a>>d>>n,a|d|n)
    {   
        while(n){
            if(isPrime[a]) n--;
            a+=d;
        }
        cout<<a-d<<endl;
    }
}

Measured memory_bytes: 3992
def main():
    N = int(input())
    A = list(map(int,input().split()))
    MOD = 10**9 +7

    S = 0
    for i in range(len(A)-1):
        tmp = 0
        for j in range(i+1,len(A)):
            tmp+=A[j]
        S+= (tmp%MOD * A[i])%MOD


    print(S%MOD)



from itertools import accumulate

m = 10**9 + 7

N,*A = map(int,open(0).read().split())

result = 0

b = [0]*N
b[0] = A[0]
for i in range(1,N):
    b[i]= b[i-1] + A[i]




for i in range (N-1):
    result += A[i]*(b[N-1]-b[i])
    result %= m
print(result)


Measured memory_bytes: 31692
#include<iostream>
#include<algorithm>
#define int long long
using namespace std;
bool cmp1(pair<int,int>a,pair<int,int>b){
    int A=a.first+a.second;
    int B=b.first+b.second;
    return A<B;
}
bool cmp2(pair<int,int>a,pair<int,int>b){
    int A=a.first-a.second;
    int B=b.first-b.second;
    return A<B;
}
signed main(){
    int N;
    cin >> N;
    pair<int,int>p[N];
    for(int i=0;i<N;i++)cin>>p[i].first>>p[i].second;
    sort(p,p+N,cmp1);
    int ans=0;
    ans=abs(p[0].first-p[N-1].first)+abs(p[0].second-p[N-1].second);
    sort(p,p+N,cmp2);
    ans=max(ans,abs(p[0].first-p[N-1].first)+abs(p[0].second-p[N-1].second));
    cout<<ans;
}

Measured memory_bytes: 6204
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <cmath>
#define rep(i,m,n) for(int i=m; i<(n); i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
typedef long long ll;
using namespace std;

bool is_prime(const unsigned n)
{
    switch(n) {
        case 0:
        case 1: return false;
        case 2: return true;
    }

    if(n % 2 == 0) return false;
    for(unsigned i = 3; i * i <= n; i += 2) {
        if(n % i == 0) return false;
    }

    return true;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> prime;
    rep(i,2,100)
    {
        if(is_prime(i)) prime.push_back(i);
    }
    int n;
    cin >> n;
    vector<int> ans(n+1);
    rep(i,0,n+1) ans[i] = 0;
    rep(i,0,prime.size())
    {
        bool ok = true;
        int beki = 1;
        while(ok)
        {
            int tmp = pow(prime[i],beki);
            if(tmp > n) ok = false;
            ans[prime[i]] += n/tmp;
            beki++;
        }
    }
    int sum = 0;
    int c1=0, c2=0;
    rep(i,1,n+1)
    {
        if(ans[i]>=4) c1++;
        if(ans[i]>=2) c2++;
    }
    sum += c1*(c1-1)/2*(c2 - 2);
    c1=0; c2=0;
    rep(i,1,n+1)
    {
        if(ans[i]>=14) c1++;
        if(ans[i]>=4) c2++;
    }
    sum += c1*(c2-1);
    c1=0;c2=0;
    rep(i,1,n+1)
    {
        if(ans[i]>=24) c1++;
        if(ans[i]>=2) c2++;
    }
    sum += c1*(c2-1);
    rep(i,1,n+1)
    {
        if(ans[i]>=74) sum++;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>

using point = std::pair<int,int>;
int main(){
  int N,M;
  std::cin>>N>>M;
  std::vector<point> students(N);
  for(auto &s:students){
    std::cin>>s.first>>s.second;
  }
  std::vector<point> check(M);
  for(auto &c:check){
    std::cin>>c.first>>c.second;
  }
  
  for(const auto &s:students){
    int mini,mindist=1000000000;
    for(int i=0;i<M;++i){
      int dist = std::abs(s.first-check[i].first)+std::abs(s.second-check[i].second);
      if(dist<mindist){
        mindist = dist;
        mini = i;
      }
    }
    std::cout<<mini+1<<std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactice problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main() 
{ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ll n;
    cin>>n;
    ll a[n];
    map<ll, ll> m1;
    ll sum=0;
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
        m1[a[i]]++;
        sum+=a[i];
    }

    ll q;
    cin>>q;
    while(q--){
        ll b,c;
        cin>>b>>c;
        if(m1.find(b)!=m1.end()){
            sum = sum-((m1.find(b)->S)*b);
            sum = sum+((m1.find(b)->S)*c);
            if(m1.find(c)!=m1.end()){
                m1[c]+=m1[b];
            }
            else{
                m1[c]=m1[b];
            }
            m1.erase(m1.find(b));
        }
        cout<<sum<<endl;
    }

    return 0;
}

Measured memory_bytes: 8324
# Aizu Problem 0038: Poker Hand
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def is_straight(hand):
    if hand == [1, 10, 11, 12, 13]:
        return True
    m = min(hand)
    if hand == list(range(m, m + 5)):
        return True
    return False


def poker_hand(hand):
    hand = sorted(hand)
    counts = {}
    for card in hand:
        counts[card] = counts.get(card, 0) + 1
    counts = sorted(list(counts.values()))
    if counts == [1, 4]:
        return "four card"
    elif counts == [2, 3]:
        return "full house"
    elif is_straight(hand):
        return "straight"
    elif counts == [1, 1, 3]:
        return "three card"
    elif counts == [1, 2, 2]:
        return "two pair"
    elif counts == [1, 1, 1, 2]:
        return "one pair"
    else:
        return "null"


while True:
    try:
        hand = [int(_) for _ in input().split(',')]
    except EOFError:
        break
    print(poker_hand(hand))

Measured memory_bytes: 7792
! 2019.12.29
!
      program answer
      implicit none
      integer :: X
      integer :: i,j
      integer :: ans
      intrinsic sqrt,mod
!
      read(*,*) X
      i=0
!
      lp1:do
        ans=X+i
        j = 2
        lp2:do
          if(dble(j) > sqrt(dble(ans))) exit lp1
          if(mod(ans,j) == 0) exit lp2
          j = j + 1
        end do lp2
        i=i+1
      end do lp1
      write(*,*) ans
      end program answer

Measured memory_bytes: 768
n=int(input())
for i in range(n):
    board=[]
    check=[[0 for a in range(9)] for b in range(9)]
    for j in range(9):
        board.append(list(map(int,input().split())))
    board_r = [list(x) for x in zip(*board)]
    for j in range(9):
        for k in range(9):
            if board[j].count(board[j][k])>1:check[j][k]=1
    for j in range(9):
        for k in range(9):
            if board_r[j].count(board_r[j][k])>1:check[k][j]=1
    for j in range(3):
        for k in range(3):
            ch_list=[]
            for l in range(9):
                ch_list.append(board[j*3+l%3][k*3+l//3])
            for l in range(9):
                if ch_list.count(ch_list[l])>1:check[j*3+l%3][k*3+l//3]=1
    for j in range(9):
        for k in range(9):    
            if check[j][k]==1:print("*",end="")
            else:print(" ",end="")
            print(board[j][k],end="")
        print()
    if i<n-1:print()


Measured memory_bytes: 5628
#include <stdio.h>
 
#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
 
#define MAX  40002
#define BASE 20000
 
int a[MAX];
int sum[MAX]; int sz;
int left[MAX];
 
int main()
{
    int i, j, k, x, h, s, ans;
    int c;
 
    h = BASE, ans = s = 0;
    for (x = 1; ; x++) {
        c = gc();
        if (c <= ' ') break;
        if (c == '\\') {
            if (s > 0) ans += s, sum[sz++] = s, s = 0;
            a[--h] = x;
        } else if (c == '/') {
            if (a[h] > 0) left[sz] = a[h], s += x-a[h];
            else if (s > 0) ans += s, sum[sz++] = s, s = 0;
            h++;
        }
    }
    if (s > 0) ans += s, sum[sz++] = s;
 
    printf("%d\n", ans);
    k = sz;
    i = sz-1; while (i > 0) {
        j = i-1; while (j >= 0 && left[j] > left[i]) {
            sum[i] += sum[j], sum[j] = 0, j--, k--;
        }
        i = j;
    }
 
    printf("%d", k);
    for (i = 0; i < sz; i++) if (sum[i] > 0) printf(" %d", sum[i]);
    putchar('\n');
    return 0;
}



Measured memory_bytes: 2096
// https://www.youtube.com/watch?v=83yW2Pp6HMk
// https://atcoder.jp/contests/abc164/tasks/abc164_d

// use std::io::{self, Read};
use std::io;

const MOD: usize = 2019;

pub struct Solution;

impl Solution {
	pub fn subarray_divisibility(s: & str) -> u64 {
		let n = s.len();
		let s: Vec<char> = s.chars().collect();

		let mut suf: usize = 0;
		let mut power_of_ten: usize = 1;
		let mut answer: u64 = 0;
		let mut cnt_suf: Vec<usize> = vec![0; MOD];
		cnt_suf[suf] += 1;

		for i in (0..=n-1).rev() {
			let digit: usize = s[i].to_digit(10).unwrap() as usize;
			suf = (suf + digit * power_of_ten) % MOD;
			power_of_ten = 10 * power_of_ten % MOD;
			answer += cnt_suf[suf] as u64;
			cnt_suf[suf] += 1;
		}

		answer
	}
}

fn main() {
	let mut s= input();
	println!("{}", Solution::subarray_divisibility(&s));
	// let mut io_iter = reader.lock().lines();
}

fn input () -> String {
    let mut ret = String::new();
    io::stdin().read_line(&mut ret).expect("Failed to read from stdin");
    String::from(ret.trim())
}


Measured memory_bytes: 3068
n,q = gets.split.map(&:to_i)
queue = []
n.times{
  queue << gets.split
}
# n,q=5,100
# queue = [["p1",150],["p2",80],["p3",200],["p4",350],["p5",20]]
time = 0
def aqueue(n,q,queue,time)
  ans = []
  while queue.size != 0
    v = queue.shift
    if v[1].to_i <= q
      time += v[1].to_i
      ans.push("#{v[0]} #{time}")
    else
      time += q
      v[1] = v[1].to_i - q
      queue.push(v)
    end
  end
  return ans
end

puts aqueue(n,q,queue,time)

Measured memory_bytes: 20280
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
#define l(i,a,b) for(auto i=a;i<b;i++)
#define lr(i,a,b) for(auto i=a;i>=b;i--)
#define ll long long
#define lli long long int
#define ld long double
#define vec vector<int>
#define mii map<ll,ll>
#define vl vector<long long>
#define se set <long long int>
#define pi pair<long long,long long>
#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define all(v) v.begin(), v.end()
#define in(x) cin>>x
#define o(x) cout<<x
#define SYNC ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.14159265359
using namespace std;
 
ll modulo(ll a, ll b, ll n){
    long long x=1, y=a; 
    while (b > 0) {
        if (b%2 == 1) {
            x = (x*y) % n; 
        }
        y = (y*y) % n;
        b /= 2;
    }
    return x % n;
}

ll dp[200009];

int main()
{
    SYNC
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll n,W;
    in(n)>>W;
    l(i,0,n)
    {
        ll w,v; in(w)>>v;
        for(ll j=0; j<=(W-w); j++)
        {
            dp[j]=max(dp[j],dp[j+w]+v);
        }
    }
    o(dp[0])<<endl;
    
 
    
 
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b; cin >> n >> a >> b;
    int ans1 = min(a, b);
    int ans2;
    if(a + b < n) ans2 = 0;
    else ans2 = a + b - n;
    cout << ans1 << " " << ans2 << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	
	bool yes = false;
	if (n % 2 == 0) {
		yes = (n / 2) >= k;
	} else {
		yes = (n / 2) + 1 >= k;
	}
	
	cout << (yes ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        ITP1_2_B(args);
    }

    public static void ITP1_2_B(String[] args) {

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if (a < b && b < c) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}



Measured memory_bytes: 26184
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
#include <bitset>

using namespace std;
#define ff(i,n,m) for(int i=n;i<m;i++)
#define i64 int64_t
#define tos(x) to_string(x)

int main() {
	int a;
	cin >> a;
	string b;
	cin >> b;
	int ans = 0;
	int x = 0;
	ff(i, 0, a) {
		if (b.at(i) == 'I') {
			x++;
		}
		else {
			x--;
		}
		ans = max(ans, x);
	}
	cout << ans << endl;
	return 0;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

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

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

Measured memory_bytes: 256
using System;
class Program
    {
        static void Main(string[] args)
        {
            string str=Console.ReadLine();
            string ans="";
            int L = str.Length;
            for (int i = 0; i < L; i++) {
                ans += str.Substring(L - 1 - i, 1);
            }
            Console.WriteLine(ans);

            Console.ReadLine();
        }
    }

Measured memory_bytes: 8540
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    clr(v,d)      memset( v, d ,sizeof(v))
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(ll num, ll idx) {return num | (1ll<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void GO(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
const int N=300000+9;
int t[N],F[N];
char C[N];
deque<char> dq;
string st;
int arr[N];
int main(){
    GO();
    string ss;
    cin>>ss;

    int q;
    cin>>q;
    for(int i=0;i<q;i++){
        cin>>t[i];
        if(t[i]==1){
            ;
        }
        else{
            cin>>F[i]>>C[i];
        }
    }
    int cnt=0;
    for(int i=q-1;i>=0;i--){

        if(t[i]==1){
            cnt++;
            cnt%=2;
        }
        else{
            if(cnt!=0) F[i]=(F[i]==1?2:1);
        }
    }
    for(int i=0;i<sz(ss)&&cnt==0;i++){
      dq.pb(ss[i]);
    }
    for(int i=sz(ss)-1;i>=0&&cnt==1;i--){
      dq.pb(ss[i]);
    }
    for(int i=0;i<q;i++){
        if(t[i]!=1){
            if(F[i]==1) dq.push_front(C[i]);
            else
                dq.pb(C[i]);
        }
    }
    while(sz(dq)>0) cout<<dq.front(),dq.pop_front();
    cout<<"\n";

}













































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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	ll N;
	cin >> N;

	ll ans = 0;
	for(int i = 0; i < 40; i++){
		if((1LL << i) - 1 <= N){
			ans = i;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 3176
#include<iostream>

using namespace std;

int main(){
  int x;
  cin>>x;
  int ans=8;
  
  if(x>=1800) ans=1;
  else if(x>=1600) ans=2;
  else if(x>=1400) ans=3;
  else if(x>=1200) ans=4;
  else if(x>=1000) ans=5;
  else if(x>=800) ans=6;
  else if(x>=600) ans=7;
  
  cout<<ans<<endl;
 
  return 0;
}

Measured memory_bytes: 3528
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
#define INF 1e9 //10^9
#define MOD 1000000007
#define INFL 100000000000000000//10^18 = 2^60


#define MAX_V 1000010

struct edge {
    int to, cap, rev;
};

vector<vector<edge>> G(MAX_V);
bool used[MAX_V];


void add_edge(int from, int to, int cap){
    edge F;
    edge T;
    F.to = to;
    F.cap = cap;
    F.rev = G[to].size();
    G[from].push_back(F);
    
    T.to = from;
    T.cap = 0;
    T.rev = G[from].size() - 1;
    G[to].push_back(T);
}

int dfs(int v, int t, int f){
    if(v == t) return f;
    used[v] = true;
    for(int i = 0; i < G[v].size(); i++){
        edge &e = G[v][i];
        if(!used[e.to] && e.cap > 0){
            int d = dfs(e.to, t, min(f, e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

int max_flow(int s, int t){
    int flow = 0;
    while(1){
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF);
        if(f == 0) return flow;
        flow += f;
    }
}


int main(void){
    int N;
    cin >> N;
    
    vector<pair<int, int>> R(N), B(N);
    
    for(int i = 0; i < N; i++) cin >> R[i].first >> R[i].second;
    for(int i = 0; i < N; i++) cin >> B[i].first >> B[i].second;
    
    int s = N * 2, t = N * 2 + 1;
    
    for(int i = 0; i < N; i++){
        add_edge(s, i, 1);
        add_edge(i + N, t, 1);
    }
    
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(R[i].first < B[j].first && R[i].second < B[j].second){
                add_edge(i, j + N, 1);
            }
        }
    }
    
    cout << max_flow(s, t) << endl;
    
}



Measured memory_bytes: 24832
#include <bits/stdc++.h>
using namespace std;
inline int read(){
    int x = 0; char c = getchar();
    while (!isdigit(c)) c = getchar();
    while (isdigit(c)) x = x * 10 + c - '0',c = getchar();
    return x;
}
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}
inline void write(int x){if (x > 9) write(x/10); putchar(x%10+'0'); }
const int N = 100050;
int n,k,s,a[N];
int main(){
	n = read(),k = read(),s = read();
	if (s!=1000000000){
		for (int i = 1; i <= k; ++i) a[i] = s;
		for (int i = 1; i <= n-k; ++i) a[i+k] = s+1;
		for (int i = 1; i <= n; ++i) write(a[i]),putchar((i<n)?(' '):('\n'));
		putchar('\n');
		return 0;
	}
	for (int i = 1; i <= k; ++i) a[i] = s;
	for (int i = 1; i <= n-k; ++i) a[i+k] = 1;
	for (int i = 1; i <= n; ++i) write(a[i]),putchar((i<n)?(' '):('\n'));
	putchar('\n');
    return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long name;
    cin>>name;
    long long  i,sum=0;
    for(i=1;i<=name;i++)
    {
        if(i%3!=0)
        {
            if(i%5!=0)
            {
                sum+=i;
            }
        }

        }
    cout<<sum<<endl;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
multiset<int> MS;
int X[200200];
int main()
{
  int N;
  cin>>N;
  for(int i=0;i<N;i++)
    cin>>X[i];
  sort(X,X+N);
  reverse(X,X+N);
  MS.insert(-X[0]);
  long long Ans=0;
  for(int i=1;i<N;i++)
  {
    Ans-=*(MS.begin());
    MS.erase(MS.begin());
    MS.insert(-X[i]);
    MS.insert(-X[i]);
  }
  cout<<Ans<<endl;
  return 0;
}

Measured memory_bytes: 13776
#include <iostream>

using namespace std;

int main() {
    int a = 0;
    int b = 0;
  int ans;
  char kigou;
  cin >> a >> kigou >> b;
  if (kigou == '+') {
      ans = a + b;
  }
  if (kigou == '-') {
      ans = a - b;
  }
  cout << ans << endl;
  return 0;
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }
// ll comb(ll n, ll k) { ll v=1; for(ll i=1; i<=k; i++) v = DIV(MUL(v, n-i+1),i); return v; }
//

ll solve(string& s) {
    int L = s.size();
    ll ans = 0;
    vi a_acc(L+1, 0), c_acc(L+1, 0), q_acc(L+1, 0);
    rep(i, L) {
        a_acc[i+1] = a_acc[i] + (s[i]=='A');
        c_acc[i+1] = c_acc[i] + (s[i]=='C');
        q_acc[i+1] = q_acc[i] + (s[i]=='?');
    }
    for (int i=1; i<L-1; ++i) {
        if (s[i] == 'A' || s[i] == 'C') continue;
        ll left_a = a_acc[i] - a_acc[0], left_q = q_acc[i] - q_acc[0];
        ll right_c = c_acc[L] - c_acc[i+1], right_q = q_acc[L] - q_acc[i+1];
        ll left = MUL(left_a, POW(3,left_q));
        if (left_q) {
           left = ADD(left, MUL(left_q, POW(3,left_q-1)));
        }
        ll right = MUL(right_c, POW(3,right_q));
        if (right_q) {
           right = ADD(right, MUL(right_q, POW(3,right_q-1)));
        }
        ans = ADD(ans, MUL(left, right));
    }
    return ans;
}

int main() {
    string s; cin >> s;
    cout << solve(s) << endl;
    return 0;
}


Measured memory_bytes: 1664
def solve():
    N, X, D = map(int, input().split())

    if D == 0:
        if X == 0:
            print(1)
        else:
            print(N+1)
        return

    LRss = {}
    for k in range(N+1):
        m = X*k
        rem = m%D
        minCoef = m//D + k*(k-1)//2
        maxCoef = m//D + k*(2*N-k-1)//2
        if rem not in LRss:
            LRss[rem] = [(minCoef, maxCoef)]
        else:
            LRss[rem].append((minCoef, maxCoef))

    ans = 0
    for rem, LRs in LRss.items():
        LRs.sort()
        LNow, RNow = LRs[0]
        for L, R in LRs[1:]:
            if L <= RNow:
                if R > RNow:
                    RNow = R
            else:
                ans += RNow - LNow + 1
                LNow, RNow = L, R
        ans += RNow - LNow + 1

    print(ans)


solve()


Measured memory_bytes: 72180
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;



Node treeMinimum(Node x){

  while(x->left!=NIL){
    x=x->left;
  }
  return x;

}

Node treeMaximum(Node x){

  while(x->right!=NIL){
    x=x->right;
  }
  return x;

}

Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key) return u;
  if(k<u->key){
    return treeSearch(u->left,k);
  }
  else return treeSearch(u->right,k);

}

Node treeSuccessor(Node x){
  Node y;
  if(x->right!=NIL)
    return treeMinimum(x->right);
  y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left==NIL || z->right==NIL)
    y=z;
  else y=treeSuccessor(z);

  if(y->left!=NIL) x=y->left;
  else x=y->right;

  if(x!=NIL) x->parent=y->parent;
  if(y->parent==NIL) root=x;
  else if(y==y->parent->left) y->parent->left=x;
  else y->parent->right=x;

  if(y!=z) z->key=y->key;
  free(y);
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }

  z->parent=y;
  if(y==NIL){
    root=z;
  }else{
    if(z->key<y->key){
      y->left=z;
    }else{
      y->right=z;
    }
  }


}

void inorder(Node u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

 
  return 0;
}



Measured memory_bytes: 20432
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 
vi g[2000005];
vi ans;

void dfs(int a,int p=-1){
	for(int c:g[a]){
		if(c==p) continue;
		ans[c]+=ans[a];
		dfs(c,a);
	}
}
signed main(){
	int n,q; cin>>n>>q;
	//vvi vec(n,vi(0));
	//vvi g(n,vi(0));
	rep(i,0,n-1){
		int a,b; cin>>a>>b;
		--a; --b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	ans.resize(n);
	rep(i,0,q){
		int a,b; cin>>a>>b;
		--a;
		ans[a]+=b;
	}
	dfs(0);
	rep(i,0,n) cout<<ans[i]<<" ";
	
	return 0;
}

Measured memory_bytes: 65664
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
const double eps = 1e-10;

int main() {
  int N;
  cin >> N;
  vi A(N);
  rep(i,N) {
    cin >> A[i];
  }
  vi s(100010,0);
  rep(i,N) {
    if(A[i]>0) {
      s[A[i]-1]++;
    }
    s[A[i]]++;
    s[A[i]+1]++;
  }
  int ans = 0;
  rep(i,100010) {
    chmax(ans,s[i]);
  }
  cout << ans << endl;
}

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


int six[] = {
1,
6,
6 * 6,
6 * 6 * 6,
6 * 6 * 6 * 6,
6 * 6 * 6 * 6 * 6,
6 * 6 * 6 * 6 * 6 * 6,
6 * 6 * 6 * 6 * 6 * 6 * 6,
};

int nine[] = {
	1,
	9,
	9 * 9,
	9 * 9 * 9,
	9 * 9 * 9 * 9,
	9 * 9 * 9 * 9 * 9,
	9 * 9 * 9 * 9 * 9 * 9};

int r[100000 + 1];

int kaisu(int N){

	if (r[N] > 0) return r[N];

	if (N <= 5) return r[N]=N;

	int *p6 = upper_bound(six, six + 7, N);
	int *p9 = upper_bound(nine, nine + 6, N);

	return r[N] = 1 + min(kaisu(N - *(p6 - 1)), kaisu(N - *(p9 - 1)));
}

int main(){

	int N;

	cin >> N;

	cout << kaisu(N) << endl;

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;
#define rep(i, b) for( int i = 0; i < b; i++ )
#define m_t 60
#define max (3*m_t*(m_t+1)+1)
#define zero (max/2)
#define mp make_pair

int dx[6] = {0,1,-1,1,-1,0};
int dy[6] = {1,1,0,0,-1,-1};
vector<int> field(max);
int t, n;
int cnt;

int main(){
    while( cin >> t >> n, t ){
        fill( field.begin(), field.end(), 1 );  // reset
        int x, y;
        /* input of obstacle */
        rep(i, n){
            cin >> x >> y;
            y = y * (m_t*2 + m_t*2+1-abs(y)) / 2;
            field[zero+x+y] = 0;
        }
        int sx, sy;
        /* input of the starting point */
        cin >> sx >> sy;
        x = sx;
        y = sy * (m_t*2 + m_t*2+1-abs(sy)) / 2;
        field[zero+x+y] = 0;
        //cnt = 0;
        //dfs(sx, sy, 0);

        int ans = 0;
        queue< pair< pair<int, int>, int > > rt;
        rt.push(mp(mp(sx, sy), 0));

        while( !rt.empty() ){
            ans++;
            int cx = rt.front().first.first;
            int cy = rt.front().first.second;
            int ct = rt.front().second;
            rt.pop();

            if( ct < t ){
                rep(i, 6){
                    int nx = cx + dx[i];
                    int ny = (cy + dy[i]) * (m_t*2 + m_t*2+1-abs(cy+dy[i])) / 2;
                    if( field[zero+nx+ny] ){
                        field[zero+nx+ny] = 0;
                        rt.push(mp(mp(nx, cy+dy[i]), ct+1));
                    }
                }
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1264
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int a, b, c, d; cin >> a >> b >> c >> d;
  if(a == c){
    cout << 0 << endl;
  }
  else cout << 1 << endl;
  system("pause");
}

Measured memory_bytes: 504
import sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    import os, zlib, base64
    open('solve.pyx', 'wb').write(zlib.decompress(base64.b85decode("c${TYO>cuR480@qAH2g<SksD5J4|Tok8~W85Fi=^lxC{7Uq74hU0=X{&(AMTO53&2Xd%xxXSJz7>bCE!gI2XS<-(vOg8X%LXU;vhylGT3lX}ZdrAE@IQs{2RE9GR(EkmL<t_%ZNs1oq^`kGMW(1(Ga6!i>F7X}`H7r5y^)s+#F<9Kdtv{BTL6HF9?=_=i%VE`DDGzbO~GDv*+Uh77|Wh7Au1V>|0yp(l`$OpW=ry#82-wQ%&5*=L<I3nkS91mLMeyjnxoC_Mo3uVbQ@U1`8@2@<^5lK3Aat{slZ0e;f-VC71YKCFZGT@9(su?&&4({63n|X#@)0TYNZqu@}piynS!l;c`8{%8;w6tA`FP1qj<+5Xskk~=E1`badh}FFHdOq<Z@*POwP?JBF$%S|<lLNOc5Aw%s(BC5>_v-Un{8mi7T;8d_YO*KO;Xw>(82E=B9iEFXbHIzhll}vB`qr2")))
    os.system('cythonize -i -3 -b solve.pyx')
import solve

Measured memory_bytes: 9904
#include <vector>
#include <array>
#include <algorithm>
#include <iostream>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <assert.h>
#include <queue>
#include <deque>
#include <iomanip>
#include <numeric>
#include <fstream>

using namespace std;

typedef long long ll;
typedef long double ld;

#define fi first
#define se second

#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<ld>> vvd;
typedef vector<string> vs;
typedef vector<bool> vb;

typedef pair <int, int> pii;
typedef pair <ll, ll> pll;



int main() {
    cout << setprecision(30);
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    ll n;
    cin >> n;
    vl a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    ld ans = a[0];
    for (int i = 1; i < n; ++i) {
        ans = (ans + a[i]) / 2.;
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

#define ll long long
#define ini(arr, val) memset(arr, (val), sizeof(arr))
#define loop(i,n)  for(ll i=0; i<n; i++)
#define loop1(i,n)  for(ll i=1; i<=n; i++)

#define all(a)      (a).begin(),(a).end()
#define exist(s,e)  (s.find(e)!=s.end())
#define dbg(x)  cout << #x << " = " << x << endl
#define pt(x) cout<<x<<"\n"
#define pts(x) cout<<x<<" "

#define mp make_pair
#define pb push_back
#define F first
#define S second


#define inf (int)1e9
#define infll 1e18
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007


#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test   int t; cin>>t; while(t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef set<int> si;

typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pll> vpll;
typedef vector<vl> vvl;
typedef map<ll,ll> mll;
typedef set<ll> sl;


int dirx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int diry[] = { -1, 0, 1, -1, 1, -1, 0, 1 };



//===========================DEBUG======================//
#define XOX 1
vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

//================================================================//



//////////////////////////////////////////////////////////////////////////////////////////
//                      main starts
//////////////////////////////////////////////////////////////////////////////////////////
int const lmt=2e5+5;
int fre[lmt],a[lmt];

int main(){
 //    #ifndef ONLINE_JUDGE
 //    freopen("../../input.txt", "r", stdin);
 //    freopen("../../output.txt", "w", stdout);
	// #endif
    fast

    ll n; cin>>n;
    loop(i,n){
    	cin>>a[i];
    	fre[a[i]]++;
    }
    ll ans=0;
    loop(i,lmt){
    	ans += 1ll*fre[i]*(fre[i]-1)/2;
    }
    loop(i,n){
    	ll val = ans - (fre[a[i]]-1);
    	pt(val);	
    }
}


/*



*/





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

int divceil(int a, int b) {
  return (a+b-1)/b;
}

int main() {
  int k, q;
  cin >> k >> q;
  vector<int> d(k);
  rep(i,k) cin >> d[i];
  rep(qi,q) {
    int n, x, m;
    cin >> n >> x >> m;
    ll last = x, eq = 0;
    rep(i,k) {
      ll num = divceil(n-1-i, k);
      last += (d[i]%m)*num;
      if (d[i]%m == 0) eq += num;
    }
    ll ans = (n-1) - (last/m - x/m) - eq;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int n,x[1000010],p;
char s[1000010],t[1000010];
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j,k,l;
	scanf("%d%s%s",&n,&s,&t);
	for(i=n-1,j=n,k=0,l=0;i>=0;i--)
	  {
	   if(j>i && t[i]!=s[i])
	     j=i;
	   if(j<=i && t[i]!=s[j])
	     {
	      for(;j>=0 && t[i]!=s[j];j--);
	      if(j<0)
	        {
	         printf("-1\n");
	         return 0;
	        }
	      k++;
	      l++;
	      x[j+l]++;
	      p=max(p,k);
	     }
	   k-=x[i+l];
	   x[i+l]=0;
      }
    printf("%d\n",p);
	return 0;
}


Measured memory_bytes: 6144
import java.util.Scanner;

public class Main {

	private static int money;

	private static int cakeFare;

	private static int donutFare;

	public static void main(String[] args) {

		scan();
		System.out.println((money - cakeFare) % donutFare);
	}

	private static void scan() {
		Scanner sc = new Scanner(System.in);
		money = sc.nextInt();
		cakeFare = sc.nextInt();
		donutFare = sc.nextInt();
		sc.close();
	}
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int dr[] = { 1, 0, -1, 0 };
int dc[] = { 0, 1, 0, -1 };

int main() {
    int w, h;
    while (cin >> w >> h) {
        if (w == 0 and h == 0) break;
        string board[51];
        rep(r, h) cin >> board[r];
        int wc = 0, bc = 0;
        rep(r, h) rep(c, w) {
            if (board[r][c] != 'B' and board[r][c] != 'W') continue;
            queue<P> que;
            que.push(make_pair(r, c));
            bitset<50*50+1> visited;
            visited[r*w+c] = 1;
            while (que.size()) {
                P p = que.front();
                que.pop();
                rep(i, 4) {
                    int nr = p.first + dr[i], nc = p.second + dc[i];
                    if (nr < 0 or nr >= h or nc < 0 or nc >= w or visited[nr*w+nc] == 1) continue;
                    if (board[nr][nc] == 'W' or board[nr][nc] == 'B') continue;
                    if (board[nr][nc] == '.') {
                        if (board[r][c] == 'W') board[nr][nc] = 'w';
                        if (board[r][c] == 'B') board[nr][nc] = 'b';
                    }
                    else {
                        if (board[r][c] == 'W' and board[nr][nc] == 'b') board[nr][nc] = 'x';
                        if (board[r][c] == 'B' and board[nr][nc] == 'w') board[nr][nc] = 'x';
                    }
                    visited[nr*w+nc] = 1;
                    que.push(make_pair(nr, nc));
                }
            }
        }
        rep(rr, h) rep(cc, w) {
            if (board[rr][cc] == 'w') wc++;
            else if (board[rr][cc] == 'b') bc++;
        }
        cout << bc << " " << wc << endl;
    }
    return 0;
}



Measured memory_bytes: 3092