akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0) {
                break;
            }
            int i, j;
            for (i = 0; i < H; i++) {

                if(i==0 || i==H-1){
                    for (j = 0; j < W; j++) {
                        System.out.printf("#");
                    }
                    System.out.printf("\n");
                }else{
                    for (j = 0; j < W; j++) {
                        if(j==0 || j==W-1){
                            System.out.printf("#");
                        }else{
                            System.out.printf(".");
                        }
                    }
                    System.out.printf("\n");
                }
            }
            System.out.printf("\n");
        }
    }
}



Measured memory_bytes: 60352
#include <iostream>
#include <vector>
#include <string>
#include <cfenv>
#include <cmath>
#include <string>
#include <algorithm>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using namespace std;

int main(){
  ll n,a,b,s,d,rec;
  cin >> n >> a >> b;
  s = a+b;
  d = n%s;
  rec = (n/s)*a + min(d,a);
  cout << rec << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<queue>

using namespace std;

int main(void){
    int N;
    cin >> N;
    vector<long long> A(N), B(N), D(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++){
        cin >> B[i];
        D[i] = A[i] - B[i];
    }

    // long long total = 0;
    // for(int i = 0; i < N; i++){
    //     cout << A[i] << " " << B[i] << " " << D[i] << endl;
    //     total += D[i];
    // }
    // cout << total << endl;

    sort(D.rbegin(), D.rend());
    auto ditr = D.begin();
    long long ans = 0;
    long long y = 0;
    for(int i = 0; i < N; i++){
        if(B[i] > A[i]){
            while(y < B[i] - A[i]){
                // cout << i << " " << y << " " << B[i] - A[i] << endl;
                if(ditr == D.end()){
                    cout << -1 << endl;
                    return 0;
                }
                y += *ditr;
                ditr++;
                ans++;
            }
            y -= B[i] - A[i];
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int W = Integer.parseInt(sc.next());
        int[] w = new int[N];
        int[] v = new int[N];
        long[][] dp = new long[N+1][200001];
        long INF = 1_000_000_000_000_000_000L;
        for (int i=0;i<N+1;i++) {
            for (int j=0;j<200001;j++) {
                dp[i][j] = INF;
            }
        }
        for (int i=0;i<N+1;i++) {
            dp[i][0] = 0;
        }
        for (int i=0;i<N;i++) {
            w[i] = Integer.parseInt(sc.next());
            v[i] = Integer.parseInt(sc.next());
            for (int j=0;j<200000;j++) {
                // dp[i][j+1] = dp[i][j];
                if (j+1-v[i]>=0 && dp[i][j+1-v[i]]!=INF) {
                    dp[i+1][j+1] = Math.min(dp[i][j+1], dp[i][j+1-v[i]]+w[i]);
                } else {
                    dp[i+1][j+1] = dp[i][j+1];
                }
            }
        }
        int ans = 0;
        for (int i=0;i<200001;i++) {
            if (dp[N][i]<=W) ans = Math.max(ans, i);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 240152
#include <stdio.h>
#include <math.h>

int main()
{
    int n, d, i, count = 0;
    double x, y, distance;

    scanf("%d %d", &n, &d);

    for(i = 0; i < n; i++)
    {
        scanf("%lf %lf", &x, &y);

        distance = sqrt(pow(x, 2) + pow(y, 2));

        if(distance <= d)
            count++;
    }

    printf("%d", count);

    return 0;
}


Measured memory_bytes: 2216
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[] s = sc.next().toLowerCase().toCharArray();
        char[] ans = new char[s.length];

        for (int i = 0; i < s.length; i ++) {
            ans[i] = (char) ((s[i] - 'a' + n) % 26 + 'a');
        }

        System.out.println(String.copyValueOf(ans).toUpperCase());
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 23124
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std;

#define int long long
#define endl '\n'

const int N = 200005;


signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int a;
	string s;
	cin >> a;
	cin >> s;
	cout << (a < 3200 ? "red" : s);
}


Measured memory_bytes: 256
def xor(A,B):
    ruijo=[]
    now=1
    for j in range(51):
        ruijo.append(now)
        now*=2
    Astr=bin(A)[2:]
    Bstr=bin(B)[2:]
    Astr='0'*(max(len(Astr),len(Bstr))-len(Astr))+Astr
    Bstr='0'*(max(len(Astr),len(Bstr))-len(Bstr))+Bstr
    ans=0
    for i in range(1,len(Astr)+1):
        if Astr[-1*i]!=Bstr[-1*i]:
            ans+=ruijo[i-1]
    return ans
def fun(x):
    if x%2==0:res=x+1
    elif x%2==1:res=x-1
    ans=[x,1,res,0]
    return ans[x%4]
A,B=map(int,input().split())
if A==B:print(A)
elif A==0:print(fun(B))
else:
    print(xor(fun(A-1),fun(B)))

Measured memory_bytes: 3064
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

#define MAX 500000

int N, K;
int a[MAX];

int main() {
	cin >> N >> K;
	for( int i = 0; i < N; i++ ) {
		cin >> a[i];
	}

	sort( a, a + N );
	int t = 0;
	int ans = N;
	for( int i = N - 1; i >= 0; i-- ) {
		if( t + a[i] < K ) {
			t += a[i];
		}
		else {
			ans = min( ans, i );
		}
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) long long((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
typedef pair<ll, ll> P;
typedef map<string, ll> M;
typedef unordered_map<ll, ll> HM;
typedef set<ll> S;
typedef multiset<ll> MS;
typedef queue<ll> Q;

int main(){
    ll a,b; cin>>a>>b;
    if((max(a,b)-min(a,b))%2 == 0)
        OUT((a+b)/2);
    else
        OUT("IMPOSSIBLE");
}

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

bool check(vector<pair<ll, ll>> &v, ll x) {
  REP(i, 0, v.size()) {
    if (v[i].first <= x && x < v[i].second) {
      return true;
    }
  }
  return false;
}

int main(void) {
  ll N, Q, K, D;
  cin >> N >> Q >> K >> D, K--, D--;

  vector<vector<pair<ll, ll>>> z(Q + 1);
  z[Q].push_back(make_pair(D, D + 1));

  for (ll i = Q - 1; i >= 0; i--) {
    vector<pair<ll, ll>> v;
    REP(k, 0, z[i + 1].size()) {
      ll l = z[i + 1][k].first, h = z[i + 1][k].second;
      if (l < N / 2 && h <= N / 2) {
        v.push_back(make_pair(l * 2, h * 2));
      } else if (l < N / 2 && h > N / 2) {
        v.push_back(make_pair(l * 2, N));
        v.push_back(make_pair(0, h * 2 - N));
      } else if (l >= N / 2 && h > N / 2) {
        v.push_back(make_pair(l * 2 - N, h * 2 - N));
      }
    }

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

    REP(k, 0, v.size()) {
      assert(v[k].first < v[k].second);
      if (z[i].size() >= 1) {
        if (z[i].back().second >= v[k].first) {
          z[i].back().second = v[k].second;
          continue;
        }
      }
      z[i].push_back(v[k]);
    }
  }

  if (!check(z[0], K)) {
    cout << -1 << endl;
  } else {
    vector<ll> ans(Q);
    ll x = K;
    REP(i, 0, Q) {
      ll n = x % 2 == 0 ? x / 2 : x / 2 + N / 2;
      if (check(z[i + 1], n)) {
        x = n;
        ans[i] = 0;
      } else {
        x = x % 2 == 0 ? x / 2 + N / 2 : x / 2;
        ans[i] = 1;
      }
    }
    REP(i, 0, Q) printf("%ld\n", ans[i]);
  }
}


Measured memory_bytes: 60012
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	sc.nextLine();
      
      	int cost[] = new int[n];
      	for(int i = 0; i < n; i++)
          cost[i] = sc.nextInt();
      
      	int result[] = new int[n];
      	result[0] = 0;
      	result[1] = Math.abs(cost[0] - cost[1]);
      
      	int cost1 = 0;
      	int cost2 = 0;
      	for(int i = 2; i < result.length; i++){
          	cost1 = Math.abs(cost[i] - cost[i-1]) + result[i-1];
          	cost2 = Math.abs(cost[i] - cost[i-2]) + result[i-2];
      		if(cost1 > cost2)
              result[i] = cost2;
          	else
              result[i] = cost1;
        }  	
      	System.out.println(result[result.length-1]);
    }
}

Measured memory_bytes: 50392
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
using namespace std;
/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compiles and gets accepted.
 *  ___  __     _______    _______      
 * |\  \|\  \  |\  ___ \  |\  ___ \     
 * \ \  \/  /|_\ \   __/| \ \   __/|    
 *  \ \   ___  \\ \  \_|/__\ \  \_|/__  
 *   \ \  \\ \  \\ \  \_|\ \\ \  \_|\ \ 
 *    \ \__\\ \__\\ \_______\\ \_______\
 *     \|__| \|__| \|_______| \|_______|
 */
//const long long mod = 1000000007;
const long long mod = 998244353;

long long pow_mod(long long base,long long power) {
	long long res = 1;
	while(power) {
		if(power&1) res = res * base % mod;
		base = base * base % mod;
		power >>= 1;
	}
	return res;
}

const int mxF = 100010;
long long fact[mxF],inv[mxF];

long long NcR(long long N,long long R) {
	if(R > N) return 0;
	return (fact[N] * inv[R] % mod) * inv[N-R] % mod;
}

long long get(long long cnt,long long dv) {
	if(dv <= 0) return cnt == 0;
	return NcR(cnt+dv-1,dv-1);
}

const int mxN = 2005;
long long dp[mxN][mxN][2];
long long N,K;

long long solve(long long mx,long long num, bool f) {
	if(mx == 1) return num <= 1;
	if(num == 0) return 1;
	if(mx == 0) return 0;
	long long & ref = dp[mx][num][f];
	if(ref != -1) return ref;
	if(f == 0) ref = (mx > K?1:2) * solve(mx,num-1,1) + solve(mx-2,num,0);
	else ref = solve(mx,num-1,1) + solve(mx-2,num,0);
	ref %= mod;
	return ref;	
}

long long get(long long i) {
	if(i > K+1) return get(K+1 - (i - K - 1));
	long long res = 0;
	for(int up = 0;up <= N;up++) {
		res = (res + get(up,K-i+1) * solve(i-1,N-up,0)) % mod;
	}
	return res;
}

int main(int argc, char** argv) {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	fact[0] = fact[1] = inv[0] = inv[1] = 1;
	for(int i = 2;i < mxF;i++) fact[i] = i * fact[i-1] % mod, inv[i] = pow_mod(fact[i],mod-2);

	cin>>K>>N;
	memset(dp,-1,sizeof dp);
	for(int i = 2;i <= (K<<1);i++) {
		cout<<get(i)<<'\n';
	}
	return 0;
}


Measured memory_bytes: 64768
import java.util.Scanner;

class A {
    public static int[] is = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    public static void main(String... args) {
        final Scanner sc = new Scanner(System.in);
        final int K = sc.nextInt() - 1;
        System.out.println(is[K]);
    }
}
public class Main {
    public static void main(String... args) {
        A.main();
    }
}


Measured memory_bytes: 21972
s=[i for i in input()]
l=[]
cnt=0
for i in range(len(s)):
  if s[i] in {"A","T","C","G"," "}:
    cnt+=1
    if i==len(s)-1:
      l.append(cnt)
  else:
    l.append(cnt)
    cnt=0    
print(sorted(l)[-1])    


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

#define pb push_back
#define ff first
#define ss second
#define N 1503
#define mod 1000000007
#define fo(n) for(int i=1;i<=n;i++)
typedef pair<int,int> pii;
typedef long long int ll;
typedef long int li;
int mod1 = 998244353;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    
    int x;
    cin>>x;
    ll ans = 1ll*1000*(x/500);
    int t = x/500;
    x -= 500*t;
    ans += (x/5)*5;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
/* Uncomment only if you are not using GNU compiler->
*/
#include <map>
#include <algorithm> 
#include <vector> 
#include <string.h> 
#include <math.h> 
#include <stdio.h> 
#include <stdlib.h> 
#include <chrono> 
#include <thread> 
#include <iomanip>
#include <typeinfo>
/**/ 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define all(v)  v.begin(), v.end()

//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const long long MOD = 1000000007;
const long long inf = 1e18;
 
using namespace std;

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

ll power(ll x, ll n)
{
    ll res=1;
    while(n>0){
        if(n&1) res=res*x;
        x=x*x;
        n>>=1;
    }
    return res;
}

bool custom_sort(int &x, int &y)
{
    if(x<y)
        return 1;
    else
        return 0;
}

void always_ignore_function_name()
{
    ll n;
    cin>>n;
    ll ans=0;
    for(ll i=1;i<=n;i+=1LL)
    {
        ans+=i*(n-i+1);
    }
    int x,y;
    rep(i,n-1)
    {
        cin>>x>>y;
        if(x>y)
            swap(x,y);
        ll x1=x, y1=n-y+1;
        ans-=x1*y1;
    }
    cout<<ans<<endl;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1, tt=1;
    // cin>>t;
    while(tt<=t)
    {
        // cout<<"Case #"<<tt<<": ";
        always_ignore_function_name();
        tt++;
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n; cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  bool ok = !(n&1);
  int mid = n/2 - 1;
  ok |= a[mid] != a[mid+1];
  int ans = 0;
  if (!ok) {
    cout << 0 << endl;
    return 0; 
  }
  cout << a[mid+1] - a[mid] << endl; 
  return 0;
}

Measured memory_bytes: 640
jk1 = [1,3,5,7,8,10,12]
jk2 = [4,6,9,11]
x,y = map(int,input().split())
if x in jk1 and y in jk1:
    print("Yes")
elif  x in jk2 and y in jk2:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

#define BUFF ios::sync_with_stdio(false)
#define rep(i,a,b) for (ll i=a; i<b; i++)
#define pb push_back
#define ll long long
#define vvi vector<vector<ll>> 
#define vi vector<ll>
#define vb vector<bool>
#define vvb vector<vector<bool>> 
#define mod 1000000007   // 1e9+7

vector<ll> visit, white, black;

void dfs_visit(vvi & adj, ll i) {
	visit[i] = 1;
	bool folha = 1;
	for (ll j : adj[i]) {
		if (!visit[j]) {
			folha = 0;
			dfs_visit(adj, j);
			ll t = (white[j] + black[j]) % mod;
			white[i] *= t;
			white[i] %= mod;
			black[i] *= white[j];
			black[i] %= mod;
		}
	}
}

void dfs(vvi & adj, ll n) {
	visit.assign(n+1, 0);
	white.assign(n+1, 1);
	black.assign(n+1, 1);
	dfs_visit(adj, 1);
}

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

	vvi g;
	vi lista;
	lista.clear();
	g.assign(n+1, lista);
	for (ll i=1; i<=n-1; i++) { 
		ll x, y;
		cin >> x >> y;
		g[x].push_back(y);
		g[y].push_back(x);
	}

	dfs(g, n);

	ll ans = white[1] + black[1];
	ans %= mod;

	cout << ans << endl;

   return 0;

}


Measured memory_bytes: 14976
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws Exception {

        ModScanner ms = new ModScanner();
        OutputStream outputStream = System.out;
        PrintWriter out = new PrintWriter(outputStream);
        int n = ms.nextInt();
        int[] heights = new int[n];
        for (int i = 0; i < n; i++) {
            heights[i] = ms.nextInt();
        }
        int[] dp = new int[n];
        Arrays.fill(dp, -1);
        out.println(findTotalJumpCost(heights, 0, dp));
        out.close();
    }

    private static int findTotalJumpCost(int[] heights, int ind, int[] dp) {
        if (ind == heights.length - 1) {
            return 0;
        }

        if (dp[ind] != -1) {
            return dp[ind];
        }

        int cost = Math.abs(heights[ind] - heights[ind + 1]) + findTotalJumpCost(heights, ind + 1, dp);

        if (ind + 2 < heights.length) {
            cost = Math.min(cost, Math.abs(heights[ind] - heights[ind + 2]) + findTotalJumpCost(heights, ind + 2, dp));
        }

        return dp[ind] = cost;
    }

}

class ModScanner {

    BufferedReader br;
    StringTokenizer st;

    public ModScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String nextToken() throws Exception {
        while (st == null || !st.hasMoreElements()) {
            st = new StringTokenizer(br.readLine());

        }
        return st.nextToken();
    }

    String nextString() throws Exception {
        return br.readLine();
    }


    int nextInt() throws Exception, Exception {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }

}


Measured memory_bytes: 56856
#include <iostream>

using namespace std;

int main() {
    string input;
    int count = 0;
    cin >> input;
    if (input[0] == '1') count++;
    if (input[1] == '1') count++;
    if (input[2] == '1') count++;

    cout << count << endl;
    return 0;
}

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

using namespace std;

int main() {
	int N,a,b,c;
  	cin >> N;
  	a = N/100;
  	b = (N%100)/10;
  	c= (N%100)%10;
  	int count=0;
  	if (a==1) {
		count++;
    }
  	if(b==1) {
      count++;
    }
  	if( c==1) {
		count++;
    }
    cout <<count << endl;
 }

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    ll N, M;
    cin >> N >> M;
    vl H(N);
    rep(i, N){
        cin >> H[i];
    }
    vll G(N);
    set<pll> s;
    rep(i, M){
        ll a, b;
        cin >> a >> b;
        a--; b--;
        //a < b
        if(a > b){
            swap(a, b);
        }
        s.insert(pll(a,b));
    }
    for(auto p : s){
        G[p.first].push_back(p.second);
        G[p.second].push_back(p.first);
    }
    ll ans = 0;
    rep(i, N){
        if(G[i].size() == 0){
            ans++;
            continue;
        }
        bool f = false;
        for(auto e : G[i]){
            if(H[i] <= H[e]){
                f = true;
                break;
            }
        }
        if(f) continue;
        ans++;
    }
    cout << ans;
}

Measured memory_bytes: 19084
/**
DufauX-XuafuD
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define reset(x) memset(x,-1,sizeof(x))
#define CheckBit(a,b) (a&(1ll<<b))
#define SetBit(a,b) a=(a|(1ll<<b))
#define UnSetBit(a,b) a=(a&(~(1ll<<b)))
#define maxx 10000006
#define PI 2*acos(0.0)
const long long INF = 2000000000000000000LL;	// 2e18
const int inf = 0x3f3f3f3f;	// 1061109567
const long double EPS = 1e-9;
//bitset<maxx/2>vis;
//bitset<maxx>pr;
//int mobi[maxx+10];
//vector<ll>prime;
//void sieve(){
//    ll x=maxx/2, y=sqrt(maxx)/2;
//    for(ll i=1;i<=y;i++){
//        if(vis[i]==0){
//            for(ll j=(i*(i+1)*2);j<x;j+=(2*i)+1)
//                vis[j]=1;
//        }
//    }
//    prime.push_back(2);
//    for(ll i=3;i<maxx;i+=2)
//        if(vis[i/2]==0)
//        prime.push_back(i);
//}
//void generate_mobius()
//{
//    for(int i=0;i<maxx;i++)mobi[i]=1;
//    for(int i=2;i<maxx;i++){
//        if(!pr[i]){
//            mobi[i]*=-1;
//            for(int j=i+i;j<maxx;j+=i){
//                pr[j]=1;
//                mobi[j]*=(j%(i*i)?-1:0);
//            }
//        }
//    }
//}
//bool isprime(ll a)
//{
//    if(a==1)return false;
//    if(a==2)return true;
//    if(a%2==0)return false;
//    for(ll i=0;i<prime.size() && prime[i]*prime[i]<=a;i++)
//        if(a%prime[i]==0)return false;
//    return true;
//}
/* Calculate ( a*b ) %c */
inline ll mulmod(ll a, ll b, ll c) {
    ll ret = 0 , cur = a % c ;
    while(b) { if(b%2) ret=(ret+cur)%c; cur=(cur<<1)%c; b=b>>1; }
    return ret%c;
}
//Calculate (b^p)%m || modular inverse: b^-1 = bigmod(b, m-2, m)
inline ll bigmod(ll b, ll p, ll m){
    ll ret = 1, cur = b % m;
    while(p) { if(p&1) ret=(ret*cur)%m; cur=(cur*cur)%m; p=p>>1; }
    return ret;
}
inline ll modulo(ll a,ll b,ll c) { //Same as big mod, use for numbers over 1e10
    ll ret = 1 , cur = a%c ;
    while(b) { if(b%2) ret=mulmod(ret,cur,c); cur=mulmod(cur,cur,c); b=b>>1; }
    return ret%c ;
}
inline ll power(ll b, ll p){
    ll ret = 1, cur = b;
    while(p) { if(p&1) ret=(ret*cur); cur=(cur*cur); p=p>>1; }
    return ret;
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
ll gcd(ll a,ll b)
{
    return __gcd(a,b);
}
void Dufaux()
{
    string s;
    cin>>s;
    int i,j;
    for(i=0;i<s.size();i++)if(s[i]=='A')break;
    for(int j=s.size()-1;j>=0;j--)if(s[j]=='Z'){
        cout<<j-i+1<<endl;
        return;
    }
}
int main()
{
    FastIO;
	///sieve();
	///generate_mobius();
	int test=1;
	while(test--){
        Dufaux();
	}
	return 0;
}





Measured memory_bytes: 3764
//---->JUST FOCUS ON YOUR GOAL
//-->BY UNBEATABLE BALORIA
//-->NEVER GIVE UP EVERYTHING IS POSSIBLE
//---------------------------------------------------------------------------------------------------//
#include <bits/stdc++.h>
#include<iostream>
#include<fstream>
#include<cstdlib>
#include<string>
#include<vector>
#include<cmath>
#include<set>
#include<algorithm>
#define endl "\n"
#define pb push_back
#define fi first
#define se second
#define pi 3.14159265358979323846
using namespace std;
//---------------------------------------------------------------------------------------------------//
typedef long long ll;
const unsigned int M = 1000000007;
//---------------------------------------------------------------------------------------------------//
bool isPrime(int n)
{
  for(int i=2;i*i<=n;i++)
    if(n%i==0) return false;
  return true;
}
int main(){
  ios::sync_with_stdio(false); 
  cin.tie(0);
  cout.tie(0);
     int a;
     cin>>a;
     cout<<a+(a*a)+(a*a*a)<<endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define deb(x) cerr << "\n" \
                    << #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n"                   \
                        << #x << "=" << x << "\n" \
                        << #y << "=" << y << "\n";
#define w(x) \
  int x;     \
  cin >> x;  \
  while (x--)

int32_t main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  char a;
  cin >> a;
  if (a >= 'a')
    cout << "a";
  else
    cout << "A";
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

int main(){
    string s;cin>>s;
    int ssz=s.size();
    int num[ssz];
    rep(i,ssz)num[i]=(int)s[i]-'a';
    int k;cin>>k;
    int newn[ssz];
    rep(i,ssz){
        if(i==ssz-1){
            newn[i]=(num[i]+k)%26;
        }
        else if(k<26-num[i]){
          newn[i]=num[i];
        }
        else{
            newn[i]=0;
            k-=26-num[i];
            if(num[i]==0)k+=26;
        }
    }
    rep(i,ssz){
        cout<<(char)('a'+newn[i]);
    }
    cout<<endl;
}


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

int	main(void)
{
	int N;
	cin >> N;
	vector<int> vec(N);
	for (int i = 0; i < N; i++)
		cin >> vec.at(i);
	for (int i = N - 1; i >= 0; i--)
	{
		cout << vec.at(i);
		if (i != 0)
			cout << ' ';

	}
	cout << endl;
}



Measured memory_bytes: 3108
import java.util.*;

public class Main {
  public static void main(String[] args ) throws Exception {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int Y = sc.nextInt();
    
    for(int i=0; i <= N; i++) {
        for(int j = 0; j <= N - i; j++) {
            int c = N - i - j;
            int y = i*10000 + j*5000 + c*1000;
            
            if(y == Y) {
                System.out.println(i + " " + j + " " + c);
                return;
            }
        }
    }
    System.out.println("-1 -1 -1");
  }
}


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

int main()
{
    vector<vector<int>> a(3, vector<int>(3));
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> a[i][j];
        }
    }

    int n; cin >> n;
    vector<int> b(n);
    for (int i = 0; i < n; i++) {
        int tmp_b; cin >> tmp_b;
        
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (a[i][j] == tmp_b) a[i][j] = -1;                
            }
        }

    }

    bool bingo = false;

    if (a[0][0] == -1 && a[0][1] == -1 && a[0][2] == -1) bingo = true;
    if (a[1][0] == -1 && a[1][1] == -1 && a[1][2] == -1) bingo = true;
    if (a[2][0] == -1 && a[2][1] == -1 && a[2][2] == -1) bingo = true;

    if (a[0][0] == -1 && a[1][0] == -1 && a[2][0] == -1) bingo = true;
    if (a[0][1] == -1 && a[1][1] == -1 && a[2][1] == -1) bingo = true;
    if (a[0][2] == -1 && a[1][2] == -1 && a[2][2] == -1) bingo = true;

    if (a[0][0] == -1 && a[1][1] == -1 && a[2][2] == -1) bingo = true;
    if (a[2][0] == -1 && a[1][1] == -1 && a[0][2] == -1) bingo = true;

    if (bingo) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

int _=[](){
    cin.tie(NULL);
    ios::sync_with_stdio(false);
    return 0;
}();

int main()
{
    int n;
    cin>>n;
    vector<int> si,damn;
    
    for(int i=0;i<n;i++)
    {
        int h;
        cin>>h;
        si.push_back(h);
    }
    damn.push_back(0);
    damn.push_back(abs(si[0]-si[1]));
    
    for(int i=2;i<n;i++)
    {
        damn.push_back(min(damn[i-1]+abs(si[i]-si[i-1]) , damn[i-2] + abs(si[i]-si[i-2])));
    }
    
    cout<<damn[damn.size()-1]<<endl;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 1<<20, mod = 1e9 + 7;
string s;
int n, ans = 1<<30;
int p[maxn], sm[maxn], tt[maxn];
//0 => -1 && 1 => 1
int solve() {//initialize to 1
	memset(p, 0, sizeof p);//prefix sum
	memset(sm, 0, sizeof sm);//suffix min of prefix sums
	int g_min = 0, g_max = 0;
	for(int i = 1; i <= n; i++) {
		p[i] = p[i-1] + (s[i] == '0' ? -1 : 1);
		sm[i] = p[i];
	}
	for(int i = n; i--;) sm[i] = min(sm[i], sm[i+1]);
	g_min = sm[0];
	for(int run = 0, i = 0; i <= n; i++) {
		sm[i] += run;
		p[i] += run;
		if(s[i] == '?' && sm[i] - 2 >= g_min) {
			sm[i] -= 2;
			p[i] -= 2;
			run -= 2;
		}
		g_max = max(g_max, p[i]);
	}
	return g_max - g_min;
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> s;
	n = s.size();
	s = "." + s;
	int ans = 1<<30;
	for(int i = 0; i < 2; i++) {
		ans = min(ans, solve());
		for(auto &c : s) 
			if(c == '0') c = '1';
			else if(c == '1') c = '0';
		ans = min(ans, solve());
		reverse(1 + s.begin(), s.end());
	}
	cout << ans;
}


Measured memory_bytes: 12668
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;



 class Main{
     
    
    
     public static void main(String args[]){
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
         try{
         
        int n =Integer.parseInt(br.readLine());
         for(int j=0; j<n;j++){
             String line = br.readLine();
             ArrayList<Integer> al = new ArrayList<Integer>();
             for(int i=0; i<line.length(); i++) al.add(Integer.parseInt(line.charAt(i)+""));
             Collections.sort(al);
             //System.out.println(Arrays.toString(al.toArray()));
             
             String maxn="";
             for(int i=0;i<line.length();i++){
                 int max=-1; 
                 for(int k=0; k<line.length()-i;k++){
                     if(max<al.get(k))max=al.get(k);
                     
                 }
                 maxn+=max+"";al.remove(al.indexOf(max));
             }
              for(int i=0; i<line.length(); i++) al.add(Integer.parseInt(line.charAt(i)+""));
             Collections.sort(al);
                          String minn="";
             for(int i=0;i<line.length();i++){
                 int min=10; 
                 for(int k=0; k<line.length()-i;k++){
                     if(min>al.get(k))min=al.get(k);
                     
                 }
                 minn+=min+"";al.remove(al.indexOf(min));
             }
             System.out.println(Integer.parseInt(maxn)-Integer.parseInt(minn));

         }
         }catch(Exception e){}
         
     }
     
 }

Measured memory_bytes: 16900
def main():
  N = int(input())
  A = list(map(int, input().split()))
  
  if 0 in A:
    print(0)
    return
  
  prod = 1
  for el in A:
    prod *= el
    if prod > 1e18:
      print(-1)
      return
  print (prod)
  
  
main()

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

using ll = long long;

// Segment-Tree
struct SegmentTree {
  int n;
  vector<ll> dat;
  
  SegmentTree(int _n) {
    init(_n);
  }
  
  void init(int _n) {
    n = 1;
    while (n < _n) n *= 2;
    dat.resize(2 * n - 1, 0);
  }
  
  // i番目の値にxを加算
  void add(ll i, ll x) {
    i += n - 1; // 葉のノード
    dat[i] += x;
    while (i > 0) { // 更新
      i = (i - 1) / 2;
      dat[i] = dat[2 * i + 1] + dat[2 * i + 2];
    }
  }
  
  // [a, b)の和
  // k:ノードの番号 [l, r)がkに対応づいている
  // query(a, b, 0, 0, n)と呼ぶ
  ll query(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r == -1) r = n;
    if (r <= a || b <= l) return 0;
    if (a <= l && r <= b) return dat[k];
    else {
      ll vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
      ll vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
      return vl + vr;
    }
  }
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, q;
  cin >> n >> q;
  
  SegmentTree st(n);
  
  while (q--) {
    ll com, x, y;
    cin >> com >> x >> y;
    if (com == 0) {
      x--;
      st.add(x, y);
    }
    else {
      x--;
      y--;
      cout << st.query(x, y + 1) << '\n';
    }
  }
}


Measured memory_bytes: 4852
#!/usr/bin/env python3
import sys
import math

def solve(N: int):
    print(str(math.ceil(N/2)))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a) begin(a),end(a)
#define FOR(x,val,to) for(int x=(val);x<int((to));++x)
#define FORE(x,val,to) for(auto x=(val);x<=(to);++x)
#define FORR(x,arr) for(auto &x: arr)
#define FORS(x,plus,arr) for(auto x = begin(arr)+(plus); x != end(arr); ++x)
#define FORREV(x,plus,arr) for(auto x = (arr).rbegin()+(plus); x !=(arr).rend(); ++x)
#define REE(s_) {cout<<s_<<'\n';exit(0);}
#define GET(arr) for(auto &i: (arr)) sc(i)
#define whatis(x) cerr << #x << " is " << (x) << endl;
#define e1 first
#define e2 second
#define INF 0x7f7f7f7f
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::vector<std::string> vs;
typedef int64_t ll;
typedef uint64_t ull;
#define umap unordered_map
#define uset unordered_set
using namespace std;
using namespace __gnu_pbds;
 
#ifdef ONLINE_JUDGE
#define whatis(x) ;
#endif
#ifdef _WIN32
#define getchar_unlocked() _getchar_nolock()
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
template<class L, class R> ostream& operator<<(ostream &os, map<L, R> P) { for(auto const &vv: P)os<<"("<<vv.first<<","<<vv.second<<")"; return os; }
template<class T> ostream& operator<<(ostream &os, set<T> V) { os<<"[";for(auto const &vv:V)os<<vv<<","; os<<"]"; return os; }
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os<<"[";for(auto const &vv:V)os<<vv<<","; os<<"]"; return os; }
template<class L, class R> ostream& operator<<(ostream &os, pair<L, R> P) { os<<"("<<P.first<<","<<P.second<<")"; return os; }
inline int fstoi(const string &str){auto it=str.begin();bool neg=0;int num=0;if(*it=='-')neg=1;else num=*it-'0';++it;while(it<str.end()) num=num*10+(*it++-'0');if(neg)num*=-1;return num;}
inline void getch(char &x){while(x = getchar_unlocked(), x < 33){;}}
inline void getstr(string &str){str.clear(); char cur;while(cur=getchar_unlocked(),cur<33){;}while(cur>32){str+=cur;cur=getchar_unlocked();}}
template<typename T> inline bool sc(T &num){ bool neg=0; int c; num=0; while(c=getchar_unlocked(),c<33){if(c == EOF) return false;} if(c=='-'){ neg=1; c=getchar_unlocked(); } for(;c>47;c=getchar_unlocked()) num=num*10+c-48; if(neg) num*=-1; return true;}template<typename T, typename ...Args> inline void sc(T &num, Args &...args){ bool neg=0; int c; num=0; while(c=getchar_unlocked(),c<33){;} if(c=='-'){ neg=1; c=getchar_unlocked(); } for(;c>47;c=getchar_unlocked()) num=num*10+c-48; if(neg) num*=-1; sc(args...); }
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; //s.find_by_order(), s.order_of_key() <- works like lower_bound
template<typename T> using ordered_map = tree<T, int, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 1000001
 
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    sc(n);
    int a[n];
    GET(a);
    int res = 0;
    FOR(i,0,n){
        FOR(x,i+1,n)
            res += a[i]*a[x];
    }
    cout << res;
}



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

int main()
{
    string str;
    getline(cin,str);
    for (int i=0; i<str.length(); i++) {
        str[i]=toupper(str[i]);
    }
    cout << str << endl;
    return 0;
}

Measured memory_bytes: 1176
import math

n,a,b = map(int,input().split())
mod = 10 ** 9 + 7
Xa = 1
Xb = 1
Ya = 1
Yb = 1

for i in range(n,n-a,-1):
    Xa = (Xa * i) % mod

for i in range(1,a+1):
    Ya = (Ya * i) % mod

for i in range(n,n-b,-1):
    Xb = (Xb * i) % mod

for i in range(1,b+1):
    Yb = (Yb * i) % mod

l = int(math.log2(mod)+1)

P = [0] * l
Q = [0] * l
R = [0] * l
P[0] = 2
Q[0] = Ya
R[0] = Yb

for i in range(1,l):
    P[i] = (P[i-1]**2) % mod
    Q[i] = (Q[i-1]**2) % mod
    R[i] = (R[i-1]**2) % mod

#print(P)
#print(Q)
#print(R)

v2 = 1
vYa = 1
vYb = 1
for i in range(l):
    if n & (2**i) == 2**i:
        v2 *= P[i]
        v2 %= mod
    if ((mod-2) & (2**i)) == 2**i:
        vYa *= Q[i]
        vYa %= mod
        vYb *= R[i]
        vYb %= mod

#print(v2,Xa,Ya,vYa,Xb,Yb,vYb)
print((v2-Xa*vYa-Xb*vYb-1)%(10**9+7))



Measured memory_bytes: 3444
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))


K=sum(B)-sum(A) #操作の回数はK回で確定

# b[j]に+1をa[j]に-1に変換する
Plus_Two=K
Minus_One=K


for i in range(N):
    D=B[i]-A[i]
    if D>0:
        Plus_Two-=(D+1)//2
        Minus_One-=D%2
    else:
        D=-D
        Minus_One-=D

if min(Plus_Two,Minus_One)>=0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 73720
#include <cstdio>
#define MAX 100000

int last_num = 0;

void partition(int A[], int start, int end){
	//基準xを設定する
	int x = A[end - 1];

	int i = start;

	for (int j = start; j < end - 1; j++) {
		if(x >= A[j]) {
			int temp = A[i];
			A[i] = A[j];
			A[j] = temp;
			i++;
		} 
	}

	int temp = A[end - 1];
	A[end - 1] = A[i];
	A[i] = temp;
	last_num = i;
}


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

	int r = A[n-1];
	partition(A, 0, n);
	for(int i = 0; i < n - 1; i++) {
		i == last_num ? printf("[%d] ",A[i]) : printf("%d ", A[i]);
	}
	printf("%d\n", A[n-1]);
}


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

int main (){
	string s;
  	cin >> s;
  	int counter = 0;
  	if(s[0] == '1') ++counter;
  	if(s[1] == '1') ++counter;
  	if(s[2] == '1') ++counter;
  	cout << counter << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
#include <sstream>


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



int main() {

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

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

	if (S == U)
	{
		cout << A - 1 <<" "<< B << endl;
	}
	else
	{
		cout << A  << " " << B - 1 << endl;


	}

	return 0;
}




Measured memory_bytes: 256
L=input()
lenl=len(L)
mod=10**9+7

a=0
b=1
newa=0
newb=0

for i in range(lenl):
    if L[i]=="0":
        a,b=a*3%mod,b%mod
    else:
        a,b=(3*a+b)%mod,2*b%mod
    #print(a,b)
print((a+b)%mod)



Measured memory_bytes: 64928
import numpy as np

D=int(input())
C=np.array(list(map(int,input().split())))
minus_list=C.copy()
S=[]
S_sa=[]
sa=[]
for i in range(D):
    s=np.array(list(map(int,input().split())))
    sa=s-minus_list
    S_sa.append(sa)
    S.append(s)
    sama=max(sa)
    for j in range(26):
        if sama==sa[j]:
            minus_list[j]=0
    minus_list+=C
for i in range(D):
    A=S_sa[i].tolist()
    ma=max(S_sa[i])
    print(A.index(ma)+1)


Measured memory_bytes: 27384
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    int n,m;
    cin >> n >> m;
    vector<int> c(m);
    REP(i, m){
        cin >> c[i];
    }
    SORT(c);

    vector<int> minimum(n+1, INF);

    minimum[0] = 0;
    minimum[1] = 1;
    Rep(i, 2, n+1){
        REP(j, m){
            int pi = i - c[j];
            if(pi < 0) continue;
            int tmp = minimum[pi] + 1;
            if(minimum[i] > tmp) minimum[i] = tmp;
        }    
    }

    pr(minimum[n]);
}


Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	int n;
	while(cin>>n)
	{
		if(n<1200)cout<<"ABC"<<endl;
		else if(n<2800)cout<<"ARC"<<endl;
		else cout<<"AGC"<<endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

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

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

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

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

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

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

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

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


int main(){
    int n,a,b;
    cin >> n >> a >> b;
    
    ll ans = 0;
    rep(i,1,n+1){
	ll t = 0,j = i;
	while(j>0){
	    t += j%10;
	    j /= 10;
	}
       
	if(a <= t && t <= b)ans += i;
    }
    P(ans);
    return  0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -std=c++11 */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int inf = 1e9;
const int maxn = 18;
int A[1<<maxn]; PII dp[1<<maxn];

bool cmp(const int i, const int j)
{ return A[i] > A[j]; }

PII best(const PII& a, const PII& b)
{
    set<int> s = { a.first, a.second, b.first, b.second };
    VI x(ALL(s));
    sort(ALL(x),cmp);
    return {x[0],x[1]};
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n; 
    while (cin >> n) {
        FOR(i,0,1<<n)
            cin >> A[i];
        FOR(k,1,1<<n) 
            dp[k] = {0,k};
        FOR(i,0,n) FORR(mask,(1<<n)-1,0) if (mask & (1<<i)) 
            dp[mask] = best(dp[mask], dp[mask^(1<<i)]);
        int pre = 0;
        FOR(k,1,1<<n) {
            int ans =  A[dp[k].first] + A[dp[k].second];
            if (k > 1)
                ans = max(ans,pre);
            cout << ans << endl;
            pre = ans;
        }
    }
    return 0;
}


Measured memory_bytes: 6144
import java.util.Scanner;

class Main {
	static int d;
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a,b,d,r;
		double f,x,y;
			a = scanner.nextInt();
			b = scanner.nextInt();
            x=a;
            y=b;
            
            d = a/b;
            r = a%b;
            f = x/y;
            System.out.println(d+" "+r+" "+String.format("%.8f", f));
	}
}


Measured memory_bytes: 26524