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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read()          freopen("in.txt","r",stdin)
#define write()         freopen("out.txt","w",stdout)
#define sf(n)           scanf("%d",&n)
#define sfd(n)          scanf("%lf",&n)
#define sl(x)           scanf("%I64d",&x)
#define sfl(n)          scanf("%lld", &n)
#define sfc(n)          scanf(" %c",&n)
#define sful(n)         scanf("%llu",&n)
#define ull             unsigned long long
#define endll           pf("\n")
#define pf              printf
#define PI              acos(-1.0)
#define eps             1e-12
#define mem(a,b)        memset(a,b,sizeof(a))
#define pb              push_back
#define xx              first
#define yy              second
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define MP make_pair
#define ll              long long
#define uniq(a)      a.erase(unique(a.begin(), a.end()), a.end())
#define cnd tree[idx]
#define lnd tree[idx<<1]
#define rnd tree[(idx<<1)+1]
#define lndp (idx<<1),(b),((b+e)>>1)
#define rndp ((idx<<1)+1),(((b+e)>>1)+1),(e)
#define inf 1999999999
#define MOD  1000000007
#define mod1 1000000009
#define var    int i,j,c=0,t,l,r,mid,z=0,k,x,y
#define aloc(n,t) ((t*)malloc((n)*sizeof(t)))

//int dx[8]={0,0,1,1,-1,-1,1,-1};  //8 direction
//int dy[8]={1,-1,1,-1,1,-1,0,0};
//int dx[4]={1,-1,0,0};  //4 direction
//int dy[4]={0,0,1,-1};

ll n,m;
vector<ll> v[1005];
int main()
{
    ll k;
    sfl(n);sfl(k);
    for(int i=1;i<=k;i++)
    {
        ll x;
        sfl(x);
        for(int j=0;j<x;j++)
        {
            sfl(m);
            v[m].pb(i);
        }
    }
    m=0;
    for(int i=1;i<=n;i++)
    {
        if(v[i].size()==0)m++;
    }
    pf("%lld\n",m);
}


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

using namespace std;

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	string s, ans;
	cin >> s;
	for (char c: s) {
		if (c == '0' || c == '1') ans += c;
		else ans = ans.substr(0, ans.length() - 1);
	}
	cout << ans << '\n';
	return 0;
}

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

using namespace std;

int main(void) {
  long n;
  vector<long> a;
  cin >> n;

  for (long i = 0; i < n; i++){
    long x;
    cin >> x;
    a.push_back(x);
  }

  long min = a[0], max = a[0], sum = 0;

  for (long i = 0; i < n; i++){
    if(max < a[i])
      max = a[i];
    if(min > a[i])
      min = a[i];
    sum += a[i];
  }

  cout << min << " " << max << " " << sum << endl;
}


Measured memory_bytes: 3256
//#include <bits/stdc++.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <string.h>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <math.h>
#define ff first
#define ss second
#define ll long long
using namespace std;

int main () {
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    string s;
    cin>>s;
    int ans = 0;
    for(int i = 0; i < s.length() / 2; i++) {
        if(s[i] != s[s.length() - i - 1])
            ans++;
    }
    cout<<ans;
}
/*
 9 2
 6 19 3 4 4 2 6 7 8
 1 7 21
 1 5 18
 1 3 14
 1 1 8
 0 8 38
 0 6 36
 0 4 32
 0 2 26
 */


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <stdio.h>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cassert>
#include <random>
#include <time.h>
#define fi first
#define se second
#define pb emplace_back
#define all(x) x.begin(),x.end()
#define re return
#define mp make_pair

using namespace std;

typedef long long ll;

const double pi = 3.14159265;
const ll mod = 1e9 + 7;
const ll N = 3e5 + 5;
const int OMG = 9e6 + 5;
const ll P0 = 281;
const ll P1 = 257;


int main()
{
    //freopen("ladder.in ", "r", stdin);
    //freopen("OMOMOMMG.txt", "w", stdout);
    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int h, a;
    cin >> h >> a;
    cout << (h - 1) / a + 1;
}



Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void)
{
long M;
long X, div500, mod500, div5, mod5;

  scanf("%ld", &X);
  mod500 = X%500;
  div500 = X/500;
  mod5 = mod500%5;
  div5 = mod500/5;
  
  printf("%ld\n", div500*1000+div5*5);

  return 0;
}


Measured memory_bytes: 128
c11, c12, c13 = map(int, input().split())
c21, c22, c23 = map(int, input().split())
c31, c32, c33 = map(int, input().split())

bs = []
for a1 in range(0, 101):
    for b1 in range(0, 101):
        if a1 + b1 == c11:
            f1 = True
            break
    for b2 in range(0, 101):
        if a1 + b2 == c12:
            f2 = True
            break
    for b3 in range(0, 101):
        if a1 + b3 == c13:
            f3 = True
            break
    if f1 and f2 and f3:
        bs.append((b1, b2, b3))

bss = []
for a2 in range(0, 101):
    for b1, b2, b3 in bs:
        if a2 + b1 == c21 and a2 + b2 == c22 and a2 + b3 == c23:
            bss.append((b1, b2, b3))

for a3 in range(0, 101):
    for b1, b2, b3 in bss:
        if a3 + b1 == c31 and a3 + b2 == c32 and a3 + b3 == c33:
            print("Yes")
            break
    else:
        continue
    break
else:
    print("No")


Measured memory_bytes: 3064
/*
 * Deleted code is debugged code :)
 */
#include "bits/stdc++.h"
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int>>
#define vvll vector<vector<ll>>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define PI acos(-1.0)
#define all(v) v.begin(),v.end()
#define pb push_back
#define FOR(i,a,b) for(i=a;i<b;i++)
#define FREV(i,a,b) for(i=a;i>=b;i--)
#define FORI(a) for(auto it=a.begin();it!=a.end();it++)
#define READ(a,i,n) FOR(i,0,n) {cin>>a[i];}
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sll(n) scanf("%lld", &n)
#define sll2(n,m) scanf("%lld %lld", &n, &m)
#define si(n) scanf(" %d", &n)
#define ss(n) scanf(" %s", n)
#define sc(n) scanf(" %c", &n)
#define INF 1000000000000007
#define MOD 1000000007
#define RANDOM_SEED chrono::high_resolution_clock::now().time_since_epoch().count()

using namespace std;

template<typename T>
void prn(T first) {
    cout << first << "\n";
}

template<typename T, typename... Args>
void prn(T first, Args... args) {
    cout << first << " ";
    prn(args...);
}

// struct custom_hash {
//     static uint64_t splitmix64(uint64_t x) {
//         // http://xorshift.di.unimi.it/splitmix64.c
//         x += 0x9e3779b97f4a7c15;
//         x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
//         x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
//         return x ^ (x >> 31);
//     }

//     size_t operator()(uint64_t x) const {
//         static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
//         return splitmix64(x + FIXED_RANDOM);
//     }
// };

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// typedef tree<
// ll,
// null_type, // insert type for map
// less<ll>,
// rb_tree_tag,
// tree_order_statistics_node_update> // required if using order_of_key(), find_by_order()
// ordered_set;

/*******************************************RANDOM STUFF BEGINS HERE**************************************************/

int brute(string s) {
	string s1 = s;
	set<string> st;
	st.insert(s1);
	int i,j,n=s.length();
	FOR(i,0,n) {
		FOR(j,i+1,n) {
			reverse(s1.begin()+i, s1.begin()+j+1);
			st.insert(s1);
			s1 = s;
		}
	}
	return st.size();
}

int main() {
	sync;
	ll i,j,t,n;
	string s;
	cin >> s;
	n = s.length();
	vll cnt(26,0);
	FOR(i,0,n) cnt[s[i] - 'a']++;
	ll ans = (n * (n - 1)) / 2 + 1;
	FOR(i,0,26) ans -= (cnt[i] * (cnt[i] - 1)) / 2;
	// int b = brute(s);
	// prn("Brute:",b);
	cout << ans;
	return 0;
}

Measured memory_bytes: 3768
n = int(input())
S = input()
ans = 0
for i in range(10):
  x = S.find(str(i))
  if x == -1:
    continue
  for j in range(10):
    y = S.find(str(j),x+1)
    if y == -1:
      continue
    for k in range(10):
      z = S.find(str(k),y+1)
      if z != -1:
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ull = unsigned long long;


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


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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int L,R;
    while (cin >> L >> R) {
        const int a = L%2019;
        VI A;
        for (int i = 0; i <= min(2019,R-L); i++)
            A.push_back((a+i)%2019);
        int ans = 2018;
        FOR(i,0,A.size()) FOR(j,i+1,A.size())
            ans = min(ans, A[i]*A[j] % 2019);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A=0,B=0;
  int N;
  int max;
    cin>>N;
  int w,p;
  vector<int> a(N);

  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  for(int i=0;i<N;i++){
    max=a.at(i);
    p=i;
    for(int j=i;j<N;j++){
      if(a.at(j)>max){
        max=a.at(j);
        p=j;
      }
    }
    w=a.at(i);
    a.at(i)=max;
    a.at(p)=w;
  }
  int i=0;
  while(i<N-1){
    A+=a.at(i);
    B+=a.at(i+1);
    i+=2;
  }
    if(N%2==1){
      A+=a.at(N-1);
    }
  cout<<A-B<<endl;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
a,b,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
x=[0]*m
y=[0]*m
c=[0]*m
d=[]
for i in range(m):
 x[i],y[i],c[i]=map(int,input().split())
 d.append(a[x[i]-1]+b[y[i]-1]-c[i])
print(min(min(d),min(a)+min(b)))



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

#define int long long
#define pb push_back

signed main(){
    int n;
    cin>>n;
    vector<int> v;
    int tmp;
    for(int i=0; i<n; i++){
        cin>>tmp;
        v.pb(tmp);
    }
    int res = INT_MIN;
    int curr = 0;
    for(int i=0; i<n-1; i++){
        res = max(res, curr);
        if(v[i] >= v[i+1]){
            curr++;
        }
        else{
            curr = 0;
        }
    }
    res = max(curr, res);
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 1400
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if 500 * i + 100 * j + 50 * k == x:
                cnt += 1

print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

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

    string ans = "Yes";
    for(int i = 0; i < 3; ++i){
        for(int j = 0; j < 3; ++j){
            if(c[i][j] - c[i][(j+1)%3] != c[(i+1)%3][j] - c[(i+1)%3][(j+1)%3])
                ans = "No";
        }
    }
    for(int j = 0; j < 3; ++j){
        for(int i = 0; i < 3; ++i){
            if(c[i][j] - c[(i+1)%3][j] != c[i][(j+1)%3] - c[(i+1)%3][(j+1)%3])
                ans = "No";
        }
    }
    cout << ans << endl;

    return 0;
}

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

int val(int a, int b){
	return 1 & __builtin_popcount(a & b);
}

int main(){
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < (1 << n) - 1; i++){
		for(int j = 0; j < (1 << m) - 1; j++){
			cout << (val(i, j) ^ val(i, j+1) ^ val(i+1, j) ^ val(i+1, j+1));
		}
		cout << '\n';
	}
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#pragma optimize("-O3")
#define int long long int
#define f first
#define s second
#define pb push_back
#define endl '\n'

main() {
	int n;
	cin>>n;
	int arr[n];
	for(int i=0; i<n; i++){
		cin>>arr[i];
	}
	sort(arr, arr+n);
	int ans=0;
	for(int i=0; i<n; i++){
		for(int j=i+1; j<n; j++){
			for(int k=j+1; k<n; k++){
				if(arr[i]==arr[j] || arr[j]==arr[k]){
					continue;
				}
				if(arr[k]<arr[i]+arr[j]){
					ans++;
				}
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  int ans =max(max(A,B),C)*(X+Y);
//  int Acount=0, Bcount =0, Ccount = 0;

  for(int i=0; i<=max(X,Y)*2; i += 2){
      int Xp = X-i/2;
      int Yp = Y-i/2;
      if(Xp < 0) Xp=0;
      if(Yp < 0) Yp=0;
      ans = min(C*i + A*Xp + B*Yp, ans);
  }
  cout << ans << endl;
  return 0;
}

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

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

int K, A, B;

signed main()
{
  cin >> K >> A >> B;

  int ans = K+1;

  if(A+2>=B) {
    cout << K+1 << endl;
    return 0;
  }

  int tmp = 1;
  int KK = K;
  if(A>tmp) {
    int k = A-tmp;
    if(KK<k) {
      cout << max(ans, tmp+k) << endl;
      return 0;
    }
    tmp += k;
    KK -= k;
  }
// cerr << tmp << " " << KK << endl;
  int kcnt = KK/2;
  tmp += (B-A)*kcnt;
  KK %= 2;
  if(KK>0) {
    tmp++;
  }

  cout << max(ans, tmp) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;


int main()
{
    int n, h, w;
    cin>>n>>h>>w;

    cout<<(n - h + 1) * (n - w + 1)<<endl;

    return 0;
}


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

namespace ConsoleApplication6
{
    class Program
    {
        static int n;
        static Dictionary<Tuple<int,long>,long> N = new Dictionary<Tuple<int, long>, long>();
        static List<long[]> list;

        static void Main(string[] args)
        {
            n = int.Parse(Console.ReadLine());

            list = new List<long[]>();
            list.Add(new long[1] { 0 });
            int i = 0;
            while(i < n-1)
            {
                var temp = Console.ReadLine().Split(' ').Select(x=>long.Parse(x)).ToArray();
                list.Add(temp);
                i++;
            }

            for (i = 1; i <= n; i++)
            {
                Console.WriteLine(Calc(i,0));
            }

          
        }


        static long Calc(int i_, long spent)
        {
            Tuple<int, long> t = Tuple.Create(i_,spent);
            if (N.ContainsKey(t))
            {
                return N[t];
            }
            
            if(i_ == n)
            {
                N.Add(Tuple.Create(n,spent),spent);
                return spent;
            }

            if(spent < list[i_][1])
            {
                var time = Calc(i_+1, list[i_][0] + list[i_][1]);
                N.Add(Tuple.Create(i_, spent), time);
                return time;
            }

            var mod = spent % list[i_][2] == (long)0 ? 0 : list[i_][2] - spent % list[i_ ][2];
            var time2 = Calc(i_ + 1, spent + mod + list[i_][0]);
            N.Add(Tuple.Create(i_, spent), time2);
            return time2;

        }

    }
}


Measured memory_bytes: 26896
import java.io.PrintWriter
import java.util.*

val pw = PrintWriter(System.out)
val sc = Scanner(System.`in`)

fun main(args: Array<String>) {
    val (a, b, c) = readLine()!!.split(" ").map{it.toLong()}
    println(pp2020(a,b,c))
}

fun pp2020(a: Long, b: Long, c: Long): String {
    val d = c-a-b
    var ans = "No"
    if(4*a*b < d * d && 0L < d) {
        ans = "Yes"
    }
    return ans
}


fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextListOfString() = next().split(" ")
fun nextListOfInt() = nextListOfString().map { it.toInt() }
fun nextListOfLong() = nextListOfString().map { it.toLong() }
fun nextListOfDouble() = nextListOfString().map { it.toDouble() }



Measured memory_bytes: 38248
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;
	static boolean debug = false;

	static void solve() {
		out.println((ir.nextInt() + 1) / 2 >= ir.nextInt() ? "YES" : "NO");
	}

	public static void main(String[] args) {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}

	static void tr(Object... o) {
		if (debug)
			out.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 24660
#include <cstdio>
#include <unordered_map>
typedef long long lld;
const int MAXN = 2e5+5;
std::unordered_map<int,int> seen;
int A[MAXN];
int P[MAXN];
int K, N;

int main() {
    scanf(" %d%d", &N, &K);
    A[0] = 0;
    for (int i = 1; i <= N; ++i) {
        scanf("%d", &A[i]);
        A[i] = (1LL * A[i-1] + A[i]) % K;
    }
    seen.clear();
    seen.reserve(N+1);
    ++seen[0];
    lld ret = 0LL;
    for (int i = 1; i <= N; ++i) {
        int cur = (1LL * A[i] - i) % K;
        if (cur < 0) cur += K;
        if (i >= K) {
            int prev = P[i-K];
            if (!--seen[prev]) {
                seen.erase(prev);
            }
        }
        if (seen.count(cur)) {
            ret += seen.at(cur);
        }
        ++seen[cur];
        P[i] = cur;
    }
    printf("%lld\n", ret);
    return 0;
}

Measured memory_bytes: 9600
import math

def main():

    a,b,h,m = map(int,input().split())
    kakub = 6.0*m
    kakua = 30.0*h + (30.0*(m/60.0))
    maxx = max(kakua,kakub)
    minn = min(kakua,kakub)
    if (maxx - 180.0) > minn:
        aug = (360.0 - maxx) + minn
    elif (maxx - 180.0) < minn:
        aug = maxx - minn
    else:
        aug = 180.0
    
    if aug == 180.0:
        ans=a+b
        print(ans)
    
    else: 
        ans = (a**2.0) + (b**2.0) -( (2.0*a*b)*math.cos(math.radians(aug)) )
        print(math.sqrt(ans))



if __name__=='__main__':
    main()

Measured memory_bytes: 62288
def main()
  s = gets.chomp.to_s
  k = gets.chomp.to_i

  len = s.length
  dic = {}
  for i in 0..(len-1) do
    for j in 1..(len-i) do
      break if (dic.size > 5) and j > 5
      dic.store(s.slice(i,j),true)
    end
  end
  list = dic.sort {|(k1, v1), (k2, v2)| k1 <=> k2 }
  puts list[k-1][0]
end

main()

Measured memory_bytes: 4344
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    string s;
    cin >> s;

    ll a = s[6] - '0';
    if(s[5] == '1') {
        out("TBD");
    }
    else if(5 <= a) {
        out("TBD");
    }
    else {
        out("Heisei");
    }
    
    re0;
}

Measured memory_bytes: 256
// Legends Never Die.

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef unsigned int UI;
typedef pair<int, int> pii;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

namespace fastIO
{
	const UI BUFFER_SIZE = (UI) 1 << 15;
	char buffer[BUFFER_SIZE], *cur, *ed;

	inline char getc() { return *(cur == ed ? ed = buffer + fread(buffer, 1, BUFFER_SIZE, stdin), cur = buffer : cur)++; }
}
using fastIO::getc;

template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getc());
	for(; !isdigit(ch); ch = getc()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getc()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

template<typename T> inline T sqr(const T &val) { return val * val; }
template<typename T> inline int chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline int chkmax(T &a, const T &b) { return b > a ? a = b, 1 : 0; }

// END tpl.

const int MAXN = 18;

int n;

int A[MAXN + 5];

inline void input()
{
	n = read<int>();
	for(int i = 1; i <= n; ++i) A[i] = read<int>();
}

const LL INF = (LL) 1e18;

map<pii, LL> f[MAXN + 5][MAXN + 5];

inline LL dfs(int l, int r, int x, int y)
{
	if(l + 1 >= r) return 0;
	if(f[l][r].count(mp(x, y))) return f[l][r][mp(x, y)];

	LL res = INF;
	for(int k = l + 1; k <= r - 1; ++k) chkmin(res, dfs(l, k, x, x + y) + dfs(k, r, x + y, y) + (LL) (x + y) * A[k]);
	return f[l][r][mp(x, y)] = res;
}

inline void solve()
{
	printf("%lld\n", dfs(1, n, 1, 1) + A[1] + A[n]);
}

int main()
{
#ifdef K_ON // K-ON!
	freopen("D.in", "r", stdin);
	freopen("D.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}



Measured memory_bytes: 18560
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
const ll INF=100000000000000LL;

int main() {
	int x,y,g[13];
	g[1]=0;
	g[2]=2;
	g[3]=0;
	g[4]=1;
	g[5]=0;
	g[6]=1;
	g[7]=0;
	g[8]=0;
	g[9]=1;
	g[10]=0;
	g[11]=1;
	g[12]=0;
	cin>>x>>y;
	if(g[x]==g[y])cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}


Measured memory_bytes: 256
/*
 *
 */
#include <cstdio>
#include <iostream>

typedef long long ll;
using namespace std;

int main(){
   // freopen("c2.in", "r", stdin);
    ll N;
    cin >> N;
    ll start = N / 4 + 1;
    for (ll h = start; h < 3501; ++h) {
        for (ll n = h; n < 3501; ++n) {
            if ((4 * h * n - N * (h + n)) > 0 && (N * h * n) % (4 * h * n - N * (h + n)) == 0) {
                ll w = (N * h * n) / (4 * h * n - N * (h + n));
                printf("%lld %lld %lld\n", h, n, w);
                return 0;
            }
        }
    }
    printf("Error, ans not found\n");
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class Main {
  public static void main(String args[]) {
    Scanner scan = new Scanner(System.in);
    int countSharp = 0;
    int count90 = 0;
    int countDon = 0;
    while(true) {
      int[] c = new int[3];
      for(int i = 0; i < 3; i++) {
        c[i] = scan.nextInt();
      }
      int maxInt = 0;
      Arrays.sort(c);
      // maxInt = Math.max(c[0], c[1]);
      // maxInt = Math.max(maxInt, c[2]);
      if (c[0] + c[1] <= c[2]) {
        break;
      }
      if(c[0] * c[0] + c[1] * c[1] < c[2] * c[2]) {
        countDon++;
      } else if (c[0] * c[0] + c[1] * c[1] > c[2] * c[2]) {
        countSharp++;
      } else{
        count90++;
      }
    }
    System.out.println(countSharp + count90 + countDon + " " + count90 + " " + countSharp + " " + countDon);
  }
}


Measured memory_bytes: 26336
import sys
input = sys.stdin.readline

def main():
    s = list(input().rstrip())
    split_list = []
    split_list.append(s[0])

    i = 1
    while i < len(s):
        buf = s[i]
        if buf == split_list[-1]:
            while ''.join(buf) == split_list[-1]:
                i += 1
                if i >= len(s):
                    split_list[-1] += buf
                    break
                buf += s[i]

        i += 1
        if i <= len(s):
            split_list.append(buf)

    print(len(split_list))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9724
#include<algorithm>
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvld;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

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

    ll r, D, x;
    cin >> r >> D >> x;

    rep(i, 10)
    {
        x = r * x - D;
        cout << x << endl;
    }

    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>
using namespace std;

int main(void) {
	int m, n;

	cin >> m >> n;

	cout << (m - 1)*(n - 1) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{   
    int N; cin>>N;
    string s=to_string(N+1);
    int ans=0,cur=0;
    REP(i,s.size()){
        if(s[i]!='0') 
            ans=max(ans,cur+(s[i]-'1')+9*((int)s.size()-i-1));
        cur+=s[i]-'0';
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys
from io import StringIO
import unittest

def resolve():
    N = map(int, input().split())
    input_str = input()
    r_cnt=0;
    for s in input_str:
        # print(s)
        if s =='R':
            r_cnt+=1
    ans = 0
    for i in range(r_cnt):
        if input_str[i] == 'W':
            ans+=1
    print(ans)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """4
WWRR"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2
RR"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """8
WRWWRWRR"""
        output = """3"""
        self.assertIO(input, output)


if __name__ == "__main__":
    resolve()


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

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  for(int i=0; i<H; i++)
    cin >> S[i];
  ll l[H][W], r[H][W], t[H][W], b[H][W];
  
  for(int i=0; i<H; i++)
    for(int j=0; j<W; j++)
      {
	l[i][j]=0;
	r[i][j]=0;
	t[i][j]=0;
	b[i][j]=0;
      }

  for(int i=0; i<H; i++)
    {
      if(S[i][0]!='#')	
	l[i][0]=1;
      if(S[i][W-1]!='#')
	r[i][W-1]=1;
      
	
   
    }

  for(int i=0; i<W; i++)
    {
      
      if(S[0][i]!='#')
	t[0][i]=1;
      if(S[H-1][i]!='#')
	b[H-1][i]=1;
	
    }

  
  for(int i=0; i<H; i++)
    for(int j=0; j<W; j++)
      {
	if(S[i][j] == '.')
	  {
	    if(j+1<W)
	      {
		 l[i][j+1]+=l[i][j]+1;
	      }
	     
	   
	    if(i+1<H)
	      {
		t[i+1][j]+=t[i][j]+1;	
	      }	     
	  }
	else
	  {
	    
	    if(j+1<W)
	      {
		 l[i][j+1]=1;
	      }
	     
	   
	    if(i+1<H)
	      {
		t[i+1][j]=1;	
	      }	
	    
	  }
      }

  
  for(int i=H-1; i>-1; i--)
    for(int j=W-1; j>-1; j--)
      {
	if(S[i][j] == '.')
	  {  
	    if(-1<j-1)
	      {
		r[i][j-1]+=r[i][j]+1;
	      }

	    if(-1<i-1)
	      {
		b[i-1][j]+=b[i][j]+1;
	      }
	     
	  }
	else
	  {
	    if(-1<j-1)
	      {
		r[i][j-1]=1;
	      }
	    
	    if(-1<i-1)
	      {
		b[i-1][j]=1;
	      }

	  }
      }

  ll max=0;
  for(int i=0; i<H; i++)
    for(int j=0; j<W; j++)
      {
	ll tmp = l[i][j]+r[i][j]+t[i][j]+b[i][j]-3;
	//cout << i << " " <<  j << " " << tmp << endl;
	if(tmp>max && S[i][j]=='.')
	  max=tmp;
      }

  cout << max  << endl;
	
		



  return 0;
}


//cout << setprecision(13);
//next_permutation();
//__gcd();
//reverse();
//set ,tuple ,pair;
//bitset
//vector.find
//vector.count



Measured memory_bytes: 129408
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    long long N,K,i,m,M,s,t,u,ans;
    cin>>N>>K;
    pair<long long,long long> a[N];
    long long A[N],F[N];
    for(i=0;i<N;i++){
        cin>>A[i];
    }
    for(i=0;i<N;i++){
        cin>>F[i];
    }
    sort(A,A+N);sort(F,F+N);
    for(i=0;i<N;i++){
        a[i].first=A[i];
        a[i].second=F[N-1-i];
    }
    m=0;M=1e12;
    while(M-m>1){
        t=(M+m)/2;
        s=0;
        for(i=0;i<N;i++){
            u=a[i].first-t/a[i].second;
            if(u>0){
                s+=u;
            }
        }
        if(s>K){
            m=t;
        }else{
            M=t;
        }
    }
    s=0;
    for(i=0;i<N;i++){
        u=a[i].first-m/a[i].second;
        if(u>0){
            s+=u;
        }
    }
    if(s>K){
        ans=M;
    }else{
        ans=m;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6528
words = lambda t : list(map(t, input().split()))
n,k = words(int)

max_m = sum(range(1,n-1))
if k > max_m:
    print(-1)
else:
    g = []
    for i in range(n):
        for j in range(i+1,n):
            g.append((i,j))
    #print(g)
    for i in range(k):
        g.pop(-1)

    print(len(g))
    for a,b in g:
        print(a+1,b+1)


Measured memory_bytes: 3992
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
    string S, T;
    cin >> S >> T;
    ll ans = INF;
    REP(i, S.size()-T.size()+1) {
        string sub = S.substr(i, T.size());
        ll cnt = 0;
        REP(j, sub.size()) {
            if (sub[j] != T[j])
                cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3612
/*
ID: andy.sc1
LANG: JAVA
TASK: lining
*/

// Imports
import java.util.*;
import java.io.*;

public class Main {

    /**
     * @param args the command line arguments
     * @throws IOException, FileNotFoundException 
     */
    public static void main(String[] args) throws IOException, FileNotFoundException {
        
        // TODO UNCOMMENT WHEN ALGORITHM CORRECT
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        
        // TODO code application logic here
        int n = Integer.parseInt(f.readLine());
        int[] counts = new int[n];
        
        StringTokenizer numbers = new StringTokenizer(f.readLine());
        for(int i = 0; i < n; i++) {
            counts[i] = Integer.parseInt(numbers.nextToken());
        }
        
        Arrays.sort(counts);
        
        int current = (n%2)^1;
        int numleft = 2;
        if(current == 0) {
            numleft--;
        }
        
        boolean consistent = true;
        for(int i = 0; i < n; i++) {
            if(counts[i] == current) {
                numleft--;
                if(numleft == 0) {
                    current += 2;
                    numleft = 2;
                }
            }
            else {
                consistent = false;
                break;
            }
        }
        
        if(consistent) {
            int pow = n/2;
            long p = 1;
            for(int i = 0; i < pow; i++) {
                p *= 2;
                p = p % 1000000007;
            }
            System.out.println(p);
        }
        else {
            System.out.println(0);
        }
    }

}


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

using namespace std;
using LL = long long;
using P = pair<int,int>;
const LL mod=1e9+7;
const LL Max_N=21;

LL dp[1<<Max_N+5];

int main(){
	int N;
	cin >> N;
	bool a[25][25];
	rep(i,N){
		rep(j,N) cin >> a[i][j];
	}
	dp[0]=1;
	rep(bit,1<<N){
		rep(i,N){
			if(!(bit&(1<<i))) continue;
			LL num=0;
			rep(j,N) if(bit&(1<<j)) num++;
			if(a[num-1][i]){
				dp[bit]+=dp[bit-(1<<i)];
				dp[bit]%=mod;
			}
		}
	}
	cout << dp[(1<<N)-1] << endl;

	return 0;
}

Measured memory_bytes: 18688
import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm;
import std.uni, std.math, std.container, std.typecons, std.typetuple;
import core.bitop, std.datetime;

void main(){
    int n, q;
    readVars(n, q);

    auto uf = new UnionFind(n);

    int com, x, y;

    foreach(qi ; 0 .. q){
        readVars(com, x, y);

        if (com == 0) {
            uf.unite(x, y);
        }
        else {
            writeln(uf.same(x, y) ? 1 : 0);
        }
    }
}

class UnionFind {
private:
    int[] p;
    int[] rank;

public:
    this(int N) {
        p = iota(N).array;
        rank = new int[](N);
    }

    int find_root(int x) {
        if(x != p[x]) p[x] = find_root(p[x]);
        return p[x];
    }

    bool same(int x, int y) {
        return find_root(x) == find_root(y);
    }

    void unite(int x, int y){
        x = find_root(x);
        y = find_root(y);

        if (x == y) return;

        if (rank[x] < rank[y]) {
            p[x] = y;
        }
        else {
            p[y] = x;

            if (rank[x] == rank[y]) rank[x]++;
        }
    }
}


void readVars(T...)(auto ref T args){
    auto line = readln.split;
    foreach(ref arg ; args){
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    if(!line.empty){
        writeln(line);
        throw new Exception("args num < input num");
    }
}

Measured memory_bytes: 3716
def solve():
  ans = 0
  N = int(input())
  C = list(map(int, input().split()))
  C.sort()
  mod = 10**9+7
  for i in range(N):
    ans += C[i]*(N+1-i)
  ans = ans*pow(2,2*N-2)%mod
  return ans
print(solve())

Measured memory_bytes: 105100
from copy import deepcopy
N = int(input())
A = []
for i in range(N):
    A.append(list(map(int,input().split())))
B = deepcopy(A)
for u in range(N):
    for v in range(u):
        if u <= v:
            continue
        for w in range(N):
            if w == u or w == v:
                continue
            if A[u][v] > A[u][w]+A[w][v]:
                print(-1)
                exit()
            if A[u][v] == A[u][w]+A[w][v]:
                B[u][v] = 0
                B[v][u] = 0
ans = 0
for i in range(N):
    for j in range(N):
        ans += B[i][j]
print(ans//2)

Measured memory_bytes: 56796
#include <iostream>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include<cassert>
#include<cctype>
#include<iterator>
using namespace std;
typedef long long ll;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
#define MOD 1000000007
#define INF 1<<30
#define INFTY 1000000000000000001LL
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
VI findAll(string S,string pattern){VI P;ll pos=(ll)S.find(pattern);
while(pos!=string::npos){P.push_back(pos);pos=(ll)S.find(pattern,pos+1);}return P;}
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
bool is_prime(ll n){if(n<2)return 0;for(int i=2;i*i<n;i++)if(n%i==0)return 0;return 1;}
inline void eratosthenes(VB& p){rep(i,SZ(p))p[i]=1;p[0]=p[1]=0;
rep(i,SZ(p)/2+1){if(p[i])for(ll j=i+i;j<SZ(p);j+=i)p[j]=0;}}
inline ll mod_add(ll a,ll b){return (a+b)%MOD;}
inline ll mod_sub(ll a,ll b){return (a+MOD-b)%MOD;}
inline ll mod_mul(ll a,ll b){return ((a%MOD)*(b%MOD))%MOD;}
inline ll mod_pow(ll x,ll n,ll mod=(ll)MOD){ll res=1;while(n>0){
if(n&1)res=res*x%mod;x=x*x%mod;n>>=1;}return res;}// x^n%mod
inline ll mod_inv(ll x){return mod_pow(x,MOD-2);}
inline ll mod_div(ll a, ll b){return mod_mul(a,mod_inv(b));}
using Graph=vector<vector<int> >;//int と P

int main(){
    ll n,k,q;cin>>n>>k>>q;
    VI who(n,0);
    rep(i,q){
        int a;cin>>a;a--;
        who[a]++;
    }
    VI score(n);
    rep(i,n){
        score[i]=k-(q-who[i]);
    }
    rep(i,n)cout<<(score[i]>0?"Yes":"No")<<endl;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int l, r, d, cnt = 0;
	scanf("%d%d%d", &l, &r, &d);
	for(int i=l; i<=r; i++)
		if(i % d == 0)
			cnt++;
	printf("%d", cnt);
	return 0;
}


Measured memory_bytes: 3824
#include<iostream>
#include<string>
using	namespace std;
int main(){


  int N;
  cin>>N;
  string S,T,X;
  cin>>S>>T;
  for(int i=0;i<N;i++)
    {
      X.append(S,i,1);

      X.append(T,i,1);

    }
  cout<<X<<endl;
}





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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> piipii;

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back

int ft[200005];
void update(int i, int v){
    for(;i<=200002;i+=(i&-i)) ft[i] += v;
}
int query(int i){
    int res = 0;
    for(;i>0;i-=(i&-i)) res+=ft[i];
    return res;
}

int a[200005];
int main(){
    int n, k;
    scanf("%d%d", &n, &k);

    vector<ll> h;
    h.eb(0);

    ll sum = 0;
    for(int i=1;i<=n;i++){
        scanf("%d", &a[i]);
        sum += a[i]-k;
        h.eb(sum);
    }   
    sort(all(h));
    h.erase(unique(all(h)), h.end());

    int idx = lower_bound(all(h), 0) - h.begin() + 1;
    update(idx, 1);
    sum = 0;
    ll ans = 0;
    for(int i=1;i<=n;i++){
        sum += a[i]-k;
        int idx = lower_bound(all(h), sum) - h.begin() + 1;
        ans += query(idx);
        update(idx, 1);
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 3440
import java.util.Scanner;

public class Main{
	//島の数をカウントする。
	public static void main(String[] args) {
		//海図を入力する
		Scanner sc=new Scanner(System.in);
		int[][] map=new int[12][12];
		while(sc.hasNext()) {
			for(int i=0;i<12;i++) {
				String map_wide_num=sc.next();
				for(int j=0;j<12;j++) {
					map[i][j]=Integer.parseInt(map_wide_num.substring(j,j+1));
				}
			}
			//mapから島(1)を探す
			//見つけたらカウントする
			//その"1"を"2"にする
			//map全体を探し、"2"の周り(上下左右)にある"1"を全て"2"にする。
			int count=0;
			for(int i=0;i<12;i++) {
				for(int j=0;j<12;j++) {
					if(map[i][j]==1) {
						count++;
						map[i][j]=2;
					}
					for(int k=0;k<12;k++) {
						for(int l=0;l<12;l++) {
							if(map[k][l]==2) {
								if(k==0) {
								}else if(map[k-1][l]==1) {//top
									map[k-1][l]=2;
								}
								if(k==11) {
								}else if(map[k+1][l]==1) {//down
									map[k+1][l]=2;
								}
								if(l==11) {
								}else if(map[k][l+1]==1) {//left
									map[k][l+1]=2;
								}
								if(l==0) {
								}else if(map[k][l-1]==1) {//right
									map[k][l-1]=2;
								}
							}
						}
					}
				}
			}
			System.out.println(count);
		}
	}

}



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

#define N 100010
#define ll long long int
#define MOD 1000000007

int main(){
  //max_hは展望台iが隣接している中で最大の標高値の値
  int n,m,h[N],max_h[N];
  cin>>n>>m;

  for(int i=1;i<=n;i++){
    cin>>h[i];
    max_h[i]=0;
  }

  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    max_h[a]=max(max_h[a],h[b]);
    max_h[b]=max(max_h[b],h[a]);
  }

  ll ans=0;
  for(int i=1;i<=n;i++){
    ans+=h[i]>max_h[i];
  }

  cout<<ans<<endl;

  return 0;
}

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

using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define INF 1 << 29

int main()
{
    int n, m;
    int a[50], b[50], c[50], d[50];
    cin >> n >> m;
    REP(i, n)
      cin >> a[i] >> b[i];
    REP(i, m)
      cin >> c[i] >> d[i];
    REP(i, n) {
      int min_cost = INF;
      int idx = -1;
      REP(k, m) {
        int dest = abs(a[i] - c[k]) + abs(b[i] - d[k]);
        if(min_cost > dest) {
          min_cost = dest;
          idx = k;
        }
      }
      cout << idx + 1 << endl;
    }
}


Measured memory_bytes: 256
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
input = sys.stdin.readline
INF = float("inf")


# 処理内容
def main():
    X, K, D = map(int, input().split())
    
    if abs(X) - K*D >= 0:
        print(abs(X) - K*D)
    else:
        L = K*D - abs(X)
        m = L // D
        if m % 2 == 0:
            print(L - m*D)
        else:
            print((m+1)*D - L)



if __name__ == '__main__':
    main()

Measured memory_bytes: 72780