akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] n = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long sum = 0;

            for (int cnt = 0; cnt < n[0] + 1; cnt++)
            {
                sum = n[0] - cnt;
                if (2 * cnt + 4 * sum == n[1])
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 28208
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int dp[100001];

int main(){
  int N, M;
  cin >> N >> M;
  string S;
  cin >> S;

  stack<int> st;
  st.push(N);

  dp[N] = 1;

  while(st.size()){
    int pos = st.top();
    st.pop();
    bool flag = true;
    rrep(i, M + 1, 1){
      int next = pos - i;
      if(next < 0) continue;
      if(S[next] == '0') {
        dp[next] = i;
        flag = false;
        if(next != 0) st.push(next);
        break;
      }
    }
    if(flag){
      cout << -1 << endl;
      return 0;
    }
  }

  int pos = 0;
  while(1){
    int ans = dp[pos];
    pos += ans;
    cout << ans;
    if(pos == N){
      cout << endl;
      break;
    }else{
      cout << " ";
    }
  }
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fill(a)  memset(a, 0, sizeof (a))
#define ff first
#define ss second
#define pb push_back
typedef long double ld;
typedef vector<ll> vll;
const ll INF = 1e18;
const ld PI = 4*atan((ld)1);
const ll mod = 1e9+7;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll tt=1;
        // cin >> tt;
    while((tt)--){
       ll n,k; cin >> n>> k;
       if(n==k){
        cout << 0 << endl;
        continue;
       }else{
            ll t= abs(n%k);

            cout << min({n,t,abs(t-k)}) << endl;
       }
    }
}


Measured memory_bytes: 384
import java.util.*;
class Main {
  public static void main(String[] args) {
    
    Scanner scan =new Scanner(System.in);
    int n = scan.nextInt();
    int arr[] = {111,222,333,444,555,666,777,888,999} ;
    int i = 0 ;
    while(n>arr[i]){
      i++;
    }
    System.out.println(arr[i]);
  }
}


Measured memory_bytes: 22484
N=int(input())
A=list(map(int,input().split()))
SUM=sum(A)
Q=int(input())
List=[0 for _ in range(10**5+1)]
for a in A:
    List[a]+=1
for q in range(Q):
    B,C=map(int,input().split())
    SUM-=B*List[B]
    SUM+=C*List[B]
    List[C]+=List[B]
    List[B]=0
    print(SUM)

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2
#define PI acos(-1.0)
#define SUM(v) accumulate((v).begin(),(v).end(),0ll)
#define range(i,left,right) (left<=i && i<right)

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;
typedef priority_queue<int> PQi;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vout(Vs &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());} //vectorの同じ要素消す
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
int leng(int n){string s=to_string(n); return s.size();} //intの桁数
int digitsum(int n){int ret=0; while(n>0){ret+=n%10;n/=10;}return ret;} //桁和
int lesscount(int x,Vi &a){return lower_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx未満の数の個数
int orlesscount(int x,Vi &a){return upper_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx以下の数の個数
int morecount(int x,Vi &a){return a.size()-orlesscount(x,a);} //vector aにおけるxより大きい数の個数
int ormorecount(int x,Vi &a){return a.size()-lesscount(x,a);} //vector aにおけるx以上の数の個数
int iscount(int x,Vi &a) {return upper_bound(ALL(a),x)-lower_bound(ALL(a),x);} //vector aにおけるxの個数
Vi accum(Vi &v){Vi ret((v).size()+1);REP(i,0,(v).size()) ret[i+1]=ret[i]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);
    int a,b,c,k;
    cin>>a>>b>>c>>k;

    int ans=0;
    if(a<=k){
        ans+=a;
        k-=a;
    }else{
        ans+=k;
        k=0;
    }
    if(b<=k){
        k-=b;
    }else{
        k=0;
    }
    if(c<=k){
        ans-=c;
        k-=c;
    }else{
        ans-=k;
        k=0;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int X, N; cin >> X >> N;
	vi p(N);
	set<int> st;
	REP(i, N) {
		cin >> p[i];
		st.insert(p[i]);
	}
	vi not_include;
	REP(i, 102) {
		if (st.find(i) == st.end()) {
			not_include.push_back(i);
		}
	}
	auto lb = lower_bound(ALL(not_include), X);
	if (*lb == 0) {
		cout << *lb << endl;
		return;
	}
	int res1 = *lb;
	int res2 = *(lb - 1);
	if (abs(X - res1) < abs(X - res2)) {
		cout << res1 << endl;
	} else {
		cout << res2 << endl;
	}
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 3664
#include <stdio.h>

long long int gcd(long long int a, long long int b)
{
	long long int c,d,e;
	
	c = a/b;
	d = c*b;
	e = a-d;
	
	return e;
}

int main (int argc, const char * argv[]) {
	long long int a,b,c,a2,b2,l,ll;
	
	while (scanf("%lld%lld",&a, &b) != EOF) {
		if (a > b) {
			c = gcd(a, b);
			a2 = b;
			b2 = c;
			while (b2 != 0) {
				c = gcd(a2, b2);
				a2 = b2;
				b2 = c;
			}
		}
		else {
			c = gcd(b, a);
			a2 = a;
			b2 =c;
			while (b2 != 0) {
				c = gcd(a2, b2);
				a2 = b2;
				b2 = c;
			}
		}
		
		l = a/a2;
		ll = l*b;
		
		printf("%lld %lld\n", a2,ll);

	}
    return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
typedef long long ll;
const int MAX=50;
ll f[MAX];
ll fib(int n){
	f[0]=f[1]=1;
	for(int i=2;i<=n;i++){
		f[i]=f[i-1]+f[i-2];
	}
	return f[n];
} 

int main(){
	int n;
	scanf("%d",&n);
	printf("%lld\n",fib(n));
	return 0;
} 


Measured memory_bytes: 3232
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
    int n;
    cin >> n;
    vector<vector<int>> r(n-1, vector<int>(3));
    rep(i, n-1) cin >> r.at(i).at(0) >> r.at(i).at(1) >> r.at(i).at(2);
    rep(i, n-1){
        int t = r.at(i).at(1)+r.at(i).at(0);
        for(int j=i+1; j<n-1; j++){
            if(t > r.at(j).at(1)){
                if(r.at(j).at(2) != 1){
                    t += (r.at(j).at(2) - t%r.at(j).at(2))%r.at(j).at(2);
                }
                t += r.at(j).at(0);
            }else{
                t = r.at(j).at(1) + r.at(j).at(0);
            }
        }
        cout << t << endl;
    }
    cout << 0 << endl;
    return 0;
}

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


int main() {
    int a,b,x;
    cin >> a >> b >> x;
    double n=((a*b-1.0*x/a)*2.0)/(1.0*a*a);
    double ans=atan(1.0*n);
    if (tan(ans)>1.0*b/a || ans<0) ans = atan((a*b*b)/(2.0*x));
    cout << setprecision(10) << ans*360/(2*M_PI) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
#define REP(i,a,b) for(int i = (int)(a); (i) < (int)(b); i++)
#define rep(i,n) REP(i,0,n)

const int INF = 1e9;

int main(){
	int n,m;
	cin >> n >> m;
	int student[n][2];
	int checkpoint[m][2];
	rep(i,n){ cin >> student[i][0] >> student[i][1]; }
	rep(j,m){ cin >> checkpoint[j][0] >> checkpoint[j][1]; }

	int res[n][2];
	rep(i,n){ res[i][0] = -1; res[i][1] = INF; }

	rep(i,n) rep(j,m){
		int dist = abs(student[i][0] - checkpoint[j][0]) + abs(student[i][1] - checkpoint[j][1]);
		if (dist < res[i][1]){
			res[i][0] = j+1;
			res[i][1] = dist;
		}
	}
	rep(i,n){ cout << res[i][0] << endl; }
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }



void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
      solve();
  }
}

template<typename T>
vector<pair<T, int> > prime_factorize(T n) {
    T tmp = n;
    vector<pair<T, int> > v;
    for (T i = 2; i * i <= n; ++i) {
        ll cnt = 0;
        while (tmp % i == 0) {
            tmp /= i;
            cnt++;
        }
        if (cnt) v.eb(i, cnt);
    }
    if (tmp != 1) v.eb(tmp, 1);
    return v;
}

void solve() {
  ll n, p;
  cin >> n >> p;
  auto v = prime_factorize(p);
  // for (auto e : v) cout << e << endl;
  ll ans = 1;
  for (auto e : v) ans *= pow(e.F, e.S / n);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int n,m;
    cin >> n >> m;
    ll x, y, z;
    vector<ll> vec[8];

    rep(i,n){
        cin >> x >> y >> z;
        vec[0].push_back(x+y+z);
        vec[1].push_back(x+y-z);
        vec[2].push_back(x-y+z);
        vec[3].push_back(x-y-z);
        vec[4].push_back(-x+y+z);
        vec[5].push_back(-x+y-z);
        vec[6].push_back(-x-y+z);
        vec[7].push_back(-x-y-z);
    }

    rep(i,8){
        sort(vec[i].begin(),vec[i].end(),greater<ll>() );
    }
    ll ans = 0;
    rep(i,8){
        ll tmp = 0;
        rep(j,m){
            tmp += vec[i][j];
        }
        ans = max(tmp,ans);
        //cout << tmp << endl;
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  int N;
  scanf("%d", &N);
  int array[N];
  int i; float arg = 0;
  for(i = 0; i < N; i++){
    scanf("%d", &array[i]);
    arg += array[i];
  }
  arg /= N;
  arg = round(arg);
  int tmp = 0, ans = 0;
  for(i = 0; i < N; i++) {
   	tmp = array[i] - arg;
    tmp *= tmp;
    ans += tmp;
  }
  printf("%d", ans);
  return 0; 
}

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

#define INF (2e9)
#define FOR(i, a, b) for (ll (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)

using namespace std;

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

using ll = long long;
using ld = long double;

#define ALL(x) (x).begin(), (x).end()
template<class T>
using vc = vector<T>;
using vi = vc<ll>;
using vvi = vc<vi>;

template<class T>
using va = valarray<T>;
using vad = va<ld>;
using vai = va<ll>;

using pii = pair<ll, ll>;

vi Read(ll n) {
    auto      v = vi(n);
    for (auto i = std::size_t(0); i < n; ++i) {
        cin >> v[i];
    }
    return v;
}

template<class T>
void DumpRow(const T& A) {
    for (const auto& value : A)
        cout << value << "\n";
}

template<class T>
void DumpColumn(const T& A) {
    auto isFirst = true;
    for (const auto& value : A) {
        if (isFirst) {
            cout << value;
            isFirst = false;
        } else {
            cout << " " << value;
        }

    }
    cout << endl;
}

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

    ll n;
    cin >> n;
    const auto a = Read(n);
    ll m;
    cin >> m;
    const auto b = Read(m);

    cout << includes(ALL(a), ALL(b)) << endl;
    return 0;
}



Measured memory_bytes: 5936
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;

int main(void)
{
    int n, count, i, j, k;
    long long l[100], tmp;
    count = 0;
    cin >> n;
    for (i = 0; i < n; i++)
    {
        cin >> l[i];
    }
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < i; j++)
        {
            if (l[i] < l[j])
            {
                tmp = l[i];
                l[i] = l[j];
                l[j] = tmp;
            }
        }
    }
    for (j = 0; j < n; j++)
    {
        for (k = 0; k < j; k++)
        {
            for (i = 0; i < k; i++)
            {
                if (l[i] != l[k] && l[k] != l[j])
                {

                    if (l[j] < l[i] + l[k])
                    {
                        count++;
                    }
                }
            }
        }
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3580
import std.stdio, std.string, std.conv;
import std.algorithm;

void main()
{
    auto buf = readln.chomp.split;
    immutable n = buf[0].to!size_t;
    auto target = buf[1..$].to!(int[]);
    int[] current;
    foreach (i; 0..n)
        current ~= readln.chomp.to!int;
    solve(n, target, current).writeln;
}

int solve(in size_t n, in int[] target, in int[] current)
{
    auto ret = int.max;
outer:
    foreach (p; 0..1<<(n*2))
    {
        auto sums = new int[3], counts = new int[3];
        auto _p = p;
        foreach (i; 0..n)
        {
            auto r = _p & 3;
            _p >>= 2;
            if (r < 3)
            {
                sums[r] += current[i];
                counts[r] += 1;
            }
        }
        int cs;
        foreach (r; 0..3)
        {
            if (!sums[r])
                continue outer;
            cs += (counts[r] - 1) * 10;
            if (sums[r] > target[r])
                cs += sums[r] - target[r];
            else
                cs += target[r] - sums[r];
        }
        ret = ret.min(cs);
    }
    return ret;
}


Measured memory_bytes: 1276
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let n: usize = read();
    let mut b = read_vec::<usize>();
    let mut answers = Vec::new();
    for j in 0..n {
        for i in (0..b.len()).rev() {
            if b[i] == i + 1 {
                answers.push(b[i]);
                b.remove(i);
                break;
            }
        }
        if b.len() == n - j {
            println!("-1");
            return;
        }
    }
    assert!(b.is_empty());

    for ans in answers.into_iter().rev() {
        println!("{}", ans);
    }
}


Measured memory_bytes: 4352
#include<cstdio>
#include<algorithm>

using namespace std;

int N, K;

long long solve(){
	long long ans = 0;
	for(int b = 1; b <= N; ++b){
		int t = N / b;
		int r = N % b;
		int tmp = t * (max(0, b - K));
		tmp += max(0, r - K + 1);
		if(K == 0) tmp--;
		ans += tmp;
	}
	return ans;
}

int main(){
	scanf("%d%d", &N, &K);
	long long ans = solve();
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

bool is_valid(int x, int y, int n, int m){
    return x>=0 && y>=0 && x<n && y<m;
}

void bfs(int x, int y, int n, int m, int k, vector<vector<bool>>& v, vector<string>& gr, vector<vector<int>>& dp, queue<pair<int,int>>& q){
    if(v[x][y]){
        v[x][y]=false;
        for(int i=1;i<=k;i++){
            int xx=x+i,yy=y;
            if(!is_valid(xx,yy,n,m) || dp[xx][yy]<=dp[x][y] || gr[xx][yy]=='@'){
                break;
            }
            else{
                dp[xx][yy]=dp[x][y]+1;
                q.push({xx,yy});
            }
        }
        for(int i=1;i<=k;i++){
            int xx=x-i,yy=y;
            if(!is_valid(xx,yy,n,m) || dp[xx][yy]<=dp[x][y] || gr[xx][yy]=='@'){
                break;
            }
            else{
                dp[xx][yy]=dp[x][y]+1;
                q.push({xx,yy});
            }
        }

        for(int i=1;i<=k;i++){
            int xx=x,yy=y+i;
            if(!is_valid(xx,yy,n,m) || dp[xx][yy]<=dp[x][y] || gr[xx][yy]=='@'){
                break;
            }
            else{
                dp[xx][yy]=dp[x][y]+1;
                q.push({xx,yy});
            }
        }
        for(int i=1;i<=k;i++){
            int xx=x,yy=y-i;
            if(!is_valid(xx,yy,n,m) || dp[xx][yy]<=dp[x][y] || gr[xx][yy]=='@'){
                break;
            }
            else{
                dp[xx][yy]=dp[x][y]+1;
                q.push({xx,yy});
            }
        }
    }
}


void solve(){
    int h,w,k;
    cin>>h>>w>>k;
    int x,y,a,b;
    cin>>x>>y>>a>>b;
    x--;y--;a--;b--;
    vector<string> gr(h);
    for(int i=0;i<h;i++) cin>>gr[i];
    vector<vector<int>> dp(h,vector<int>(w,MOD));
    vector<vector<bool>> v(h,vector<bool>(w,true));
    dp[x][y]=0;
    queue<pair<int,int>> q;    
    q.push({x,y});
    while(!q.empty()){
        x=q.front().first;
        y=q.front().second;
        q.pop();
        bfs(x,y,h,w,k,v,gr,dp,q);
    }

    // for(int i=0;i<h;i++){
    //     for(int j=0;j<w;j++){
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<"\n";
    // }

    if(v[a][b]){
        cout<<"-1\n";
    }
    else{
        cout<<dp[a][b]<<"\n";
    }
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    std::cout.tie(NULL);

    solve();
    return 0;
}

Measured memory_bytes: 12160
#if defined(LOCAL)
#define PROBLEM_NAME "a"
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) debug(x)
#else
#define L(x, ...) (x)
#include <bits/stdc++.h>
#endif

using namespace std;
using vi = vector<int>; using vvi = vector<vi>;
using ii = pair<int,int>; using vii = vector<ii>;
using l = long long; using vl = vector<l>; using vvl = vector<vl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using lu = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)

#if defined(LOCAL)
#define L(x...) debug(x)
#else
#define L(x, ...) (x)
#endif

void solve(istream& cin, ostream& cout) {
  l n;
  cin >> n;
  vl v(n);
  F(i, 0, n) cin >> v[i];
  l z = 0, f = 0;
  F(i, 0, n) {
    if (v[i] % 2 != 0) z++;
    if (v[i] % 4 == 0) f++;
  }
  bool ok = (f >= z) or (f + z == n and f + 1 == z);
  cout << (ok ? "Yes" : "No") << lf;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}


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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i <= int(r); ++i)
#define ford(i, n) for (int i = int(n)-1; i >= 0; --i)
#define pb push_back
#define eb emplace_back
#define ms(a, x) memset(a, x, sizeof(a))
#define F first
#define S second
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define de(x) cout<<#x<<" = "<<(x)<<endl
#define de2(x,y) cout<<#x<<" = "<<(x) <<' '<< #y<<" = "<<y<<endl;

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());
ll nxt(){ll x;cin>>x;return x;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
	string st;
    cin>>st;
    if(st!="AAA"&&st!="BBB") cout<<"Yes";
    else cout<<"No";
    return 0;
}



Measured memory_bytes: 256
x,n=map(int,input().split())
S=map(int, input().split())
K=(list(range(0,102)))
for i in S:
    K.remove(i)
L=[]
for i in K:
    L.append(abs(x-i))
m=min(L)
ind_m=L.index(m)
print(K[ind_m])

Measured memory_bytes: 9076
#include <stdio.h>
#include <stdlib.h>
int int_sort( const void * a , const void * b ) {
  if( *( int * )a < *( int * )b ) {
    return -1;
  }
  else
  if( *( int * )a == *( int * )b ) {
    return 0;
  }
  return 1;
}
int main(void){
    int n;
    int d[100000+5];
    scanf("%d", &n);
    for(int i=0; i<n; i++)scanf("%d", &d[i]);
    qsort(d, n, sizeof(int), int_sort);
    printf("%d\n", d[n/2]-d[n/2-1]);
    return 0;
}


Measured memory_bytes: 2308
import sys
input = sys.stdin.readline
from collections import Counter


def read():
    N = int(input().strip())
    L = list(map(int, input().strip().split()))
    return N, L


def solve(N, L):
    ans = 0
    L.sort()
    for k in range(N):
        for j in range(k):
            for i in range(j):
                if L[i] < L[j] and L[j] < L[k] and L[i] + L[j] > L[k]:
                    ans += 1
    return ans


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 9452
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
int main()
{
  string S;
  bool ans=true;
  cin>>S;
  if(S[2]!=S[3])ans=false;
  if(S[4]!=S[5])ans=false;
  if(ans)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

typedef long long ll;
ll n, k, cur;
map <ll, bool> mp;

bool cool (ll x)
{
    while(x){
        if(mp[x%10]){
            return 0;
        }
        x/=10;
    }
    return 1;
}

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

    cin>>n>>k;
    for(ll i=0; i<k; i++){
        ll x;
        cin>>x;
        mp[x]=1;
    }
    cur=n;

    for(ll w=cur; 1; w++){
        if(cool(w)){
            cout<<w;
            return 0;
        }
    }


}


Measured memory_bytes: 256
<?php
// Your code here!
$n = trim(fgets(STDIN));
$stdin = trim(fgets(STDIN));
// $a = str_split($stdin);
$a = explode(' ', $stdin);
$b = 0;
for ($i = 1; $i < ($n - 1); $i++) {
    // echo $a[$i];
    if(($a[$i - 1] <= $a[$i] && $a[$i] <= $a[$i + 1]) || ($a[$i - 1] >= $a[$i] && $a[$i] >= $a[$i + 1])){
        $b++;
    }
     // code...
}
echo $b;
?>


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

long long int gcd(long long int a, long long int b){
	long long int tmp;
	if(b>a) {tmp=b;b=a;a=tmp;}

	if(a%b==0) return b;
	else gcd(b,a%b);
}

int main(void){
	long long int a, b;
	while(cin >> a >> b){
		cout << gcd(a,b) << " " << a*b/gcd(a,b) << endl;
	}
	return 0;
}
	

Measured memory_bytes: 0
K = gets.to_i
a = Array.new(10 ** 6 + 1, false)
c = 1
m = 7

non = false

while true do
  break if m % K == 0
  m = (m * 10 + 7) % K
  if a[m] then
    non = true
    break
  end
  a[m] = true
  c += 1
end

puts non ? '-1' : c


Measured memory_bytes: 22128
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>
#include <cstdint>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef unsigned long long		SQWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
vector<P> city[100001];
int main()
{
	ll N, M;
	cin >> N >> M;
	REP(i, M) {
		ll a, b;
		cin >> a >> b;
		city[a].emplace_back(P{b, i});
	}
	for(auto &one : city) {
		sort(one.begin(), one.end());
	}
	
	vector<P> res(M);
	for (int i = 0; i < 100001; i++) {
		auto oneCity = city[i];
		for (int j = 0; j < oneCity.size(); j++) {
			auto oneTown = oneCity[j];
			res[oneTown.second].first = i;
			res[oneTown.second].second = j + 1;
		}
	}

	for (auto one : res) {
		printf("%06d", one.first);
		printf("%06d", one.second);
		printf("\n");
	}
	return 0;
}


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

int main()
{
    int n, m, k;
    int i, j, ans;
    scanf("%d %d",&n,&m);
    int nn = m/n;
    while(m%nn!=0) {
        nn--;
    }
    printf("%d",nn);
    return 0;
}

Measured memory_bytes: 128
fun main(args :Array<String>){
    val N = readLine()!!.toInt()
    val cities = readLine()!!.split(" ").map { it.toInt() }.toMutableList()
    val powers = readLine()!!.split(" ").map { it.toInt() }

    var sum :Long = 0
    for(i in 0..N-1){
      	var p :Int = powers[i]
        val con1 = Math.min(cities[i],p)
        p -= con1
        val con2 = Math.min(cities[i+1],p)
      	cities[i+1] -= con2
		
        sum += con1+con2
    }
    println(sum)
}

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

#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int h,w,a,b;
  cin >> h >> w >> a >> b;
  cout << h*w-(h/a*a)*(w/b*b) << endl;
  return 0;
}



Measured memory_bytes: 3076
#142
import numpy as np
N = int(input())
S = list(map(int,input().split()))

l = []
for i, j in enumerate(S,1):
    l_tem = [i,j]
    l += l_tem
l = np.array(l).reshape(N,2)
l = list(l[np.argsort(l[:,1])][:,0])

print(' '.join(list(map(str,l))))

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

using namespace std;

long long dp[2][100005];

int main()
{
    int n, w, a, b;
    scanf("%i%i", &n, &w);
    for (int x = 0; x < n; x++)
    {
        scanf("%i%i", &a, &b);
        for (int y = 0; y <= w; y++)
        {
            dp[x&1][y] = dp[x&1^1][y];
            if (y-a >= 0)
                dp[x&1][y] = max(dp[x&1][y], dp[x&1^1][y-a] + b);
        }
    }
    long long ma = 0;
    for (int x = 0; x <= w; x++)
        ma = max(ma, dp[n&1^1][x]);
    printf("%lli\n", ma);
}


Measured memory_bytes: 1792
////.......Symoon Zadid.......////
//..State University Of Bangladesh..//
//**********************************//
#include<bits/stdc++.h>
using namespace std;

int main()
{

   string s;
   int t;
   cin>>t>>s;
   if(t>=3200)
    cout<<s<<"\n";
   else
   cout<<"red"<<"\n";


return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  long long x,y;
  cin>>x>>y;
  long long ans;
  if(x%y==0){
    cout<<-1<<endl;
    return 0;
  }
  ans = x*(y-1);
  cout<<ans<<endl;
  return 0;
}


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

int main(){
  int N;
  int *X;
  int *Y;
  cin >> N;
  X = new int[N];
  Y = new int[N];
  for(int i=0;i<N;i++){
    cin >> X[i];
    Y[X[i]-1]=i+1;
  };
  for(int i=0;i<N;i++){
    cout << Y[i] << " ";
  }
  
  delete[] X;
  delete[] Y;
}

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

using namespace std;

typedef long long lint;

template<int mod> class modint {
public:
  int x;
  modint(): x(0) {}
  modint(int a) { x = a % mod; if (x < 0) x += mod; }
  inline modint &operator+=(modint that) { x = (x + that.x) % mod; return *this; }
  inline modint &operator-=(modint that) { x = (x + mod - that.x) % mod; return *this; }
  inline modint &operator*=(modint that) { x = lint(x) * that.x % mod; return *this; }
  inline modint &operator/=(modint that) { return *this *= that.inverse(); }
  inline modint operator-() { return modint(-this->x); }
  friend ostream& operator<<(ostream &out, modint m) { return out << m.x; }
  inline modint inverse() {
    int a = x, b = mod, u = 1, v = 0;
    while (b) { int t = a / b; a -= t * b; u -= t * v; swap(a, b); swap(u, v); }
    return modint(u);
  }
#define op(o, p) inline modint operator o(modint that) { return modint(*this) p that; }
  op(+, +=) op(-, -=) op(*, *=) op(/, /=)
#undef op
#define op(o) inline bool operator o(modint that) { return x o that.x; }
  op(==) op(!=) op(<) op(<=) op(>) op(>=)
#undef op
};

typedef modint<1000000007> mint;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  vector<mint> f(h + w + 1, 1);
  for (int i = 1; i <= h + w; i++) {
    f[i] = f[i - 1] * i;
  }
  mint ans = 0;
  for (int d = 0; d < w - b; d++) {
    int y1 = h - a - 1;
    int x1 = b + d;
    int y2 = a - 1;
    int x2 = w - (b + d) - 1;
    ans += (f[x1 + y1] / (f[x1] * f[y1])) * (f[x2 + y2] / (f[x2] * f[y2]));
  }
  cout << ans << endl;
  return 0;
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "
#define fi first
#define se second

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  ll b=mod, u=1, v=0;
  while(b){
    ll t=a/b;
    a-=t*b; swap(a, b);
    u-=t*v; swap(u, v);
  }
  u%=mod;
  if(u<0)u+=mod;
  return u;
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}
/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  llvec D1(N);
  llvec D2(N);
  ll ans = 0;
  rep(i, N){
    cin >> D1[i] >> D2[i];
  }
  rep(i, N-2){
    if(D1[i]==D2[i]  and D1[i+1] == D2[i+1] and D1[i+2] == D2[i+2])ans++;
  }
  
  if(ans>=1)cout << "Yes";
  else cout << "No";
  return 0;
}


Measured memory_bytes: 3632
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.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;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int H, W;
int di[2] = {0, 1}, dj[2] = {1, 0};
char A[10][10];

int main(){
  scanf("%d%d", &H, &W);
  for (int i = 0; i < H; i++) scanf("%s", A + i);

  queue <Pii> que;
  que.push({0, 0});
  A[0][0] = '.';

  while(!que.empty()){
    Pii Q = que.front(); que.pop();
    
    int cnt = 0;
    for (int k = 0; k < 2; k++){
      int I = Q.fi + di[k], J = Q.se + dj[k];
      if (A[I][J] == '#'){
        cnt++; que.push({I, J});
        A[I][J] = '.';
      }
    }
    if (cnt == 2){
      printf("Impossible\n"); return 0;
    }
  }

  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      if (A[i][j] == '#'){
        printf("Impossible\n");
        return 0;
      }
    }
  }
  printf("Possible\n");

  return 0;
}


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

using ull = unsigned long long;
using ll = long long;

#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 pb push_back
#define fill(x, y) memset(x, y, sizeof(x))
#define even(x) x % 2 == 0
#define odd(x) x % 2 != 0
#define all(x) x.begin(), x.end()
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

// these functions return the position of result of Binary Search.
#define LB(s, t, x) (int) (lower_bound(s, t, x) - s)
#define UB(s, t, x) (int) (upper_bound(s, t, x) - s)

ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1) ans = 1ll * ans * a % mo; a = 1ll * a * a % mo; } while (b >>= 1); return ans; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll temp = gcd(a, b); return temp ? (a / temp * b) : 0; }
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx8[] = { 1, -1, 0, 0, 1, 1, -1, -1 }, dy8[] = { 0, 0, -1, 1, -1, 1, -1, 1 };

template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts>
auto make_v(size_t a, size_t b, Ts... ts) { return vector<decltype(make_v<T>(b, ts...))>(a, make_v<T>(b, ts...)); }
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }
// auto dp = make_v<int>(4, h, w);
// fill_v(dp, 0);

const ll INF_LL = (1ll << 60);
const int INF_INT = (int)1e9;
const ll MOD_CONST = (ll)(1e9 + 7);

template <typename T>
vector<T> pows(int n) {
	vector<T> ret;
	T x = 1;
	while (ret.size() < n) {
		ret.push_back(x);
		x *= 10;
	}
	return ret;
}

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

inline tuple<ll, ll> rotate45(tuple<ll, ll> point) { ll x = get<0>(point), y = get<1>(point); return tuple<ll, ll>(x + y, x - y); }
inline bool rangeCheck2D(int nx, int ny, int Width, int Height) { return nx >= 0 and nx < Width and ny >= 0 and ny < Height; }

template <typename T>
void out(T o) { cout << o << endl; }
template <typename T>
void out(vector<T> &out) { REP(i, (int)out.size()) { cout << out[i]; if (i == (int)out.size() - 1) cout << endl; else cout << " "; } }



int main(void)
{
	cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(20);

	ll N; cin >> N;
  	if (N < 1200) cout << "ABC" << endl;
  	else if (N >= 2800) cout << "AGC" << endl;
  	else cout << "ARC" << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;
import java.util.concurrent.atomic.*;

class Main {
  static String[][] field;
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    sc.nextLine();
    long[] A = Arrays.stream(sc.nextLine().split(" "))
      .mapToLong(Long::parseLong)
      .sorted()
      .toArray();
    long total = 0;
    for (int i = 1; i <= N-1; i++) {
       total += A[N-1-(i/2)];
    }
    System.out.println(total);
  }
}

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

int main(void){
    string s,t;
    cin >> s >> t;
    int sum = 0;
    rep(i,s.size()){
        if(s[i] != t[i])sum++;
    }
    cout << sum;
    
    
    
}

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

int main()
{
	string word;
	
	while(cin>>word)
	{
		int count=0,county=0;
		for(int i=0;(i=word.find("JOI",i))!=word.npos; i++)
		{
		    count++;
	        
		}
		cout<<count<<endl;
		for(int i=0;(i=word.find("IOI",i))!=word.npos; i++)
		{
			county++;
			
		}
		cout<<county<<endl;
	}
	return 0;
}

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

int main() {
    int x,y;
    while(true){
        cin >> x >> y;
        if(x==0 && y==0) break;

        if(x>y)
            swap(x, y);

        cout << x << " " << y << endl;
    }
}


Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

int main(){
    string s;cin>>s;
    int k;cin>>k;
    for(int i=0;i<k;i++){
        if(s[i]!='1'){
            cout<<s[i]<<endl;
            return 0;
        }
    }
    cout<<1<<endl;
    return 0;
}

Measured memory_bytes: 256
A, B = map(int, input().split())
sum = 0
if A < B:
    sum += B
    a = B - 1
    flag = True
else:
    sum += A
    a = A - 1
    flag = False

if flag:
    b = max(a, A)
    print(sum + b)
else:
    b = max(a, B)
    print(sum + b)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    string s;
    ll k;
    cin >> s >> k;
    for (int i = 0; i < min((ll)s.length(), k); i++) if (s[i] != '1') {
        cout << s[i];
        return 0;
    }
    cout << 1;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) { 

 int a,b,c,i=0;

 scanf("%d",&a);

  scanf("%d",&b); 

 scanf("%d",&c); 

 if (a>b)  {  

 i=a;   a=b;   b=i;

 } 

 if (b>c)  { 

  i=b;   b=c;   c=i;

 }

 if (a>b)

 { 

  i=a;   a=b;   b=i;

 }  

printf("%d %d %d\n",a,b,c); 

 return 0;

}

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

int main() {
	// your code goes here
	int n;
	cin>>n;
	int arr[n][3];
	for(int i=0;i<n;i++){
	    for(int j=0;j<3;j++){
	        cin>>arr[i][j];
	    }
	}
	int dp[n][3];
    dp[0][0]=arr[0][0];dp[0][1]=arr[0][1];dp[0][2]=arr[0][2];
    // dp1[0]=max(dp[0][0],max(dp[0][1],dp[0][2]));
    for(int i=1;i<n;i++){
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+arr[i][0];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+arr[i][1];
        dp[i][2]=max(dp[i-1][0],dp[i-1][1])+arr[i][2];
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}


Measured memory_bytes: 5876
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N,X,Y;
vector<vector<int>> G;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> N >> X >> Y;
    X--,Y--;
    G.resize(N);
    for (int i = 0; i < N-1; i++)
    {
        G[i].push_back(i+1);
        G[i+1].push_back(i);
    }
    G[X].push_back(Y);
    G[Y].push_back(X);    
}

vector<bool> seen;
vector<int> dist;

// void bfs(int s, int d){
//     // if(seen[s]) return;
//     // seen[s] = true;
//     dist[d]++;
//     for(auto v:G[s]){
//         // if(seen[v]) continue;
//         // dist[d+1]++;
//         bfs(v,d+1);
//     }
// }

void bfs(int s,int di){
    queue<pii> q;
    q.push({s,di});
    vector<bool> seen(N,false);
    while(!q.empty()){
        int now,d;
        tie(now,d) = q.front();
        q.pop();
        if(seen[now]) continue;
        dist[d]++;
        seen[now]=true;
        for(auto v:G[now]){
            if(seen[v]) continue;
            q.push({v,d+1});
        }
    }

}

int solve(){
    dist.assign(N+1,0);
    for (int i = 0; i < N; i++)
    {
        seen.assign(N,false);
        bfs(i,0);
        DBG(dist)
    }
    for (int i = 1; i < N; i++)
    {
        cout << dist[i]/2 << "\n";
    }
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x,i##end=y;i<=i##end;++i)
#define _rep(i,x,y) for(int i=x,i##end=y;i>=i##end;--i)
#define ll long long

int main(){
	int x; std::cin>>x;
	std::cout<<(x^1)<<'\n';
	return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>

int main (void ){
  int x,a,b,dist_A,dist_B;

  scanf("%d %d %d",&x,&a,&b);

dist_A=a-x;
dist_B=b-x;

if(dist_B < 0){
  dist_B = -dist_B;
}
if(dist_A < 0){
  dist_A = -dist_A;
}

  if(dist_A < dist_B){
printf("A\n");
  }
  if(dist_A > dist_B){
    printf("B\n");
  }
  /* code */
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

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

  int ans = n % 1000;
  ans = 1000 - ans;

  if (ans == 1000) {
    ans = 0;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3620