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

using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

const ll mod = 1000000007;

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

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


    vector<ll> p;
    vector<ll > a(n);

    p.push_back(2);
    for (ll i = 3; i <= 2000; i += 2) {
        bool is_ok = true;
        ll max_i = sqrt(i) + 10;
         for(ll cur : p) {
            if (cur >= max_i) {
                break;
            }
            if (i % cur == 0) {
                is_ok = false;
                break;
            }
         }
         if (is_ok) {
            p.push_back(i);
         }
    }

    map<ll,ll> lcm;

    for (int i = 0; i < n; i++) {
        cin >> a[i];
        ll val = a[i];

        for(int j = 0; p[j] <= 1010; j++) {
            ll cur = p[j];
            ll count = 0;
            while ((val % cur) == 0) {
                val /= cur;
                count++;
            }
            if (count > 0) {
                lcm[cur] = max(count, lcm[cur]);
                if (val == 1) {
                    break;
                }
            }
        }
        if (val > 1) {
            lcm[val] = 1;
        }
    }



    ll lcm_val = 1;
    for(auto itr : lcm) {
        ll k = itr.first;
        ll v = itr.second;
        //cout << "k:" << k << " v:" << v << endl;
        for (int i = 0; i < v; i++) {
            lcm_val = (lcm_val * k) % mod;
        }

    }
    //cout << "lcm_val:" << lcm_val << endl;
    ll ans = 0;

    for (int i = 0; i < n; i++) {
        ll cur_ans = (lcm_val *  modinv(a[i], mod)) % mod;
        ans = (ans + cur_ans) % mod;
    }
     /*
    for (int i = 0; i < n; i++) {
        ll cur = a[i];
        ll cur_ans = 1;
        for(auto itr : lcm) {
            ll k = itr.first;
            ll v = itr.second; 

            for (int i = 0; i < v; i++) {
                if (cur % k == 0) {
                    cur /= k; 
                } else {
                    cur_ans = (cur_ans * k) % mod;
                }
            }
        }
        ans = (ans + cur_ans) % mod;
    }
    */
 	cout << ans << endl;
 	
	return 0;
}

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

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

    string S, T, U;
    int A, B;

    cin >> S >> T;
    cin >> A >> B;
    cin >> U;

    if (U == S){
        A--;
    }
    else {
        B--;
    }

    cout << A << " " << B << "\n";

    return 0;
}

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

typedef long long ll;

#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back

const long double PI = acos(-1);

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll GetDigit(ll num) {return log10(num)+1;}

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

  ll b = 0, w = 0;
  for(ll i = 0; i < s.size(); i++){
      if(s[i] == s[i+1]) continue;
      else if(s[i] == 'B') b++;
      else if(s[i] == 'W') w++;
  }
    
  if(b == 0 || w == 0) cout << 0 << endl;
  else cout << b + w - 1 << endl;

  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main(void) {
    long long int N, M;
    cin >> N >> M;

    vector< pair<long long int, long long int> > AB(N);
    for(int i=0;i<N;i++){
        cin >> AB[i].first >> AB[i].second;
    }

    sort(AB.begin(), AB.end());

    long long int ans=0;
    for(int i=0;i<N;i++){
        if( M <= AB[i].second ){
            ans += AB[i].first * M;
            break;
        } else{
            ans += AB[i].first * AB[i].second;
            M -= AB[i].second;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define PUT(x) cout << x << endl
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };

int main(void)
{
	int x, y;
	cin >> x >> y;

	if (x % y == 0) {
		cout << -1 << endl;
	}
	else {
		cout << x << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

    public static void solve(Scanner sc) {
        long x = sc.nextLong();
        long y = sc.nextLong();

        long ans = x +x;
        if (x % y == 0) {
            System.out.println(-1);
        } else {
            System.out.println(x);
        }
    }
}

Measured memory_bytes: 23124
fun main(args: Array<String>) {
    var (N) = readLine()!!.split(" "). map { it.toInt() }
    var A = readLine()!!.split(" "). map { it.toInt() }
    var old = -1
    var ans = true
    A.sorted().forEach {
        if (old == it) {
            ans = false
        }
        old = it
    }
    if (ans) {
        println("YES")
    } else {
        println("NO")
    }
}

Measured memory_bytes: 81788
#include<stdio.h>

int main(){

  int i,a=0,j,l,c=0,n,num[100000],q,qnum[50000];
  int left, right, mid;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&num[i]);
  }

  scanf("%d",&q);
  for(j=0;j<q;j++){
    scanf("%d",&qnum[j]);
  }
  
  for(i=0;i<q;i++){
    left=0;
    right=n;
    while(left<right){
      mid=(left + right) /2;
      if(num[mid] == qnum[i]){
	c++;
	break;
      }
      else if(qnum[i] < num[mid]){
	right = mid;
      }
      else {
	left = mid +1;
      }
    }
  }
      
  printf("%d\n",c);
  return 0;
}



Measured memory_bytes: 2272
n = gets.to_i
ss = $stdin.read.split.sort { |bef, aft| bef.length - aft.length }

ans = ''
sh = ss.shift
sh.chars do |c|
  next unless ss.all? { |s| s.include? c }
  ans << c
  ss.each do |s|
    s.slice! c
  end
end

puts ans.split('').sort.join('')

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

const int mod = 1000000007;
// const int mod = 998244353;

struct mint
{
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint &operator+=(const mint m)
    {
        if((x += m.x) >= mod) x -= mod;
        return *this;
    }
    mint &operator-=(const mint m)
    {
        if((x += mod - m.x) >= mod) x -= mod;
        return *this;
    }
    mint &operator*=(const mint m)
    {
        (x *= m.x) %= mod;
        return *this;
    }
    mint operator+(const mint m) const
    {
        return mint(*this) += m;
    }
    mint operator-(const mint m) const
    {
        return mint(*this) -= m;
    }
    mint operator*(const mint m) const
    {
        return mint(*this) *= m;
    }
    mint pow(ll n) const
    {
        if(!n) return 1;
        mint m = pow(n>>1);
        m *= m;
        if(n & 1) m *= *this;
        return m;
    }
    mint inv() const { return pow(mod-2);}
    mint &operator/=(const mint m) { return *this *= m.inv();}
    mint operator/(const mint m) const { return mint(*this) /= m;}
};
istream &operator>>(istream &is, mint &m) { return is >> m.x;}
ostream &operator<<(ostream &os, const mint &m) { return os << m.x;}

struct combination
{
    vector<mint> fact, ifact;
    combination(int n) : fact(n+1), ifact(n+1)
    {
        assert(n < mod);
        fact.at(0) = 1;
        for(int i=1; i<=n; i++)
        {
            fact.at(i) = fact.at(i-1) * i;
        }
        ifact.at(n) = fact.at(n).inv();
        for(int i=n; i>=1; i--)
        {
            ifact.at(i-1) = ifact.at(i) * i;
        }
    }
    mint operator()(int n, int k)
    {
        if(k < 0 || k > n) return 0;
        return fact.at(n) * ifact.at(k) * ifact.at(n-k);
    }
};

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int K;
    cin >> K;
    string S;
    cin >> S;

    mint ans = 0;
    mint a = 25;
    mint b = 26;
    combination comb(S.length() + K);
    for(int i=0; i<=K; i++)
    {
        // cout << comb(S.length()+i-1, S.length()-1) << ", " << a.pow(i) << ", " << b.pow(K-i) << endl;
        ans += comb(S.length()+i-1, S.length()-1) * a.pow(i) * b.pow(K-i);
    }
    cout << ans << endl;

    return 0;
}


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

#define $(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl '\n'
#define x first
#define y second
#define int long long
#define double long double
#define pii pair<int, int>
#define pb push_back
#define vec vector
#define beg begin
#define dbg(x) cerr << #x << " = " << x << endl;

template<class T> ostream& operator<<(ostream &str, vector<T> &a) {
    for (auto &i : a) {
        str << i << " ";
    }
    return str;
}

template<class T> istream& operator>>(istream &str, vector<T> &a) {
    for (auto &i : a) {
        str >> i;
    }
    return str;
}

template<class T> ostream& operator<<(ostream &str, pair<T, T> &a) {
    str << a.first << " " << a.second;
    return str;
}

template<class T> istream& operator>>(istream &str, pair<T, T> &a) {
    str >> a.first >> a.second;
    return str;
}

void solve(); signed main() {
#ifdef LOCAL
    freopen("C:\\Users\\artma\\CLionProjects\\problems\\input.txt", "r", stdin);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(6);
    solve();
    return 0;
}

const int MOD = 1e9 + 7, MAXN = 1e6 + 10, INF = 1e18 + 10, BASE = 37;

void solve() {
    int k;
    cin >> k;
    if (k % 7 == 0) k /= 7;
    if (k % 2 == 0 || k % 5 == 0) {
        cout << -1 << endl;
        return;
    }

    vec<int> r(k);
    int val = 1;
    int ans = INF;
    for (int i = 1; i < 2e6; ++i) {
        if (r[val] == 0) {
            r[val] = i;
            val = (val * 10 + 1) % k;
        }
        else {
            ans = min(ans, i - r[val]);
            r[val] = i;
            val = (val * 10 + 1) % k;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 11104
if __name__ == '__main__':
    N = int(input()) + 1
    P = [list(map(int, input().split())) for x in range(N-1)]
    P.insert(0, [0,0,0])
    #print(N, P)
    for i in range(1, N):
        t = abs(P[i-1][0] - P[i][0])
        
        if t%2 == 0:
            if (abs( sum(P[i-1][1:]) - sum(P[i][1:]) ) <= t) and (abs( sum(P[i-1][1:]) - sum(P[i][1:]))) % 2 == 0:
                pass
            else:
                break
        
        else:
            if (abs( sum(P[i-1][1:]) - sum(P[i][1:]) ) <= t) and (abs( sum(P[i-1][1:]) - sum(P[i][1:]))) % 2 == 1:
                pass
            else:
                break
    else:
        print('Yes')
        exit()
    print('No')

Measured memory_bytes: 27300
#include <iostream>
#include <vector>
#include <string>

int main(){
    int N;
    std::cin >> N;
    std::vector<double> x(N);
    std::vector<std::string> u(N);
    for(auto i = 0; i < N; i++){
        std::cin >> x.at(i) >> u.at(i);
    }

    double ans = 0;
    for(auto i = 0; i < N; i++){
        if(u.at(i) == "JPY"){
            ans += x.at(i);
        }
        else{
            ans += (x.at(i) * 380000);
        }
    }

    printf("%.6lf\n", ans);

    return 0;
}


Measured memory_bytes: 256
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        int n, m, k;
        cin >> n >> m >> k;
        char a[7][7];
        memset(a, '.', sizeof(a));

        int tot = 0;
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < m; j++) {
                cin >> a[i][j];
                if(a[i][j] == '#')
                   tot++;
            }
        }

        int ans = 0;
        // for(int mi = 0; mi < (1 << n); mi++) {
        //     int curr = 0;
        //     for(int i = 0; i < n; i++) {
        //         if(mi & (1 << i)) {
        //             for(int j = 0; j < m; j++)
        //                 curr += (a[i][j] == '#');
        //         }
        //     }

        //     if(tot - curr == k) {
        //         cout << mi << ' ' << tot << ' ' << curr << ' ' << k << '\n';
        //         ans++;
        //     }
        // }
        // cout << ans << '\n';

        // for(int mj = 0; mj < (1 << m); mj++) {
        //     int curr = 0;
        //     for(int j = 0; j < m; j++) {
        //         if(mj && (1 << j)) {
        //             for(int i = 0; i < n; i++) {
        //                 curr += (a[i][j] == '#');
        //             }
        //         }
        //     }
        //     if(tot - curr == k)
        //         ans++;
        // }

        for(int mi = 0; mi < (1 << n); mi++) {
            for(int mj = 0; mj < (1 << m); mj++) {

                char b[7][7];
                for(int i = 0; i <= 6; i++) {
                    for(int j = 0; j <= 6; j++)
                        b[i][j] = a[i][j];
                }

                for(int i = 0; i <= n; i++) {
                    for(int j = 0; j <= m; j++) {
                        if((mi & (1 << i)) || (mj & (1 << j))) {
                            // cout << "yo\n";
                            b[i][j] = '.';
                        }
                    }
                }

                int curr = 0;
                for(int i = 0; i <= n; i++) {
                    for(int j = 0; j <= m; j++)
                        curr += (b[i][j] == '#');
                }

                if(curr == k) {
                    // cout << mi << ' ' << mj << ' ' << curr << ' ' << k << '\n';
                    ans++;
                }
            }
        }

        cout << ans << '\n';


        

        
    }
    
    return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll N, W; cin>>N>>W;
    vector<ll> v(N), w(N);
    rep(i,N) cin>>v[i]>>w[i];
    vector<ll> dp(W+1, 0);
    rep(i,N){
        for(ll j=w[i]; j<=W; j++){
            chmax(dp[j], dp[j-w[i]]+v[i]);
        }
    }
    ll res=0;
    rep(i,W+1) chmax(res, dp[i]);
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A;
  cin >> N >> A;
  
  if ( N%500==0 ) {
    cout << "Yes" << endl;
  }
  else if ( A>=N%500) {
    cout << "Yes" << endl;
  }
  else
    cout << "No" <<endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

class Cookie{
  int flag;
  
  
public:
  void und(int A,int B){
    flag = 0;
    if((A%3 != 0) && (B%3 != 0) && ((A+B)%3 != 0)){
      cout << "Impossible" << endl;
    }
    else{
      cout<<"Possible"<<endl;
    }
    
    
  }
};
  
int main(){
  Cookie a;
  int A,B;
  cin >> A >> B;
  a.und(A,B);
  return 0;
  
}


Measured memory_bytes: 256
<?php
  fscanf(STDIN, "%d %d", $n,$m);
while ($a = fgets(STDIN)){
$a = str_replace(PHP_EOL, '', $a);// 改行削除
$arr = explode(" ", $a);
$cal=array_sum($arr);
  $ans =$n-$cal;
  if($ans>=0){
  echo $ans;
  }else{
  echo "-1";
  }
}
?>

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

struct report{
    int left, right;
    long distance;
};

struct road{
    int goal;
    long distance;
};

vector<int> parents;

int find_root(int now){
    if(parents[now] == now){
        return now;
    }else{
        int ans = find_root(parents[now]);
        parents[now] = ans;
        return ans;
    }
}

vector<vector<int>> roots;
vector<vector<road>> roads;
vector<long> distances;

void find_error(int now){
    for(int i = 0; i < roads[now].size(); i++){
        if(distances[roads[now][i].goal] > 1e15){
            distances[roads[now][i].goal] = distances[now] + roads[now][i].distance;
            find_error(roads[now][i].goal);
        }else if(distances[roads[now][i].goal] != distances[now] + roads[now][i].distance){
            cout << "No" << endl;
            exit(0);
        }
    }
}

int main(){
    int N, M;
    cin >> N >> M;
    for(int i = 0; i < N; i++){
        parents.push_back(i);
    }
    report reports[M];
    roads.resize(N);
    for(int i = 0; i < M; i++){
        cin >> reports[i].left >> reports[i].right >> reports[i].distance;
        parents[find_root(reports[i].left - 1)] = find_root(reports[i].right - 1);
        roads[reports[i].left - 1].push_back({reports[i].right - 1, reports[i].distance});
        roads[reports[i].right - 1].push_back({reports[i].left - 1, -reports[i].distance});
    }
    roots.resize(N);
    for(int i = 0; i < N; i++){
        roots[find_root(i)].push_back(i);
    }
    vector<report> reports_group[N];
    for(int i = 0; i < M; i++){
        reports_group[find_root(reports[i].left - 1)].push_back(reports[i]);
    }
    distances.resize(N);
    fill(distances.begin(), distances.end(), 1e16);
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < N; j++){
            if(roots[j].size()){
                distances[roots[j][0]] = 0;
            }
            for(int k = 0; k < roots[j].size(); k++){
                find_error(roots[j][k]);
            }
            long max_position = 0, min_position = 0;
            for(int k = 0; k < roots[j].size(); k++){
                max_position = max(max_position, distances[roots[j][k]]);
                min_position = min(max_position, distances[roots[j][k]]);
            }
        }
    }
    cout << "Yes" << endl;
}


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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
#define rAll(a) (a).rbegin(), (a).rend()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CCIN(...)                                                              \
    char __VA_ARGS__;                                                          \
    CIN(__VA_ARGS__)
#define DCIN(...)                                                              \
    double __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef pair<ll, ll> PL;
typedef vector<PL> VPL;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<double> VD;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const double PI = atan(1.0) * 4.0;
const ll dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
#define PI 3.141592653589793238

void cinfast() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

ll N;
VL P;
map<ll, ll> memo;
set<ll> st;

signed main() {
    LCIN(N);
    ll ans = 0;
    VL B(N);
    REP(i, N - 1) {
        cin >> B[i];
        if(i)
            ans += min(B[i], B[i - 1]);
        else
            ans += B[i];
    }
    ans += B[N - 2];
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

ll calc(ll n, ll a, ll k){
	if(k == 1) return n;
	ll x = pow(n, 1.0 / k) + EPS, lo = -1, hi = k, mid;
	while(lo + 1 < hi){
		mid = (lo + hi) / 2;
		ll prd = 1;
		rep(i, k) prd *= x + (i < mid);
		if(prd >= n) hi = mid;
		else lo = mid;
	}
	return x * k + hi + a * (k - 1);
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	ll n, a; cin >> n >> a;
	ll ans = n;
	for(int k = 1; k <= 100; k++){
		ans = min(ans, calc(n, a, k));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<algorithm>
#include<numeric>
#include<string>
#include<cstdio>
using namespace std;

int main(){
	int n, a, b, c, x;

	while (cin >> n >> a >> b >> c >> x, n + a + b + c + x != 0){
		int y[100];
		for (int i = 0; i < n; i++){
			cin >> y[i];
		}

		int f = 0;
		int i = 0;

		while (true){
			if (f > 10000){
				cout << -1 << endl;
				break;
			}
			if (x == y[i]){
				i++;
				if (i == n){
					cout << f << endl;
					break;
				}
				
			}
			f++;
			x = (a*x + b) % c;
		}

	}

	return 0;
}

Measured memory_bytes: 1160
# coding: utf-8
N,M=map(int,input().split())
AB=[]

for i in range(M):
    AB.append(list(map(int,input().split())))

AB.sort()

INF=10**9
ans=0
bottom=INF

for i in range(M):
    a,b=AB[i]
    
    if a>=bottom:
        ans+=1
        bottom=INF
    
    bottom=min(bottom,b)

print(ans+1)


Measured memory_bytes: 27864
#include <stdio.h>

int main(void){
    int W, H, x, y, r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    if( x>=r && x<=W-r && y>=r && y<=H-r ){
    	printf("Yes\n");
    }else{
    	printf("No\n");
    }
    return 0;
}

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

#define For(i, j, k) for (int i = j; i <= k; i++)
#define Forr(i, j, k) for (int i = j; i >= k; i--)

using namespace std;

const int N = 1010;

int n, m, A, B;
char Map[N][N];

int main() {

	scanf("%d%d%d%d", &n, &m, &A, &B);

	memset(Map, '.', sizeof Map);
	For(i, 1, n) Map[i][m + 1] = '\0';

	if (n & 1) {
		int p = 1;
		while (A && p + 1 <= m) Map[n][p] = '<', Map[n][p + 1] = '>', p += 2, --A;
	}
	if (m & 1) {
		int p = n;
		while (B && p > 1) Map[p - 1][m] = '^', Map[p][m] = 'v', p -= 2, --B;
	}

	Forr(i, n / 2, 1) For(j, 1, m / 2) {
		int x = i * 2 - 1, y = j * 2 - 1;

		if (n % 2 && m % 2 && A == 1 && B == 1 && i == 1 && j == m / 2) {
			Map[x][y] = '^', Map[x + 1][y] = 'v', --B;
			Map[x][y + 1] = '<', Map[x][y + 2] = '>', --A;
		}

		if (A && B < 2) {
			Map[x][y] = '<', Map[x][y + 1] = '>', --A;
			if (A) Map[x + 1][y] = '<', Map[x + 1][y + 1] = '>', --A;
		}
		else if (B) {
			Map[x][y] = '^', Map[x + 1][y] = 'v', --B;
			if (B) Map[x][y + 1] = '^', Map[x + 1][y + 1] = 'v', --B;
		}
	}

	if (A || B) puts("NO");
	else {
		puts("YES");
		For(i, 1, n) puts(Map[i] + 1);
	}

	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include<math.h>
#include <limits>
#include <iomanip>
using namespace std;
#define rep(i, n) for (int i =0; i < (int)(n); i++)



int main() {
	int A, B;
	cin >> A>>B;
	int AA = 0;
	rep(i, 9) {
		AA = (B * 10 + i) * 0.08;
		if (AA == A) {
			cout << (B * 10 + i) << endl;
			return 0;
		}
	}

	cout << "-1"<< endl;
return 0;
} 

Measured memory_bytes: 256
#include <iostream>

int main()
{
	int a, b, c;
	std::cin >> a >> b >> c;
	int result = 3;
	if (a == b)
	{
		result--;
	}
	
	if (b == c)
	{
		result--;
	}
	if (result == 3 && a == c)
	{
		result--;
	}
	std::cout << result;
    return 0;
}



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

int main() {
    ll N;
    cin >> N;
    ll A[N];
    for(ll i = 0; i < N; ++i) cin >> A[i];
    
    map<ll,ll> mp;
    bool isExist = false;

    for(ll i = 0; i < N; ++i){
        if(mp.count(A[i]) == 0) mp.insert(make_pair(A[i],A[i]));
        else{
            isExist = true;
            break;
        }
    }

    if(isExist) cout << "NO" << endl;
    else cout << "YES" << endl;
}

Measured memory_bytes: 14336
a = input()
if len(a)==1 and a == "L":
    print("No")
    exit()
elif len(a)==1:
    print("Yes")
    exit()
for i in a[::2]:
    for j in a[1::2]:
        if i =="L" or j =="R":
            print("No")
            exit()
else:
    print("Yes")

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

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

#define fore(i,a,b) for(int i=a,ggdem=b;i<ggdem;i++)
#define FIN ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define SZ(a) ((int)(a).size())
#define ALL(a) a.begin(),a.end()
#define pb push_back
#define fst first
#define snd second
const int MAXN=1<<20;
string s;
int n,len,l[MAXN],r[MAXN],vis[MAXN];
vector<int>g[MAXN],diff;

int dfs(int x) {
	if(vis[x])return 0;
	vis[x]=1;
	int take=0;
	for(int i:g[x])take=(take+dfs(i))%26;
	int a=(diff[x]+diff[len-x-1]+take+26)%26;
	// cout<<x<<" : "<<take<<" "<<a<<endl;
	return a;
}

int main() {FIN;
	cin>>s>>n;s="a"+s+"a";len=SZ(s)-1;
	fore(i,1,SZ(s))diff.pb((s[i]-s[i-1]+26)%26);
	// for(int i:diff)cout<<i<<" ";cout<<endl;
	fore(i,0,len)g[i].pb(len-i-1);
	fore(i,0,n){
		int l,r;cin>>l>>r;
		g[l-1].pb(r);
		g[r].pb(l-1);
	}
	fore(i,0,len)if(dfs(i))return!(cout<<"NO"<<endl);
	cout<<"YES"<<endl;
}

Measured memory_bytes: 34408
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;
const double PI = acos(-1);

int main(){
  int n,m;
  ull k;
  cin >> n >> m >> k;
  vector<ull> a(n+1,0),b(m+1,0);
  for(int i = 0; i < n; i++){
    cin >> a[i+1];
    a[i+1] += a[i];
  }
  for(int i = 0; i < m; i++){
    cin >> b[i+1];
    b[i+1] += b[i];
  }
  int ans = 0, j = m;
  for(int i = 0; i <= n; i++){
    if(a[i] > k) break;
    while(a[i] + b[j] > k) j--;
    ans = max(ans,i+j);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6336
#include<cstdio>
int n,k;
bool vis[10];
bool check(int x)
{
	while(x)
	{
		if(vis[x%10]) return false;
		x/=10;
	}
	return true;
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=k;i++)
	{
		int x;
		scanf("%d",&x);
		vis[x]=true;
	}
	for(;;n++)
		if(check(n))
		{
			printf("%d\n",n);
			return 0;
		}
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
using namespace std;

int main(){
  string d1,d2,d3;
  int a1,a2,a3;
  int c1=0,c2=0;
  while(getline(cin,d1,',')){
    a1 = atoi(d1.c_str());
    getline(cin,d2,',');
    a2 = atoi(d2.c_str());
    getline(cin,d3,'\n');
    a3 = atoi(d3.c_str());
    if (a1*a1+a2*a2==a3*a3)
      c1++;
    if (a1==a2)
      c2++;
  }
  cout <<c1<<endl<<c2<<endl;
  return 0;
}

Measured memory_bytes: 0
def sep():
    return map(int,input().strip().split(" "))
def lis():
    return list(sep())

s=input()
n=len(s)
a=s[:n//2]
b=s[n//2 +1 : ]
if s==s[::-1] and a==a[::-1] and b==b[::-1]:
    print("Yes")
else:
    print("No")

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

typedef long long int ll;
typedef long double ld;

#define bug(v) cerr << #v << " = " << (v) << endl;
#define bug2(v1, v2) cerr << #v1 << " = " << (v1) << ' ' << #v2 << " = " << (v2) << endl;
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define pb emplace_back
#define vii vector<int>
#define vll vector<ll>
#define vpll vector<pair<ll, ll>>
#define pll pair<ll, ll>
#define pii pair<int, int>
#define pq priority_queue<int>
#define khtm "\n"
#define F first
#define S second
#define fr(i, a, n) for (i = a; i < n; i++)
#define mem(arr, l) memset(arr, l, sizeof arr)
#define ALL(x) x.begin(), x.end()
#define frr(i, a, n) for (i = n - 1; i >= a; i--)
#define fast                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define testcase \
    ll T;        \
    cin >> T;    \
    while (T--)

const double pi = 3.14159265359;
const int MAX = 1e6 + 2;
const ll inf = 1e18;
const int N = 1010;
const ll mod = 1000000007;
inline ll add(ll a, ll b)
{
    a += b;
    if (a >= mod)
        a -= mod;
    return a;
}
inline ll mul(ll a, ll b) { return (((a + mod) % mod) * (b + mod) % mod) % mod; }
inline ll power(ll a, ll b)
{
    ll rt = 1;
    while (b > 0)
    {
        if (b & 1)
            rt = mul(rt, a);
        a = mul(a, a);
        b >>= 1;
    }
    return rt;
}
inline ll modInverse(ll n, ll p) { return power(n, p - 2) % p; }

void stArt()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
void eNd()
{
#ifndef ONLINE_JUDGE
    cout << "\nTime Elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " s";
#endif
}

ll i, j, k, l, m, r, n;
ll a[MAX], b[MAX];
ll q, lst[MAX], ans[MAX];

struct bit
{
    vll BIT;
    bit(int sz)
    {
        n = sz + 4;
        BIT = vector<ll>(n + 1);
    }
    void update(ll x, ll val)
    {
        x++;
        for (; x <= n; x += x & -x)
        {
            BIT[x] += val;
        }
    }
    ll query(ll x)
    {
        x++;
        ll sum = 0;
        for (; x > 0; x -= x & -x)
            sum += BIT[x];
        return sum;
    }

    ll query(ll l, ll r)
    {
        if (l > r)
            return 0;
        ll ret = query(r) - (l <= 0 ? 0 : query(l - 1));
        return ret;
    }
};

vpll Q[MAX];

int main()
{

    // stArt();
    fast;
    cin >> n >> q;
    fr(i, 1, 1 + n) cin >> a[i];
    fr(i, 0, q)
    {
        cin >> l >> r;
        Q[r].pb(l, i);
    }
    bit A(n);
    fr(i, 1, 1 + n)
    {
        A.update(i, 1);
        if (lst[a[i]])
            A.update(lst[a[i]], -1);
        lst[a[i]] = i;
        for (auto it : Q[i])
        {
            ans[it.S] = A.query(i) - A.query(it.F - 1);
        }
    }
    fr(i, 0, q) cout << ans[i] << khtm;
    eNd();
    return 0;
}

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

using namespace std;

long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }

int main() {
        long long a, b, c, d;
        scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
        if (a == c || b == d) return !printf("%d\n", 0);
        printf("%lld\n", abs(c - a) + abs(d - b) - gcd(abs(c - a), abs(d - b)));
        return 0;
}



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

typedef vector<int> vi;

vi r;

bool calc(const vector<vi>& v){
	int n = v[0].size();
	vi score(n);
	vi idx(n);
	for(int i = 0; i < n; i++) idx[i] = i;
	for(int col = 0; col < 3; col++) {
		sort(idx.begin(), idx.end(), [&](const int a, const int b){return v[col][a] > v[col][b];});

		// cout<<endl;
		// for(int i = 0; i < n; i++) cout<<" "<<idx[i];//<<endl;
		// cout<<endl;
		score[idx[0]] += r[0];
		int cnt = 0;
		for(int i = 1; i < n; i++) {
			if(v[col][idx[i-1]] == v[col][idx[i]]) {
				cnt++;
				score[idx[i]] += r[i-cnt];
			}
			else {
				score[idx[i]] += r[i];
				cnt = 0;
			}
		}
	}
	sort(idx.begin(), idx.end(), [&](const int a, const int b){return score[a] == score[b] ? a < b: score[a] > score[b];});
	//for(int i = 0; i < n; i++) cout<<" "<<idx[i]<<endl;
	for(int i = 0; i < 8; i++) if(idx[i] == 0) return true;
	return false;
}

int main(){
	int N;
	cin >> N;
	r.resize(N);
	for(int i = 0; i < N; i++) cin >> r[i];
	vector<vi> v(3);
	for(int i = 0; i < 3; i++) {
		v[i].resize(N);
	}
	for(int j = 0; j < N; j++) for(int i = 0; i < 3; i++) cin >> v[i][j];
	int ans = 1e9;
	for(int i = 0; i < 3; i++) {
		for(int j = 0; j + v[i][0] <= 101; j++) {
			//cout<<""<<i<<" "<<j<<endl;
			v[i][0] += j;
			if(calc(v)) ans = min(ans, j);
			v[i][0] -= j;
		}
	}
	if(ans == 1e9) cout<<"Saiko"<<endl;
	else cout<<ans<<endl;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define sortr(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define max 100005
#define nil -1
constexpr int inf = 100000000;

struct edge{
    int from,to,cost;
};

vector<edge> es;
vector<int> d;
int n;

void be(int s){
    d.resize(max);
   fill(d.begin(),d.end(),inf);
   d[s]=0;
   while(true){
       bool update=false;
       for(int i=0;i<es.size();i++){
           edge e=es[i];
           if(d[e.from]!=inf&&d[e.from]+e.cost<d[e.to]){
               d[e.to]=d[e.from]+e.cost;
               update=true;
           }
       }
       if(!update){
           break;
       }
   }
}

int main() {
  int  u,k,v,c;
  cin>>n;
    d.resize(n);
  rep(i,n){
      cin>>u>>k;
      for(int j=0;j<k;j++){
          cin>>v>>c;
          es.push_back({u,v,c});
        }
    }
    be(0);
    rep(i,n){
        cout<<i<<" "<<d[i]<<endl;
    }
  return 0;
}



Measured memory_bytes: 3364
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int N;cin>>N;
    vector<vector<pair<int,int>>> graph(N);
    REP(i,N-1){
        int a,b; cin>>a>>b;
        a--;b--;
        graph[a].push_back({b,i});
        graph[b].push_back({a,i});
    }
    int M;cin>>M;
    vector<pair<int,int>> Q(M);
    REP(i,M){
        cin>>Q[i].first>>Q[i].second;
        Q[i].first--;Q[i].second--;
    }
    function<bool(int,int,int,ll&)> dfs=[&](int now,int pre,int v,ll &D){
        if(now==v) return true;
        for(auto e:graph[now]){
            if(e.first==pre) continue;
            if(dfs(e.first,now,v,D)){
                D=D|(1LL<<e.second);
                return true;
            }
        }
        return false;
    };
    ll ans=0;
    vector<ll> E(M);
    REP(i,M){
        dfs(Q[i].first,-1,Q[i].second,E[i]);
    }
    ll app=0;
    rep(bit,1,1<<M){
        app=0;
        REP(i,M) if(bit>>i&1){
            app|=E[i];
        }
        int n=N-1-__builtin_popcountll(app);
        if(__builtin_popcount(bit)%2==1) ans+=1LL<<(n);
        else ans-=1LL<<(n);
    }
    ans=(1LL<<(N-1))-ans;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
var
  a,b,k,i:longint;
begin
  read(a,b,k);
  for i:=1 to k do
    if i mod 2=1 then
      begin
        a:=a div 2;
        b:=b+a;
      end else
      begin
        b:=b div 2;
        a:=a+b;
      end;
  write(a,' ',b);
end.

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int X = in.nextInt();
            int[] L = new int[N];
            for (int i = 0; i < N; i++) {
                L[i] = in.nextInt();
            }

            int[] D = new int[N + 1];
            for (int i = 1; i < N + 1; i++) {
                D[i] = D[i - 1] + L[i - 1];
            }

            int count = 0;
            for (int i = 0; i < N + 1; i++) {
                if (D[i] <= X) {
                    count++;
                }
            }

            System.out.println(count);
        }
    }
}


Measured memory_bytes: 27244
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define lint long long
using namespace std;
lint readint() {
	char c = getchar_unlocked();
	lint ans = 0;
	while ('0' <= c && c <= '9') {
		ans = ans * 10 + c - '0';
		c = getchar_unlocked();
	}
	return ans;
}
char ch[1024];
void writeint(lint x) {
	int ptr = 0;
	while (x) {
		ch[ptr++] = (x % 10) + '0';
		x /= 10;
	}
	while (ptr) {
		putchar_unlocked(ch[--ptr]);
	}
	putchar_unlocked(' ');
}
int q;
constexpr int mod=1000000007;
lint x,y,a,n,m;
constexpr lint f[]={0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,17711,28657,46368,75025,121393,196418,317811,514229,832040,1346269,2178309,3524578,5702887,9227465,14930352,24157817,39088169,63245986,102334155,165580141,267914296,433494437,701408733,1134903170,1836311903,2971215073,4807526976,7778742049,12586269025,20365011074,32951280099,53316291173,86267571272,139583862445,225851433717,365435296162,591286729879,956722026041,1548008755920,2504730781961,4052739537881,6557470319842,10610209857723,17167680177565,27777890035288,44945570212853,72723460248141,117669030460994,190392490709135,308061521170129,498454011879264,806515533049393,1304969544928657,2111485077978050,3416454622906707,5527939700884757,8944394323791464,14472334024676221,23416728348467685,37889062373143906,61305790721611591,99194853094755497,160500643816367088,259695496911122585,420196140727489673,679891637638612258,1100087778366101931};
int main(){
	q=readint();
	rep(i,q){
		x=readint();y=readint();
		if(x>y)swap(x,y);
		if(y<=2){
			writeint(1);writeint(y==1?1:x==1?2:4);
			continue;
		}
		rep(j,99){
			if(x<f[j]||y<f[j+1]){
				a=(x==1?2:1);
				rep(k,j-2){
					n=f[j-1]+f[j-3-k]*f[k+2],m=f[j]+f[j-2-k]*f[k+2];
					if(n<=x&&m<=y)a+=(y-m)/n+1;
				}
				if(f[j]<=x){
					a++;
					rep(k,j-2)a+=(x-f[j])/(f[j-2-k]*f[k+2]);
				}
				writeint(j-2);writeint(a%mod);
				break;
			}
		}
	}
}

Measured memory_bytes: 4588
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>
using namespace std;

#define ll long long
#define dd double

ll  mod =100000009;

char ans[1000000];

int main(){
    ll n;
    string s;
    cin>>n>>s;
    ll count =0;
    for(int i=1;i<n;i++){
        if(s[i]=='E')count++;
    }
    ll ans=count;
    for(int i=1;i<n;i++){
        if(s[i]=='E'){
            count--;
        }
        
        if(s[i-1]=='W'){
            count++;
        }
        if(count<ans){
            ans=count;
        }
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 900
def resolve():
	n = int(input())
	a = list(map(int, input().split()))
	s = [0]*(n+1)
	for i in range(n):
		s[i+1] = s[i] + a[i]
	ans = float('inf')
	for i in range(1, n):
		ans = min(ans, abs(s[-1] - s[i]*2))
	print(ans)
resolve()

Measured memory_bytes: 76752
import java.util.Scanner;
 
public class Main {
 
	public Main() {
		// TODO 自動生成されたコンストラクター・スタブ
	}
 
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n,m,answer,index,i,j;
		float ans;
		String s,s1,a1,t,u;
		
			// 整数の入力
		
		n = sc.nextInt();
		s = sc.next();
		sc.close();
		String alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		t="";
		
		for(index=0;index<s.length();index++) {
			s1=s.substring(index,index+1);
			//System.out.print(s1+":");
			
			LoopA: for(i=0;i<26;i++) {
				if(s1.equals(alpha.substring(i,i+1))){
					//System.out.print("*"+i+"*");
					j=(i+n)%26;
					//t.concat(alpha.substring(j,j+1));
					System.out.print(alpha.substring(j,j+1));
					break LoopA;
				}
			}
		}
			// 出力
 
	}
}	

Measured memory_bytes: 32084
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String[] numstr = str.split(" ", 4);
		double x1 = Double.parseDouble(numstr[0]);
		double y1 = Double.parseDouble(numstr[1]);
		double x2 = Double.parseDouble(numstr[2]);
		double y2 = Double.parseDouble(numstr[3]);
		double distance = Math.pow(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2),
				0.5);
		System.out.println(distance);
	}
}

Measured memory_bytes: 24364
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; edge(ll f, ll t, ll c) : from(f), to(t), cost(c) { } };
struct edge{ ll to, cost; edge(ll t, ll c) : to(t), cost(c) { } };
// using Graph = vector<vector<ll>>;  // 重み無し
using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);

const ll MAX_V = 1000000;  // 制約に従う
Graph G(MAX_V);  // 隣接リスト表現
ll d[MAX_V];
// 実際の頂点数Vはここで定義する必要なし


void dijkstra(ll s){  // 始点 (0-based)
    priority_queue<pll, vector<pll>, greater<pll>> pq;  // 経路長, 頂点番号
    FILL(d, INF);
    d[s] = 0;
    pq.push(pll(0, s));

    while(!pq.empty()){
        pll p = pq.top(); pq.pop();
        ll v = p.second;  // 確定させる候補の頂点番号
        if(d[v] < p.first) continue;  // より小さいのが後で来るのでスルー
        rep(i, G[v].size()){
            edge e = G[v][i];
            if(chmin(d[e.to], d[v] + e.cost)) pq.push(pll(d[e.to], e.to));
        }
    }
}


int main(){
    ll h, w, sh, sw, gh, gw; cin >> h >> w >> sh >> sw >> gh >> gw; sh--, sw--, gh--, gw--;
    vector<string> maze(h);
    rep(i, h) cin >> maze[i];
    rep(hi, h){
        rep(wi, w){
            if(maze[hi][wi] == '#') continue;
            Rep(i, max(0LL, hi-2), min(h, hi+3)){
                Rep(j, max(0LL, wi-2), min(w, wi+3)){
                    if(maze[i][j] == '#' || (i == hi && j == wi)) continue;
                    ll dist = abs(i - hi) + abs(j - wi), cost = dist == 1 ? 0 : 1;
                    // 無向
                    G[hi*w + wi].push_back(edge(i*w + j, cost));
                    G[i*w + j].push_back(edge(hi*w + wi, cost));
                }
            }
        }
    }
    dijkstra(sh*w + sw);
    if(d[gh*w + gw] == INF) cout << -1 << endl;
    else cout << d[gh*w + gw] << endl;
}


Measured memory_bytes: 292344
unittest
{
	assert( [ "3", "1 0 0" ].parse.expand.solve == "1\n1" );
	assert( [ "5", "0 0 0 0 0" ].parse.expand.solve == "0" );
}



import std.conv;
import std.format;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	long[] anss;
	auto bs = new long[ as.length ];
	auto bc = 0L;
	for( auto i = as.length.signed; 0 < i; i-- )
	{
		auto bt = 0L;
		for( auto d = 1L; i * d <= as.length; d++ )
		{
			bt += bs[ i * d - 1 ];
		}
		if( bt % 2 == as[ i - 1 ] ) continue;
		bs[ i - 1 ] = 1;
		anss ~= i;
	}
	if( anss.length == 0 ) return format( "%s", anss.length );
	else                   return format( "%s\n%s", anss.length, anss.to!( string[] ).join( " " ) );
}


Measured memory_bytes: 16536
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  vi a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  vector<pii> v(m);
  rep(i, m){
    int b,c;
    cin >> b >> c;
    v[i] = make_pair(c, b);
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  int cnt = 0, last = n;
  ll ans = 0;
  rep(i, n){
    if(v[cnt].second <= 0) cnt++;
    if(cnt < m && v[cnt].first > a[i]){
      v[cnt].second--;
      ans += v[cnt].first;
    }else{
      last = i;
      break;
    }
  }
  for(int i = last; i < n; i++) ans += a[i];
  cout << ans << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cctype>
#include <stdio.h>
using namespace std;

int main() {
	char ch;
	while (1) {
		scanf("%c", &ch);
		if (islower(ch))
			ch = toupper(ch);
		else
			ch = tolower(ch);
		cout << ch;
		if (ch == '\n') break;
	}
}

Measured memory_bytes: 3128