akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>

using namespace std;

template<typename T, typename S>
istream& operator >> (istream& is, pair<T, S>& p) {
    is >> p.first >> p.second;
    return is;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& v) {
    for (auto& x : v) {
        is >> x;
    }
    return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& v) {
    for (auto& x : v) {
        os << x << " ";
    }
    os << "\n";
    return os;
}

int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);

#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n;
    cin >> n;
    vector<int> b(n);
    cin >> b;
    sort(b.rbegin(), b.rend());

    vector<int> a, k;
    for (int i = 0; i < n; ++i) {
        if (i == 0 || b[i] != b[i - 1]) {
            a.push_back(b[i]);
            if (k.empty()) {
                k.push_back(1);
            } else {
                k.push_back(k.back() + 1);
            }
        } else {
            k.back()++;
        }
    }
    a.push_back(0);
    int m = k.size();
    for (int i = 0; i < m; ++i) {
        int prev_k = i == 0 ? 0 : k[i - 1];
        if (a[i] - prev_k > 0 && a[i + 1] - k[i] < 0) {
            if ((a[i] - k[i]) % 2 == 0) {
                cout << "Second";
                return 0;
            } else {
                cout << "First";
                return 0;
            }
        }
    }
    for (int i = 0; i + 1 < m; ++i) {
        if (a[i + 1] - k[i] == 0) {
            bool left_win, right_win;
            {
                if (((a[i] - k[i]) % 2) == ((a[i + 1] - k[i]) % 2)) {
                    left_win = true;
                } else {
                    left_win = false;
                }
            }
            {
                if (((a[i + 1] - k[i + 1]) % 2) == ((a[i + 1] - k[i]) % 2)) {
                    right_win = true;
                } else {
                    right_win = false;
                }
            }
            if (!left_win || !right_win) {
                cout << "First";
                return 0;
            } else {
                cout << "Second";
                return 0;
            }
        }
    }


}


Measured memory_bytes: 4600
from collections import deque, defaultdict


def main():
    people_count, info_count = [int(x) for x in input().split()]
    if info_count == 0:
        return 1
    if info_count == 1:
        return 2

    friends = [set() for _ in range(people_count)]
    for _ in range(info_count):
        a, b = [int(x) - 1 for x in input().split()]
        friends[a].add(b)
        friends[b].add(a)
    seen = [False] * people_count
    circle_id = 0
    counter = defaultdict(int)
    for i, circle in enumerate(friends):
        if seen[i]:
            continue
        circle_id += 1
        qu = deque()
        qu.append(i)
        seen[i] == 1
        while qu:
            now = qu.popleft()
            for new in friends[now]:
                if seen[new]:
                    continue
                qu.append(new)
                seen[new] = True
                counter[circle_id] += 1
    return max(v for v in counter.values())


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 72816
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,-1};
const int dy[6] = {0, 1, 0, -1,1,-1};
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; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    while(1){
        int t,n;
        cin >> t >> n;
        if(t == 0) break;
        set<P> suzu;
        for(int i=0; i<n; i++){
            int a,b;
            cin >> a >> b;
            P p = {a, b};
            suzu.insert(p);
        }
        int fx,fy;
        cin >> fx >> fy;
        set<P> used;
        queue<pair<int,P>> que;
        que.emplace(0,make_pair(fx,fy));
        used.insert(make_pair(fx,fy));
        while(que.size()){
            auto hoge = que.front();
            que.pop();
            int cnt = hoge.first;
            int x,y;
            x = hoge.second.first;
            y = hoge.second.second;
            if(cnt == t) continue;
            for(int i=0; i<6; i++){
                int nx = x + dx[i];
                int ny = y + dy[i];
                P p = {nx,ny};
                if(!suzu.count(p) and !used.count(p)){
                    used.insert(p);
                    que.emplace(cnt+1,p);
                }
            }
        }
        cout << used.size() << enld;
    }
    return 0;
}


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

int main(){
    int n;cin>>n;
    vector<string> w(n);
    for(auto&& x:w)cin >>x;
    string ret="Yes";
    for(int i=0;i<n-1;i++)if(w[i][w[i].size()-1]!=w[i+1][0])ret="No";
 //   cout<<ret<<endl;
    sort(w.begin(),w.end());
    for(int i = 0; i < n-1; i++)
    {
        if(w[i]==w[i+1])ret="No";
    }
    cout<<ret<<endl;
}

Measured memory_bytes: 256
n, d = map(int, input().split())

x = [list(map(int, input().split())) for i in range(n)]
count = 0

for j in range(0, n-1):
    for k in range(j+1, n):
        sum = 0
        for i in range(0, d):
            sum = sum + (abs(x[j][i] - x[k][i]) ** 2)
        if sum**(1/2) % 1 == 0:
            count += 1

print(count)

Measured memory_bytes: 3064
MAX = 2 * (10**5) + 1


def main():
    N = int(input())
    ps = list(map(int, input().split()))

    min_i = []
    current_min = MAX
    for p in ps:
        if p < current_min:
            current_min = p

        min_i.append(current_min)

    ans = 0
    for tmp_min, p in zip(min_i, ps):
        if tmp_min >= p:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 24744
def mm(N, A, x):
  S = 0
  for i in range(N):
    S += abs(A[i] - x)
  return S

N = int(input())
A = []
j = 0
for i in input().split():
  j += 1
  A.append(int(i)-j)
A.sort()
if N % 2 == 0:
  print(mm(N, A, A[N//2]))
elif N == 1:
  print(0)
else:
  print(min(mm(N, A, A[N//2]), mm(N, A, A[N//2 + 1])))

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

const unsigned long long MAX = 1000000000000000000;

int main(void) {
    int N;
    cin >> N;
    vector< unsigned long long > A(N);
    bool zero = false;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if (A[i] == 0) {
            zero = true;
        }
    }
    if (zero) {
        printf("0\n");
        return 0;
    }
    unsigned long long ans = 1L;
    bool flag = true;
    for (int i = 0; i < N; i++) {
        unsigned long long p = ans;
        ans *= A[i];
        if (ans > MAX || ans / p != A[i]) {
            flag = false;
            break;
        }
    }
    if (flag) {
        printf("%llu\n", ans);
    } else {
        printf("-1\n");
    }
    return 0;
}


Measured memory_bytes: 4052
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
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 solve(){
   ll n,r;
   cin>>n>>r;
   if(n>=10) cout<<r<<endl;
   else cout<<r+100*(10-n)<<endl;

}



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

    solve(); 


    return 0;
}


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

int main(){
  int N;
  cin>>N;
  vector<int> x(N+1);
  for (int i=2; i<N+1; i++){
    int A;
    cin>>A;
    x.at(A)++;
  }
  for (int i=1; i<N+1; i++){
    cout<<x.at(i)<<endl;
  }
}

Measured memory_bytes: 3992
package main

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

func main() {
  input := Input{bufio.NewReaderSize(os.Stdin,100)}
  n,q := input.NextInts()
  t := make([][]int,n)
  for i:=0;i<n-1;i++ {
    a,b := input.NextInts()
    t[a-1] = append(t[a-1],b-1)
    t[b-1] = append(t[b-1],a-1)
  }
  ans := make([]int,n)
  for i:=0;i<q;i++ {
    p,x := input.NextInts()
    ans[p-1] += x
  }
  var dfs func(int,int)
  dfs = func(v,p int) {
    for _,u := range t[v] {
      if u == p { continue }
      ans[u] += ans[v]
      dfs(u,v)
    }
  }
  dfs(0,-1)
  for i:=0;i<n;i++ { fmt.Println(ans[i]) }
}

type Input struct { reader *bufio.Reader }
func(i *Input) NextLine() string {
  var buffer []byte
  for {
    line,isPrefix,err := i.reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func(i *Input) NextInts() (int,int) {
  s := strings.Fields(i.NextLine())
  x,_ := strconv.Atoi(s[0])
  y,_ := strconv.Atoi(s[1])
  return x,y
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  cout << "{";
  for (int i = 0; i < vec.size(); i++)
    os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  cout << "}";
  return os;
}

// ====================================================================

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];

  ll gokei = accumulate(v.begin(), v.end(), 0ll);

  vector<ll> yakusu;  // 約数を入れる
  for (ll g = 1; g * g <= gokei; g++)
    if (gokei % g == 0) yakusu.push_back(g), yakusu.push_back(gokei / g);
  sort(yakusu.begin(), yakusu.end());

  ll ans = -1;
  for (auto x : yakusu) {
    vector<ll> r;  // xで割った余りを入れる
    for (int i = 0; i < n; i++)
      if (v[i] % x != 0) r.push_back(v[i] % x);
    sort(r.begin(), r.end());
    if (r.size() == 0) ans = max(ans, x);  // 手を付けずともokならok
    // cout << x << " " << r << " ---------" << endl;
    ll shita = accumulate(r.begin(), r.end(), 0);  // 全てを0にするとき
    ll ue = 0;
    for (int i = r.size() - 1; i >= -1; i--) {
      // cout << shita << " " << ue << endl;
      if (abs(shita - ue) % x == 0 && ue + abs(shita - ue) <= k) {  // これならいける
        ans = max(ans, x);
      }
      if (i < 0) break;
      ue += x - r[i];  // 上側にずらすとする
      shita -= r[i];
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
#define codejam cout<<"Case #"<<ii+1<<": ";
#define impossible cout<<"IMPOSSIBLE"<<endl;
#define error(s) throw runtime_error(s)
#define log loga
// std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
// int myRand(int R) {
// 	int val=rng() % R;
//       assert(val>=0);
//       return val;
// }
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=3e18;
const int32_t LOG=21;
const int32_t MOD=MOD1;

int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      {
          int n;
          cin>>n;
          int a[n];
          rep(i,0,n)cin>>a[i];
          sort(a,a+n);
          reverse(a,a+n);
          int ans=a[0];

          int tot=0;
          int ptr=1;
          rep(i,1,n-1)
          {
               tot++;
               ans+=a[ptr];
               if(tot==2)
               {
                     tot=0;
                     ptr++;
               }     
          }
          cout<<ans<<endl;

      }
      return 0;                         
}

/*
 TIPS:
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/

Measured memory_bytes: 5228
#include <string.h>
#include <stdio.h>

int main() {
    char S[10];
    int AC=0,WA=0,TLE=0,RE=0;
    unsigned int N;
    scanf("%d",&N);
    for (int i=0; i<N; i++) {
        scanf("%s",S);
        if (strcmp(S, "AC")==0) {
            AC++;
        }
        if (strcmp(S, "WA")==0) {
            WA++;
        }
        if (strcmp(S, "TLE")==0) {
            TLE++;
        }
        if (strcmp(S, "RE")==0) {
            RE++;
        }
    }
    printf("AC x %d\n",AC);
    printf("WA x %d\n",WA);
    printf("TLE x %d\n",TLE);
    printf("RE x %d",RE);
}


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

const string WED[7] = {"SAT","FRI","THU","WED","TUE","MON","SUN"};

int main() {
    string S;
    cin >> S;
    for (int i = 0; i < 7; i++) {
        if (WED[i] == S) cout << i+1 << endl;
    }
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18
const int N = 100010;//10^5+10

int main() {

	int n; cin >> n;

	vector<int> p(n);

	for (int i = 0; i < n; i++) {
		cin >> p[i];
		p[i]--;
	}

	vector<int>a(n), b(n);

	for (int i = 0; i < n; i++)a[i] = i*n + 1;
	for (int i = 0; i < n; i++)b[n - 1 - i] = i*n + 1;

	for (int i = 0; i < n; i++) {
		a[p[i]] += i;
	}

	for (int i = 0; i < n; i++) {
		cout << a[i];

		if (i != n - 1) {
			cout << " ";
		}
		else {
			cout << endl;
		}
	}


	for (int i = 0; i < n; i++) {
		cout << b[i];

		if (i != n - 1) {
			cout << " ";
		}
		else {
			cout << endl;
		}
	}

	
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
void ans(ll a,ll b){
    cout<<a<<' '<<b<<endl;
}
int main(){
    ll n;cin>>n;
    ll k=1;
    while(k*2<=n)k*=2;
    if(k==n)dame("No");
    out("Yes");
    ans(k,n);
    ans(n-k,k);
    ans(n*2-k,n);
    ans(k+n,n*2-k);
    ans(2*n,n-k);
    ll t=-1,u=-1;
    REP(i,1,k){
        ll j=i^k^n;
        if(i>j)continue;
        ans(i,j);
        ans(i,k);
        ans(j+n,n);
        ans(j+n,i+n);
        if(t==-1)t=j;
        else u=j;
    }
    REP(i,k+1,n){
        ll a=i-k,b=a^k^n;
        if(a<b){
            ans(a,i);
            ans(k,i+n);
        }
        else{
            ans(b,i);
            ans(n-k,i+n);
        }
    }
}

Measured memory_bytes: 2688
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;


int main()
{
	int Max = 101010;
	vector<int> prime(Max, 1);
	prime[0] = 0; prime[1] = 0;
	for (int i = 2;i < Max;i++){
		if (!prime[i]) continue;
		for (int j = i * 2;j < Max;j += i) prime[j] = 0;
	}
	vector<int> a(Max, 0);
	rep(i, Max) {
		if (i % 2 == 0) continue;
		if (prime[i] == 1 and prime[(i + 1) / 2] == 1)
			a[i] = 1;
	}
	vector<int> s(Max + 1, 0);
	s[0] = 0;
	for (int i = 0;i < Max;i++) {
		s[i+1] = s[i] + a[i];
	}
	int q; cin >> q;
	vector<int> ans(q);
	rep(i, q) {
		int a, b;
		cin >> a >> b;
		b++;
		ans[i] = s[b] - s[a];
	}
	rep(i, q)cout << ans[i] << endl;
}



Measured memory_bytes: 4720
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;

int main() {
	int K;
	cin >> K;
	queue<long long > que;
	for (int i = 0; i < 9; i++) {
		que.push(i + 1);
	}
	for (int i = 0; i < K - 1; i++) {
		long long tmp = que.front();
		if (tmp % 10 != 0) {
			que.push(10 * tmp + (tmp % 10) - 1);
		}
		que.push(10 * tmp + (tmp % 10));
		if (tmp %10 != 9) {
			que.push(10 * tmp + (tmp % 10) + 1);
		}
		que.pop();
	}
	long long ans = que.front();
	cout << ans << endl;
}

Measured memory_bytes: 1792
program diverta2019b
  implicit none
  integer r, g, b, n, i
  integer, allocatable :: a(:)

  read *, r, g, b, n
  allocate(a(0:n))
  a = 0
  a(0) = 1

  do i = r, n
     a(i) = a(i) + a(i - r)
  end do

  do i = g, n
     a(i) = a(i) + a(i - g)
  end do

  do i = b, n
     a(i) = a(i) + a(i - b)
  end do

  print *, a(n)
end program diverta2019b


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a <= 9 && b <= 9){
      System.out.println(a * b);
    }else {
      System.out.println("-1");
    }
  }
}

Measured memory_bytes: 21972
import math
import numpy as np
from operator import mul

# 整数Nを桁ごとのリストにする
# l = [int(x) for x in list(str(N))]

# リストliから重複を削除したリストli_uniqを作成
#li_uniq = []
#for i in li:
#    if x not in li_uniq:
#        li_uniq.append(x)

# 複数行のinput - list版
#list = [list(map(int, input().split())) for i in range(N)]
# 複数行のinput - dictionary版
# key = a, value = b
#for i in range(N):
#    a, b = map(int, input().split())
#    dict[a] = b


N = int(input())
A = int(input())

a = N%500
if a <= A:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 13980
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll evaluate(int contest, int date, vector<ll>& last, vector<ll>& c, vll& s) {
    ll point_today = 0;
    point_today += s[date][contest];
    for (ll j = 1; j <= 26; j++) {
        if(j==date){
            continue;
        }
        point_today += c[contest] * (date - last[contest]);
    }
    return point_today;
}

int main(){
  ll d;
  cin >> d;//全日数
  vl c(27);
  for(ll i=1;i<=26;i++){//c_i==c[i]
    cin >> c[i];
  }
  vll s(d + 1, vl(27)); //s_d,i==s[d][i]
  for (ll i = 1; i <= d; i++){
    for (ll j = 1; j <= 26;j++){
      cin >> s[i][j];
    }
  }
  vl t;
  vl last(27, 0);//last(d,i)==last[i]
  //ll satisfy = 0;
  for (ll date = 1; date <= d;date++){
    priority_queue<pair<ll, int>> q;
    for (ll contest = 1; contest <= 26;contest++){
      q.push(mp(evaluate(contest, date, last,c,s), contest));
    }
    t.pb(q.top().S);
    //satisfy += q.top().F;
    last[q.top().S] = date;
  }
  rep(i,d){
    print(t[i]);
  }
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  while(n){
    int k,max=0,now=0;
    for(int i=0;i<n;i++){
      cin>>k;
      if(k>0){
	now++;
	if(k>1){
	  max++;
	}
      }
    }
    if(max){
      cout<<now+1<<endl;
    }else{
      cout<<"NA"<<endl;
    }
    cin>>n;
  }
  return (0);
}



Measured memory_bytes: 3108
#include <stdio.h>

int main(int argc, char *argv[])
{
	int a,b,c;
	scanf("%d %d %d", &a, &b, &c);

	if(a==5)
	{
		if(b==7)
		{
			if(c==5)
				printf("YES");
			else
				printf("NO");
		}
		else if(b==5)
		{
			if(c==7)
				printf("YES");
			else
				printf("NO");
		}	
	} else if(a==7)
	{
		if(b==5)
		{
			if(c==5)
				printf("YES");
			else
				printf("NO");
		}
		else
			printf("NO");
	}
	else printf("NO");

	return 0;
}

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

int main(){
    int N;
    cin >> N;
    int tcount = 0;
    set<int> st;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        if(a>=3200){
            tcount++;
        }else{
            st.insert(a/400);
        }
    }
    cout << max((int)st.size(),1) << " " << st.size() + tcount;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e9+9;
int main()
{
	int n;cin>>n;
	ll W,V=0,ans=0;cin>>W;
	ll w[n+1];int v[n+1];ll i,j;
	for(i=1;i<=n;i++){
	cin>>w[i]>>v[i];V=V+v[i];}
	ll dp[n+1][V+1];
	for(i=0;i<=n;i++)for(j=0;j<=V;j++)dp[i][j]=inf;
	for(i=0;i<=n;i++)dp[i][0]=0;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=V;j++)
		{
			if(v[i]<=j){
			dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i]);
			}
			else dp[i][j]=dp[i-1][j];
		}
	}
	for(j=V;j>=1;j--)
	{
		if(dp[n][j]<=W)
		{
			ans=j;break;
		}
	}
	cout<<ans;
}

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

int main(){
  long n,W;
  cin >> n >> W;
  long w[n],v[n];
  for(int i = 0;i < n;i++){
    cin >> w[i] >> v[i];
  }
  long dp[n+1][W+1];
  for(int i = 0;i <= W;i++){
    dp[0][i] = 0;
  }
  for(int i = 0;i < n;i++){
    for(int j = 0;j <= W;j++){
      if(j < w[i]){
        dp[i+1][j] = dp[i][j];
      }
      else{
        dp[i+1][j] = max(dp[i][j],dp[i][j-w[i]] + v[i]);
      }
    }
  }
  cout << dp[n][W] << endl;
}

Measured memory_bytes: 79104
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		String a = scan.next();
		String b = scan.next();
		String c = scan.next();
		char[] sa = a.toCharArray();
		char[] sb = b.toCharArray();
		char[] sc = c.toCharArray();
		int countA = 0;
		int countB = 0;
		int countC =0;

		for(int i=0,m=-1,n=-1;;) {
			if(sa[i]=='a') {

				sa[i]='x';
				i++;
				//System.out.println(1);
				if(i==sa.length) {
					System.out.println("A");
					break;
				}

			}else if(sa[i]=='b') {

				sa[i]='x';
			m++;
				//System.out.println(2);
				if(m==sb.length) {
					System.out.println("B");
					break;
				}
			}else if(sa[i]=='c') {

				sa[i]='x';
				n++;
				//System.out.println(3);
				if(n==sc.length) {
					System.out.println("C");
					break;
				}
			}

				if(m>=0) {
				if(sb[m]=='a') {

					sb[m]='x';
					i++;
					//System.out.println(4);
					if(i==sa.length) {
						System.out.println("A");
						break;
					}

				}else if(sb[m]=='b') {

					sb[m]='x';
					m++;
					//System.out.println(5);
					if(m==sb.length) {
						System.out.println("B");
						break;
					}
				}else if(sb[m]=='c') {

					sb[m]='x';
					n++;
					//System.out.println(6);
					if(n==sc.length) {
						System.out.println("C");
						break;
				}
				}
				}
					if(n>=0) {
					if(sc[n]=='a') {

					sc[n]='x';
					i++;
					//System.out.println(7);
					if(i==sa.length) {
						System.out.println("A");
						break;
					}

				}else if(sc[n]=='b') {

					sc[n]='x';
					m++;
					//System.out.println(8);
					if(m==sb.length) {
						System.out.println("B");
						break;
					}
				}else if(sc[n]=='c') {

					sc[n]='x';
					n++;
					//System.out.println(9);
					if(n==sc.length) {
						System.out.println("C");
						break;
			}
		}

	}

}
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN=100010;
int x,y,a,b,c,t,tot;
ll p[MAXN*3],q[MAXN],r[MAXN],ans;
int main () {
	scanf("%d%d%d%d%d",&x,&y,&a,&b,&c);
	for (int i=1;i<=a;i++) {
		scanf("%d",&q[i]);
	}
	sort(q+1,q+a+1);
	for (int i=a;i>=a-x+1;i--) {p[++tot]=q[i];}
	for (int i=1;i<=b;i++) {
		scanf("%d",&r[i]);
	}
	sort(r+1,r+b+1);
	for (int i=b;i>=b-y+1;i--) {p[++tot]=r[i];} 
	for (int i=1;i<=c;i++) {
		scanf("%d",&t);
		p[++tot]=t;
	}
	sort(p+1,p+tot+1);
	for (int i=tot;i>=tot-x-y+1;i--) {
		ans+=p[i];
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main(){
    int n,k;
    cin >> n >>k;
    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin >> p[i];
    }
    double sum =0;
    for(int i=0;i<k;i++){
        sum+= (double)(p[i]+1)/2;
    }
    double maxv = sum;
    for(int i=k;i<n;i++){
        sum -= (double)(p[i-k]+1)/2;
        sum += (double)(p[i]+1)/2;
        if(sum>maxv){
            maxv = sum;
        }
    }
    cout << fixed << setprecision(6) << maxv << endl;
}

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;
//るんるんは場に奇数個のりんごがあるときに勝てる
//つまり場に残るりんごが偶数個になるとダックスフンドが何かしらりんごをとったとき奇数個だけが残る
//複数の木があった時，奇数個りんごがなっている木を狙い撃ちにして取ると良さそう
int main(){

    ll N; cin >> N;

    ll sum = 0;
    for(ll i = 0; i < N; i++){
        ll t; cin >> t;
        if(t % 2 == 1){
            sum++;
        }
    }

    if(sum > 0){
        cout << "first" << endl;
    }else{
        cout << "second" << endl;
    }
    //if(s)

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

signed main() {
  ll N;
  cin >> N;
  map<ll, ll> m;
  rep(i, N) {
    ll a;
    cin >> a;
    if (m[a] == 0) {
      m[a] = a;
    } else {
      COUT("NO");
      return 0;
    }
  }
  COUT("YES");
  return 0;
}

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

int num[100010],n;

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

int main()
{
	n=rd();
	for (int i=1;i<=n;i++) num[i]=rd();
	sort(num+1,num+n+1);
	if (num[n]-num[1]>1) { puts("No");return 0; }
	if (num[1]==num[n])
	{
		if (num[1]==n-1) puts("Yes");
		else puts(num[1]*2<=n?"Yes":"No");
		return 0;
	}
	int h1=0,h2=0;
	for (int i=1;i<=n;i++) if (num[i]==num[1]) h1++;else h2++;
	if (num[1]+1<=h1) { puts("No");return 0; }
	int hh=num[1]-(h1-1);
	puts(hh*2<=h2?"Yes":"No");
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <set>
#include <utility>
#include <vector>

using namespace std;
set<int> G[100010];
int n,mx = 10000000,a[100010];
pair<int,int> t[200010];
vector<pair<int,int>> v;
void built(){
	for(int i = n-1;i>0;i--){
		t[i] = min(t[i<<1],t[i<<1|1]);
	}
}

void update(int p,int y){
	int x = t[p+n].first;
	for(t[p+=n] = {x - y,p};p>1;p >>= 1){
		t[p>>1] = min(t[p],t[p^1]);
	}
}

pair<int,int> query(int l, int r){
	pair<int,int> mn = {mx,-1};
	for(l += n, r += n; l<r; l >>= 1,r >>= 1){
		if(l&1) mn = min(mn,t[l++]);
		if(r&1) mn = min(mn,t[--r]);
	}
	return mn;
}

int main(){
	int i,m;
	cin >> n >> m;
	if(m&1){
		cout << -1 << endl;
		return 0;
	}
	for(i=0;i<m;i++){
		int a,b; cin >> a >> b;
		a--; b--;
		G[a].insert(b);
		G[b].insert(a);
	}
	for(i=0;i<n;i++){
		t[i + n] = {G[i].size(),i};
	}
	built();
	while(v.size()<m){
		auto p = query(0,n);
		if(p.first==0){
			update(p.second,-10000000);
			continue;
		}
		int ver = p.second;
		int e = *G[ver].begin();
		G[ver].erase(e); G[e].erase(ver);
		update(ver,1); update(e,1);
		if(a[ver]&1){
			v.push_back({ver,e}); a[ver]++;
		}else{
			v.push_back({e,ver}); a[e]++;
		}
	}
	for(i=0;i<n;i++){
		if(a[i]&1){
			cout << "NO" << endl;
			return 0;
		}
	}
	for(i=0;i<m;i++){
		cout << v[i].first + 1 << " " << v[i].second + 1 << endl;
	}
}
	

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

int R,G,B,N;
int main(void){
  cin>>R>>G>>B>>N;
  int cnt=0;
  for(int r=0;r<3001;r++){
    for(int g=0;g<3001;g++){
      int M = r*R+g*G;
      if(M>N) break;
      if((N-M)%B==0) cnt++;
    }
    if(r*R>N) break;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(ll i=(x);i<(y);i++)
#define RREP(i,x,y) for(ll i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cout << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

struct Point {
    int x, y;
};

struct PointSet {
    unordered_set<int> xset, yset;
};

class UnionFind {
    vector<int> values_;
public:
    UnionFind(const int n) : values_(vector<int>(n+1, -1)) {};

    void unionGroups(const int a, const int b) {
        int groupA = getGroupId(a);
        int groupB = getGroupId(b);
        if (groupA == groupB) return;
        values_[groupB] = groupA;
    }

    int getGroupId(const int a) {
        if (values_[a] == -1) return a;
        int groupId = getGroupId(values_[a]);
        values_[a] = groupId;
        return groupId;
    }
};

class FMustBeRectangular {
public:
    void solve(std::istream& in, std::ostream& out) {
        int N;
        in >> N;
        vector<Point> points(N);
        REP(i,0,N) in >> points[i].x >> points[i].y;

        vector<vector<int>> pointIndexByY(1e5+1), pointIndexByX(1e5+1);
        REP(i,0,N) {
            pointIndexByY[points[i].y].push_back(i);
            pointIndexByX[points[i].x].push_back(i);
        }

        UnionFind uf(N);
        REP(i,0,pointIndexByY.size()) {
            if (pointIndexByY[i].empty()) continue;
            REP(j,1,pointIndexByY[i].size()) {
                uf.unionGroups(pointIndexByY[i][0], pointIndexByY[i][j]);
            }
        }
        REP(i,0,pointIndexByX.size()) {
            if (pointIndexByX[i].empty()) continue;
            REP(j,1,pointIndexByX[i].size()) {
                uf.unionGroups(pointIndexByX[i][0], pointIndexByX[i][j]);
            }
        }
        unordered_map<int, PointSet> pointSets;
        REP(i,0,N) {
            const int groupId = uf.getGroupId(i);
            const auto& point = points[i];
            pointSets[groupId].xset.insert(point.x);
            pointSets[groupId].yset.insert(point.y);
        }
        int answer = -N;
        for (const auto& p : pointSets) {
            answer += p.second.xset.size() * p.second.yset.size();
        }
        out << answer << "\n";
    }
};


signed main() {
    FMustBeRectangular solver;
    std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 15232
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;

int main(){
	int n;
	scanf("%d", &n);
	std::vector<P> ab(n);
	for(int i=0; i<n; i++) scanf("%ld %ld", &ab[i].first, &ab[i].second);
	std::sort(ab.begin(), ab.end(), [](P x, P y){
		return x.second < y.second;
	});
	
	ll now = 0;
	bool cant = false;
	for(P p: ab){
		ll a, b;
		std::tie(a, b) = p;
		now += a;
		if(now>b) cant = true;
	}
	
	if(cant) puts("No");
	else puts("Yes");
	return 0;
}


Measured memory_bytes: 3328
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.IO.Pipes;
using System.ComponentModel;
using System.Drawing;
using Microsoft.VisualBasic;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {

            long[] Arr = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            long X = Math.Abs(Arr[0]);
            long K = Arr[1];
            long D = Arr[2];
            long ans = 0;
            long tmp = 0;

            long tmpa = 0;
            long tmpb = 0;


            if (X / D > K)
            {
                ans = X - (K * D);
            }
            else
            {
                tmp = X / D;
                tmpa = X - (D * tmp);
                tmpb = Math.Abs(tmpa - D);
                if ((K - tmp) % 2 == 0)
                {
                    ans = tmpa;
                }
                else
                {
                    ans = tmpb;
                }

            }

            Console.WriteLine(ans);

        }

    }
}


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

    ll cntA = 0, cntB = 0;
    vl ans(n);
    rep(i, n) {
        if(cntA + cntB >= a+b) {
            break;
        }
        if(s[i] == 'a') {
            ans[i] = 1;
            cntA++;
        }
        if(s[i] == 'b') {
            if(cntB < b) {
                ans[i] = 1;
                cntB++;
            }
        }
    }

    rep(i, n) {
        if(ans[i]) {
            out("Yes");
        }
        else {
            out("No");
        }
    }
    
    re0;
}

Measured memory_bytes: 1664
x,y,z = map(int,input().split())
box_A = [x]
box_B = [y]
box_C = [z]

box_B.append(box_A.pop(0))
box_A.append(box_B.pop(0))
box_A.append(box_C.pop(0))
box_C.append(box_A.pop(0))
print(box_A[0],box_B[0],box_C[0])


#1 2 3
#100 100 100
#41 59 31

Measured memory_bytes: 9104
import java.util.Scanner;

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

        int n = sc.nextInt();
        String s = sc.next();

        int r = 0;
        for(int i = 0; i < n; i++) {
            if(s.charAt(i) == 'R') r++;
        }

        System.out.println(r > n - r? "Yes" : "No");

        sc.close();
    }
}

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

namespace ClassLibrary1
{
    public class ListNode
    {
        public int val;
        public ListNode next;
        public ListNode(int x) { val = x; }
    }


    public class Class1
    {
        static int[][] mtx ;
        static List<int>[] tm;
        static int n;
        static int[] results;
        static List<string> cons = new List<string>();
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            char[] odd = new char[] { 'R', 'U', 'D' };
            char[] even = new char[] { 'L', 'U', 'D' };

            char[] c = s.ToCharArray();
            for(int i=0; i< c.Length; i++)
            {
                var arr = odd;
                if((i+1) % 2 == 1)
                {
                    arr = odd;
                }
                else
                {
                    arr = even;
                }

                if( !arr.Contains(c[i]))
                {
                    Console.WriteLine("No");
                    return;
                }
            }

            Console.WriteLine("Yes");


            /*
                        //int n = int.Parse(Console.ReadLine());
                        string[] s1 = Console.ReadLine().Split(' ');

                        int[] p = new int[n];
                        for (int i = 0; i < n; i++)
                        {
                            p[i] = int.Parse(s1[i]);
                        }


                        Console.WriteLine(rec(p, 0, n-1, 1000000));
                        */
        }


        static int rec(int[] n, int i, int j, int x)
        {
            if (i+1 == j)
            {
                return Math.Min(n[j], x);
            }
            return rec(n, i + 1, j, n[i]) + rec(n, i, j - 1, n[j]);
        }
    }

}

Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
#include <typeinfo>
#include <numeric>
#include "math.h"
#include <string>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
using namespace std;

//Teleporter
int main() {
	long long int n, k,roop=0,start=0,end=0,next=1;
	vector<pair<int, bool>> kingdom;
	pair<int,bool> town;
	town.second = false;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> town.first;
		kingdom.push_back(town);
	}

	while (0<k) {		
		if (start != 0 && next == start && end==0) {
			
			k %= roop;
			end = 1;
			if (k == 0) {
				break;
			}
		}
		if (start != 0 && end == 0) {
			roop++;
		}

		if (kingdom[next-1].second==true &&start==0) {
			start = next ;
			roop++;
		}
		
		kingdom[next - 1].second = true;
		next = kingdom[next - 1].first;		
		k--;
	}
	cout << next;
	return 0;
}

Measured memory_bytes: 5364
n = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))

r = [i+1 for i in range(n)]
from itertools import permutations

count = 0
a = 0
b = 0
for rr in list(permutations(r)):
    count +=1
    if p == rr:
        a = count
    if q == rr:
        b = count

print(abs(a-b))






Measured memory_bytes: 13848
#include <iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<queue>
using namespace std;
char A[100000];
int main() {
	cin >> A;
	int Max = 0;
	for (int i = 0,temp = 0; A[i] != '\0'; i++) {
		if (A[i] == 'A' || A[i] == 'C' || A[i] == 'G' || A[i] == 'T') {
			temp++;
			Max = max(Max, temp);
		}
		else {
			temp = 0;
		}
	}
	cout << Max << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int a, b, c;
	
	cin >> a >> b >> c;
	
	for (int i = a; i <= a * b; i += a) {
		if (i % b == c) {
			cout << "YES" << endl;
			return (0);
		}
	}
	
	cout << "NO" << endl;
	
	return (0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n,m; cin>>n>>m;
	priority_queue<ll> pq; int x;
	for(int i = 0 ; i < n; i++){
		cin>>x;
		pq.push(x);
	}
	for(int i = 0; i < m; i++){
		ll ans = pq.top()/2;
		pq.pop();
		pq.push(ans); 
	}
	ll sum = 0;
	while(!pq.empty()){
		sum += pq.top();
		pq.pop();
	}
	cout<<sum<<"\n";
}

Measured memory_bytes: 1400
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int a, b;

int main()
{
	cin >> a >> b;
	if (a == b) {
		cout << "Draw" << endl;
	}
	else if ((a > b && b > 1) || a == 1) {
		cout << "Alice" << endl;
	}
	else {
		cout << "Bob" << endl;
	}

	return 0;
}


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

int main(){
  int m,d;
  cin>>m>>d;
  
  int ans=0;
  for(int i=1;i<=m;i++){
    for(int j=1;j<=d;j++){
      int d1=j%10,d10=j/10;
      if(d1>=2&&d10>=2){
        if(d1*d10==i){
          ans++;
        }
      }
    }
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#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,m;
    cin >> n >> m;
    vector<int> h(n+1);
    for(int i=1;i<=n;i++) cin >> h[i];
    
    //各展望台の番号を持つ配列を作り、そこに繋がる展望台がそれより高ければ-1を入れる
    vector<int> tenbo(n+1);
  
    rep(i,m){
        int a,b;
        cin >> a >> b;
        if(h[a] == h[b]){
            tenbo[a] = -1;
            tenbo[b] = -1;
            continue;
        }
        if(h[a] < h[b]) swap(a,b);
        tenbo[b] = -1;
    }
    
    //for(int i=1;i<=n;i++){
    //    cout << "i=" << i << "tenbo" << tenbo[i] << endl;
    //}    
    
    int ans = 0;
    for(int i=1;i<=n;i++){
        if(tenbo[i] != -1) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4052
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <set>
using namespace std;
int main(){
    int a,b, c;
    cin>>a>>b>>c;
    set<int> s;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    cout<<s.size()<<endl;
    return 0;
}

Measured memory_bytes: 256
use std::collections::VecDeque;

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 v = read_vec::<usize>();
    let (n, m) = (v[0], v[1]);
    let mut h = vec![0; n + m - 1];
    let mut g = vec![Vec::new(); n + m - 1];
    let mut parents = vec![Vec::new(); n + m - 1];
    for _ in 0..n + m - 1 {
        let v = read_vec::<usize>();
        let (s, t) = (v[0] - 1, v[1] - 1);
        g[s].push(t);
        parents[t].push(s);
        h[t] += 1;
    }
    // println!("{:?}", parents);

    let mut st: VecDeque<usize> = VecDeque::new();

    for i in 0..n {
        if h[i] == 0 {
            st.push_back(i);
        }
    }

    let mut sorted_indexes = Vec::new();
    while !st.is_empty() {
        let i = st.pop_back().unwrap();
        sorted_indexes.push(i);
        for &j in g[i].iter() {
            h[j] -= 1;
            if h[j] == 0 {
                st.push_back(j);
            }
        }
    }
    // println!("sorted_indexes {:?}", sorted_indexes);

    let mut idx_dict = std::collections::HashMap::new();
    for (i, &idx) in sorted_indexes.iter().enumerate() {
        idx_dict.insert(idx, i);
    }

    for i in 0..n {
        if idx_dict[&i] == 0 {
            println!("0");
            continue;
        }
        let mut nearest_index = parents[i][0];
        let mut max_num = 0;
        for parent in parents[i].iter() {
            if idx_dict[parent] > max_num {
                max_num = idx_dict[parent];
                nearest_index = *parent;
            }
        }
        println!("{}", nearest_index + 1);
    }
}


Measured memory_bytes: 26876