akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

bool flg = false;

int main() {
  int C[3][3],C1[3][2],C2[2][3];
  for (int i = 0; i<3; i++) for (int j = 0; j<3; j++) cin >> C[i][j];
  for (int i = 0; i<3; i++) for (int j = 0; j<2; j++) C1[i][j] = C[i][j+1]-C[i][j];
  for (int i = 0; i<2; i++) for (int j = 0; j<3; j++) C2[i][j] = C[i+1][j]-C[i][j];
  
  for (int i = 0; i<2; i++) for (int j = 0; j<2; j++) if(C1[i][j]-C1[i+1][j] != 0) flg = true;
  for (int i = 0; i<2; i++) for (int j = 0; j<2; j++) if(C2[i][j]-C2[i][j+1] != 0) flg = true;
  if(flg == false) cout << "Yes\n";
  else cout << "No\n";
    
}

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

//using namespace--------------------------------------------------------------------------------------------------------------
using namespace std;

//define-----------------------------------------------------------------------------------------------------------------------
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1 << 25
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cerr << #x << " = " << (x) << "\n";
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)

//typedef----------------------------------------------------------------------------------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned int uint;
typedef unsigned long long ull;

//const------------------------------------------------------------------------------------------------------------------------
const double EPS = 1e-10;
const double PI = acos( -1.0 );

//global-----------------------------------------------------------------------------------------------------------------------
short n;
short prime[10000];
short many_prime = 2;
short mx = 1;

//function---------------------------------------------------------------------------------------------------------------------
int main() {
	while ( scanf( "%d", &n ) ) {
		if ( n == 0 ) {
			return 0;
		}
		many_prime = 2;
		mx = 1;
		prime[ 0 ] = 3;
		prime[ 1 ] = 5;
		for ( int i = 7; i <= n; i += 2 ) {
			bool check = true;
			for ( int j = 0; prime[ j ] * prime[ j ] <= i; j++ ) {
				if ( i % prime[ j ] == 0 ) {
					check = false;
					break;
				}
			}
			if ( check ) {
				prime[ many_prime ] = i;
				if ( prime[ many_prime ] - prime[ many_prime - 1 ] == 2 ) {
					mx = many_prime;
				}
				many_prime++;
			}
		}
		printf( "%d %d\n", prime[ mx - 1 ], prime[ mx ] );
	}
	return 0;
}

Measured memory_bytes: 1196
//
// Created by Hideaki Imamura on 2020-01-02.
//
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    ll n, k, r, s, p;
    string t;
    cin >> n >> k >> r >> s >> p >> t;

    ll dp[100001][3];
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j < 3; ++j) {
            dp[i][j] = 0;
        }
    }

    for (int i = 0; i < k; ++i) {
        if (t[i] == 'r') {
            dp[i][0] = p;
        } else if (t[i] == 's') {
            dp[i][1] = r;
        } else {
            dp[i][2] = s;
        }

        for (int j = i + k; j < n; j += k) {
            if (t[j] == 'r') {
                dp[j][0] = max(dp[j - k][1], dp[j - k][2]) + p;
                dp[j][1] = max(dp[j - k][2], dp[j - k][0]);
                dp[j][2] = max(dp[j - k][0], dp[j - k][1]);
            } else if (t[j] == 's') {
                dp[j][0] = max(dp[j - k][1], dp[j - k][2]);
                dp[j][1] = max(dp[j - k][2], dp[j - k][0]) + r;
                dp[j][2] = max(dp[j - k][0], dp[j - k][1]);
            } else if (t[j] == 'p') {
                dp[j][0] = max(dp[j - k][1], dp[j - k][2]);
                dp[j][1] = max(dp[j - k][2], dp[j - k][0]);
                dp[j][2] = max(dp[j - k][0], dp[j - k][1]) + s;
            }
        }
    }

    ll ans = 0;
    for (int i = n - 1; i >= n - k; --i) {
        ans += max(dp[i][0], max(dp[i][1], dp[i][2]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}
 
const ll MODBASE = 1000000007LL;
const int MAXN = 400010;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    string s;
  cin >> s;
  	int res = 1000000000;
  	FOR(i,0,SZ(s)-1) {
      if (i + 2 >= SZ(s)) break;
      int g = (s[i] - '0') * 100 + (s[i+1] - '0') * 10 + (s[i+2] - '0');
      		res = min(res, abs(753 - g));
    }
 	cout << res;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void) {
  int x,n,m;
  unsigned int Ans;
  scanf("%d", &x);
  n = x % 500;
  m = n % 5;
  Ans = (x-n)*2+(n-m);
  printf("%u", Ans);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define max 1000000
#define pb push_back
#define pairs pair<int, int>
#define vi vector<int>
#define vb vector<bool>
#define vii vector<pairs>
#define lb lower_bound
#define ub upper_bound
#define lli long long int
#define endl '\n'
#define FastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)
#define read(x) freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)
#define InputArray(a,n) for(int i=0;i<n;i++) cin >> a[i];
#define CopyArray(a,temp,n) for(int i=0;i<n;i++) temp[i]=a[i];
#define PrintArray(a,n) for(int i=0;i<n;i++) cout << a[i] << " "; cout << endl;
using namespace std;


int main() {
#ifdef Niloy
	read("input.txt");
	write("output.txt");
#endif

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

	if(b >= a) {
		cout << "unsafe\n";
	} else {
		cout << "safe\n";
	}

	cerr << "time = " << (clock() / CLOCKS_PER_SEC) << " sec" << '\n';
	return 0;
}

Measured memory_bytes: 3636
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
Arr.shift();
var t=0;
var h=0;
Arr.forEach(function(v){
var arr=v.split(" ");
if(arr[0]==arr[1]){t++;h++;}
if(arr[0]>arr[1])t+=3;
if(arr[0]<arr[1])h+=3;
});
console.log(t+" "+h);

Measured memory_bytes: 8696
#pragma GCC optimize("Ofast")

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

#define M 1000000007
#define MM 998244353 
#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define PI 3.1415926536
#define INF 2e18
#define endl "\n"

ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,(e-1)/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,(e-1)/2);
	return power(b*b,e/2);
}

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

	int n;
	cin>>n;
	int a[n],dp[n+1],i;
	for(i=0;i<n;i++)
		cin>>a[i];
	dp[1]=0;dp[2]=abs(a[1]-a[0]);
	for(i=3;i<=n;i++)
	{
		dp[i]=min(dp[i-1]+abs(a[i-1]-a[i-2]),dp[i-2]+abs(a[i-1]-a[i-3]));
	}
	cout<<dp[n];
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define MAXN 10000

using namespace std;
typedef long long ll;

int main()
{
	//freopen("t.txt","r",stdin);
	long n;
	long long *a = new long long [n];
	cin>>n;
	for (int i=0;i<n;i++) cin>>a[i];
	sort (a,a+n);
	long i = (n/2)-1;
	long j = i+1;
	long long kq = a[j] -a[i];
	cout<<kq;
}

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

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

  int x = a * b;

  if(x % 2 == 0){
    cout << "Even" << endl;
  }else{
    cout << "Odd" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace CSharp
{
    static class Program
    {
        static void Main(string[] args)
        {
            long r, d, x;
            ReadLong(out r, out d, out x);

            for (int i = 0; i < 10; i++)
            {
                x = r * x - d;
                Console.WriteLine(x);
            }
        }

        #region Helpers

        static int[] ReadIntArray() => Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        static long[] ReadLongArray() => Console.ReadLine().Split().Select(s => long.Parse(s)).ToArray();

        static int[] ReadLineIntArray(int count) => Enumerable.Repeat(0, count).Select(_ => int.Parse(Console.ReadLine())).ToArray();
        static long[] ReadLineLongArray(int count) => Enumerable.Repeat(0, count).Select(_ => long.Parse(Console.ReadLine())).ToArray();

        static string ReadString() => Console.ReadLine();
        static int ReadInt() => int.Parse(Console.ReadLine());
        static long ReadLong() => long.Parse(Console.ReadLine());

        static void ReadInt(out int first)
        {
            var array = ReadIntArray();
            first = array[0];
        }

        static void ReadInt(out int first, out int second)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
        }

        static void ReadInt(out int first, out int second, out int third)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadInt(out int first, out int second, out int third, out int fourth)
        {
            var array = ReadIntArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        static void ReadLong(out long first)
        {
            var array = ReadLongArray();
            first = array[0];
        }

        static void ReadLong(out long first, out long second)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
        }

        static void ReadLong(out long first, out long second, out long third)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
        }

        static void ReadLong(out long first, out long second, out long third, out long fourth)
        {
            var array = ReadLongArray();
            first = array[0];
            second = array[1];
            third = array[2];
            fourth = array[3];
        }

        #endregion
    }
}

Measured memory_bytes: 13268
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, K = MAP()
A = LIST()
 
n = max(A+[K]).bit_length()
cnt = [0]*n
 
for a in A:
	for i in range(n):
		if a & (1<<i):
			cnt[i] += 1

X = 0
for i in range(n-1, -1, -1):
	if X + (1<<i) <= K and cnt[i] <= (N-1)//2:
		X += (1<<i)
 
#print(X)
ans = 0
for a in A:
	ans += a^X
 
print(ans)

Measured memory_bytes: 21992
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cfloat>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define EACH( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

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

	while ( true )
	{
		int n, m;
		cin >> n >> m;

		if ( !( n | m ) )
		{
			break;
		}

		VVI G( n, VI() );

		REP( i, 0, m )
		{
			int a, b;
			cin >> a >> b;

			a--;
			b--;

			G[a].PB( b );
			G[b].PB( a );
		}

		VI dist( n, INT_MAX );
		dist[0] = 0;

		queue<int> que;
		que.push( 0 );

		while ( !que.empty() )
		{
			auto cur = que.front();
			que.pop();

			EACH( next, G[ cur ] )
			{
				if ( dist[ next ] <= dist[ cur ] + 1 )
				{
					continue;
				}

				que.push( next );
				dist[ next ] = dist[ cur ] + 1;
			}
		}

		cout << count_if( dist.begin() + 1, dist.end(), []( int a ){ return a <= 2; } ) << endl;
	}

	return 0;
}

Measured memory_bytes: 1376
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

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

using namespace std;

int main()
{
	int n;
	while(cin >> n && n)
	{
		vector<int> a(n),b(n);

		rep(i,n) cin >> a[i];
		rep(i,n) cin >> b[i];

		sort(a.begin(),a.end(),greater<int>());
		sort(b.begin(),b.end());

		bool flag = false;
		rep(i,n-1)
		{
			//revease
			int cnt = lower_bound(b.begin(),b.end(),a[i]) - b.begin();
			cnt = n - cnt;

			if((i+1) - cnt > (i+1)/2)
			{
				cout << i+1 << endl;
				flag = true;
				break;
			}
		}

		if(!flag) cout << "NA" << endl;
	}

	return 0;
}

Measured memory_bytes: 1452
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int main(){
	int n;
	vector<P> v;
	for(int u = 0; u < 2; u++){
		cin >> n;
		for(int i = 0; i < n; i++){
			int h, m;
			cin >> h >> m;
			v.push_back(P(h,m));
		}
	}
	sort(v.begin(),v.end());
	v.erase(unique(v.begin(),v.end()),v.end());
	for(int i = 0; i < v.size(); i++){
		if(i) cout << " ";
		cout << v[i].first << ":" << (v[i].second<10?"0":"") << v[i].second;
	}
	cout << endl;
}

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

main()
{
  int n;
  for(;cin>>n,n;)
    {
      n+=1;
      vector<int> x;
      for(int i=0;i<n;i++)
	{
	  int t;
	  cin>>t;
	  x.push_back(t);
	}
      for(int i=0;i<x.size();i++)
	{
	  vector<int> y;
	  y=x;
	  y.erase(y.begin() + i);
	  bool c = true;
	  for(int j=1;j<y.size()-1;j++)
	    {
	      if(y[j]-y[j-1] != y[j+1]-y[j])
		{
		  c=false;
		  break;
		}
	    }
	  if(c)
	    {
	    cout<<x[i]<<endl;
	    break;
	    }
	}
    }
}

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n; i < (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
void debug(vector<vector<ll>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
void debug(vector<ll>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}
//m.emplace(x,0).fi->second++;

int main(){
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll a,b;cin>>a>>b;
  if(abs(a-b)%2==1)cout<<"IMPOSSIBLE"<<endl;
  else{
    cout<<(a+b)/2<<endl;
  }

  return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    string a, b, c; cin >> a >> b >> c;
    int an = a.size() == 1 ? 0 : a.size() - 1;
    int bn = b.size() == 1 ? 0 : b.size() - 1;
    if(a[an] == b[0] && b[bn] == c[0]){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
n = gets.to_i
w = gets.split.map(&:to_i)
w.unshift(0)
sum = 0
w.each { |e|
  sum += e
}
s1 = [0]
s2 = [0]
d_abs_min = 1000000
for i in 1..n do
  s1[i] = s1[i-1] + w[i]
  s2[i] = sum - s1[i]
  d_abs = (s1[i] - s2[i]).abs
  d_abs_min = d_abs if d_abs_min > d_abs
end
puts d_abs_min


Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<functional>
#include<utility>
#include<algorithm>
#include<map>
using ll = long long;
#define int ll
constexpr int mod = 1e9 + 7;
signed  main(){
    int N,K;
    std::cin >> N >> K;
    std::vector<std::vector<int>>edge(N);
    std::vector<bool>used(N,false);
    for(int i = 0; i < N - 1; ++i){
        int s,t;
        std:: cin >> s >> t;
        --s;--t;
        edge[s].push_back(t);
        edge[t].push_back(s);
    }
    int root = 0;
    std::vector<int>d(N + 1,0LL);
    std::map<int,int>memo;
    std::function<int(int,int)>solve = [&](int v,int prev ){
        used[v] = true;
        int crt = K - memo[prev];
        if(root != v)memo[v]++;
        d[v] = crt;
        int res = 1;
        for(auto nv : edge[v]){
            if(used[nv]) continue;
            memo[v]++;
            res *= solve(nv,v);
            res %= mod;
        }
        return (res * d[v]) % mod;
    };
    std::cout << solve(root,N) << std::endl;
    
}


Measured memory_bytes: 22144
#include <iostream>
#include <cstdio>
#include <vector>
#include <deque>
#include <algorithm>
#include <climits>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
 
int main(){
    int H,W;
    cin >> H >> W;
    if(H%3 == 0 || W%3 == 0){
        cout << 0 << endl;
    }else{
        ull ans = LLONG_MAX;
        ull h = H, w = W;
        for(ull i = 1; i < w; i++){
            ull S1 = i*h;
            ull S2, S3;
            ull diff;
            if(h % 2 == 1){
                S2 = (w-i)*(h-1)/2;
                S3 = (w-i)*(h+1)/2;
                ull MAX = max(S1, max(S2, S3));
                ull MIN = min(S1, min(S2, S3));
                diff = MAX - MIN;
                if(S2 == 0 || S3 == 0) diff = LLONG_MAX;
            }
            else{
                S2 = (w-i)*(h/2);
                diff = (S1 > S2) ? S1 - S2 : S2 - S1;
            }
            ull diff2;
            if((w-i) % 2 == 1){
                S2 = (w-i-1)/2*h;
                S3 = (w-i+1)/2*h;
                ull MAX = max(S1, max(S2, S3));
                ull MIN = min(S1, min(S2, S3));
                diff2 = MAX - MIN;
                if(S2 == 0 || S3 == 0) diff2 = LLONG_MAX;
            }
            else{
                S2 = (w-i)/2*h;
                diff2 = (S1 > S2) ? S1 - S2 : S2 - S1;
            }
            diff = min(diff, diff2);
            ans = min(ans, diff);
            //printf("ans:%d\tdiff:%lld\tS1:%lld\tS2:%lld\n", ans, diff, S1, S2);
        }

        for(ull i = 1; i < h; i++){
            ull S1 = i*w;
            ull S2, S3;
            ull diff;
            if(w % 2 == 1){
                S2 = (h-i)*(w-1)/2;
                S3 = (h-i)*(w+1)/2;
                ull MAX = max(S1, max(S2, S3));
                ull MIN = min(S1, min(S2, S3));
                diff = MAX - MIN;
                if(S2 == 0 || S3 == 0) diff = LLONG_MAX;
            }
            else{
                S2 = (h-i)*w/2;
                //diff = abs(S1 - S2);
                diff = (S1 > S2) ? S1 - S2 : S2 - S1;
            }
            ull diff2;
            if((h-i) % 2 == 1){
                S2 = (h-i-1)/2*w;
                S3 = (h-i+1)/2*w;
                ull MAX = max(S1, max(S2, S3));
                ull MIN = min(S1, min(S2, S3));
                diff2 = MAX - MIN;
                if(S2 == 0 || S3 == 0) diff2 = LLONG_MAX;
            }
            else{
                S2 = (h-i)/2*w;
                diff2 = (S1 > S2) ? S1 - S2 : S2 - S1;
            }
            diff = min(diff, diff2);
            ans = min(ans, diff);
        }
            cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
object Main {
  import scala.math
  def main(args: Array[String]) {
    val sc = new java.util.Scanner(System.in)
    val m,n = sc.nextInt
    val list = List.fill(m)(sc.nextLong)
    //print(list)
    if (m <= n) println(0) else{
      val list2 = list.sorted
      //print(list)
      println(list.sorted.take(m-n).sum)
    }
  }
}


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

int main(){
    int h, w, n, x=0;
    cin >> h >> w >> n;
    vector<int> A(n);
    vector<int> C(h*w);
    for(int i=0 ; i<n ; i++){
        cin >> A[i];
    }
    for(int j=0 ; j<n ; j++){
        for(int k=x ; k<x+A[j]; k++){
            C[k]=j+1;
        }
        x+=A[j];
    }
    for(int l=0 ; l<=h*(w-1) ; l+=2*w){
        sort(C.rbegin()+l, C.rbegin()+l+w);
    }
    for(int m=0 ; m<h*w ; m++){
        cout << C[m];
        if((m+1)%w==0){
            cout << endl;
        }else{
            cout << " ";
        }
    }
    return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            if (a >= 3200)
            {
                Console.WriteLine(s);
            }
            else
            {
                Console.WriteLine("red");
            }
        }
    }
}


Measured memory_bytes: 13140
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(){
    int n;
    char s[11111];
    scanf("%d%s",&n,s);
    int l = strlen(s);
    for(int i=0;i<l;i++){
        putchar('A' + (s[i] - 'A' + n)%26);
    }
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdint>
#include <map>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cstddef>
#include <cctype>
#include <iomanip>
#include <iostream>
#include <tuple>
#include <utility>
#include <math.h>
#include <stack>

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; }


const long long mod = 1e9+7;

void chmod(long long &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

long long modpow(long long x, long long n){
    if(n==0) return 1;
    long long res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };



/* <-------------------------------------------------------------------------> */
/* <-------------------------------------------------------------------------> */
/* <-------------------------------------------------------------------------> */
/* <-------------------------------------------------------------------------> */

bool solve(int i, int n, std::vector<int> & a, int m) {
    if(i == n) { return m == 0; }
    if(m == 0) { return true; }

    return (solve(i+1, n, a, m) || solve(i+1, n, a, m-a[i]));
}

int main() {

    int n; scanf("%d\n", &n);
    std::vector<int> a(n, 0);
    for(int i=0; i<n; ++i) { scanf(" %d", &a[i]); }
    int q; scanf("%d\n", &q);
    for(int i=0; i<q; ++i) {
        int m; scanf(" %d", &m);
        if (solve(0, n, a, m)) { printf("yes\n"); }
        else { printf("no\n"); }
    }


    return 0;
}



Measured memory_bytes: 3156
<?php

class Scanner
{
    private $arr = [];
    private $count = 0;
    private $pointer = 0;

    public function next()
    {
        if ($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(" ", $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }

    public function hasNext()
    {
        return $this->pointer < $this->count;
    }

    public function nextInt()
    {
        return (int)$this->next();
    }

    public function nextDouble()
    {
        return (double)$this->next();
    }
}

class out
{
    public static function printIn($str = "")
    {
        echo $str . PHP_EOL;
    }
}

$sc = new Scanner;

$n = $sc->nextInt();
$a = [];

for ($i = 0; $i < $n; $i++) {
    $a[] = $sc->nextInt();
}

/* 線形探索 */
//$c = 0;
//// 偶数判定
//while(true){
//    for ($i = 0; $i < $n; $i++) {
//        if($a[$i] % 2 !== 0){
//            break 2;
//        }
//        $a[$i] /= 2;
//    }
//    $c ++;
//}
//
//echo $c;

/* other solution */
$res = 1000000;
for ($i = 0; $i < $n; $i++) {
    $c = 0;
    while ($a[$i] % 2 === 0) {
        $c ++;
        $a[$i] /= 2;
    }
    if($res > $c){
        $res = $c;
    }
}
echo $res;


Measured memory_bytes: 5496
#include "bits/stdc++.h"
#define MAXN 200009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int fac[MAXN],inv[MAXN];
int mod(ll x){
	return (x%INF);	
}
int C(int x,int y){
	if(x<y)
		return 0;
	return mod(fac[x]*1LL*mod(inv[y]*1LL*inv[x-y]));			
}
int Fe(int x,int y){
	if(!y)
		return 1;
	int h=Fe(x,y/2);
	h=mod(h*1LL*h);
	if(y&1)
		h=mod(h*1LL*x);
	return h;			
}
int main(){
	int n,m,k;
	scanf("%d%d%d",&n,&m,&k);
	inv[0]=fac[0]=1;
	for(int i=1;i<MAXN;i++){
		fac[i]=mod(fac[i-1]*1LL*i);
		inv[i]=Fe(fac[i],INF-2);	
	}
	printf("%d\n",mod(C(n*m-2,k-2)*1LL*mod(mod(m*1LL*m)*1LL*C(n+1,3)+mod(n*1LL*n)*1LL*C(m+1,3))));	
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<long long> b(n);
  for(int i = 0; i < n; i++){
    long long a;
    cin >> a;
    b[i] = a - i - 1;
  }
  sort(b.begin(), b.end());
  long long c = b[n/2];
  long long ans = 0;
  for(int i = 0; i < n; i++)
    ans += abs(b[i] - c);
  cout << ans << endl;
  return 0;
}

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

using namespace std;

const int md=1e9+7;

long long ans=1;
int n;
int pf[10000];

int main()
{
	scanf("%d",&n);
	int tmp=n;
	
	for(int i=1;i<=n;i++)
	{
		int x=i;
		for(int j=2;j<=x;j++)
			while(x%j==0)
			{
				pf[j]++;
				x/=j;
			}
	}
	
	for(int i=1;i<1000;i++)
	{
		ans*=(pf[i]+1);
		ans=ans%md;
	}
	
	cout<<ans;	
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
using namespace std;
string s;
int x,m,i;
struct node
{
int data;
struct node * lchild;
struct node * rchild;
};
typedef struct node;
typedef node * tree;
tree root;
void findn(tree bt,int n)
{
if(bt)
{
if(n<bt->data) findn(bt->lchild,n);
else if(n>bt->data) findn(bt->rchild,n);
else cout<<"yes"<<endl;
}
else cout<<"no"<<endl;
}
void insert(tree &bt,int n)
{
if(bt)
{
if(n<bt->data)insert(bt->lchild,n);
else if (n>bt->data)insert(bt->rchild,n);
}
else
{
bt=new node;
bt->data=n;
bt->lchild=bt->rchild=NULL;
}
}

void printh(tree bt)
{
if(bt)
{
if(bt->data!=-99)
cout<<" "<<bt->data;
printh(bt->lchild);
printh(bt->rchild);

}
}
void printz(tree bt)
{
if(bt)
{
printz(bt->lchild);
if(bt->data!=-99)
cout<<" "<<bt->data;
printz(bt->rchild);
}
}
void delet(tree &bt,int z)
{
if(bt->data>z)
delet(bt->lchild,z);
else if(bt->data<z)
delet(bt->rchild,z);
else
{
if(bt->lchild&&bt->rchild)
{
tree tmp=bt->rchild;
while(tmp->lchild)
{
tmp=tmp->lchild;
}
bt->data=tmp->data;
delet(bt->rchild,tmp->data);
}
else
{
tree tmp=bt;
if(bt->rchild!=NULL)
{
bt=bt->rchild;
}
else if(bt->lchild!=NULL)
{
bt=bt->lchild;
}
else
bt->data=-99;
}
}
}
int main()
{
root=NULL;
int n;
cin>>n;
for(int i=1;i<=n;i++)
{

cin>>s;

if(s=="insert")
{
cin>>x;
insert(root,x);
}
if(s=="find")
{
cin>>x;
findn(root,x);
}
if(s=="print")
{
printz(root);
cout<<endl;
printh(root);
cout<<endl;
}
if(s=="delete")
{
int c;
scanf("%d",&c);
delet(root,c);
}
}

//system("pause");
return 0;
}

Measured memory_bytes: 15792
n,m = map(int,input().split())
submit = []
for i in range(m):
    temp = [x for x in input().split()]
    submit.append(temp)
#print(submit)

ac = [0] * (n + 1)
wa = [0] * (n + 1)

for i in range(m):
    result = submit[i][1]
    question = int(submit[i][0])

    if result == 'AC' and ac[question] == 0:
        ac[question] = 1
    elif result == 'WA' and ac[question] == 0:
        wa[question] += 1

for i in range(n + 1):
    if ac[i] != 1:
        wa[i] = 0

print(sum(ac), sum(wa))

Measured memory_bytes: 27404
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

template < typename T > using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

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

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < ll, ll > pll;
typedef pair < int, int > pii;
typedef vector < ll > vll;
typedef vector < int > vi;

#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, base = 1e9, MOD = 1e9 + 7, N = 1e5 + 10, M = 1e3 + 10;
const int INF = INT_MAX;
const db PI = acos(-1);

void test();

int main() {
    fast_io();
    test();
    return 0;
}

void test() {
    ll r, d, cur;
    cin >> r >> d >> cur;
    for (ll i = 0; i < 10; ++i) {
        cur = r * cur - d;
        cout << cur << "\n";
    }
}


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

int main(void) {
  int num,roads,idx,total=0;
  bool flag=true;
  cin>>num>>roads;
  vector<int> heights(num);
  vector<vector<int>> roadmap(num);

  for(int i=0;i<num;i++){
    cin>>heights.at(i);
  }

  for(int i=0;i<roads;i++){
    int a_num,b_num;
    cin>>a_num>>b_num;
    a_num--;b_num--;
    roadmap.at(a_num).push_back(b_num);
    roadmap.at(b_num).push_back(a_num);
  }

  for(int i=0;i<num;i++){
    flag=true;
    for(int j=0;j<roadmap.at(i).size();j++){
      idx=roadmap.at(i).at(j);
      if(heights.at(i)<=heights.at(idx)){ flag=false;break; }
    }
    if(flag) total++;
  }

  cout<<total<<endl;
  return 0;
}


Measured memory_bytes: 8356
/*Made by Shivam Solanki*/
#include<bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define ll long long int
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<pii> vp;
typedef vector<pll> vpll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef set<int> sii;
typedef set<ll> sll;
typedef priority_queue<int> pq;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;
typedef queue<int> qii;
#define rep(i,k,n) for (int i = k; i < n; ++i) 
#define repr(i,k,n) for (int i = n; i>=k; --i)
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define repll(i,k,n) for (ll i = k; i < n; ++i) 
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int INF = 1e9+5;
const int MOD = 1e9+7;

void solve(){
    int a,b;
    cin>>a>>b;
    int c=1;
    while(1){
        if(c!=a and c!=b){
            cout<<c<<'\n';
            break;
        }
        else{
            c++;
        }
    }
}
    
int main(){
    // #ifndef ONLINE_JUDGE  
        // freopen("input.txt", "r", stdin); 
        // freopen("output.txt", "w", stdout); 
    // #endif 
    // fastio;
    int t=1;
    // cin>>t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
#include<map>
#include<set>
const int inf=2147483647;
const int ine=-2147482647;
using namespace std;
#define in() freopen("t.in","r",stdin)
#define out() freopen("t.out","w",stdout)
#define m(a) memset(a,0,sizeof(a))
#define I inline
#define R register
typedef long long ll;
string s;int len;
template <typename _Tp>
  I void _(_Tp &x){
      int w=1;char c=0;x=0;
      while (c^'-'&&(c<'0'||c>'9')) c=getchar();
      if (c=='-') w=-1, c=getchar();
      while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
      x*=w;
  }
I int mx(int a,int b){return a>b?a:b;}I int mn(int a,int b){return a<b?a:b;}
int main(){
    //in(t);out(t);
    cin>>s;len=s.size();
    int id=-1;
    for(R int i=0;i<len;++i)
        if(s[i]=='C'){
        	id=i;
        	break;
		}
	if(id<0){
		puts("No");
        return 0;
	}
	for(R int i=id;i<len;++i){
		if(s[i]=='F'){
			puts("Yes");
			return 0;
		}
	}
	puts("No");
    return 0;
}


Measured memory_bytes: 256
#JMD
#Nagendra Jha-4096

 
import sys
import math

#import fractions
#import numpy
 
###File Operations###
fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile

###Defines...###
mod=1000000007
 
###FUF's...###
def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 
##### Main ####
s=str(input())
if(len(s)==2):
    print(s)
else:
    print(s[::-1])
    
    
#####File Operations#####
if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>

using namespace std;

const long long INF = 1LL << 40;

int main() {
  int n, k;
  cin >> n >> k;
  long long h[n];
  for(int i=1; i <= n; i++) {
    cin >> h[i];
  } 

  long long dp[n+1];
  for(int i=1; i <= n; i++) dp[i] = INF;
  dp[1] = 0;

  for(int i=1; i < n; i++) {
    for(int j=1; j < k + 1; j++) {
      if (i + j > n) break;
      dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
    }
  }

  cout << dp[n] << endl;

  return 0;
}

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

int main() {
  int N, M;
  cin >> N;
  cin >> M;
  int ans[N];
  int tru[N];
  memset(ans, 0, sizeof(ans));
  memset(tru, 0, sizeof(tru));

  for (int m_i = 0; m_i < M; m_i++) {
    int q_i;
    string result;
    cin >> q_i;
    q_i--;
    cin >> result;
    if (result == "AC") {
      tru[q_i] = 1;
    } else {
      if (!tru[q_i]) {
        ans[q_i] += 1;
      }
    }
  }

  int rig = 0;
  int pen = 0;
  for (int n_i = 0; n_i < N; n_i++) {
    rig += tru[n_i];
    if (tru[n_i]) {
      pen += ans[n_i];
    }
  }
  cout << rig << " " << pen << endl;
}


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

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

ans = 0 
d = {}
for i in a:
    if i not in d:
        d[i] = 1 
    else:
        d[i] += 1

d = sorted(d.items(), key=lambda x:x[0], reverse=True)
area = 1 
cnt = 0 
allone = True
for i in d:
    if i[1] != 1:
        allone = False
        if i[1] >= 4:
            if cnt == 0:
                area = i[0]*i[0]
                break
            else:
                if cnt == 2:
                    break
                area *= i[0]
                cnt += 1
        else:
            if cnt == 2:
                break
            area *= i[0]
            cnt += 1

if allone:
    print(0)
else:
    print(area)


Measured memory_bytes: 21896
/*数组有没有开小
有没有开long long
会不会爆long long
初始化（多组数据，一定要记得把数组清零！！！）
时刻小心数组/容器是否为空
最后容器中剩余是否需要加入答案 
位运算结果的数组，要开2倍。位运算时注意结果的范围可能大于两个数的范围
要考虑边界情况(n=0?n=1?n=最大值?) 
注意变量名(尤其注意:n,n2 i,j)
开bool时注意取值不能为0~2
*/
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define pb push_back
#define r1 rt<<1
#define r2 rt<<1|1
#define fi first
#define se second
#define ri register int
#define rep(i,a,b) for(ri i=(a);i<=(b);++i)
#define rep2(i,a,b,c) for(ri i=(a);i<=(b);i+=(c))
#define REP(i,a,b) for(ri i=(a);i>=(b);--i)
#define REP2(i,a,b,c) for(ri i=(a);i>=(b);i-=(c))
using namespace std;

inline ll read(){
	ll x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^'0'),c=getchar();
	return x*f;
}
inline void write(ll x){
	if(x<0) putchar('-'),x=-x;
	if(x>9) write(x/10);
	putchar(x%10+'0');
}

int main()
{
	string s;cin>>s;
	if(s=="SUN")cout<<7;
	if(s=="MON")cout<<6;
	if(s=="TUE")cout<<5;
	if(s=="WED")cout<<4;
	if(s=="THU")cout<<3;
	if(s=="FRI")cout<<2;
	if(s=="SAT")cout<<1;
	return 0; 
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

#define LL long long
#define fgx cerr<<"--------------"<<endl;
#define dgx cerr<<"=============="<<endl;

inline LL read(){
	LL x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int MAXN = 200010;
const LL INF = 2147483600;

struct dat{
	LL id,val;
}a[MAXN+1]; LL N;
bool cmpval(dat a,dat b){
	return a.val>b.val;
}
LL Node[MAXN<<1],Next[MAXN<<1],Root[MAXN+1],cnt;
inline void insert(LL u,LL v){
	Node[++cnt]=v; Next[cnt]=Root[u]; Root[u]=cnt; return ;
} LL sz[MAXN+1],f[MAXN+1],b[MAXN+1];
inline void dfs(LL k,LL Fa){
	sz[k]=1; for(LL x=Root[k];x;x=Next[x]){
		LL v=Node[x]; if(v==Fa) continue;
		dfs(v,k); sz[k]+=sz[v]; f[1]+=sz[v];
	} return ;
}
inline void dfs2(LL k,LL Fa){
	if(f[k]!=b[k]){ puts("-1"); exit(0); }
	for(LL x=Root[k];x;x=Next[x]){
		LL v=Node[x]; if(v==Fa) continue;
		f[v]=f[k]+N-2*sz[v]; dfs2(v,k);
	} return ;
} LL s1[MAXN+1],s2[MAXN+1],top;

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	N=read();
	for(LL i=1;i<=N;i++){
		a[i].id=i; a[i].val=read(); b[i]=a[i].val;
	} sort(a+1,a+N+1,cmpval);
	for(LL i=1;i<=N;i++) sz[i]=1;
	for(LL i=1;i<N;i++){
		LL val=a[i].val-N+2*sz[i]; 
		LL l=i+1,r=N,pos=-1;
		while(l<=r){
			LL mid=(l+r)>>1;
			if(a[mid].val>=val) pos=mid,l=mid+1;
			else r=mid-1;
		} if(pos==-1||a[pos].val!=val){
			puts("-1"); return 0;
		} sz[pos]+=sz[i];
		s1[++top]=a[i].id; s2[top]=a[pos].id;
		insert(a[i].id,a[pos].id);
		insert(a[pos].id,a[i].id);
		//sz=N+a[fa]-a[i].val
	} dfs(1,0); dfs2(1,0);
	for(LL i=1;i<=top;i++) printf("%lld %lld\n",s1[i],s2[i]); 
	return 0;
}




Measured memory_bytes: 20640
#include<bits/stdc++.h>
using namespace std;
int cnt[200010],a[200010],idx;
bool cmp(int x,int y){return cnt[x]<cnt[y];}
int main()
{
    //priority_queue<int,vector<int>,greater<int> >q;
    int n,k,t=0;
    scanf("%d%d",&n,&k);
    for (register int i=1;i<=n;++i)
    {
        int x;
        scanf("%d",&x);
        if (!cnt[x]) {a[++idx]=x;++t;}
        ++cnt[x];
    }
    sort(a,a+idx+1,cmp);
    int m=t-k,ans=0;
    for (int i=1;i<=m;++i)
        ans+=cnt[a[i]];
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
vector<bool> makePrimeTableBasedOne(int);

int main() {
  vector<int> questions;
  int q;
  while(cin >> q, q) questions.push_back(q);
  int maxQuestion = *(max_element(questions.begin(), questions.end()));
  auto primeTable = makePrimeTableBasedOne(maxQuestion);
  for(auto i = questions.begin(); i != questions.end(); ++i) {
    int question = *i;
    int deltas[] = {0, 2, 4, 2};
    bool loopEnd = false;
    int k, l, j;
    for(j = ((question % 2) ? question : question - 1); !loopEnd && j >= 7; j -= 2) for(k = 0, l = j; !loopEnd && primeTable[l]; ++k, l -= deltas[k]) if(k == 3) {
      cout << l + 8 << endl;
      loopEnd = true;
    }
  }
  return 0;
}

vector<bool> makePrimeTableBasedOne(int max) {
  vector<bool> primeBools(max + 1, true); // one based
  double squareMax = pow(max, (double)1 / (double)2);
  primeBools[1] = false;
  for(int i = 2; i <= squareMax; ++i) {
    if(primeBools[i]) {
      for(int j = 2; i * j < max + 1; ++j) primeBools[i * j] = false;
    }
  }
  return primeBools;
}

Measured memory_bytes: 2316
/**
 *    author:  tourist
 *    created: 26.11.2019 03:48:15       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, a, b;
  cin >> n >> a >> b;
  if (a * 1LL * b < n || a + b - 1 > n) {
    cout << -1 << '\n';
    return 0;
  }
  vector<int> c(a, 1);
  c[0] = b;
  int ptr = 1;
  for (int i = a + b - 1; i < n; i++) {
    if (c[ptr] == b) {
      ++ptr;
    }
    ++c[ptr];
  }
  ptr = 0;
  for (int x : c) {
    for (int i = 0; i < x; i++) cout << ptr + x - i << " ";
    ptr += x;
  }
  return 0;
}


Measured memory_bytes: 3072
#include <cstdio>

int main()
{
	int a,b,c;
	scanf("%d %d %d", &a, &b, &c);
	if(a+b==c)
	{
		printf("Yes");
	}
	else if(a+c==b)
	{
		printf("Yes");
	}
	else if(b+c==a)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
}

Measured memory_bytes: 1680
#include<stdio.h>
 
int main(void)
 
 
{
 
 
 int n, i, ai, min, max;
 
 
 long sum;
 
 sum=0;
 
 
 min=1000000;
 
 
 max=-1000000;
 
 
 scanf("%d",&n);
 
 
 for(i=1; i<=n; i++){
 
 
  scanf("%d",&ai);
 
 
  sum+=ai;
 
 
  if(min>ai){
 
 
   min=ai;
 
 
   }
 
 
  if(max<ai){
 
 
   max=ai;
 
 
  }
 
 
 }
 
 
 printf("%d %d %lld\n",min, max, sum);
 
 
 return 0;
 
 
}
  

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

alias E = Tuple!(int, "to", int, "cap", size_t, "rev");

E[][100+100+2] G;
bool[100+100+2] USED;

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

    auto lake = new char[][](H, W);
    int sx, sy, tx, ty;
    foreach (int y; 0..H) {
        foreach (int x, c; readln.chomp.to!(char[])) {
            lake[y][x] = c;
            if (c == 'S') {
                sx = x;
                sy = y;
            }
            if (c == 'T') {
                tx = x;
                ty = y;
            }
            if (c == 'o') {
                G[x] ~= E(100+y, 1, G[100+y].length);
                G[100+y] ~= E(x, 1, G[x].length-1);
            }
        }
    }

    G[200] ~= E(sx, 100000, G[sx].length);
    G[sx] ~= E(200, 0, 0);
    G[200] ~= E(sy+100, 100000, G[sy+100].length);
    G[sy+100] ~= E(200, 0, 1);

    G[201] ~= E(tx, 0, G[tx].length);
    G[tx] ~= E(201, 100000, 0);
    G[201] ~= E(ty+100, 0, G[ty+100].length);
    G[ty+100] ~= E(201, 100000, 0);

    if (sx == tx || sy == ty) {
        writeln(-1);
        return;
    }

    int solve(int i) {
        if (i == 201) return 1;
        USED[i] = true;
        foreach (ref e; G[i]) if (e.cap > 0 && !USED[e.to]) {
            if (solve(e.to)) {
                --e.cap;
                ++G[e.to][e.rev].cap;
                return 1;
            }
        }
        return 0;
    }
    int r;
    while (solve(200)) {
        USED[] = false;
        ++r;
    }
    writeln(r);
}

Measured memory_bytes: 1148