akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline

h, w, K = [int(x) for x in input().split()]
s = [input().rstrip() for _ in range(h)]
# print(s)
# print(len(s[1]))

# ans = h + w - 2
ans = h + w - 2
for i in range(2 ** (h - 1)):
    new_s = []
    cnt = 0
    i_bin = bin(i)[2:].zfill(h - 1)
    add = []
    for j in range(h - 1):
        if i_bin[j] == "1":
            cnt += 1
            add.append(s[j])
            new_s.append(add)
            add = []
        else:
            add.append(s[j])
        if j == h - 2:
            add.append(s[-1])
            new_s.append(add)
    if h == 1:
        new_s = [s]
    #print(len(new_s))
    total = [0] * len(new_s)
    #print(new_s)
    for k in range(w):
        # print(k)
        tmp_list = [0]*len(new_s)
        #print(total)
        flag = 0
        for l in range(len(new_s)):
            tmp = sum([int(new_s[l][x][k]) for x in range(len(new_s[l]))])
            # tmp_list[l] = tmp
            # print(tmp)
            if tmp > K:
                cnt = 10**18
                flag = 1
                break
            tmp_list[l] = tmp
            total[l] += tmp
        if flag:
            break
        for m in total:
            flag_2 = 1
            if m > K:
                cnt += 1
                total = tmp_list
                flag_2 = 0
                break
        # if flag_2:
        #     for m in total:
        #         if m == K and k != w - 1:
        #             cnt += 1
        #             total = [0]*len(new_s)
        #             break
    if not flag:
        #print(cnt)
        ans = min(ans, cnt)
print(ans)






Measured memory_bytes: 46680
#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 ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main()
{
	ll n;
	cin >> n;
	vector<ll> a(n);
	rep(i,n)cin >> a[i];
	vector<ll> sum(n+1);
	rep(i,n)
	{
		sum[i+1] = sum[i]+a[i];
	}
	sort(ALL(sum));
	
	ll ans = 0;
	ll now = 1;
	rep(i,n)
	{
		if(sum[i]==sum[i+1])
		{
			now++;
		}
		else
		{
			ans += now*(now-1)/2;
			now = 1;
		}
		
	}
	ans += now*(now-1)/2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define sortall(obj) sort(ALL(obj))
#define revall(obj) reverse(ALL(obj))
#define SortRevAll(obj) revall(sortall(obj))
typedef string str;
typedef long long ll;
const int mod=1e9+7;
const int INF=1e9;
const ll LINF=1e18;
#define V vector
#define P pair
#define M map
#define F first()
#define S second()
#define PB(a) push_back(a)
#define IN(a) insert(a)
#define ins(a) int a;cin >> a
#define lls(a) ll a;cin >> a
#define in(a) cin >> a
#define sts(a) string (a);cin >> a
#define For(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) For(i,0,n)
#define Forr(i,m,n) for(int i=n-1;i>=m;i--)
#define repr(i,n) Forr(i,0,n)
#define print(a) cout << a << endl
#define Endl cout << endl
#define YES(n) cout << ((n)? "YES" : "NO") << endl
#define Yes(n) cout << ((n)? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE" ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

int main(){
    ins(a);ins(b);
    if(a==1)a=14;if(b==1)b=14;
    if(a==b){
        print("Draw");
    }else if(a>b){
        print("Alice");
    }else{
        print("Bob");
    }
    return 0;
}


Measured memory_bytes: 256
def main():
  x = int(input())
  sosu = []
  tgt = 2
  is_sosu = True
  while(1):
    for i in sosu:
      if tgt % i == 0:
        is_sosu = False
        break
    if is_sosu:
      sosu.append(tgt)
    if tgt >= x and is_sosu:
      print(tgt)
      break
    else:
      tgt += 1
      is_sosu = True

if __name__ == "__main__":
  main()


Measured memory_bytes: 39024
def main():
    n = int(input())
    count = 0
    for _ in range(n):
        x = int(input())
        count += isprime(x)
    print(count)

def isprime(x: int):
    if x == 2:
        return True
    if x % 2 == 0:
        return False
    for y in range(3, int(x**0.5)+1, 2):
        if x % y == 0:
            return False
    return True

if __name__ == '__main__':
    main()



Measured memory_bytes: 5676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, m, a, b, l, r;
string s;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n >> m;
	
	bool used[n+1];
	memset(used, 0, sizeof(used));

	vector<ll> edge[n+1];
	deque<ll> ans;
	rep(i, 1, m){
		cin >> a >> b;
		edge[a].push_back(b);
		edge[b].push_back(a);
		if(i == 1){
			ans.push_back(a);
			ans.push_back(b);
			used[a] = true;
			used[b] = true;
		}
	}
	
	bool loop = true;
	while(loop){
		ll at = ans.front();
		for(ll i = 0; i < edge[at].size(); i++){
			ll nx = edge[at][i];
			if(!used[nx]){
				ans.push_front(nx);
				used[nx] = true;
				break;
			}
			if(i == edge[at].size()-1){
				loop = false;
			}
		}
	}
	
	loop = true;
	while(loop){
		ll at = ans.back();
		for(ll i = 0; i < edge[at].size(); i++){
			ll nx = edge[at][i];
			if(!used[nx]){
				ans.push_back(nx);
				used[nx] = true;
				break;
			}
			if(i == edge[at].size()-1){
				loop = false;
			}
		}
	}
	
	print(ans.size())
	for(auto it = ans.begin(); it != ans.end(); it++){
		cout << *it << " ";
	}
	return 0;
}

Measured memory_bytes: 7168
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::vector<i64> a(n), ret(n);
    std::cin >> a[n - 1];
    for (int i = 0; i + 1 < n; i++) {
        std::cin >> a[i];
        ret[i + 1] = a[i] - ret[i];
    }

    i64 x = (a[n - 1] - ret[n - 1]) / 2;
    std::cout << 2 * x + 2 * ret[n - 1] << " ";
    for (int i = 0; i < n - 1; i++) {
        std::cout << (i % 2 ? -2 : 2) * x + 2 * ret[i] << " ";
    }
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 2944
#include<map>
#include<queue>
#include<time.h>
#include<limits.h>
#include<cmath>
#include<ostream>
#include<iterator>
#include<set>
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define rep_1(i,m,n) for(int i=m;i<=n;i++)
#define mem(st) memset(st,0,sizeof st)
inline int read()
{
	int num=0, w=0;
	char ch=0;
	while (!isdigit(ch))
	{
		w|=ch=='-';
		ch = getchar();
	}
	while (isdigit(ch))
	{
		num = (num<<3) + (num<<1) + (ch^48);
		ch = getchar();
	}
	return w? -num: num;
}
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef pair<double,double> pdd;
const int inf = 0x3f3f3f3f;
const int N=100100;
int n;
int a[N];
int q[N];
int ans[N];
void solve()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	int ans=0;
	for(int i=1;i<=n;i+=2)
		if(a[i]%2)
			ans++;
		cout<<ans<<endl;
}
signed main()
{
	int t=1;
	while(t--)
		solve();
	return 0;
}


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

using namespace std;

typedef pair <int, int> pii;

const int maxn = 3e5;
int n, m, a[maxn], val[maxn];
pii p[maxn];

int main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n;
	m = 1 << n;
	for (int i = 0; i < m; ++i)
		cin >> a[i];
	for (int i = 1; i < m; ++i) {
		p[i].first = a[0];
		for (int j = i; j; j = (j - 1) & i)
			if (a[j] > p[i].first)
				p[i] = {a[j], p[i].first};
			else if (a[j] > p[i].second)
				p[i].second = a[j];
		val[i] = p[i].first + p[i].second;
	}
	for (int i = 1; i < m; ++i) {
		int ans = val[i], mask = i, d;
		while (mask) {	
			d = mask & -mask;
			ans = max(ans, val[(i - d) | (d - 1)]);
			mask -= d;
		}
		cout << ans << '\n';
	}
	return 0;
}


Measured memory_bytes: 7680
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> P1;
typedef long long int ll;

//define
#define INF 1e9
#define NUM 1000000007
#define all(x) begin(x),end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

/*ll gcd(ll a, ll b) {
	if (b == 0) return a;
	else return gcd(b, a%b);
}*/

/*ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a * (b / g);
}*/

/*int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}*/

int main () {
	int n;
	cin >> n;
	vector<pair<int, int>> p;
	int a, b;
	rep (i, n) {
		cin >> a >> b;
		p.emplace_back (a, b);
	}
	sort (all (p));
	int ans = p[0].first ;
	rep (i, n-1) {
		ans += p[i + 1].first - p[i].first;
	}
	ans += p[n - 1].second - 0;
	cout << ans << endl;
}



Measured memory_bytes: 1400
/*
author: Apoorv Singh
*/
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
 
typedef vector <int> vi;
typedef pair <int, int> pii;
typedef vector <long long> vll;
typedef pair <long long, long long> pll;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define For(i, a, b) for (long long i = a; i < b; ++i)
#define Forr(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define ll long long 
#define endl "\n"
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;  
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

template <class X>
void printarr(X arr[], int n) {
	for (int i = 0; i < n; ++i)
		cout << arr[i] << ' ';
	cout << endl;
}
 
template <class T, class cmp = less<T>> using ordered_set = tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
 
ll modulo = 1e9 + 7;

ll fpow(ll a, ll n) {
	ll ans = 1;
	while (n) {
		if (n&1) ans = (ans*a)%modulo;
		a = (a*a)%modulo; n = n >> 1;
	}
	return ans;
}

void solve() {
	int n;
	cin >> n;
	set <string> st;
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		st.insert(s);
	}		
	cout << st.size() << endl;
}

int main() {
	fast_io();
	int t = 1;
	// cin >> t;
	while (t--) solve();
	return 0;
}

Measured memory_bytes: 19244
l = list(map(int, input().split()))
l.sort()
a, b, c = l

count = 0
if ((a % 2) == (b % 2)):
    count = ((b - a) / 2) + c - b
elif ((a % 2) == (c % 2)):
    count = (c - b + 1) / 2
    b = c + 1
    count += ((c - a) / 2) + b - c
else:
    count = (c - a + 1) / 2
    a = c + 1
    count += ((c - b) / 2) + a - c

print(int(count))


Measured memory_bytes: 3064
N, D = list(map(int,input().split()))
X = []
for i in range(N):
    X.append(list(map(int,input().split())))
#print(X)
count = 0
for i in range(0,N,1):
    for j in range(i+1,N,1):
        wa = 0
        for k in range(D):
            wa += (X[i][k] - X[j][k])**2
        if wa**0.5 == int(wa**0.5):
            count += 1
print(count)

Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;

using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
	public Program() { }

	static void Main(string[] args)
	{
		new Program().prog();
	}
	Scanner cin;
	const int MOD = 1000000007;
	const int INF = int.MaxValue - 10;
	const long INFL = long.MaxValue - 10;
	const double EPS = 1e-7;
	const double PI = 3.1415926536;

	int N;

	void prog()
	{
		cin = new Scanner();
		int[,] dir8 = new int[8, 2] { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 }, { 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 } };
		int[,] dir4 = new int[4, 2] { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

		N = cin.nextInt();
		
		int max = (int)Math.Ceiling(Math.Sqrt(2 * N));
		for (int i = max; i > 0; i--)
		{
			if ((long)i * (i + 1) >= 2 * N && (long)(i - 1) * i < 2 * N)
			{
				max = i;
				break;
			}
		}
		int sum = max * (max + 1) / 2;
		for (int i = 1; i <= max; i++)
		{
			if (i != sum - N)
			{
				Console.WriteLine(i);
			}
		}
	}
}

class Scanner
{
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner()
	{
		s = new string[0];
		i = 0;
	}

	public string next()
	{
		if (i < s.Length) return s[i++];
		string st = Console.ReadLine();
		while (st == "") st = Console.ReadLine();
		s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
		i = 0;
		return next();
	}

	public int nextInt()
	{
		return int.Parse(next());
	}

	public long nextLong()
	{
		return long.Parse(next());
	}

	public double nextDouble()
	{
		return double.Parse(next());
	}
}

Measured memory_bytes: 2904
// Solution.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(void) {

	int n; cin >> n;
	n %= 10;
	switch (n) {
	case 3: cout << "bon" << endl;
		break;
	case 0:
	case 1:
	case 6:
	case 8: cout << "pon" << endl; break;
	default: cout << "hon" << endl; break;

	}
	return 0;
}


Measured memory_bytes: 3564
#include <iostream>
#include <vector>

int main() {
    int n;
    std::cin >> n;
    std::vector<int> h(n);
    for (int i = 0; i < n; i++) {
        std::cin >> h[i];
    }

    int ans = 0, prev = -1, tmp = 0;
    for (int i = 0; i < n; i++) {
        if (prev >= h[i]) {
            prev = h[i];
            tmp++;
            ans = std::max(ans, tmp);
        } else {
            prev = h[i];
            tmp = 0;
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 640
/**
* Think twice, code once.
* 1.integer overflow(maybe even long long overflow : (a+b >= c) -> (a >= c-b)
* 2.runtime error
* 3.boundary condition
* ---------------------------------------------------------------------------------------
* Author : zzy
* Date : 2020-03-22-19.58.21 Sunday
*/
#include <bits/stdc++.h>

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) ((int)(x).size())

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int n, m;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    cin >> n >> m;
    int ans = 0;
    if (n >= 2) ans += n*(n-1)/2;
    if (m >= 2) ans += m*(m-1)/2;
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 30;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

string s;

int main()
{
	cin >> s;
	string t = s;
	reverse(s.begin(), s.end());

	if (s == t) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


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

using namespace std;

vector<vector<pair<int, long long>>> v(100000);
vector<long long> dist(100000);

void dfs(int i, int p, long long d);

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

	int a, b, c;
	for (int i = 0; i < n - 1; i++) {
		cin >> a >> b >> c;
		a--;
		b--;

		v[a].emplace_back(make_pair(b, c));
		v[b].emplace_back(make_pair(a, c));
	}

	int q, k;
	cin >> q >> k;
	k--;
	dfs(k, k, 0);

	int x, y;
	for (int i = 0; i < q; i++) {
		cin >> x >> y;
		cout << dist[x - 1] + dist[y - 1] << endl;
	}
	
	return 0;
}

void dfs(int i, int p, long long d)
{
	dist[i] = d;

	for (auto & j : v[i]) {
		if (j.first == p) {
			continue;
		}

		dfs(j.first, i, d + j.second);
	}
}

Measured memory_bytes: 14336
#include <iostream>

using namespace std;

int main()
{
  long long int n, a, b;
  long long int ans = 0, mod;
  
  cin >> n >> a >> b;
  
  ans = a * (n / (a + b));
  mod = n % (a + b);
  
  if (mod > a) {
    ans += a;
  }
  else {
    ans += mod;
  }
  
  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++)
int main(){ 
    int n;
    cin>>n;
    vector<int> a(n);
    REP(i,n) cin>>a[i];
    if(n%2==0){
        for(int i=n-1;i>0;i-=2){
            cout<<a[i]<<' ';
        }
        for(int i=0;i<n;i+=2){
            cout<<a[i]<<' ';
        }
    }else{
        for(int i=n-1;i>=0;i-=2){
            cout<<a[i]<<' ';
        }
        for(int i=1;i<n;i+=2){
            cout<<a[i]<<' ';
        }
    }
    return 0;
}


Measured memory_bytes: 2944
import java.util.Scanner;
import java.util.Arrays;
import java.util.Collections;

public class Main {
    public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
//       while(true) {
    	   String[] s = sc.next().split("");
    	   boolean YY = true;
    	   boolean MM = true;
    	   if(Integer.valueOf(s[0]+s[1]) > 12 || Integer.valueOf(s[0]+s[1]) == 0) {
    		   MM = false;
    	   }
    	   if(Integer.valueOf(s[2]+s[3]) > 12 || Integer.valueOf(s[2]+s[3]) == 0) {
    		  YY = false;
    	   }
    	   if(!YY && !MM) {
    		   System.out.print("NA");
    	   }
    	   if(YY && MM){
    		   System.out.println("AMBIGUOUS");
    	   }
    	   else if(YY) {
    		   System.out.println("YYMM");
    	   }
    	   else if(MM) {
    		   System.out.println("MMYY");
    	   }
    	   
//      }
    }
}

Measured memory_bytes: 21716
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        int c = stdIn.nextInt();
        // String s = stdIn.next();
        boolean flag = true;
         
        if(a == b && b == c){
            flag = false;
        } 
        
        if(a != b && a != c && b != c){
            flag = false;
        }
        
        // int num[] = new int[n];
        
        // for(int i = 0; i < n; i++){
        //     num[i] = stdIn.nextInt();
        // }
        
        // char c[] = s.toCharArray();
        
        // for(int i = 0; i < s.length(); i++){
        //     c[i];
        // }
        
        if(flag){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        
        // System.out.println();
        // System.out.print();
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long
using namespace std;
int main()
{
    ll n,m,k;
    cin>>n>>m>>k;
    if(n<0) n=n*-1;
    ll  div =n/k;
    ll rem=n%k;
    ll x=m-div;
    ll fx=rem-k;
    if(div<=m)
    {




        if(x%2==0) {
            cout<<rem<<endl;
        }
        else {
            cout<<abs(fx)<<endl;
        }






    }
    else
    {
        ull w=k*m;
        cout<<n-w<<endl;
    }

}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define For(i,n) for(int i=0;i<n;i++)
#define Fre(i,a,b) for(int i = a; i < b; i++)
#define sf(n) scanf("%d", &n)
#define sff(a,b) scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pfn(n) printf("%d\n", n)
#define pfs(n) printf("%d ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define READ freopen("in.txt", "r", stdin)
#define WRITE freopen("out.txt", "w", stdout)
#define sz size()
#define number_of_digit(n) __builtin_ffs(n);
#define ll long long
#define T int
#define ld long double
inline void print(T n)
{
	if (n == 0)
	{
		putchar('0');
		putchar('\n');
	}
	else if (n == -1)
	{
		putchar('-');
		putchar('1');
		putchar('\n');
	}
	else
	{
		char buf[11];
		buf[10] = '\n';
		int i = 9;
		while (n)
		{
			buf[i--] = n % 10 + '0';
			n /= 10;
		}
		while (buf[i] != '\n')
			putchar(buf[++i]);
	}
}
int read()
{
       int cc = getc(stdin);
       for (;cc < '0' || cc > '9';)  cc = getc(stdin);
       int ret = 0;
       for (;cc >= '0' && cc <= '9';)
       {
          ret = ret * 10 + cc - '0';
          cc = getc(stdin);
       }
      return ret;
}
ll power(ll num,ll g)
{
	if(g==0)return 1;

	if(g%2==1)return (num*power((num*num)%mod,g/2))%mod;
	return power((num*num)%mod,g/2);
}
vector<int> vec[4];
int main()
{
	ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
  	cout.tie(NULL);

  	map<pair<int,int>,int> mp1;
  	For(i,3)
  	{
  		int a,b;
  		cin>>a>>b;
  		mp1[mp(a,b)]=1;
  		mp1[mp(b,a)]=1;
  	}
  	string s="1234";
  	bool is=false;
  	while(1)
  	{
  		int a=s[0]-'0';
  		int b=s[1]-'0';
  		int c=s[2]-'0';
  		int d=s[3]-'0';
  		if(mp1.find(mp(a,b))!=mp1.end() && mp1.find(mp(b,c))!=mp1.end() && mp1.find(mp(c,d))!=mp1.end())is=true;
  		if(!next_permutation(s.begin(),s.end()))break;
  	}
  	if(is)cout<<"YES\n";
  	else cout<<"NO\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;
const int INF=1001001001;
int main(){
  ll n,m;
  cin>>n>>m;
  vector<pair<int,int>>key;
  rep(i,m){
    int a,b;
    cin>>a>>b;
    int s=0;
    rep(j,b){
      int c;
      cin>>c;
      --c;
      s|=1<<c;
    }
    key.emplace_back(s,a);
  }
  
  vector<int> dp(1<<n,INF);
  dp[0]=0;
  rep(s,1<<n){
    rep(i,m){
      int t=s | key[i].first;
      int cost = dp[s]+key[i].second;
      dp[t]=min(dp[t],cost);
    }
  }
  int ans=dp.back();
  if (ans==INF) ans=-1;

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


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

using namespace std;

int main(){

	int n, tmp, twin=0, ans=0;

	cin>> n;
	for (int i = 0;i < n;i++) {
		cin >> tmp;
		twin += tmp * tmp;
		ans += tmp;
	}

	cout << (ans * ans - twin) / 2 << endl;


}


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

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";


#define     SPEED     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	ll          long long int
#define 	pb          push_back
#define 	pii         pair<int,int>
#define 	vi          vector<int>
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	hell        1000000007
#define 	rep(i,n)    for(i=0;i<n;i++)
#define 	repe(i,a,b) for(i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search
#define 	mp          make_pair

ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2);
	if(b%2==0)
		return((c%hell)*(c%hell))%hell;
	return ((((c%hell)*(c%hell))%hell)*(a%hell))%hell;
}

/********************************************************/
ll dp[101][100005],wt[105],v[105],p,n;

ll f(ll x,ll w)
{
	if(w>p)
		return -hell;
	if(x==n)
		return 0;
	if(dp[x][w]==-1)
	{
		dp[x][w]= max( f(x+1,w+wt[x])+v[x], f(x+1,w) );
	}
	return dp[x][w];
}


int main()
{
	SPEED;
	ll k,t,c=0,i,j,m,cs=0;
	t=1;

	//cin>>t;
	string s;
	while(t--)
	{
		cin>>n>>p;
		// n=s.length();
		// ll a[n];
		rep(i,n)
		{
			cin>>wt[i]>>v[i];
			memset(dp[i],-1,sizeof(dp[i]));
		}
		
		cout<<f(0,0);
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 78336
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;


int main() {
    int n, W;
    cin >> n >> W;
    vi w(n), v(n);
    rep(i, n) {
        cin >> w[i] >> v[i];
    }

    map<int, int> dp;
    dp[0] = 0;
    rep(i, n) {
        map<int, int> dp_;
        dp_ = dp;
        for(pair<int,int> x:dp_) {
            if(x.second+w[i] <= W) {
                if(!dp.count(x.first+v[i])) {
                    dp[x.first+v[i]] =x.second+w[i];
                } else {
                    dp[x.first+v[i]] =min(x.second+w[i], dp[x.first+v[i]]);
                }
            }
        }
    }
    int c=0;
    for(auto x:dp) {
        c = max(c, x.first);
    }
    cout << c << '\n';
}

Measured memory_bytes: 4992
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

bool data[100][100][30000];

int main() {
  //
  ll h, w;
  cin >> h >> w;
  vvl a(h, vl(w)), b(h, vl(w));
  rep(i, h) rep(j, w) cin >> a[i][j];
  rep(i, h) rep(j, w) cin >> b[i][j];
  data[0][0][abs(a[0][0] - b[0][0])] = true;
  REP(i, 1, h) {
    int j = 0;
    rep(k, 30000) {
      if (!data[i - 1][j][k]) continue;
      int k1 = k + abs(a[i][j] - b[i][j]);
      int k2 = abs(k - abs(a[i][j] - b[i][j]));
      data[i][j][k1] = true;
      data[i][j][k2] = true;
    }
  }
  REP(j, 1, w) {
    int i = 0;
    rep(k, 30000) {
      if (!data[i][j - 1][k]) continue;
      int k1 = k + abs(a[i][j] - b[i][j]);
      int k2 = abs(k - abs(a[i][j] - b[i][j]));
      data[i][j][k1] = true;
      data[i][j][k2] = true;
    }
  }
  REP(i, 1, h) {
    REP(j, 1, w) {
      rep(k, 30000) {
        if (data[i - 1][j][k]) {
          int k1 = k + abs(a[i][j] - b[i][j]);
          int k2 = abs(k - abs(a[i][j] - b[i][j]));
          data[i][j][k1] = true;
          data[i][j][k2] = true;
        }
        if (data[i][j - 1][k]) {
          int k1 = k + abs(a[i][j] - b[i][j]);
          int k2 = abs(k - abs(a[i][j] - b[i][j]));
          data[i][j][k1] = true;
          data[i][j][k2] = true;
        }
      }
    }
  }
  rep(k, 30000) {
    if (data[h - 1][w - 1][k]) {
      cout << k << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 234240
import java.util.Scanner;
import java.util.*;
import java.io.*;

public class Main{
	public static void main(String [] args){
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in),1200);
		String w = "";
		String work = "";
		String input = "";
		int count = 0;
		try{
			w = r.readLine();
			input = r.readLine();
			while(input != null){
				work += " ";
				work += input;
				input = r.readLine();
			}
		}catch(Exception e){
			System.out.println(e);
		}
		//System.out.println("w:"+w);
		//System.out.println("wcount:"+w.length());
		input = work;
		input = input.toLowerCase();
		//System.out.println(input);
		StringTokenizer st = new StringTokenizer(input," ");
		while(st.hasMoreTokens()){
			work = st.nextToken();
			if(work.length() < w.length()){
					continue;
			}else{
				/*for(int i = 0; i < work.length() - (w.length() - 1); i++){
					if(w.equals(work.substring(i,i + w.length()))){
						count++;
						break;
						//i = i + w.length() - 1;
					}
				}
				*/
				if(w.equals(work)){
					count++;
				}
			}
		}
		
		
		System.out.println(count);
	}
}

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

int main() {
  
  int n;
  cin >> n;
  vector<int> card(n);
  for (int i = 0; i < n; i++) {
    cin >> card.at(i);
  }
  
  int count_a = 0;
  int count_b = 0;
  sort(card.begin(), card.end());
  reverse(card.begin(), card.end());
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) {
      count_a += card.at(i);
    }
    else {
      count_b += card.at(i);
    }
  }
  cout << count_a - count_b << endl;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
const int mod = 1e9+7;
int main() {
    int n,m;
    cin>>n>>m;
    vector<int> dp(n+1);
    fill(dp.begin(),dp.end(),-1);
    dp[0] = 1;
    dp[1] = 1;
    for(int x,i=0;i<m;i++) {
        cin>>x;
        dp[x] = 0;
    }
    for(int i=0;i<=n;i++) {
        if(dp[i]==-1)
        dp[i] = (dp[i-1] + dp[i-2])%mod;
    }
    cout << dp[n];
}

Measured memory_bytes: 640
def main():
    n, x = map(int, input().split())

    # p_n = 1 + 2 * p_n-1
    # l_n = 3 + 2 * p_n-1
    # p0 = 1
    # l0 = 1
    p = [0] * (n + 1)
    l = [0] * (n + 1)
    p[0] = 1
    l[0] = 1
    for i in range(1, n + 1):
        p[i] = 1 + 2 * p[i - 1]
        l[i] = 3 + 2 * l[i - 1]

    res = 0
    while n and x > 0:
        x -= 1  # bands

        if x == l[n - 1] or x == l[n - 1] + 1:
            res += p[n - 1] + (x - l[n - 1])
            break
        if x == l[n - 1] * 2 + 2:
            res += 2 * p[n - 1] + 1
            break
        if x < l[n - 1]:
            n -= 1
        else:
            res += p[n - 1] + 1
            x -= l[n - 1]

    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

// {s = digit, c = number}
vector<pair<int, int>> conds;

vector<int> calc_digits(int x) {
    if (x == 0) {
        return {0};
    }

    vector<int> res;
    while (x != 0) {
        int d = x % 10;
        res.push_back(d);
        x /= 10;
    }
    // while ((int) res.size() < 3) {
    //     res.push_back(' ');
    // }
    reverse(res.begin(), res.end());
    return res;
}

int pow(const int base, int n) {
    int ans = 1;
    if (n <= 0) {
        return ans;
    }
    return base * pow(base, n - 1);
}

int solve(const int N, const int M) {
    int start, end;
    if (N == 1) {
        start = 0;
    } else {
        start = pow(10, N - 1);
    }
    end = pow(10, N);
    for (int i = start; i < end; i++) {
        vector<int> digits = calc_digits(i);

        // for (int i = 0; i < 3; i++) {
        //     cout << i << ": " << digits[i] << ", ";
        // }
        // cout << endl;

        bool ok = true;
        for (auto &cond : conds) {
            if (cond.first >= N) {
                ok = false;
                break;
            }
            if (digits[cond.first] != cond.second) {
                ok = false;
                break;
            }
        }
        if (ok) {
            return i;
        }
    }

    return -1;
}

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

    conds.resize(M);
    for (int i = 0; i < M; i++) {
        int s, c;
        cin >> s >> c;
        s--;
        conds[i] = {s, c};
    }

    int ans = solve(N, M);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
char in[310][310];
int R[310];
int ans[310][310];
int main(){
	int a,b,c;scanf("%d%d%d",&a,&b,&c);
	for(int i=0;i<a;i++)scanf("%s",in[i]);
	for(int i=0;i<a;i++){
		for(int j=0;j<b;j++)if(in[i][j]=='#')R[i]++;
	}
	for(int i=0;i<a;i++)for(int j=0;j<b;j++)ans[i][j]=-1;
	int ind=0;
	int fi=1;
	for(int i=0;i<a;i++){
		if(fi&&R[i]==0){
			continue;
		}
		fi=0;
		int st=0;
		for(int j=0;j<b;j++){
			if(in[i][j]=='#'){
				for(int k=i;k<a;k++){
					if(k>i&&R[k])break;
					for(int l=st;l<=j;l++){
						ans[k][l]=ind;
					}
				}
				ind++;
				st=j+1;
			}
		}
		if(st){
			for(int j=st;j<b;j++){
				for(int k=i;k<a;k++){
					if(k>i&&R[k])break;
					ans[k][j]=ind-1;
				}
			}
		}
	}
	for(int i=a-1;i>=0;i--){
		for(int j=0;j<b;j++){
			if(ans[i][j]==-1)ans[i][j]=ans[i+1][j];
		}
	}
	for(int i=0;i<a;i++){
		for(int j=0;j<b;j++){
			if(j)printf(" ");
			printf("%d",ans[i][j]+1);
		}
		printf("\n");
	}
}


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

typedef long long ll;
#define pa pair<int, int> 
#define pal pair<long long, long long>
#define pad pair<double, double>
#define pb push_back
#define mp make_pair
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}

typedef vector<bool> bvec;
typedef vector<int> ivec;
typedef vector<long long> lvec;
typedef vector<double> dvec;
typedef vector<pa> pvec;



typedef vector< vector<bool> > bmat;
typedef vector< vector<int> > imat;
typedef vector<string> svec;
typedef vector< vector<string> > smat;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    ll sum=0;
    cin >> n;
    svec s;
    map<string, ll> hmap;
    for (ll i=0; i<n; i++) {
        string x;
        cin >> x;
        sort(x.begin(), x.end());
        if(hmap.count(x)) hmap[x]++;
        else hmap[x]=1;
    }

    for(auto& x : hmap) sum+=x.second*(x.second-1)/2;
    cout << sum << endl;

}


Measured memory_bytes: 11264
"use strict";
function body(W, H, x, y, r){
    if (0 <= x-r && x+r <= W && 0 <= y-r && y+r <= H){
	return "Yes";
    } else {
	return "No";
    }
}

(function (){
    var s = require("fs").readFileSync("/dev/stdin", "utf8");
    var [W, H, x, y, r] = s.split(' ').map(Number);

    var ans=body(W, H, x, y, r);
    
    console.log(ans);
})();


Measured memory_bytes: 15380
#include <stdio.h>
int k=0;
int A[100];
void bubbleSort(int);

int main()
{
  int N,i;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  bubbleSort(N);
  for(i=0;i<N;i++){
    if(i>0) printf(" ");
    printf("%d",A[i]);
    //if(i==N) printf("%d",A[N]);
  }
  //printf("\n");
  printf("\n%d\n",k);
  return 0;
}

void bubbleSort(int h)
{
  int flag=1,temp,j;
  while(flag){
    flag=0;
    for(j=h-1;j>=1;j--){
      if(A[j]<A[j-1]){
	temp=A[j];
	A[j]=A[j-1];
	A[j-1]=temp;
	k++;
	flag=1;
      }
    }
  }
}
	
  

Measured memory_bytes: 604
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

MOD = 10**9+7

fac = [1, 1]     # 元テーブル
f_inv = [1, 1]   # 逆元テーブル
inv = [0, 1]     # 逆元テーブル計算用テーブル

def prepare(n, mod):
    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inv.append((-inv[mod % i] * (mod//i)) % mod)
        f_inv.append((f_inv[-1] * inv[-1]) % mod)

def modcmb(n, r, mod):
    if n < 0 or r < 0:
        return 0
    if r > n:
        return 0

    return fac[n] * f_inv[r] * f_inv[n-r] % mod


def main():
    K = int(readline())
    S = readline().strip()
    N = len(S)

    prepare(N + K + 10, MOD)

    ans = 0
    for i in range(K+1):
        ans += modcmb(N-1+i, i, MOD) * pow(25, i, MOD) * pow(26, K-i, MOD) % MOD
        ans %= MOD

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 226704
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
#include<string>
#include <queue>
#include <stack>
using namespace std;
typedef long long ll;
const int maxn=1e5+4;
int main(){
    int n,i;
    while(cin>>n){
    	ll ar[104];
    	for(i=1;i<=n;i++)
    		scanf("%lld",&ar[i]);
    	ll mi=ar[1],ma=ar[1],ans=0;
    	for(i=2;i<=n;i++){
    		mi=min(mi,ar[i]);
    		ma=max(ma,ar[i]);
    		ans=max(ma-mi,ans);
		}
		printf("%lld\n",ans);
	}
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    cout<<in()*in()<<endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>

using namespace std;

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

Measured memory_bytes: 3552
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

	int x = 0;
	if (b < 10)
		x = b + a * 10;
	else if (b < 100)
		x = b + a * 100;
	else
		x = b + a * 1000;

	for (int i = 1; i < 320; i++)
	{
		if (x == i * i)
		{
			cout << "Yes" << endl;
			return 0;
		}
			
	}

	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import sys

a, b, c = map(int,input().split())

a1 = a
b1 = b
c1 = c
cnt = 0
while (a1%2 ==0) and (b1%2 == 0) and (c1%2 == 0):
    a1,b1,c1 = b1//2 + c1//2, c1//2 + a1//2, a1//2 + b1//2
    cnt += 1
    if (a1 == a) and (b1 == b) and (c1 == c):
        print(-1)
        sys.exit()

print(cnt)


Measured memory_bytes: 3060
#include<stdio.h>
#define N 100000
 
typedef struct pp{
  char name[100];
  int t;
}Trump;
 
int h, sh, n, c=0, q;
Trump Q[N];

void mes(){
  Q[h].t = Q[h].t -q;
  Q[sh] = Q[h];
  if(sh > n+1) sh = 0;
  else sh++;
}
  
int main(){
  int i;
   
  scanf("%d %d", &n, &q);
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  h = 1;
  sh = n+1;
  i = 1;
  while(h != sh){
    if(Q[h].t > q){
      mes();
      c = c + q;
    }
    else{
      printf("%s %d\n",Q[h].name, Q[h].t+c);
      c = c + Q[h].t;
    }
    if(h > n+1) h = 0;
    else h++;
  }
  return 0;
}

Measured memory_bytes: 6744
maxi = 0

n_blue = int(input())
blue_str = [input() for _ in range(n_blue)]
n_red = int(input())
red_str = [input() for _ in range(n_red)]

kind = list(set(blue_str))

blue_count= [blue_str.count(i) for i in kind]
red_count= [red_str.count(i) for i in kind]

profit = [blue_count[i] - red_count[i] for i in range(len(blue_count))]

print(max(0, max(profit)))

Measured memory_bytes: 3064
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto hw = readln.split.to!(int[]);
    auto H = hw[0];
    auto W = hw[1];
    int[][] cs;
    foreach (_; 0..H) cs ~= readln.split.to!(int[]);

    int[] xs1, ys1, xs2, ys2;
    foreach (i; 0..H) {
        foreach (j; 0..W) {
            if (cs[i][j] % 2 == 1) {
                xs1 ~= j+1;
                ys1 ~= i+1;
                if (j < W-1) {
                    cs[i][j+1] += 1;
                    xs2 ~= j+2;
                    ys2 ~= i+1;
                } else if (i < H-1) {
                    cs[i+1][j] += 1;
                    xs2 ~= j+1;
                    ys2 ~= i+2;
                }
            }
        }
    }
    writeln(xs2.length);
    foreach (i; 0..xs2.length) {
        writeln(ys1[i], " ", xs1[i], " ", ys2[i], " ", xs2[i]);
    }
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	int x=0, y=0, w, h, n;
	cin >> w >> h >> n;
	
	int tx, ty, a;
	REP(i, 0, n){
		cin >> tx >> ty >> a;
		if(a==1) x = max(x, tx);
		else if(a == 2) w = min(w, tx);
		else if(a == 3) y = max(y, ty);
		else h = min(h, ty);
		//cout << x << " " << w << " " << y << " " << h << endl;
	}
	
	if(w < x || h < y) cout << 0;
	else cout << (w-x)*(h-y);

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000

int main(){
  string s;
  cin >> s;
  int n = s.size();
  bool key = true;
  reverse(s.begin(),s.end());
  string srev = s;
  reverse(s.begin(),s.end());
  if(s != srev) key = false;
  string pros = s.substr(0,(n-1)/2);
  reverse(pros.begin(),pros.end());
  string revpros = pros;
  reverse(pros.begin(),pros.end());
  if(pros != revpros) key = false;
  string afters = s.substr((n+3)/2-1,(n-1)/2);
  reverse(afters.begin(),afters.end());
  string revafters = afters;
  reverse(afters.begin(),afters.end());
  if(afters != revafters) key = false;
  if(key) cout << "Yes" << endl; else cout << "No" << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def solve():
    c = [list(map(int, input().split())) for _ in range(3)]
    for a0 in range(-100, 101) :
        b = [c[0][i] - a0 for i in range(3)]
        if any(c[1][0] - b[0] != c[1][i] - b[i] for i in range(3)):
            continue
        if any(c[2][0] - b[0] != c[2][i] - b[i] for i in range(3)):
            continue
        return True


if __name__ == '__main__':
    if solve() :
        print("Yes")
    else :
        print("No")


Measured memory_bytes: 38384
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	K := sc.nextInt()
	ans := 0
	var dp [201][201]int
	for i := 0; i < 201; i++ {
		for j := 0; j < 201; j++ {
			dp[i][j] = -1
		}
	}
	for i := 1; i <= K; i++ {
		for j := 1; j <= K; j++ {
			for k := 1; k <= K; k++ {
				var b, a int
				if dp[i][j] != -1 {
					b = dp[i][j]
				} else {
					b = gcd(i, j)
					dp[i][j] = b
				}
				if dp[b][k] != -1 {
					a = dp[b][k]
				} else {
					a = gcd(b, k)
					dp[b][k] = a
				}
				ans += a
			}
		}
	}

	fmt.Fprintln(wtr, ans)
}


Measured memory_bytes: 2152
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main()
{
	cin>>a>>b>>c;
  	if(a*a+b*b==c*c)
    {
		cout<<(a*b)/2<<endl;
    	return 0;
    }
    else if(a*a+c*c==b*b)
    {
		cout<<(a*c)/2<<endl;
    	return 0;
    }
    else if(b*b+c*c==a*a)
    {
    	cout<<(b*c)/2<<endl;
    	return 0;
    }
	return 0;
}

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

int main(void){
  string s;
  cin >> s;
  int a[1000];
  for(int i=0;i<1000;++i){
    a[i] = 0;
  }
  for(int i=0;i<s.size();++i){
    ++a[s[i]];
  }
  for(int i='a';i<='z';++i){
    if(a[i]==0){
      cout << (char)i << endl;
      return 0;
    }
  }
  cout << "None\n";
}

Measured memory_bytes: 512
S = gets.to_s.split("")

h = S.slice(0,2)
t = S.slice(2,2)

h_ = (h[0].to_s + h[1].to_s).to_i
t_ = (t[0].to_s + t[1].to_s).to_i

if h_ > 12 || h_ == 0

  if t_ > 12 || t_ == 0
    puts "NA"
  else
    puts "YYMM"
  end

else

  if t_ > 12 || t_ == 0
    puts "MMYY"
  else
    puts "AMBIGUOUS"
  end


end




Measured memory_bytes: 1788