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

string s;

int main() {
	ios_base::sync_with_stdio(false);
	cin >> s;
	int n = s.length();

	for(int i = 0; i < n-2; i++) {
		if(s[i] == s[i+2]) {
			cout << i+1 << ' ' << i+3 << endl;
			return 0;
		}
	}

	for(int i = 0; i < n-1; i++) {
		if(s[i] == s[i+1]) {
			cout << i+1 << ' ' << i+2 << endl;
			return 0;
		}
	}

	cout << -1 << ' ' << -1 << endl;

	return 0;
}

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

int main() {
    int N; cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; ++i) cin >> A[i];
    map<int, bool> c;
    for(int i=0; i<N; ++i) c[A[i]] = (i & 1);
    sort(begin(A), end(A));

    int res = 0;
    for(int i=0; i<N; ++i) {
        if(c[A[i]] != (i & 1)) ++res;
    }
    cout << res / 2 << endl;
}

Measured memory_bytes: 5376
n,a,b = map(int,input().split())
s = input()
na = 0
nb = 0
for i in range(len(s)):
  if na + nb >= a+b:
    print("No")
  elif s[i]=="a":
    na += 1
    print("Yes")
  elif s[i]=="b":
    if nb < b:
      nb += 1
      print("Yes")
    else:
      print("No")
  else:
    print("No")

Measured memory_bytes: 75532
#include <iostream>
#include <cmath>
using namespace std;
int main(){
int n, total=0;
cin >> n;
for (int i=1; i<=n; i++){
int s=0;
if (i%2==1){
for (int j=1; j<=int(sqrt(i)); j++){
if (i%j==0) s+=2;
}
if ( sqrt(i)==int(sqrt(i)) ) s--;
if (s==8) total++;
}
}
cout << total;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int t, x;
    cin >> t >> x;
    cout << fixed << (double)t/x << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func solve() {
	var H, W int
	fmt.Scan(&H, &W)
	m := make([]string, H)
	for i := range m {
		fmt.Scan(&m[i])
	}

	clampH := func(n int) int {
		return max(0, min(H-1, n))
	}

	clampW := func(n int) int {
		return max(0, min(W-1, n))
	}

	dxs := []int{0, 1, 0, -1}
	dys := []int{1, 0, -1, 0}

	ans := true

ALL:
	for i, h := range m {
	PO:
		for j, w := range h {
			if w == '#' {
				for p := 0; p < 4; p++ {
					if m[clampH(i+dys[p])][clampW(j+dxs[p])] == '#' {
						continue PO
					}
				}
				ans = false
				break ALL
			}
		}
	}
	if ans {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func main() {
	solve()
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define pb push_back
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

int main() {
    int n, a, b;
    scanf("%d%d%d", &n, &a, &b);
    printf((b-a)%2? "Borys\n" : "Alice\n");
    return 0;
}

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

int main()
{
	int x, y;

	while (1)
	{
		cin >> x >> y;

		if (x == 0 && y == 0)
		{
			return 0;
		}
		if (x <= y)
		{
			cout << x << " " << y << "\n";
		}
		else
		{
			cout << y << " " << x << "\n";
		}
	}
	return 0;
}

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

using namespace std;
int m, k;
int main(){
    cin >> m >> k;
    if(m == 1 && k == 1){
        cout << -1;
        return 0;
    }
    if((1 << m) - 1 < k){
        cout << -1;
        return 0;
    }
    if(k == 0){
        for(int i = 0; i <= (1 << m) - 1; i++){
            cout << i << " " << i << " ";
        }
    }
    else{
        int l, r;
        vector < int > v;
        if(k % 4 == 0){
            l = k;
            r = k + 3;
            v.push_back(k + 1);
            v.push_back(k + 2);
            v.push_back(k + 3);
        }
        else if(k % 4 == 1){
            l = k - 1;
            r = k + 2;
            v.push_back(k - 1);
            v.push_back(k + 1);
            v.push_back(k + 2);
        }
        else if(k % 4 == 2){
            l = k - 2;
            r = k + 1;
            v.push_back(k - 2);
            v.push_back(k - 1);
            v.push_back(k + 1);
        }
        else{
            l = k - 3;
            r = k;
            v.push_back(k - 3);
            v.push_back(k - 2);
            v.push_back(k - 1);
        }
        for(int i = 0; i < l; i++){
            cout << i << " ";
        }
        for(int i = r + 1; i <= (1 << m) - 1; i++){
            cout << i << " ";
        }
        for(auto to : v){
            cout << to << " ";
        }
        cout << k << " ";
        reverse(v.begin(), v.end());
        for(auto to : v){
            cout << to << " ";
        }
        for(int i = (1 << m) - 1; i > r; i--){
            cout << i << " ";
        }
        for(int i = l - 1; i >= 0; i--){
            cout << i << " ";
        }
        cout << k;
    }
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 105
int table[SIZE];

int main(){

	for(int i = 0; i < SIZE; i++){

		table[i] = 0;
	}

	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);

	for(int i = a; i <= b-1; i++){

		table[i]++;
	}

	int ans = 0;

	for(int i = c; i <= d-1; i++){

		if(table[i] == 1)ans++;
	}

	printf("%d\n",ans);

	return 0;
}


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

typedef long long ll;
using namespace std;
int main()
{
  ll n,a[200010];
  cin>>n;
  ll md=1000000007;
  ll ans=0;
  ll tmp=0;

  for(ll i=0;i<n;i++){
    cin>>a[i];
    ans+=a[i];
    ans%=md;
  }



  for(ll i=0;i<n;i++){
    ans-=a[i];
    if(ans<0)ans+=md;
    tmp+=a[i]*ans;
    tmp%=md;
  }

  // tmp%=md;
  cout<<tmp<<endl;
  return 0;
}


Measured memory_bytes: 5164
#include<iostream>
#include<algorithm>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;

  int n = N/2 + (N%2);

  bool ans = (n >= K)? true : false;
  if (ans) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 888
from operator import itemgetter, attrgetter

class data:
    def __init__(self, i, c, n):
        self.ind = i
        self.city = c
        self.num = -int(n)

N = int(input())
d = []
for i in range(N):
    s, p = input().split()
    d.append(data(i, s, p))

d.sort(key=attrgetter('city', 'num'))

for i in range(N):
    print(d[i].ind+1)

Measured memory_bytes: 3064
S = input()
N = len(S)

# indexごとに次のLまでの距離を入れる
nextL = [0]*N
nextR = [0]*N

dist = 0
for i in range(N-1, -1, -1):
    if S[i] == 'R':
        dist += 1
        nextL[i] = dist
    else:
        dist = 0

dist = 0

for i in range(N):
    if S[i] == 'L':
        dist += 1
        nextR[i] = dist
    else:
        dist = 0

ans = [0]*N

for i in range(N):
    if S[i] == 'R':
        if nextL[i] % 2 == 0:
            ans[i + nextL[i]] += 1
        else:
            ans[i+nextL[i]-1] += 1

for i in range(N-1, -1, -1):
    if S[i] == 'L':
        if nextR[i] % 2 == 0:
            ans[i - nextR[i]] += 1
        else:
            ans[i - nextR[i] + 1] += 1

print(*ans)


Measured memory_bytes: 80464
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main(void)
{
    long long x;
    cin >> x;
    long long ans;
    ans=((x+10)/11)*2;
      //          cout <<ans<<endl;
    if(((ans/2)*11)-x >=5 ) ans--;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  ll K;
  cin >> K;
  int N = 50;
  vector<ll> ans;
  rep(i, N+1) if(i!=N-K%N) ans.push_back(i+K/N);
  cout << N << endl;
  for(ll a: ans) cout << a << ' ';
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string S;
    cin >> S;
    int answer = 700;
    if(S[0] == 'o' ){
        answer += 100;
    }
    if(S[1] == 'o' ){
        answer += 100;
    }
    if(S[2] == 'o' ){
        answer += 100;
    }
    cout << answer << endl;   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)

void solve() 
{
    string s;cin>>s;if(s[2]==s[3]&&s[4]==s[5]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

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

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

int main() {
	string s,t,u;
  int a,b,c;
  b=0;
  cin>>a;
 vector<int> vec(a);
 for(int i=0;i<a;i++){
 	cin>>vec.at(i);
 }
  sort(vec.begin(), vec.end()); 
	
  for(int i=1;i<a;i++){
  	if(vec.at(i-1)==vec.at(i)){
    	b=1;
    }
  }
  
  if(b==1)cout<<"NO"<<endl;
  else cout<<"YES"<<endl;

}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
int main() {
    int N;
    cin >> N;
    long double x[N];
    vector<string> u;
    string k;
    for(int i = 0;i<N;i++){
        cin >> x[i] >> k;
        u.push_back(k);
    }
    long double ans = 0;
    for (int i = 0;i<N;i++){
        if(u[i][0] == 'J'){
            ans = ans + x[i]; 
        }
        else{
            ans = ans + x[i]*380000.0;
        }
    }
    cout << ans << endl;   
}

Measured memory_bytes: 888
import java.io.*;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException{
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//String str = br.readLine();
		StringBuilder sb = new StringBuilder();
		
		int i = 1;
			
		while(true){
			int line = Integer.parseInt(br.readLine());
			
			if(line == 0){
				break;
			}
			
			
			sb.append("Case ").append(i).append(": ").append(line).append("\n");
		i++;
		}
		System.out.print(sb);
	}
}

Measured memory_bytes: 30116
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in); 
		
		int H, W;
		char a = '#';
		
		for(;;){

			H = scan.nextInt();
			W = scan.nextInt();
			
			if(H == 0 && W ==0){
				break;
			}
			for(int i = 0; i < H; i++){
				for(int j = 0; j < W; j++){
					System.out.print(a);
				}
				System.out.println();	
			}
			System.out.println();
		}
	}
}

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

int main(){
  char c[100][100];
  int h, w;
  cin >> h >> w;
  for(int i = 0; i < h; i++ ){
    for ( int j = 0; j < w; j++ ){
      cin >> c[i][j];
    }
  }
  
  for ( int i = 0; i < h; i++ ){
    for ( int j = 0; j < w; j++ ){
      cout << c[i][j];
    }
    cout << endl;
    for ( int j = 0; j < w; j++ ){
      cout << c[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>

#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>

using namespace std;

int main()
{
    std::string S;
    std::cin >> S;

    size_t count = 0;
    for (size_t i = 0; i < S.size() - 1; ++i) {
        if (S[i] != S[i+1]) {
            ++count;
        }
    }

    std::cout << count << std::endl;

    return 0;
}


Measured memory_bytes: 512
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

ll Pow(ll A, ll N){
  if (N == 0) return 1;
  if (N % 2 == 0) return Pow(A * A % nmax, N / 2) % nmax;
  else return A * Pow(A * A % nmax, N / 2) % nmax;
}

int main(){
  int N; cin >> N;
  vector <ll> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];

  map <ll, ll> mp;
  for (int i = 0; i < N; i++){
    ll num = A[i];
    vector <Pll> now;
    for (int j = 2; j * j <= A[i]; j++){
      ll cnt = 0;
      while (num % j == 0){
        num /= j;
        cnt++;
      }
      mp[j] = max(cnt, mp[j]);
    }
    mp[num] = max(mp[num], (ll)1);
  }
  
  ll ans = Pow(2, mp[2]);
  for (int i = 3; i < 1e6; i+=2){
    ans *= Pow(i, mp[i]);
    ans %= nmax;
  }
  
  ll now = 0;
  for (int i = 0; i < N; i++){
    now += Pow(A[i], nmax - 2);
    now %= nmax;
  }
  ans = ans * now;
  ans %= nmax;
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 31616
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ll N, A, B;
  cin>>N>>A>>B;
   ll temp = N/(A+B);
  // required a; atleast temp*A is required + remaining N%(A+B); 
  ll final_ans = temp*A + min(N%(A+B), A);
  cout<<final_ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <string>
#include <iostream>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;
	while (isspace(c)) {c = gcu();}
	if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

using S = string;
using K = pair<int, int>;

void decode(S s, K k) {
	vector<char> t(26);
	for (int i = 0; i < 26; i++)
		t[(i * k.first + k.second) % 26] = i;
	for (char &c: s)
		pcu(islower(c) ? t[c - 'a'] + 'a' : c);
	outl();
}

K attack(S s) {
	S w;
	for (char c: s) {
		if(islower(c))
			w += c;
		else {
			if (w.size() == 4)
				for (int a = 1; a < 26; a += 2)
					if (a != 13) {
						int b = (26 + w[0] - 'a' - ('t' - 'a') * a % 26) % 26;
						auto d = [=](int c) {return ((c - 'a') * a + b) % 26 + 'a';};
						if (w[1] == d('h') &&
							((w[2] == d('a') && w[3] == d('t')) ||
							 (w[2] == d('i') && w[3] == d('s'))))
							return {a, b};
					}
			w = "";
		}
	}
	return {0, 0};
}

int main() {
	for (int n = in(); n; n--) {
		S s;
		getline(cin, s);
		decode(s, attack(s + ' '));
	}
}


Measured memory_bytes: 3080
/*
 * Problem Description: Reconstruction of a Tree
 * Category: Tree
 * Author: Khan
 * Date: 23th October, 2017
 */

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

using namespace std;

int n, pos;
vector<int> pre, in, post;

void rec(int l, int r)
{
    if(l >= r)
        return;
    int root = pre[pos++];
    int m = distance(in.begin(), find(in.begin(), in.end(), root));
    rec(l, m);
    rec(m + 1, r);
    post.push_back(root);
}

int main(int argc, char const *argv[])
{
    //freopen("sample.txt", "r", stdin);
    int k;
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        cin >> k;
        pre.push_back(k);
    }

    for (int i = 0; i < n; ++i)
    {
        cin >> k;
        in.push_back(k);
    }

    pos = 0;
    rec(0, pre.size());
    for (int i = 0; i < n; ++i)
    {
        if(i)
            cout << " ";
        cout << post[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<string> name;
  vector<int> point;
  int n,m;
  string s;
  cin>>n;
  for(int i=0;i<n;i++){
    int t=0,k;
    cin>>s;
    k=name.size();
    for(int j=0;j<k;j++){
      if(s==name.at(j)){
        point.at(j)++;
        t=1;
      }
    }
    if(t==0){
      name.push_back(s);
      point.push_back(1);
    }
  }
  cin>>m;
  for(int i=0;i<m;i++){
    int t=0,k;
    cin>>s;
    k=name.size();
    for(int j=0;j<k;j++){
      if(s==name.at(j)){
        point.at(j)--;
        t=1;
      }
    }
    if(t==0){
      name.push_back(s);
      point.push_back(-1);
    }
  }
  int k=name.size(),max;
  for(int i=0;i<k;i++){
    if(max<point.at(i)){
      max=point.at(i);
    }
  }
  cout<<max;
}

Measured memory_bytes: 256
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools


import queue
from collections import deque

def check(max_length, left, right, r, index):
    if index == 1000:
        print(left)
        sys.exit()
    half = (left + right) / 2
    if 2 * half <= max_length * (r - half) / r:
        check(max_length, half, right, r, index + 1)
    else:
        check(max_length, left, half, r, index + 1)

def main():
    data = [list(map(int, input().split())) for i in range(3)]
    a = ((data[0][0] - data[1][0]) ** 2 + (data[0][1] - data[1][1]) ** 2) ** 0.5
    b = ((data[1][0] - data[2][0]) ** 2 + (data[1][1] - data[2][1]) ** 2) ** 0.5
    c = ((data[0][0] - data[2][0]) ** 2 + (data[0][1] - data[2][1]) ** 2) ** 0.5

    s = (a + b + c) / 2
    S = (s * (s - a) * (s - b) * (s - c)) ** 0.5
    r = 2 * S / (a + b + c)

    left, right = 0, max(a, b, c)

    check(max(a, b, c), left, right, r, 0)





if __name__ == '__main__':
    main()
    # test()



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

using namespace std;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

typedef long long  ll;
#define endl '\n'




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


const int MOD = 1000000007;

//////////////////////////////////////////


int n;
void Input() {

    cin >> n;
}



void Solve() {

    cout << n * n << endl;


}

int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);
  Input();
  Solve();


  return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long N,M;
    cin >> N >> M;
    vector<long long> h(N),A(M),B(M);
    vector<pair<long long,long long>> H(N),C(M);
    vector<bool> F(N,true);
    map<long long,long long> mp;
    for(int i = 0; i < N; i++){
        cin >> h[i];
        H[i] = make_pair(h[i],i+1);
        mp[i+1] = h[i]; 
    }
    for(int i = 0; i < M; i++){
        cin >> A[i] >> B[i];
        C[i] = make_pair(A[i],B[i]);
    }
    long long ans = 0;
    //sort(H.begin(),H.end());
    for(int i = 0; i < M; i++){
        if(mp[A[i]] > mp[B[i]]){
            F[B[i]-1] = false;
        }
        else if(mp[A[i]] < mp[B[i]]) F[A[i]-1] = false;
        else F[B[i]-1] = F[A[i]-1] = false;
    }
    for(int i = 0; i < N; i++){
        if(F[i] == true) ans++;
    }
    /*for(int i = 0; i < N; i++){
        bool flag = true;
        for(int j = 0; j < M; j++){
            if(A[j] == H[i].second && mp[B[j]] >= mp[A[j]]){
                flag = false;
                break;
            }
            else if(B[j] == H[i].second && mp[A[j]] >= mp[B[j]]){
                flag = false;
                break;
            }
        }
        if(flag == true) ans++;
    }*/
    cout << ans << endl;
}

Measured memory_bytes: 15072
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;

int main() {
    int n;
    cin >> n;
    vector<pair<ll, ll>> p(n);
    const ll INF = 1LL << 40;
    ll mn = INF, mx = -1 * INF;
    ll mn2 = INF, mx2 = -1 * INF;
    ll mn3 = INF, mx3 = -1 * INF;
    rep(i, n) {
        ll x, y;
        cin >> x >> y;
        p[i] = {x, y};
        mn = min(mn, x + y);
        mx = max(mx, x + y);
        mn2 = min(mn2, (-x) + y);
        mx2 = max(mx2, (-x) + y);
        mn3 = min(mn3, x + (-y));
        mx3 = max(mx3, x + (-y));
    }

    cout << max(max(max(mx - mn, mx2 - mn2), mx3 - mn3), 0LL) << endl;
    // cout << mn << endl;
    // cout << mx << endl;
    // cout << mn2 << endl;
    // cout << mx2 << endl;
    return 0;
}
/*
g++ -std=c++17 -Wall -Wextra -g -O0 -fsanitize=undefined,address main.cpp && oj t
*/

Measured memory_bytes: 6420
#include<iostream>
#include<vector>
#include<queue>

using namespace std;

int ans = 0;
void dfs(vector<string> v, int x,int y,vector< vector<int> > &vv){
	int dx[4] = {-1, 1, 0, 0};
	int dy[4] = { 0, 0,-1, 1};
	if (vv[y][x] == 1) return ;
	if (v[y][x] == '#') return ;	
	vv[y][x] = 1;
	ans++;
	for (int i = 0; i < 4; i++){
		if (0 <= x + dx[i] and x + dx[i] < v[0].size() and 0 <= y + dy[i] and y + dy[i] < v.size()){
			dfs(v,x + dx[i],y + dy[i],vv);
		}
	}
	return ;
}
int main(){
	while(1){
		int w,h; cin >> w >> h;
		ans = 0;
		if (w + h == 0) break;
		vector<string> tile(h);
		vector< vector<int> > check(h, vector<int>(w,0));
		int at_x;
		int at_y;
		for (int i = 0; i < h; i++){
			cin >> tile[i];
			for (int j = 0; j < w; j++){
				if (tile[i][j] == '@'){
					at_x = j;
					at_y = i;
				}
			}
		}
		dfs(tile,at_x,at_y,check);
		cout << ans << endl;
	}
return 0;
}

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

int main()
{
    int n;
    cin >> n;
    long long sum = 0;
    int cnt = 0;
    int minNum = 1000000000 + 1;
    for(int i = 0; i < n; ++i)
    {
        int t;
        cin >> t;
        if(t < 0) ++cnt;
        int abst = abs(t);
        if(abst < minNum) minNum = abst;
        sum += abst;
    }
    if(cnt%2!=0) sum -= 2*minNum;
    cout << sum << endl;
}

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

int main()
{
	int n;
	cin>>n;
	int x=n%10;
	
	if(x==2 || x==4 || x==5 || x==7 || x==9)
		cout<<"hon"<< endl;
	else if(x==0 || x==1 || x==6 || x==8)
		cout<<"pon"<< endl;
	else if(x==3)
		cout<<"bon"<< endl;
	
	return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>

int main()
{
	int i, n;
	long min=0, max=0, sum=0;
	int num[10000];
	scanf("%d",&n);
	for(i=0; i<n; i++){
		scanf("%d", &num[i]);
	}
	min = num[0];
	max = num[0];
	for(i=0; i<n; i++){
		if(num[i] < min){
			min = num[i];
		}
		else if(num[i] > max){
		max = num[i];
		}
		sum = sum + num[i];
	}
	printf("%ld %ld %ld\n", min, max, sum);
	return 0;
}

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

int main() {
  string S;
  cin>>S;
  int ans=0;
  for(int i=0;i<4;i++) {
    if(S.at(i)=='+') {
      ans++;
    }
    if(S.at(i)=='-') {
      ans--;
    }
  }
  cout<<ans<<endl;
}

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

int main(){
	int m, f, b, ans;
	scanf("%d%d%d", &m, &f, &b);
	if(m >= b){
		ans = 0;
	}else if(m+f >= b){
		ans = b-m;
	}else ans = -1;
	if(ans == -1)printf("NA\n");
	else printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3216
N = int(input())
H = list(map(int, input().split()))

base = H[0] - 1 if H[0] != 1 else 1 
for h in H[1:]:
    if h - base == 0 or h - base == 1:
        continue
    elif h - base > 1:
        base = h -1
    else:
        print("No")
        break
else:
    print("Yes")


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll I, O, T, J, L, S, Z;
    cin >> I >> O >> T >> J >> L >> S >> Z;
    ll ans = 0;
    {
        ll s = O;
        ll i = I, j = J, l = L;
        s += (i / 2) * 2;
        i %= 2;
        if (i > 0 && j > 0 && l > 0) {
            s += 3;
            i--;
            j--;
            l--;
        }
        s += (j / 2) * 2 + (l / 2) * 2;
        ans = std::max(s, ans);
    }
    {
        ll s = O;
        ll i = I, j = J, l = L;
        s += (i / 2) * 2 + (j / 2) * 2 + (l / 2) * 2;
        ans = std::max(s, ans);
    }
    {
        ll s = O;
        ll i = I, j = J, l = L;
        if (i > 0 && j > 0 && l > 0) {
            s += 3;
            i--;
            j--;
            l--;
        }
        s += (j / 2) * 2 + (l / 2) * 2;
        s += (i / 2) * 2;
        ans = std::max(s, ans);
    }

    cout << ans << endl;

    return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        var sol = new Solve();
        sol.Exec();
    }
}

class Solve
{
    public void Exec()
    {
        var N = int.Parse(Console.ReadLine());
        var count = 0;
        for (var i = 0; i < N; i++)
        {
            var t = int.Parse(Console.ReadLine());
            if (IsPrime(t)) count++;
        }

        Console.WriteLine(count);
    }

    public static bool IsPrime(int num)
    {
        if (num < 2) return false;
        else if (num == 2) return true;
        else if (num % 2 == 0) return false;

        var sqrtNum = Math.Sqrt(num);
        for (var i = 3; i <= sqrtNum; i += 2)
        {
            if (num % i == 0)
            {
                return false;
            }
        }

        return true;
    }
}



Measured memory_bytes: 15896
#include <stdio.h>
#include <stdlib.h>
int cmp( const void *p, const void *q ) {
   		 return *(int*)p - *(int*)q;}
int main(){
  int n,a[100];
  scanf("%d",&n);
  for(int i=0;i<n;i++)scanf("%d",&a[i]);
  qsort(a,n,sizeof(int),cmp);
  printf("%d",a[n-1]-a[0]);
  return 0;
}

Measured memory_bytes: 128
S = input()
res = 'No'
if len(S) % 2 == 0 and len(S) > 0:
    res = 'Yes'
    for i in range(int(len(S)/2)):
        # print(S[i*2:i*2+2])
        if S[i*2:i*2+2] != 'hi':
            res = 'No'
            break
print(res)

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

int main(){
  int n,m,i,j,k,kazu,kari,amari,max=1,gomi,hantei,kotae,ans=0;
  cin>>n>>m;
  int a[m][n],p[m];
  for(i=0;i<n;i++){
    max*=2;
  }
  for(i=0;i<m;i++){
    for(j=0;j<n;j++){
      a[i][j]=0;
    }
  }
  for(i=0;i<m;i++){
    cin>>gomi;
    for(j=0;j<gomi;j++){
      cin>>k;
      a[i][k-1]=1;
    }
  }
  for(i=0;i<m;i++){
    cin>>p[i];
  }
  for(kazu=0;kazu<max;kazu++){
    kotae=1;
    for(i=0;i<m;i++){
      hantei=0;
      kari=kazu;
      for(j=n-1;j>=0;j--){
        amari=kari%2;
        kari/=2;
        if(a[i][j]==1&&amari==1){
          hantei++;
        }
      }
      if(hantei%2!=p[i]){

        kotae*=0;
      }
    }
    ans+=kotae;
  }
  cout<<ans;
}

Measured memory_bytes: 256
using System;

namespace ABC071_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = new int[26];
            var s = Console.ReadLine();
            for(var i=0;i<s.Length;i++)
            {
                a[s[i] - 'a']++;
            }
            for(var i=0;i<26;i++)
            {
                if(a[i] == 0)
                {
                    Console.WriteLine((char)('a' + i));
                    return;
                }
            }
            Console.WriteLine("None");
        }
    }
}


Measured memory_bytes: 13140
/*  Author:  Hariom_Pandey
    Created: 8/22/2020 11:10:35 AM
*/

#include <bits/stdc++.h>
using namespace std;
#define Mset(s, n)      memset(s, n, sizeof(s))
#define Rp0(i, m)       for(int i = 0; i < m; ++i)
#define Rpd(i, m, l)    for(int i = l; i >= m; --i)
#define Rp1(i ,m)       for(int i = 1; i <= m; i++)
#define All(a)          (a).begin(), (a).end()
#define Lwb             lower_bound
#define Upb             upper_bound
#define Sz(a)           int((a).size())
#define u_map           unordered_map
#define Exist(a, b)     (find(All(a), (b)) != (a).end())
#define Sort(x)         sort(All(x))
#define Gsort(x)        sort(All(x), greater<typeof(*((x).begin()))>())
#define Unique(v)       Sort(v); (v).resize(unique(ALL(v)) - (v).begin())
#define ll              long long int  

int32_t  main(){
   
   string str; cin>>str;
   int cnt=0, an=0;
   for(int i=0; i<3; i++){
       if(str[i]=='R') {
           cnt+=1;
           an++;
       }
       
       else if(an>=1 and str[i]=='S') break;
       else cnt=0;
   }
    cout<<cnt;
    return 0;
}



Measured memory_bytes: 3632
N = int(input())

a = []
for i in range(1, N + 1):
    if i % 3 == 0 and i % 5 == 0:
        pass
    elif i % 3 == 0:
        pass
    elif i % 5 == 0:
        pass
    else:
        a.append(i)

print(sum(a))

Measured memory_bytes: 30164
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////



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

    set<int> num;
    int wa[n+1] = {};
    int sumwa = 0;
    rep(i,0,m){
	int p;
	string s;
	cin >> p >> s;

	if(s == "AC"){
	    if(num.count(p) <= 0)sumwa += wa[p];
	    num.it(p);
	}else{
	    if(num.count(p) <= 0)wa[p]++;
	}
    }
    
    PS(sz(num));P(sumwa);
}


Measured memory_bytes: 5376
//???????????????????????????????????????????????¢?????????
#include<stdio.h>

int main(void){
    int h, w;
    int i,j;
    
    while(1){
        scanf("%d", &h);
        scanf("%d", &w);
        
        if(h == 0) break;
        
        for(i = 0; i < h; i++){
            for(j =0; j < w; j++){
                if((i+j) % 2 == 0)putchar('#');
                else putchar('.');
            }
            putchar('\n');
        }
        putchar('\n');
    }
    return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
int main()
{
  ll n ;
  cin >> n ;
  int cnt = 0 ;
  ll t ;
  for(t = 2 ;t <= n ;t *= 2)
   {
     cnt ++ ;
     if(n / t == 1) break ;
   }
   if(n == 1) cout << 1 << endl ;
   else 
   cout << t * 2 - 1 << endl ;
  return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int> d;
vector<int> f;
vector<bool> used;
vector< vector<int> > v;
int n;
int cnt = 1;

void dfs(int pos){
  d[pos] = cnt; cnt++;
  used[pos] = true;
  for(int i = 0; i < n; i++){
    if(v[pos][i] && !used[i]){
      dfs(i);
    }
  }
  f[pos] = cnt; cnt++;
}

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

  cin >> n;
  d = f = vector<int>(n, -1);
  used = vector<bool>(n, false);
  v = vector< vector<int> >(n, vector<int>(n, 0));
  for(int i = 0; i < n; i++){
    int u, k; cin >> u >> k;
    u--;
    for(int j = 0; j < k; j++){
      int a; cin >> a;
      a--;
      v[u][a] = 1;
    }
  }
  for(int i = 0; i < n; i++)
    if(!used[i]) dfs(i);
  for(int i = 0; i < n; i++){
    cout << i+1 << " " << d[i] << " " << f[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 1308
#include <stdio.h>

#define MAX 500000
#define INFTY 2000000000

int L[(MAX/2)+2],R[(MAX/2)+2],count;

void merge(int A[], int n, int left, int mid, int right){

  int i,j,k,n1,n2;

  n1 = mid - left;
  n2 = right - mid;

  for(i=0;i<n1;i++){
    L[i] = A[left + i];
  }

  for(i=0;i<n2;i++){
    R[i] = A[mid + i];
  }

  L[n1] = R[n2] = INFTY;

  i = j = 0;

  for(k=left;k<right;k++){
    count++;
    if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }
    else{
      A[k] = R[j];
      j++;
    }
  }
}

void mergeSort(int A[], int n, int left, int right){

  int mid;

  if((left + 1) < right){
    mid = (left + right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}

int main(){

  int A[MAX], n ,i;

  scanf("%d",&n);

  count = 0;
  
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    if(A[i] >= INFTY){
      return 1;
    } 
  }

  mergeSort(A,n,0,n);

  for(i=0;i<n;i++){
    if(i){
      printf(" ");
    }
    printf("%d",A[i]);
  }
  printf("\n");

  printf("%d\n",count);

  return 0;

}



Measured memory_bytes: 5620
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		long A = sc.nextLong();
		long B = sc.nextLong();
		long C = sc.nextLong();
		long K = sc.nextLong();

        if(K<A){
			System.out.println(K);
			return;
		}

		if(K<=(A+B)){
			System.out.println(A);
			return;
		}else{
			long diff = (K-(A+B));
			System.out.println(A-diff);
			return;
		}

	}
}


Measured memory_bytes: 35808
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q;
struct sushi {
	int t, d, i;
	sushi(int l = 0, int r = 0, int c = 0) : t(l), d(r), i(c) {}
	bool operator<(const sushi &rhs) const {
		return d < rhs.d;
	}
};
signed main() {
	cin >> N >> K;
	vector< int > D(N), T(N);
	rep(i, N) cin >> T[i] >> D[i];
	vector< sushi > S(N);
	rep(i, N) {
		S[i] = sushi(T[i] - 1, D[i], i);
	}
	sort(S.rbegin(), S.rend());
	vector< int > best(N);
	rep(i, N) chmax(best[S[i].t], S[i].d);
	vector< int > count(N, 0);
	int ans = 0;
	int tmp = 0;
	int x = 0;
	stack< sushi > sk;
	rep(i, K) {
		sushi s = S[i];
		tmp += s.d;
		sk.push(s);
		if (!count[s.t])
			x++;
		count[s.t]++;
	}
	ans = tmp + x * x;
	int i = K;
	while (i < N && sk.size() > 0) {
		sushi s = sk.top();
		//cout << s.d << " " << s.i << endl;
		sk.pop();
		if (count[s.t] > 1) {
			count[s.t]--;
			tmp -= s.d;
			while (i < N && count[S[i].t])
				i++;
			if (i >= N)
				break;
			tmp += S[i].d;
			count[S[i].t]++;
			x++;
			chmax(ans, tmp + x * x);
		}
	}
	cout << ans << endl;
	return 0;
}

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

h, w, d = [ int(v) for v in input().split() ]
def manhattan(intuple1,intuple2):
	return abs(intuple1[2]-intuple2[2]) + abs(intuple1[1]-intuple2[1])

grid_list = [ None for i in range(w*h) ]
for i in range(h):
	num_list = [ int(v) for v in input().split() ]
	for j in range(w):
		grid_list[i*w+j] = (num_list[j],i,j)
grid_list = sorted(grid_list)

sum_list = []

for i in range(1,d+1):
	temp_list = []
	left = i
	s = 0
	for j in range(i,w*h+1,d):
		s +=  manhattan(grid_list[left-1],grid_list[j-1])
		temp_list.append(s)

		left = j
	sum_list.append(temp_list)

m = int(input())
for i in range(m):
	l, r = [ int(v) for v in input().split() ]
	print(sum_list[r%d-1][(r-1)//d]-sum_list[l%d-1][(l-1)//d])

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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());

            Func<long, long> S = x =>
            {
                var res = 0L;
                while (x >= 1)
                {
                    res += x % 10;
                    x /= 10;
                }
                return res;
            };

            Console.WriteLine(n % S(n) == 0 ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int INF = 1000000;
int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> E(N);
  for (int i = 0; i < M; i++){
    int A, B;
    cin >> A >> B;
    A--;
    B--;
    E[A].push_back(B);
    E[B].push_back(A);
  }
  vector<int> d(N, INF);
  vector<int> prev(N, -1);
  d[0] = 0;
  queue<int> Q;
  Q.push(0);
  while (!Q.empty()){
    int v = Q.front();
    Q.pop();
    for (int w : E[v]){
      if (d[w] == INF){
        d[w] = d[v] + 1;
        prev[w] = v;
        Q.push(w);
      }
    }
  }
  bool ok = true;
  for (int i = 0; i < N; i++){
    if (d[i] == INF){
      ok = false;
    }
  }
  if (!ok){
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
    for (int i = 1; i < N; i++){
      cout << prev[i] + 1 << endl;
    }
  }
}

Measured memory_bytes: 10576
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;



#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)
#define MP(a,b) make_pair(a,b)

ll debugFlag = false;
template<typename T> void debug(T&);
template<typename T> void debug(T&, bool);
template<typename T> void debug(vector<T>&);
template<typename T> void debug(vector<T>&, bool);
template<typename T, typename U> void debug(pair<T, U>&);
template<typename T, typename U> void debug(pair<T, U>&, bool);

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& obj) {
	debug(obj, true);
}

template<typename T>
void debug(vector<T>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "[";
	rep(i, obj.size()) {
		if (i != 0) cout << ",";
		debug(obj[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& obj) {
	debug(obj, true);
}

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

void solve() {

	string S;
	cin >> S;
	if (S[0]==S[1] && S[1]==S[2]) {
		cout << "No";
	} else {
		cout << "Yes";
	}

}


int main(int argc, char* argv[]) {
	if (argc == 2 && string(argv[1]) == "debug") debugFlag = true;
	solve();
	return 0;
}

Measured memory_bytes: 3576
import sys
from operator import itemgetter
n=int(sys.stdin.readline())
task=[]
ans="Yes"
for i in range(n):
    task.append(list(map(int,sys.stdin.readline().split())))
task.sort(key=itemgetter(1))
ryou=0
for i in task:
    ryou+=i[0]
    if i[1]<ryou:
        ans="No"
        break
print(ans)


Measured memory_bytes: 54600
open System

let [|x; y|] = stdin.ReadLine().Split() |> Array.map int

if x <= 0 && y <= 0 || x >= 0 && y >= 0 then
    if x > y then 2 + x - y + (if x = 0 || y = 0 then -1 else 0)
    else y - x
else
    let x = abs(x)
    let y = abs(y)
    if x > y then 1 + x - y
    else 1 + y - x
|> stdout.WriteLine


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int X; cin >> X;
	int N; cin >> N;
	vector<int>p(N); rep(i, 0, N) { cin >> p[i]; }
	set<int>s;
	s.insert(0);
	rep(i, 1, 200) {
		s.insert(i);
		s.insert(-i);
	}
	for (auto a : p)s.erase(a);
	int ans = INF;
	int x = 0;
	for (auto a : s) {
		if (chmin(ans, abs(X - a))) {
			x = a;
		}
	}
	cout << x << endl;

	return 0;
}


Measured memory_bytes: 3676
import java.util.Scanner;


public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
			
			int N = sc.nextInt();
			int[] a = new int[N]; 
			int check = 1;
			int destroy = 0;
			for(int i=1;i<=N;i++) {
				a[i-1] = sc.nextInt();
				if(a[i-1]==check) {
					check++;
				}else {
					destroy++;
				}
			}
			
			if(destroy==N) {
				System.out.println(-1);
			}else {
				System.out.println(destroy);
			}
			
	}	

}

Measured memory_bytes: 60684
#include<bits/stdc++.h>
using namespace std;
int t[58],n,f,ans,d;
int main(){
    cin>>n>>d;
    for(int i=0;i<n;i++){
        cin>>f;
        t[f]++;
    }
    for(int i=50;i>=0;i--)
        while(t[i]!=0&&d!=0){
            t[i]--;ans+=i;d--;
        }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256