akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int n;
    scanf("%d", &n);
    int a[n];
    int multi = 1;
    for(int i = 0;i < n;i++){
        scanf("%d", &a[i]);
        if(a[i] < 0){
            multi = multi * (-1);
        }
    }
    if(multi > 0){
        long int sum = 0;
        for(int i = 0;i < n;i++){
            sum = sum + abs(a[i]);
        }
        printf("%ld\n", sum);
    }else{
        int min = abs(a[0]);
        for(int i = 1;i < n;i++){
            if(abs(a[i]) < min){
                min = abs(a[i]);
            }
        }
        long int sum = 0;
        for(int i = 0;i < n;i++){
            sum = sum + abs(a[i]);
        }
        printf("%ld\n", sum-2*min);
    }
    return 0;
}

Measured memory_bytes: 512
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    int ns = s.size(), nt = t.size();
    int q;
    cin >> q;
    vector<int> accum_s(ns + 1), accum_t(nt + 1);

    IFOR(i, 1, ns) {
        if (s[i-1] == 'A')
            accum_s[i] = accum_s[i - 1] + 1;
        else
            accum_s[i] = accum_s[i - 1] + 2;
    }

    IFOR(i, 1, nt) {
        if (t[i-1] == 'A')
            accum_t[i] = accum_t[i - 1] + 1;
        else
            accum_t[i] = accum_t[i - 1] + 2;
    }

    FOR(i, 0, q) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        int num1 = accum_s[b] - accum_s[a - 1];
        int num2 = accum_t[d] - accum_t[c - 1];
        if (num1 < num2)
            swap(num1, num2);
        if ((num1 - num2) % 3 == 0)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;

    }
    return 0;
}

Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		double a=sc.nextDouble();
		double b=sc.nextDouble();
		double t=sc.nextDouble();
		int n=0;
		sc.close();
		for(double i=a;i<t+0.5;i=i+a){
			n +=b;
		}
		System.out.println(n);
	}
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define endl '\n'

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	
	
	//ll t; cin>>t; while(t--)
	{
		
		ll a;
		cin>>a;
		cout<<a+a*a+a*a*a;
		
	}
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
#define mp make_pair
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const dou pi = 3.14159265358;
const ll mod = 1000000007LL;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return a / gcd(a,b) * b;
}

//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logm)
ll modpow(ll n,ll m,ll MOD){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    ll ans = 0;
    for(ll i = 1;i <= 33LL;i++){
        for(ll j = 2;j <= 15LL;j++){
            if(modpow(i,j,INF) <= N)chmax(ans,modpow(i,j,INF));
        }
    }
    cout << ans << endl;
}

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

namespace ConsoleApp15
{
    class Class159
    {
        static void Main()
        {
            var abc = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long a = abc[0], b = abc[1], c = abc[2];
            long r =c-a-b;
            if (r >= 0)
            {
                Console.WriteLine(r * r > 4 * a * b ? "Yes" : "No");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13396
#include<stdio.h>
int main(void){
	int w,h,x,y,r;
	scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
	if(x+r<=w&&y+r<=h&&x+r>=0&&y+r>=0&&x-r>=0&&y-r>=0)
		printf("Yes\n");
	else
		printf("No\n");
	
	return 0;
}


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

#define _USE_MATH_DEFINES

#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <functional>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <iterator>
#include <bitset>
#include <complex>
#include <limits>
#include <random>


using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;

const double EPS = 1e-9;

struct BIT //0-indexed
{
	vector<int> node;
	int mn;

	BIT(int mn)
	{
		this->mn = mn;
		node.resize(mn + 1, 0);
	}

	void add(int i, int x)
	{
		i++;
		while (i <= mn)
		{
			node[i] += x;
			i += (i&-i);
		}
	}

	int sum(int i)
	{
		i++;
		int res = 0;
		while (i > 0)
		{
			res += node[i];
			i -= (i&-i);
		}
		return res;
	}
};

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

	int N, Q;
	cin >> N >> Q;

	vector<queue<int>> QV(N);
	vector<int> PRE(N, -1);
	vector<int> C(N);
	rep(i, 0, N)
	{
		cin >> C[i];
		C[i]--;
		QV[C[i]].push(i);
	}

	vector<pair<pii,int>> PV(Q);
	rep(i, 0, Q)
	{
		cin >> PV[i].first.second >> PV[i].first.first;
		PV[i].first.first--, PV[i].first.second--;
		PV[i].second = i;
	}
	sort(all(PV));

	BIT bit(N + 3);
	vector<int> ANS(Q);

	int r = 0;
	rep(i, 0, Q)
	{
		while (r <= PV[i].first.first)
		{
			if (PRE[C[r]] != -1)
			{
				bit.add(PRE[C[r]], -1);
			}
			PRE[C[r]] = QV[C[r]].front();
			QV[C[r]].pop();
			bit.add(PRE[C[r]], 1);
			r++;
		}
		ANS[PV[i].second] = bit.sum(PV[i].first.first);
		if (PV[i].first.second > 0)ANS[PV[i].second] -= bit.sum(PV[i].first.second-1);
	}

	rep(i, 0, Q)
	{
		cout << ANS[i] << endl;
	}

	
	return 0;
}

Measured memory_bytes: 370840
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int X, Y;
  cin >> X >> Y;
  if (Y % 2) {
    cout << "No" << endl;
    return 0;
  }
  int b = (Y - 2 * X) / 2;
  int a = X - b;
  if (a >= 0 && b >= 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3116
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N =Integer.parseInt(sc.next());
        int min = Integer.MAX_VALUE;
        int max = Integer.MIN_VALUE;
        for(int i = 0; i < N ;i++){
            int in = Integer.parseInt(sc.next());
            if(min > in){
                min = in;
            }
            if(max < in){
                max = in;
            }
        }
        System.out.println(max-min);
    }
}

Measured memory_bytes: 21972
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  vector<vector<int>> table(3, vector<int>(3));
  rep(i, 3) {
    rep(j, 3) {
      int c;
      cin >> c;
      table.at(i).at(j) = c;
    }
  }
  vector<int> a(3);
  vector<int> b(3);
  bool flag = false;
  rep(i, 101) {
    rep(j, 101) {
      rep(k, 101) {
        a.at(0) = i;
        a.at(1) = j;
        a.at(2) = k;
        b.at(0) = table.at(0).at(0) - a.at(0);
        b.at(1) = table.at(1).at(1) - a.at(1);
        b.at(2) = table.at(2).at(2) - a.at(2);
        int counta = 0;
        rep(ii, 3) {
          rep(jj, 3) {
            if (a.at(ii)+b.at(jj) == table.at(ii).at(jj)) {
              counta++;
            }
          }
        }
        if (counta == 9) {
          coYes;
          flag = true;
          break;
        }
      }
      if (flag) {
        break;
      }
    }
    if (flag) {
      break;
    }
  }
  if (!flag) {
    coNo;
  }
}
  

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

int main() {
  int n, i, ans = 0;
  cin >> n;
  vector<int> a(n), b(n-1);
  for (i = 0; i < n-1; i++)
    cin >> b[i];
  a[0] = b[0];
  for (i = 1; i <= n-2; i++)
    a[i] = min(b[i], b[i-1]);
  a[n-1] = b[n-2];
  for (i = 0; i < n; i++)
    ans += a[i];
  cout << ans << endl;
}

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

using namespace std;

int main() {
  long long int n, k;

  cin >> n >> k;

  vector<long long int> num(100001, 0);

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

    num[a] += b;
  }

  long long int sum = 0;
  for (int i = 1; i <= 100001; i++) {
    sum += num[i];
    if (k <= sum) {
      cout << i << endl;
      break;
    }
  }
}


Measured memory_bytes: 1024
n = int(input())

from collections import defaultdict
import sys
sys.setrecursionlimit(1000)

MINV = 10**13

di = defaultdict(int)
tmp = n
for i in range(2, int(n**0.5)+1):
    while tmp % i == 0:
        di[i] += 1
        tmp //= i
if tmp != 1:
    di[tmp] += 1

def gettotal(di, keys, keyindex, nowa, nowb):
    key = keys[keyindex]
    mins = MINV
    if keyindex == len(keys) -1:
        for i in range(di[key]+1):
            a = key ** i
            b = key ** (di[key] - i)
            if nowa * a + nowb * b < mins:
                mins = nowa * a + nowb * b
        return mins
    for i in range(di[key] + 1):
        a = key ** i
        b = key ** (di[key] - i)
        res = gettotal(di, keys, keyindex+1, nowa * a, nowb * b)
        if res < mins:
            mins = res
    return mins

result = gettotal(di, list(di.keys()), 0, 1, 1)
print(result -2)


Measured memory_bytes: 44124
import Foundation

func readInt() -> Int {
    return Int(readLine()!)!
}

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

// ABC178B
let input = readInts()
let a = input[0]
let b = input[1]
let c = input[2]
let d = input[3]

print(max(a * c, a * d, b * c, b * d))


Measured memory_bytes: 13616
#include<bits/stdc++.h>
using namespace std;
#include <climits>
#define Sheryang main
typedef long long ll;
#pragma GCC optimize(3)
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > >
template<class T> inline T min(T &x,const T &y){return x>y?y:x;}
template<class T> inline T max(T &x,const T &y){return x<y?y:x;}
int read()
{
    int x=0,f=1;	char c=getchar();
    while(c<'0'||c>'9')	{if(c=='-') f=-1;c=getchar();}
    while(c>='0'&&c<='9')	{x=x*10+c-'0';c=getchar();}
    return x*f;
}
struct ios
{
	inline char gc()
	{
		static const int IN_LEN=1<<18|1;
		static char buf[IN_LEN],*s,*t;
		return (s==t)&&(t=(s=buf)+fread(buf,1,IN_LEN,stdin)),s==t?-1:*s++;
	}
	template <typename _Tp> inline ios & operator >> (_Tp&x)
	{
		static char ch,sgn; ch = gc(), sgn = 0;
		for(;!isdigit(ch);ch=gc())
		{	
			if(ch==-1)return *this;sgn|=ch=='-';
		}
		for(x=0;isdigit(ch);ch=gc())x=(((x<<2)+x)<<1)+(ch^'0');
		sgn&&(x=-x); return *this;
	}
}io;
const int maxn = 5e6 + 7;
const int mod = 1e9 + 7;
/** keep hungry and keep calm! **/

int h,w;
int main()
{
	cin >> h >> w;
	int cnt = 0;
	for(int i=1;i<=h;i++)
	{
		getchar();
		for(int j=1;j<=w;j++)
		{
			char ch;
			ch = getchar();
			if(ch == '#')	cnt++;
		}
	}
	if(cnt == h+w-1)	printf("Possible\n");
	else	printf("Impossible\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;;
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin >> n;
  string s,t;cin >> s >> t;
  rep(i,n){
    cout << s[i] << t[i] ;
  }
  cout << endl;
}

Measured memory_bytes: 256
/*input
5 4 2 2 1
*/
fn read_line() -> String {
    let mut return_ = format!("");
    std::io::stdin().read_line(&mut return_).ok();
    return_.pop();
    return_
}

fn main() {
    // w, h, x, y, r
    let v: Vec<i32> = read_line()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    if v[4] <= v[2] && v[2] <= v[0] - v[4] && v[4] <= v[3] && v[3] <= v[1] - v[4] {
        println!("Yes");
    } else {
        println!("No");
    }
}



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

int main(){
  long long N;
  cin >> N;
  vector<long long> move(5);
  for(int i =0; i < 5; i++){
    cin >> move[i];
  }
  
  vector<long long> time(5,0);
  time[0] = (N-1)/move[0] + 1;//time[i]:pos[i-1]=0->pos[i]=0
  //cout << time[0] << endl;
  for(int i=1; i < 5; i++){
    long long min_move = *min_element(move.begin(),move.begin() + i);
    //cout << "i:" << i << " min_move" << min_move <<endl; 
    if(move[i] >= min_move){
      time[i] = 1;
    }else{//move[i] < min_move
      //cout << "i:" << i << " min_move" << endl; 
      long long tmp_time = 0;
      for(int j = 0; j < i; j++){
        tmp_time += time[j] - 1;
      }
      time[i] = ((N - (tmp_time * move[i])) - 1)/move[i] + 1;
    }
    
  }
  for(int i = 0;i < 5;i++){
    //cout << time[i] << endl;
  }
  long long ans=0;
  for(int i = 0;i < 5;i++){
    ans += time[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
h.reverse()

for i in range(n-1):
    d = h[i+1] - h[i]
    if d == 1:
        h[i+1] -= 1
    elif d > 1:
        print('No')
        exit()
    else:
        pass

print('Yes')

Measured memory_bytes: 20808
import java.util.*;

class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int h = sc.nextInt();
                int w = sc.nextInt();
                while(h != 0){
                        sc.nextLine();
                        char[][] map = new char[h][w];
                        boolean[][] passed = new boolean[h][w];
                        int[] xy = new int[2];
                        passed[0][0] = true;
                        for(int i = 0 ; i < h ; i++){
                                String s = sc.nextLine();
                                for(int j = 0 ; j < w ; j++){
                                        map[i][j] = s.charAt(j);
                                }
                        }
                        System.out.println((move(map, xy, passed) == 1) ? xy[0] + " " + xy[1] : "LOOP");
                        h = sc.nextInt();
                        w = sc.nextInt();
                }
        }
        static int move(char[][] map, int[] xy, boolean[][] passed){
                switch(map[xy[1]][xy[0]]){
                        case '>':
                                xy[0]++;
                                break;
                        case '<':
                                xy[0]--;
                                break;
                        case '^':
                                xy[1]--;
                                break;
                        case 'v':
                                xy[1]++;
                                break;
                        case '.':
                                return 1;
                }
                if(passed[xy[1]][xy[0]]){
                        return -1;
                }else{
                        passed[xy[1]][xy[0]] = true;
                        return move(map, xy, passed);
                }
        }
}

Measured memory_bytes: 12000
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		String input = sc.next();
		String[] corrects = new String[]{"AKIHABARA", "KIHABARA", "AKIHBARA", "AKIHABRA", "AKIHABAR", "KIHBARA", "KIHABRA", "KIHABAR", "AKIHBRA", "AKIHBAR", "AKIHABR", "KIHBRA", "KIHBAR", "KIHABR", "AKIHBR", "KIHBR"}; 
		for (String s : corrects) {
			if (input.equals(s)) {
				System.out.println("YES");
				return;
			}
		}
		System.out.println("NO");
	}
}


Measured memory_bytes: 22996
n, m = map(int, input().split())
l_max = 0
r_min = n
for i in range(m):
  l, r = map(int, input().split())
  if(l_max < l):
    l_max = l
  if(r_min > r):
    r_min = r
ans = r_min - l_max + 1
print(ans if ans >= 0 else 0)

Measured memory_bytes: 3060
#![allow(non_snake_case, unused)]
use std::collections::*;

////////// missing functions in 1.15.1 //////////
macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}
/////////////////////////////////////////////////
pub trait SetMinMax {
	fn setmin(&mut self, v: Self) -> bool;
	fn setmax(&mut self, v: Self) -> bool;
}
impl<T> SetMinMax for T where T: PartialOrd {
	fn setmin(&mut self, v: T) -> bool {
		*self > v && { *self = v; true }
	}
	fn setmax(&mut self, v: T) -> bool {
		*self < v && { *self = v; true }
	}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}

pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

fn run() {
	let (N, W) = read!(usize, usize);
	let mut crt = vec![W + 1; N * 1000 + 1];
	crt[0] = 0;
	for (w, v) in read!(usize, usize; N) {
		for i in (v..crt.len()).rev() {
			let t = crt[i - v] + w;
			crt[i].setmin(t);
		}
	}
	for v in (0..crt.len()).rev() {
		if crt[v] <= W {
			println!("{}", v);
			break;
		}
	}
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int N;
    cin >> N;

    ll ans = 0;
    for (int i = 1; i <= N; ++i)
        ans += (ll)i * (i + 1) / 2;

    for (int i = 1; i < N; ++i) {
        int u, v;
        cin >> u >> v;
        if (u > v)
            swap(u, v);
        ans -= (ll)u * (N - v + 1);
    }

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


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n;
    cin>>n;
    vector<pair<ll,ll> >v;
    for(ll i=0;i<n;i++)
    {
        ll a,b;
        cin>>a>>b;
        v.push_back(make_pair(a,b));
    }
    ll cnt=0;
    for(int i=0;i<n;i++)
    {
       // cout<<v[i].first<<" "<<v[i].second<<"\n";
        if(v[i].first==v[i].second)
            cnt++;
        else
            cnt=0;
           // cout<<cnt<<"\n";
        if(cnt==3)
            break;
    }
    if(cnt==3)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}

Measured memory_bytes: 3620
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
//ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int N,A,B;
int main(){
	cin>>N>>A>>B;
	cout<<min(N*A,B)<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
	
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		
		if (n % 2 == 1) {
			System.out.println(n * 2);
			return;
		}
		
		System.out.println(n);
		
	}

}

Measured memory_bytes: 21712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
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; }

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) do{}while(0)
#endif





ll n;

int main(){
	cin >> n;
	map<string,int> m;
	
	rep(i,n){
		string s;
		cin >> s;
		m[s]++;
	}
	
	cout << "AC x " << m["AC" ] << endl;
	cout << "WA x " << m["WA" ] << endl;
	cout << "TLE x "<< m["TLE"] << endl;
	cout << "RE x " << m["RE" ] << endl;
	
	return 0;
}




Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007

#define access(i) a[i/3][i%3]
//#define random_shuffle(r...)random_shuffle(r,[](int _){return my_rand()%_;})

 int main(){

 ll n;
 cin>>n;
  vector<int>e(1e5+1),o(1e5+1);

  for(int i=0;i<n;i++){
     int x; cin>>x;
     if(i%2 == 0) o[x]++;
     else e[x]++;
  }

  int max_even = max_element(e.begin(),e.end())-e.begin();
  int max_odd = max_element(o.begin(),o.end())-o.begin();

  // if the max_even is equal to max_odd that means that the array elements are same hence
  // even dont want to have the array elements as same so
  // case1: e[max_even]-o[second_maxeven]
  // case2: o[max_even]-e[second_max_even]

  if(max_even != max_odd)
  {
        cout<<n-e[max_even]-o[max_odd]<<endl;
  }
 else {

   sort(e.rbegin(),e.rend());
   sort(o.rbegin(),o.rend());

   cout<<min(n-e[1]-o[0],n-e[0]-o[1])<<endl;

 }


 return 0;
 }


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

#define pii pair<int, int>
#define mp make_pair
#define fi first
#define se second

int n, cnt, ans;

int main(){	
	cin >> n;
	for(int i = 1; i <= n; i++){
		if(i % 2 == 0) continue;
		cnt = 0;
		for(int j = 1; j <= i; j++) if(i % j == 0) cnt++;
		if(cnt == 8) ans++;
	}
	cout << ans << '\n';
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 1001001001;

int main(){
	ll Q; cin >> Q;
	priority_queue<ll> head;
	priority_queue<ll, vector<ll>, greater<ll>> back;
	ll head_sum = 0, back_sum = 0, sum = 0;
	for (ll i = 0; i < Q; i ++) {
		ll q, a, b;
		cin >> q;
		if (q == 1) { 
			cin >> a >> b;
			sum += b;
			if (head.size() == 0) {
				head_sum += a;
				head.push(a);
				continue;
			}
			if (head.size() > back.size()) {
				ll head_last = head.top();
				if (head_last > a) {
					head_sum -= head_last;
					head_sum += a;
					back_sum += head_last;
					head.pop();
					head.push(a);
					back.push(head_last);
				} else {
					back.push(a);
					back_sum += a;
				}
			} else {
				ll back_first = back.top();
				if (back_first < a) {
					back_sum -= back_first;
					back_sum += a;
					head_sum += back_first;
					back.pop();
					back.push(a);
					head.push(back_first);
				} else {
					head_sum += a;
					head.push(a);
				}
			}
		} else {
			ll mid = head.top();
			ll ans = mid * head.size() - head_sum + back_sum - mid * back.size() + sum;
			cout << mid << " " << ans <<endl;
		}
	}
}

Measured memory_bytes: 3828
//
//  main.cpp
//  ProjG
//
//  Created by Tay Yong Kiat on 14/1/19.
//  Copyright © 2019 Tay Yong Kiat. All rights reserved.
//

#include <bits/stdc++.h>

using namespace std;

int n, x, dp[100001];
vector<int> a;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    cin >> n;
    for (int i = 0; i < n && cin >> x; i++) {
        a.push_back(x);
    }
    
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    for (int i = 2; i < n; i++) {
        dp[i] = min(dp[i - 1] + abs(a[i - 1] - a[i]), dp[i - 2] + abs(a[i - 2] - a[i]));
    }
    
    cout << dp[n - 1];

    return 0;
}


Measured memory_bytes: 1144
# coding=utf-8
# Author: lee215

get = lambda: int(raw_input().strip())
gets = lambda: [int(i) for i in raw_input().strip().split()]
getss = lambda n: [gets() for _ in xrange(n)]


C = raw_input().strip()
m = {'A': 'T', 'C': 'G', 'G': 'C', 'T': 'A'}
print m[C]


Measured memory_bytes: 2568
import collections 
n,k = map(int, raw_input().split(' '))

cc=  collections.Counter()
for ii in range(1, n+1):
	cc[ii % k] +=1

r = 0
for ii in cc:
	if ((k - ii) % k + (k - ii) % k) % k == 0:
		r += cc[ii] * cc[(k - ii) % k ] * cc[(k - ii) % k] 
print r

Measured memory_bytes: 85276
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;

using namespace std;

int main()
{
   FAST/**/
   
   ll n,k;
   cin>>n>>k;
   
   ll arr[n];
   for(ll i=0;i<n;i++)
        cin>>arr[i];
   ll ans = 0;
   for(ll i=0;i<n;i++)
        ans+=(arr[i]>=k);
   cout<<ans;        
   return 0;
}

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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    bool isZero=false;
    for(int i=1;i<=b;i++){
        int r=(a*i)%b;
        if(r%b==c){
            isZero=true;
            break;
        }
    }
    if(isZero) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	X, _ := sc.NextInt(), sc.NextInt()
	A := sc.NextMap()
	ans := 0
	p := X
	for i := 0; i <= 101; i++ {
		if A[i] {
			continue
		}
		l := abs(i - X)
		if l < p {
			p = l
			ans = i
		}
	}
	fmt.Println(ans)
}

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

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 1776
#include <bits/stdc++.h>
#define SZ(x) ((int) (x).size())
using namespace std;

typedef long long i64;

int main() {
    #ifdef LOCAL_RUN
    freopen("task.in", "r", stdin);
    freopen("task.out", "w", stdout);
    //freopen("task.err", "w", stderr);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);

    string S, T;
    cin >> S >> T;
    int n = SZ(S), m = SZ(T);

    vector<int> sum1(n + 1, 0), sum2(m + 1, 0);
    for (int i = 1; i <= n; ++i) {
        sum1[i] = sum1[i - 1] + (S[i - 1] == 'A');
    }
    for (int i = 1; i <= m; ++i) {
        sum2[i] = sum2[i - 1] + (T[i - 1] == 'A');
    }

    int q;
    cin >> q;
    while (q-- > 0) {
        int l1, r1, l2, r2;
        cin >> l1 >> r1 >> l2 >> r2;

        int a1 = sum1[r1] - sum1[l1 - 1];
        int b1 = (r1 - l1 + 1) - a1;
        int a2 = sum2[r2] - sum2[l2 - 1];
        int b2 = (r2 - l2 + 1) - a2;
        a1 %= 3;
        b1 %= 3;
        a2 %= 3;
        b2 %= 3;
        bool ok = false;
        for (int i = 0; i < 3; ++i) {
            ok |= make_pair((a1 + i) % 3, (b1 + i) % 3) == make_pair(a2, b2);
        }


        cout << (ok ? "YES\n": "NO\n");
    }
}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int N;
int x;

bool q(LL z){
	printf("? %lld\n" , z);
	fflush(stdout);
	char c;
	scanf(" %c" , &c);
	return c == 'Y';
}

LL BS(LL a , LL b){
	if(b-a<2) return a;
	LL c = (a+b) / 2;
	return !q(c*10) ? BS(c,b) : BS(a,c);
}

int main(){
	LL a = 10;
	repp(i,1,10){
		if(!q(a)){
			x = i;
			break;
		}
		a *= 10;
	}
	if(x == 0){
		LL p = 10;
		repp(i,1,10){
			if(q(p-1)){
				printf("! %lld\n" , p/10);
				fflush(stdout);
				return 0;
			}
			p *= 10;
		}
		printf("! 1000000000\n");
		fflush(stdout);
	} else {
		LL p = 1;
		repp(i,1,x){
			p *= 10;
		}
		printf("! %lld\n" , BS(p,p*10)+1);
		fflush(stdout);
	}
	return 0;
}


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


def main():
    a, b = map(int, input().split())
    for i in range(1250+1):
        a_ = int(i * 0.08)
        b_ = int(i * 0.1)
        if a == a_ and b == b_:
            print(i)
            return
    print(-1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 39280
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int     a,b,c,p1,p2;
    cin>>a>>b>>c;
    p1=abs(a-b);
    p2=abs(a-c);
    if(p1<p2)
        cout<<"A"<<endl;
    else
        cout<<"B"<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mod 1000000007
#define MAX  1e18
#define ss 1e15
#define pb push_back

int main() {
    int p,q,r;
    cin>>p>>q>>r;
    int val = min(p+q,min(q+r,r+p));
    cout<<val<<"\n";
    return 0;
}


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

int main() {
    int a,b;
    cin >> a >> b;
    int count = 0;
    int num = 0;
    vector <int> vec(a);
    for(int i = 0;i<a;i++){
      cin >> vec.at(i);
      count += vec.at(i);
    }
    for(int i = 0;i<a;i++){
      if((vec.at(i)*4*b)>=count)num++;
    }
  if(num>=b) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  string s;
  cin >> s;
  sort(all(s));
  YesorNo(s=="abc");
}

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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  int sum = a + b + c;
  if (sum >= 22) cout << "bust" << endl;
  else cout << "win" << endl;
  
}

Measured memory_bytes: 256
using System;

public class hello
{
    public static void Main()
    {
        string line;
        for (; (line = Console.ReadLine()) != null;)
        {
            var n = int.Parse(line);
            var count = 0;
            for (int i = 0; i < 10; i++)
                for (int j = 0; j < 10; j++)
                    for (int k = 0; k < 10; k++)
                        for (int l = 0; l < 10; l++)
                            if (i + j + k + l == n) count++;
            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol a,b,c,d;
int i[100000];
int u[100000];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >>a>>b>>c;
  if(c<1000000000){
    for(int n=0;n<a;n++){
      if(n==0){
	if(b==0) cout <<c+1;
	else cout <<c;
      }
      else{
	if(n<b) cout <<' '<<c;
	else cout <<' '<<c+1;
      }
    }
    cout <<'\n';
  } else{
    for(int n=0;n<a;n++){
      if(n==0){
	if(b==0) cout <<c-1;
	else cout <<c;
      }
      else{
	if(n<b) cout <<' '<<c;
	else cout <<' '<<c-1;
      }
    }
    cout <<'\n';
  }
  return (0);
}


Measured memory_bytes: 1280
from collections import Counter
n = int(input())
a = Counter(map(int, input().split()))
ans = 0
b = [k for k, v in sorted(a.items()) if v >= 2]
for k, v in sorted(a.items(), reverse=True):
    if v >= 4:
        ans = max(ans, k * k)
if len(b) >= 2:
    ans = max(ans, b[-1] * b[-2])
print(ans)

Measured memory_bytes: 24096
#include <iostream>
#include <iomanip>
#include <string>
#include <unordered_map>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  string s, t, u;
  int a, b;

  cin >> s >> t >> a >> b >> u;

  if (s == u) a -= 1;
  else b -= 1;

  cout << a << " " << b << endl;
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  char* s = new char[N];
  char* t = new char[N];
  long long int alfa[26];
  cin >> s >> t;
  for(int i = 0; i < 26;i++) alfa[i] = 0;
  alfa[s[0]-'a'] = 1;
  for(int i = 1; i < N-1; i++){
    alfa[s[i]-'a'] += alfa[t[i]-'a'];
    alfa[s[i]-'a']%=1000000007;
  }
  
  cout << alfa[t[N-1]-'a'] << endl;

 return 0;
}



Measured memory_bytes: 3216
def myAnswer(N:int,M:int) -> int:
   ans = (1900 * M + (N - M) * 100) * 2 ** M
   return ans

def modelAnswer():
   return
def main():
   N,M = map(int,input().split())
   print(myAnswer(N,M))
if __name__ == '__main__':
   main()

Measured memory_bytes: 3060
from collections import deque
import sys

input = sys.stdin.buffer.readline

n, m = map(int, input().split())
graph = [[] for _ in range(n + 1)]
for _ in range(m):
    a, b = map(int, input().split())
    graph[a].append(b)
infi = 10 ** 10


def bfs(start):
    # res = 頂点数, サイクル最後の頂点、で持つ
    res = (infi, -1)
    dist = [-1] * (n + 1)
    par = [-1] * (n + 1)
    que = deque([])
    que.append(start)
    dist[start] = 0
    while que:
        v = que.popleft()
        for u in graph[v]:
            if dist[u] >= 0:
                continue
            dist[u] = dist[v] + 1
            par[u] = v
            que.append(u)
    for i in range(1, n + 1):
        if i == start:
            continue
        if dist[i] == -1:
            continue
        if start in graph[i]:
            if res[0] > dist[i] + 1:
                res = (dist[i] + 1, i)
    if res[0] == infi:
        return -1, []
    cycle_num = res[0]
    v = res[1]
    CYCLE = deque([])
    while v > 0:
        CYCLE.appendleft(v)
        v = par[v]

    return cycle_num, CYCLE


jisho = {}
ans = (-1, [])
cycle_num = infi
kouho_v = -1
for i in range(1, n + 1):
    temp_num, temp_cycle = bfs(i)
    if temp_num == -1:
        continue
    if cycle_num > temp_num:
        cycle_num = min(cycle_num, temp_num)
        kouho_v = i
        jisho[i] = temp_cycle

if kouho_v == -1:
    print(-1)
    exit()
else:
    ans_num = cycle_num
    ans_list = jisho[kouho_v]
    print(cycle_num)
    print(*ans_list, sep="\n")


Measured memory_bytes: 50780
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
using namespace std;
typedef long long ll;
const int N = 2 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
int main(){/*
    freopen("in","r",stdin);
    freopen("out","w",stdout);*/
    int n,m;
    cin >> n >> m;
    vector<pair<ll,ll> > v(n),p(m);
    for(pair<ll,ll> &i : v)cin >> i.F >> i.S;
    for(pair<ll,ll> &i : p)cin >> i.F >> i.S;
    int mn = 1 << 30;
    int idx;
    fore(i,0,n){
        mn = 1 << 30;
        idx = -1;
        fore(j,0,m){
            if(mn > abs(v[i].F - p[j].F) + abs(v[i].S - p[j].S)){
                mn = abs(v[i].F - p[j].F) + abs(v[i].S - p[j].S);
                idx = j;
            }
        }
        cout << idx + 1 << '\n';
    }
    return 0;
}   

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

const ll INF =100000000009;
ll dp[100005][3];
ll abc[100005][3];

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

int main(){
	ll n; cin >> n;
	rep(i,n){
		rep(j,3){
			cin >> abc[i][j];
		}
	}
	rep(i,n){
		rep(now,3){
			rep(nex,3){
				if(now == nex)continue;
				chmax(dp[i+1][nex],dp[i][now]+abc[i][nex]);
			}
		}
	}
	ll ans = 0;
	rep(i,3)ans =max(ans,dp[n][i]);
	cout << ans << endl;
}

Measured memory_bytes: 4992