akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

    int A,B,C,D,E,F;

    public void solve() {
        A = nextInt();
        B = nextInt();
        C = nextInt();
        D = nextInt();
        E = nextInt();
        F = nextInt();

        boolean[] a = new boolean[3000 + 1];
        boolean[] b = new boolean[3000 + 1];

        for(int i = 0;i <= 30;i++) {
            for(int j = 0;j <= 30;j++) {
                int k = i * A * 100 + j * B * 100;
                if (k > 0 && k <= F) {
                    a[k] = true;
                }
            }
        }

        for(int i = 0;i <= 3000;i++) {
            for(int j = 0;j <= 3000;j++) {
                int k = i * C + j * D;
                if (k <= F) {
                    b[k] = true;
                }
            }
        }

        double max = 0;
        int ansA = 100 * A;
        int ansB = 0;

        for(int i = 0;i <= 3000;i++) {
            for(int j = 0;j <= 3000;j++) {
                if (a[i] && b[j] && i + j <= F && i / 100 * E >= j) {
                    double k = 100.0 * j / (i + j);
                    if (k >= max) {
                        max = k;
                        ansA = i + j;
                        ansB = j;
                    }
                }
            }
        }

        out.println(ansA + " " + ansB);
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


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

using namespace std;
const int MAX = 1e6;
const int MOD = 1e9+7;

long int expmod(long int n, long int p){
    if(p == 0){
        return 1;
    }else if(p % 2 == 0){
        long int t = expmod(n, p / 2);
        return (t * t) % MOD;
    }else{
        return (n * expmod(n, p - 1)) % MOD;
    }
}

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

    cout << (expmod(10,n) - ((expmod(9,n)*2) % MOD) + expmod(8,n) + MOD) % MOD << endl;


    return 0;
}

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

ll choose(ll a){
  if(a<=1) return 0;
  else return a*(a-1)/2;
}

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> cnt(n);
  rep(i,n) {
    cin >> a[i];
    a[i]--;
    cnt[a[i]] +=1;
  }
  ll sum=0;
  rep(i,n){
    sum += choose(cnt[i]);
  }
  rep(i,n){
    ll ans;
    ans = sum - choose(cnt[a[i]]);
    ans += choose(cnt[a[i]]-1);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 4096
def g;gets.split.map &:to_i;end
while(c,n,m,s,d=g)[0]>0
l=(0..n).map{{}}
m.times{a,b,f=g;l[a][b]=l[b][a]=f}
q=[[0,s]+[0]*c]
p loop{o,i,*a=q.shift
i==d&&(break o)
l.map{|h|h.delete i}
l[i].map{|k,v|t,*u=(a+[v]).sort;q<<[o+v/2+t/2,k]+u}
q.sort!
}
end

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

int main() {
    int A, B, X;
    cin >> X;

    bool finished = false;
    for (int a = -118; a < 120; a++) {
        for (int b = -119; b < 119; b++) {
            if (pow(a, 5) - pow(b, 5) == X) {
                A = a;
                B = b;
                finished = true;
                break;
            }
        }
        if (finished) break;
    }

    printf("%d %d\n", A, B);
    return 0;
}

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

namespace ABC142
{
	class Program
	{
		static void Main(string[] args)
		{
			var line = Console.ReadLine();
			Odds.GetOddProbability(int.Parse(line));
		}
	}

	public class Odds
	{
		public static double GetOddProbability(int N)
		{
			double answer;
			if (N == 1)
			{
				answer = N / N;
				Console.WriteLine(answer);
				return answer;
			}
			if (N % 2 == 0)
			{
				answer = (N / 2.0) / N;
				Console.WriteLine(answer);
				return answer;
			}

			answer = (N / 2 + 1.0) / N;
			Console.WriteLine(answer);
			return answer;
		}
	}

}


Measured memory_bytes: 13140
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
long long int gcd(long long int x, long long int y){
  return y!=0 ? gcd(y, x%y) : x;
}
long long int lcm(long long int x, long long int y){
  return x*y/gcd(x, y);
}
long long int factorial(long long int x){
  return x==0 ? 1 : x*factorial(x-1);
}
int main(){
  int i, j, n, com=0, flag;
  cin >> n;
  char s[n+1], t[n+1];
  cin >> s >> t;
  for(i=1; i<=n; i++){
    flag=0;
    for(j=0; j<i; j++)
      if(s[n-i+j]!=t[j]){
	flag++;
	break;
      }
    if(flag==0) com=i;
  }
  cout << 2*n-com;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a,k=1,ans=0;
	bool e=false;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		if(a==k){
			k++;
			e=true;
		}else{
			ans++;
		}
	}
	if(e){
		cout<<ans<<endl;
	}else{
		cout<<"-1"<<endl;
	}
}

Measured memory_bytes: 384
#include"bits/stdc++.h"
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	map<int,int> x;
	int a,b;
	for(int i=1;i<=n;++i)
		x[i];
	for(int i=1;i<=m;++i){
		cin>>a>>b;
		++x[a];
		++x[b];
	}
	for(auto i:x)
		cout<<i.second<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

main() {
	char s[7];
	int N, i, cnt;
    cnt = 0;
	scanf("%d", &N);

	for (i = 1; i <= N; ++i) {
		if (sprintf(s, "%d", i) % 2 == 1) {
			cnt ++;
		}
	}
	printf("%d\n", cnt);
}



Measured memory_bytes: 1732
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

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

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _int128
#define ld long double
long double PI =3.14159265358979323846;
using ll = unsigned long long;



const ll modo=1e9+7;
const ll inf=LONG_LONG_MAX;
const ll ms=(1e6)+5;

int has[ms]={0};
int ar[ms];

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

    for(i=1;i<=n;i++)
    {
        cin>>ar[i];
        has[ar[i]]++;
    }
    ll ans=0;int j; int j2;
    for(i=1;i<=n;i++)
    {
        ans++;
        has[ar[i]]--;
       // cout<<ans<<"\n";
        for(j=1;j*j<=ar[i];j++)
        {
            if(!(ar[i]%j))
            {
               j2=ar[i]/j;
               if(has[j]||has[j2])
               {
                   --ans; break;
               }
            }
        }

        has[ar[i]]++;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 8236
/* is_contain_in_triangle.cpp
    点が三角形に含まれているか判定する

    verified:
        AOJ 0143
        http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0143
*/

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

using D = double;

// P: 点,座標
using P = std::complex<D>;
namespace std {
bool operator<(const P& a, const P& b) { return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b); }
bool operator>(const P& a, const P& b) { return real(a) != real(b) ? real(a) > real(b) : imag(a) > imag(b); }
}  // namespace std
D dot(const P& a, const P& b) { return real(conj(a) * b); }    // 内積
D cross(const P& a, const P& b) { return imag(conj(a) * b); }  // 外積
D norm(const P& a) { return dot(a, a); }

const D PI = std::acos(-1);
const D EPS = 1e-10;
const D INF = 1e12;

int sgn(D a) { return (a < -EPS) ? -1 : (a > EPS) ? 1 : 0; }  // 比較

/* ccw(a,b,c)
    出力:
    1: a-bから見てcは反時計, -1: a-bから見てcは時計
    2: c-a-bで直線, -2: a-b-cで直線, 0: a-c-bで直線
*/
int ccw(const P& a, const P& b, const P& c) {
    if (sgn(cross(b - a, c - a)) == 1) return 1;         // 1: a-bから見てcは反時計
    if (sgn(cross(b - a, c - a)) == -1) return -1;       //-1: a-bから見てcは時計
    if (sgn(dot(b - a, c - a)) == -1) return 2;          // 2: c-a-bで直線
    if (sgn(norm(c - a) - norm(b - a)) == 1) return -2;  //-2: a-b-cで直線
    return 0;                                            // 0: a-c-bで直線
}

/* is_contain_in_triangle(p, a,b,c)
    p が 三角形abc に含まれていれば true を返す
*/
bool is_contain_in_triangle(const P& p, const P& a, const P& b, const P& c) {
    int r1 = ccw(p, b, c), r2 = ccw(p, c, a), r3 = ccw(p, a, b);
    if (r1 == r2 && r2 == r3 && (r1 == 1 || r1 == -1)) return true;
    return false;
}

int main() {
    int n;
    cin >> n;
    vector<int> ans(n);
    for (int i = 0; i < n; i++) {
        D x, y;
        P p[3];
        for (int j = 0; j < 3; j++) {
            cin >> x >> y;
            P tmp(x, y);
            p[j] = tmp;
        }
        cin >> x >> y;
        P k(x, y);
        cin >> x >> y;
        P s(x, y);

        if (is_contain_in_triangle(k, p[0], p[1], p[2]) ^ is_contain_in_triangle(s, p[0], p[1], p[2])) {
            ans[i] = 1;
        } else {
            ans[i] = 0;
        }
    }

    for (int i = 0; i < n; i++) {
        if (ans[i]) {
            cout << "OK\n";
        } else {
            cout << "NG\n";
        }
    }
    return 0;
}



Measured memory_bytes: 3248
/* --- author: dxm --- */
#include<bits/stdc++.h>
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define fst first
#define snd second
typedef long long ll;
inline void Fail(){printf("0");exit(0);}

const int maxn=5005;
int n,k;
char c[maxn];
string s;
vector<string>ans;

int main(){
	scanf("%s%d",c,&k);s=c;n=s.size();
	rep(i,n)for(int j=i;j<n;j++){
		if(j-i+1>=10)continue;
		ans.pb(s.substr(i,j-i+1));
	}
	sort(ans.begin(),ans.end());
	ans.resize(unique(ans.begin(),ans.end())-ans.begin());
	printf("%s",ans[k-1].c_str());
	return 0;
}

/*
Input:
-----------------
Output:
*/

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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> ans(N+1, 0);
    for(int n=1; n<N; n++) {
        int A;
        cin >> A;
        ans[A]++;
    }
    for(int n=1; n<=N; n++) {
        cout << ans[n] << endl;
    }
    

    return 0;
    
}

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

int main() {
  // 入力
  string S;
  cin >> S;
  
  // 配列に変換
  vector<string> tile(S.size());
  for (int i = 0; i < S.size(); i++) {
    tile.at(i) = S.substr(i, 1);
  }
  
  // 正解の配列
  vector<string> a(S.size());
  vector<string> b(S.size());
  for (int i = 0; i < S.size(); i++) {
    if (i % 2 == 0) {
      a.at(i) = "0";
      b.at(i) = "1";
    } else {
      a.at(i) = "1";
      b.at(i) = "0";
    }
  }
  
  // 判定
  int count_a = 0;
  int count_b = 0;
  for (int i = 0; i < S.size(); i++) {
    if (tile.at(i) != a.at(i)) {
      count_a++;
    }
    if (tile.at(i) != b.at(i)) {
      count_b++;
    }
  }
  
  // 出力
  cout << min(count_a, count_b) << endl;
  
  return 0;
}

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

int main () {
  int N,K;
  cin >> N >> K;
  
  vector<int> sunuke(N);
  
  for (int i=0;i<K;i++){
    int d;
    cin >> d;
    for (int j=0;j<d;j++){
      int A;
      cin >> A;
      sunuke.at(A-1)++;
    }
  }
  int count;        
  for (int k=0;k<N;k++){
    if (sunuke.at(k)==0){
      count++;
    }
  }
  cout << count <<endl;
}

Measured memory_bytes: 3628
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();
		int n = Integer.parseInt(str);

		int ans = 0;
		int id = n;

		for (int i = 1; i <= n; i++) {
			if (i % 2 == 0) {
				int num = i;
				int count = 0;
				while (num % 2 == 0) {
					num /= 2;
					count++;
				}
				if (count > ans) {
					ans = count;
					id = i;
				}
			}
		}
		System.out.println(id);
	}
}

Measured memory_bytes: 22740
#include <iostream>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <utility>

#define repd(i,a,b); for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define ll long long int
 
 
using namespace std;
int main() {
  int n,k; cin >> n >> k;
  int h[n];
  rep(i,n){
    cin >> h[i];
  }
  sort(h,h+n);
  
  int ans=1000000001;
  for(int j=0;j<(n-k+1);j++){
    ans = min(ans,(h[j+k-1]-h[j]));
  }
              
              cout << ans;
              
 
 return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template<typename T> void swap(T *t1, T *t2){ T* tmp=t1; t1=t2; t2=tmp;}
Int tmpi = 0;
double tmpd = 0.0;


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

    Int dist[5], k;
    for(Int i=0; i<5; i++){
        cin >> dist[i];
    }
    cin >> k;

    Int cnt = 0;
    for(Int i=0; i<5; i++){
        for(Int j=i+1; j<5; j++){
            if(dist[j]-dist[i] <= k){
                cnt++;
            }
        }
    }
    if(cnt == 10){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int main(){
	int N;cin>>N;
	string s;
	map<char,long> cnt;vector<char> march={'M','A','R','C','H'};
	rep(i,0,N){ cin>>s; cnt[s[0]]++; }
	long ans=0;
	rep(i,0,3)rep(j,i+1,4)rep(k,j+1,5){
		ans+=cnt[march[i]]*cnt[march[j]]*cnt[march[k]];
	}cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<set>
#include<map>
#include<bitset>
#include<ctime>
#include<queue>
using namespace std;
#define int long long
#define pii pair <int, int>
#define XX first
#define YY second

// constants:
const int mn = 200005;
const int mod = 1000000007;
const long long inf = 4444444444444444444;
const int sminf = 1111111111;
const bool is_multitest = 0;
const bool is_interactive = 0;

// i/o methods:
const bool input_from_file = 0;
const bool output_to_file = 0;
#define filename ""
#define in_extension "inp"
#define out_extension "out"

// data preprocessing: (e.g.: divisor generating, prime sieve)
void preprocess()
{
    
}

// global variables:
int n;
vector <int> dsk[mn];
int par[mn];
void dfs(int u) {
    for (int v:dsk[u]) if (v!=par[u]) {
        par[v]= u;
        dfs(v);
    }
}
// main solution goes here:
void execute(int test_number)
{
    cin>>n;
    int u, v;
    for (int i=1; i<n; i++) {
        cin>>u>>v;
        dsk[u].push_back(v);
        dsk[v].push_back(u);
    }
    dfs(1);
    int ans = 0;
    for (int i=1; i<=n; i++) {
        int p = par[i];
        // cerr<<i<<" "<<p<<"\n";
        if (p==0) ans += i*(n-i+1);
        else if (p < i) ans += (i-p) * (n-i+1);
        else ans += i*(p-i);
    }
    cout<<ans;
    
}
// REMEMBER TO CHOOSE TEST METHODS
// PLEASE REMOVE cout AND cerr DEBUG LINES BEFORE SUBMITTING PROBLEMS
// Solution by low_



















signed main()
{
#ifdef lowie
    if (!is_interactive)
    {
        freopen("test.inp", "r", stdin);
        freopen("test.out", "w", stdout);
    }
#else
    if (input_from_file) freopen(filename"."in_extension, "r", stdin);
    if (output_to_file) freopen(filename"."out_extension, "w", stdout);
#endif
    if (!is_interactive)
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
    }

    preprocess();
    int ntest;
    if (is_multitest) cin >> ntest;
    else ntest = 1;

    for (int testno = 1; testno <= ntest; testno++)
    // use for instead of while to serve facebook hacker cup test format
    {
        execute(testno); // only start coding in this function, not in main
    }
}
// Template by low_
// Contact me via mail: ttuandung1803@gmail.com
// ...or codeforces: www.codeforces.com/profiles/low_
// ...or if you're interested in food: www.instagram.com/lowie.exe/

Measured memory_bytes: 25472
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
#include <iomanip>
 
#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;
 
using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0ULL); }
 
int main() {
  //std::cout << std::fixed << std::setprecision(10);
  ull n;
  cin >> n;

  vector<ull> h;
  each(i, n) {
    ull tmp;
    cin >> tmp;
    h.push(tmp);
  }

  ull maxv = 0;
  each(i, n) {
    if (i == 0) {
      maxv = h[i];
      continue;
    }

    const auto current = h[i];
    if (maxv <= current) {
      maxv = current;
      continue;
    } else if ((maxv - 1) == current) {
      continue;
    } else {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}


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

signed main(void)
{
	int n, a, b, cnt;
	cin >> n >> a >> b;
	cnt = 0;
	rep(i, n) 
	{
		int t;
		cin >> t;
		if (t < a || t >= b)
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#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 fcout cout << fixed << setprecision(10)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


string S;
int Q;


signed main(){
    cin >> S;
    cin >> Q;
    bool r = true;
    deque<char> dq;
    for(auto c : S) dq.push_back(c);
    rep(i, 0, Q){
        int T;
        cin >> T;
        if(T == 1) r = !r;
        else {
            int F;
            char C;
            cin >> F >> C;
            if(F == 1){
                if(r) dq.push_front(C);
                else dq.push_back(C);
            }
            else {
                if(r) dq.push_back(C);
                else dq.push_front(C);
            }
        }
    }

    if(r) while(!dq.empty()) cout << dq.front(), dq.pop_front();
    else while(!dq.empty()) cout << dq.back(), dq.pop_back();
    cout << endl;

    return 0;
}

Measured memory_bytes: 896
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    string S;
    int Q;
    cin >> N >> S >> Q;
    vector<set<int>> se(26);
    rep(i, N) { se[S[i] - 'a'].insert(i + 1); }
    rep(i, 26) se[i].insert(INF);
    rep(i, Q) {
        int q;
        cin >> q;
        if(q == 1) {
            int idx;
            cin >> idx;
            char c;
            cin >> c;
            se[S[idx - 1] - 'a'].erase(idx);
            S[idx - 1] = c;
            se[c - 'a'].insert(idx);
        } else {
            int cnt = 0;

            int l, r;
            cin >> l >> r;
            rep(j, 26) {
                int right = *se[j].lower_bound(l);
                if(right <= r)
                    cnt++;
            }
            cout << cnt << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 24196
def pmod(a,b,m):
  ret=1
  while b>0:
    if b&1:
      ret=(ret*a)%m
    a=(a*a)%m
    b=b>>1
  return ret
  
def fmod(n,m):
  ret=1
  for i in range(n,0,-1):
    ret=(ret*i)%m
  return ret
 
def cmod(n,r,m):
  ret=1
  for i in range(r):
    ret=(ret*(n-i))%m
  return (ret*pmod(fmod(r,m),m-2,m))%m

n,k=map(int,input().split())
ans=[0]*(k+1)
mod=10**9+7
for i in range(1,k+1):
  if n-k-(i-1)<0:
    break
  ans[i]=(cmod(k-1,i-1,mod)*cmod(n-k+1,n-k-(i-1),mod))%mod
for i in range(1,k+1):
  print(ans[i]%mod)

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

struct edge{int to; int cost;};
typedef pair<int,int> P;

void dijkstra(int s,const vector<vector<edge>>&G, vector<int>&d, vector<int> &prev){
    priority_queue<P,vector<P>,greater<P>> que;
    fill(d.begin(),d.end(),INF);
    fill(prev.begin(),prev.end(),-1);
    d[s]=0;
    que.push(P(0,s));
    while(!que.empty()){
        P p=que.top();que.pop();
        int v=p.second;
        if(d[v]<p.first)continue;
        for(int i=0;i<G[v].size();i++){
            edge e=G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                prev[e.to]=v;
                que.push(P(d[e.to],e.to));
            }
        }
    }
}

int main(){
    int N, M; cin >> N >> M;
    vector<vector<edge>> G(N);
    REP(i,M){
        int s, t;
        cin >> s >> t; s--; t--;
        G[s].push_back((edge){t,1});
    }
    vector<vector<int>> d(N,vector<int>(N)), p(N,vector<int>(N));
    REP(i,N){
        dijkstra(i,G,d[i],p[i]);
    }
    int cycle_length = 1<<30;
    int s=-1, t=-1;
    REP(i,N)REP(j,N){
        if(i!=j && d[i][j]!=INF && d[j][i]!=INF && d[j][i]+d[i][j]<cycle_length){
            cycle_length = d[j][i] + d[i][j];
            s=i; t=j;
        }
    }
    int u=s, v=t;
    set<int> Se;
    while(v!=s){
    	v=p[s][v];
        Se.insert(v+1);
    }
    while(u!=t){
    	u=p[t][u];
        Se.insert(u+1);
    }
    if(Se.empty()) cout << -1 << endl;
    else{
    	cout << (int)Se.size() << endl;
    	for(int e:Se){
        	cout << e << endl;
        }
    }
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n, m; cin>>n>>m;
  vector<vector<pll>> g(n, vector<pll>());
  rrep1(i, n-1)g[i].push_back({0, i-1});
  rep(i, m){
    ll l, r, c; cin>>l>>r>>c; l--;r--;
    g[l].push_back( {c, r} );
  }

  priority_queue<pll, vector<pll>, greater<pll>> pq;
  vector<ll> d(n);
  rep(i, n)d[i]=INF;
  d[0]=0;
  pq.push( {0, 0} );
  while(pq.size()){
    auto p = pq.top();pq.pop();
    if(p.first > d[p.second])continue;
    d[p.second] = p.first;
    for(auto np: g[p.second]){
      if(d[np.second] <= np.first+p.first)continue;
      d[np.second] = np.first+p.first;
      pq.push( {d[np.second], np.second} );
    }
  }

  cout<<(d[n-1] == INF ? -1 : d[n-1])<<endl;

  return 0;
}

Measured memory_bytes: 10104
#include <iostream>
//#include <math.h>
#include <set>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define space ' '
#define pll pair<ll,ll>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 5000;

int num[maxn][maxn]={0};

int main(){
    
    int n;
    string t;
    int ans = 0;
    
    cin >> n;
    cin >> t;
    
    rep(k,n){
        string s;
        if(k==0)s=t;
        else s = t.substr(k,t.size()-k);
        
        num[k][0]=s.size();
        
        int i=1,j=0;
        while(i<s.size()){
            while(i+j<s.size()&&s[j]==s[i+j])j++;
            num[k][i]=j;
            if(j==0){i++;continue;}
            int z=1;
            while(i+z<s.size()&&z+num[k][z]<j)num[k][i+z]=num[k][z],z++;
            i+=z,j-=z;
        }
    }
    
    rep(i,n){
        for(int j=1;j<t.size()-i;j++){
            if(num[i][j]-1<j)ans=max(ans,num[i][j]);
        }
    }
    
    cout << ans<<endl;
    
    return 0;
}


Measured memory_bytes: 96768
def printChessBoard(h,w)
  h.to_i.times{|i|
    black = i % 2
    w.to_i.times{|j|
      print (black == 0)? "#" : "."
      black = (black + 1) % 2
    }
    print "\n"
  }
end

while true
  h,w = gets.chomp.split
  break if h.to_i == 0 && w.to_i == 0
  printChessBoard(h,w)
  puts "\n"
end

Measured memory_bytes: 6108
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy
 
## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))
 
N,K=map(int, input().split())
A=list(map(int, input().split()))

D = collections.Counter(A)
Dval = list(D.values())
Dval.sort()

ans = 0
for i in range(len(Dval)-K):
    ans += Dval[i]

print(ans)

Measured memory_bytes: 124140
/*
 * 题目大意：给定 01 串 s，每次可以进行如下操作：
 * 选择前两个字符中的一个删去，将另一个移到 s 的任意位置，
 * 问经过若干次操作后可以得到多少个不同的串。
 * |s| <= 300
 *
 * 算法：
 * 令 f[i][z][o] 表示前 i 位被操作选中过，剩下 z 个 0 和 o 个 1 可不可以达到
 * 令 g[i][z][o] 表示有多少个字符串包含 s[i:n] 为子序列，但是不包含 s[i+1:n] 为子序列，且有 z 个 0 和 o 个 1 的方案数
 */

#include <bits/stdc++.h>

using namespace std;

const int mod = 998244353, maxn = 310;

bool f[maxn][maxn][maxn], h[maxn][maxn][maxn];
int g[maxn][maxn][maxn], cntz[maxn], cnto[maxn];

void upd(int &x, const int &y) {
	x = (x + y < mod ? x + y : x + y - mod);
	return;
}

int main() {
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int n = s.size(), ans = 0;
	for (int i = n - 1; i >= 0; --i) {
		if(s[i] == '0') cntz[i] = cntz[i + 1] + 1, cnto[i] = cnto[i + 1];
		else cntz[i] = cntz[i + 1], cnto[i] = cnto[i + 1] + 1;
	}
	f[0][0][0] = 1;
	for (int i = 0; i <= n; ++i) for (int z = n - 1; z >= 0; --z) for (int t, o = n - 1; o >= 0; --o) if(t = f[i][z][o]) {
		if(z >= 2) f[i][z - 1][o] = 1;
		if(o >= 2) f[i][z][o - 1] = 1;
		if(z >= 1 && o >= 1) f[i][z - 1][o] = f[i][z][o - 1] = 1;
		if(i < n) {
			if(s[i] == '0') {
				if(z >= 1) f[i + 1][z][o] = 1;
				if(o >= 1) f[i + 1][z + 1][o - 1] = f[i + 1][z][o] = 1;
				if(i + 1 < n) {
					if(s[i + 1] == '0') f[i + 2][z + 1][o] = 1;
					else f[i + 2][z + 1][o] = f[i + 2][z][o + 1] = 1;
				}
			}
			else {
				if(o >= 1) f[i + 1][z][o] = 1;
				if(z >= 1) f[i + 1][z - 1][o + 1] = f[i + 1][z][o] = 1;
				if(i + 1 < n) {
					if(s[i + 1] == '1') f[i + 2][z][o + 1] = 1;
					else f[i + 2][z + 1][o] = f[i + 2][z][o + 1] = 1;
				}
			}
		}
	}
	g[n][0][0] = 1;
	for (int i = n; i > 0; --i) for (int z = 0; z <= n; ++z) for (int t, o = 0; o + z <= n; ++o) if(t = g[i][z][o]) {
		if(s[i - 1] == '0') upd(g[i - 1][z + 1][o], t), upd(g[i][z][o + 1], t);
		else upd(g[i - 1][z][o + 1], t), upd(g[i][z + 1][o], t);
	}
	for (int i = n; i >= 0; --i) for (int z = 0; z <= n; ++z) for (int o = 0; o + z <= n; ++o) {
		h[i][z][o] = h[i + 1][z][o] | (z >= cntz[i] && o >= cnto[i] && f[i][z - cntz[i]][o - cnto[i]]);
		if(h[i][z][o]) upd(ans, g[i][z][o]);
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

#define int long long

const int N = 105;
const int INF = 1e15;
const int W = 1e5 + 10;
int dp[N][W], n, w, weight[N], value[N];

//minimum weight to gain points equal to val
//sol(idx,val) -> min weight to gain points equal to 'val' using [idx....n] numbered weights
int sol(int idx, int val) {
    if (idx == n + 1) {
        if (val == 0) return 0;
        return INF;
    }
    int &ans = dp[idx][val];
    if (ans != -1) return ans;
    ans = INF;
    ans = min(sol(idx + 1, val), (val - value[idx] >= 0) ? (sol(idx + 1, val - value[idx]) + weight[idx]) : INF);
    return ans;
}

void solve() {
    cin >> n >> w;
    for (int i = 1; i <= n; i++) cin >> weight[i] >> value[i];
    memset(dp, -1, sizeof(dp));
    int ans = 0;
    for (int i = 0; i < W; i++) {
        int wgot = sol(1, i);
        if (wgot <= w) ans = i;
    }
    cout << ans << "\n";
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    //cin>>t;
    while (t--) {
        solve();
    }
}

Measured memory_bytes: 82304
#include <iostream>
    #include <string>
    #include <set>  
    #include <algorithm>
    #include <vector>
    #include <cmath>
    #include <queue>
    #include <deque>
    #include <cstring>
    #include <cstdio>
    #include <map>
    #include <numeric>
    #include <cassert>
    #include <iomanip>
    #include <sstream>
using namespace std;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
char a[808][808];
int h,w,k;
int dis[808][808];
queue<pair<int,int> > Q;
int main()
{
	cin>>h>>w>>k;
	memset(dis,-1,sizeof(dis));
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
		{
			cin>>a[i][j];
			if(a[i][j]=='S')
			{
				Q.push(make_pair(i,j));
				dis[i][j]=0;
			}
		}
	while(!Q.empty())
	{
		pair<int,int> x=Q.front();
		Q.pop();
		for(int i=0;i<4;i++)
		{
			int xx=x.first+dx[i],yy=x.second+dy[i];
			if(xx<0||yy<0||xx>=h||yy>=w)continue;
			if(a[xx][yy]=='.'&&dis[xx][yy]==-1)
			{
				Q.push(make_pair(xx,yy));
				dis[xx][yy]=dis[x.first][x.second]+1;
			}
		}
	}
	int ans=1e9+7;
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
			if(dis[i][j]!=-1&&dis[i][j]<=k)
			{
				int mn=min(min(i,j),min(h-i-1,w-j-1));
				ans=min(ans,(mn+k-1)/k+1);
			}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
const int mx=1e4+10;
uli a[mx];
int main(){
  int n;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%lld",a+i);
  }
  uli sp=0,sn=0;
  for(int i=0;i<n;i++){
    uli x;
    scanf("%lld",&x);
    a[i]-=x;
    if(a[i]>0)sp+=a[i];
    else sn+=(-a[i])/2;
  }
  if(sn>=sp)puts("Yes");
  else puts("No");

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>

using namespace std;
int main()
{
	int n,a[200010];
	long long sum[200010]={0};
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	sum[0] = a[0];
	for(int i=1; i<n; i++){
		sum[i] = sum[i-1] + a[i];
	}
	sort(sum,sum+n);
	long long ans=0,cnt=0;
	for(int i=0; i<n; i++){
		if(sum[i] == 0)
			cnt++;
	}
	ans += (cnt * (cnt + 1)) / 2;
	cnt = 0;
	int tmp = -2;
	for(int i=0; i<n-1; i++){
		if(sum[i] == sum[i+1]){
			if(sum[i] != 0){
				cnt++;
				tmp = i;
				if(i == n-2)
					ans += (cnt * (cnt + 1)) / 2;
			}
		}
		else if(tmp == i - 1){
			ans += (cnt * (cnt + 1)) / 2;
			cnt = 0;
		}
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(), v.end()
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define um unordered_multiset
#define us unordered_set
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define cc continue
#define bb break
#define rem 1000000007
#define debug(n1) cout<<"debug... "<<n1<<"\n"
#define PI 3.141592653589793238462643383279502
//fflush(stdin);
// do {
// // process permutation
// } while (next_permutation(permutation.begin(),permutation.end()));
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ld a,b,x;
    cin>>a>>b>>x;
    ld v=(a*a*b)/2;
    ld ang=atan2(b,a)*180 /PI;
    if (x>v)
    {
        cout<<fixed<<setprecision(15)<<atan((b-(2*(x-v)/(a*a)))/a)*180/PI;
    }
    else if (x==v)
    {
        cout<<fixed<<setprecision(15)<<ang;
    }
    else
    {
        cout<<fixed<<setprecision(15)<<atan(b*b*a/(2*x))*180/PI;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int q,h,s,d;
  cin >>q >>h >>s >>d;
  long long int n;
  cin >> n;
  if (n==1)cout << min(q*4,min(h*2,s)) <<endl;
  else if (n%2==0) cout << n/2*min(q*8,min(h*4,min(s*2,d))) <<endl;
  else cout << (n-1)/2*min(q*8,min(h*4,min(s*2,d)))+min(q*4,min(h*2,s)) <<endl;
}


Measured memory_bytes: 384
N,M=map(int,input().split())
AC={}
WA={}
for i in range(M):
    a,b=input().split()
    if not(a in AC.keys()):
        if b=="AC":
            AC[a]=1
        else:
            if a in WA.keys():
                WA[a]+=1
            else:
                WA[a]=1
y=0
for i in AC.keys():
    if i in WA.keys():
        y+=WA[i]
print(sum(AC.values()),y)

Measured memory_bytes: 17116
import java.util.*;

import static java.lang.System.*;

class Main {
	public static Scanner sc = new Scanner(in);
	public static Random rand=new Random();

	int m=256;

	double EPS=1E-6;
	public void run() {
		while(true){
			int N=sc.nextInt();
			if(N==0)return;

			int[] l=nextIntArray(N);

			double resh=Double.MAX_VALUE;
			int ress=-1,resa=-1,resc=-1;
			for(int s=0;s<=15;s++)
				for(int a=0;a<=15;a++)
					for(int c=0;c<=15;c++){
						int[] r=new int[N+1];
						int[] o=new int[m];
						r[0]=s;
						for(int i=1;i<=N;i++){
							r[i]=(a*r[i-1]+c)%m;
							o[(r[i]+l[i-1])%m]++;
						}

						double h=0;
						for(int i=0;i<m;i++){
							if(o[i]!=0)h-=((double)o[i]/N)*Math.log((double)o[i]/N);
						}
						if(h+EPS<resh){
							resh=h;
							ress=s;
							resa=a;
							resc=c;
						}
					}
			ln(ress+" "+resa+" "+resc);
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}

	public int[] nextIntArray(int n){
		int[] res=new int[n];
		for(int i=0;i<n;i++){
			res[i]=sc.nextInt();
		}
		return res;
	}
	public static void pr(Object o) {
		out.print(o);
	}
	public static void ln(Object o) {
		out.println(o);
	}
	public static void ln() {
		out.println();
	}
}

Measured memory_bytes: 90040
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    H, W, A, B = map(int, input().split())
    [print('0'*A + '1'*(W-A)) for _ in range(B)]
    [print('1'*A + '0'*(W-A)) for _ in range(H-B)]

if __name__ == "__main__":
    main()


Measured memory_bytes: 9448
#include<iostream>
using namespace std;
char s1,s2;
int main()
{
	cin>>s1>>s2;
	if(s1>s2)
	{
		cout<<">";
	}
	if(s1<s2)
	{
		cout<<"<";
	}
	if(s1==s2)
	{
		cout<<"=";
	}
	cout<<endl;
}

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

int main(){
  int K,S,s;
  cin >> K >>S;
  int count=0;
  for(int i=0;i<=K;i++){
    for(int j=0;j<=K;j++){
      s = S;
      s =s- (i+j);
      if(s<=K&&0<=s){
        count++;
      }
    }
  }
  cout << count<< endl;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
    return string(1, val);
}

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

    int res = 0;
    for(int i = 1; i <= 100; ++i) {
        for(int k = 2; k <= 100; ++k) {
            for(int m = 1; m <= X; ++m) {
                int tmp = pow(i, k);
                if(tmp == m) {
                    if(res < tmp) {
                        res = tmp;
                    }
                }
            }
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define fill(x, y)     memset(x, y, sizeof(y))
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define rep(i, x, y)   for (__typeof(x) i = x; i <= y; i ++)
#define repi(i, x, y)  for (__typeof(x) i = x; i >= y; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
const   int            inf = 0;
const   double         eps = 0;
const   int            ms  = 0;
const   int            md  = 0;


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	double pi = 2*acos(0.0);
	int a,b,h,m;
    cin>>a>>b>>h>>m;
//    if(h == 0) h = 12;
//    if(m == 0)
//    h += m/60;
//    double deg = abs(h - (double)m*11/60)*30;
//    cout<<deg<<endl;
    double res = sqrt(a*a + b*b - 2*a*b*cos(abs(h - (double)m*11/60)*pi/6));
    cout<<fixed<<setprecision(12)<<res<<endl;


	return 0;
}


Measured memory_bytes: 4204
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using Graph= vector<vector<int>>;
const int TBC= INT_MIN;
const int Codd = -1;
const int Ceven= 0;

void BFS(const Graph &gph, vector<int> *checked, int *Nodd){
  const int N= gph.size();

  queue<int> bfs;
  bfs.push(0);
  checked->at(0)= Ceven;

  while( !bfs.empty() ){
    int p= bfs.front();
    bfs.pop();
    int Dp= checked->at(p);
    if(Dp%2 != 0) *Nodd+= 1;
    for(const auto& v:gph.at(p)){
      if(checked->at(v)==TBC){
        bfs.push(v);
        checked->at(v)= (Dp%2==0) ? Codd
                                  : Ceven; // 点pと点vで偶奇が入れ替わることに注意
      }
    }
  }

  return;
}

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

  Graph tree(N);
  vector<int> memo(N, TBC);
  int Nodd= 0;

  int buf1,buf2;
  for(int i=0; i<N-1; i++){
    cin >> buf1 >> buf2;
    buf1--; buf2--; // 1-indexed -> 0-indexed
    tree.at(buf1).emplace_back(buf2);
    tree.at(buf2).emplace_back(buf1);
  }

  BFS(tree, &memo, &Nodd);
  int Neven= N-Nodd;
  vector<queue<int>> labels(3);
  for(int i=1; i<=N; i++){
    labels.at(i%3).push(i);
  }

  if(3*Nodd <= N || 3*Neven <= N){// 奇数距離,偶数距離がどちらかに偏っている場合
    int Nminor= (Nodd < Neven) ? Nodd
                               : Neven;
    int Cminor= (Nodd < Neven) ? Codd
                               : Ceven;
    int Cmajor= (Nodd < Neven) ? Ceven
                               : Codd;
    int cnt_minor= 0;
    int i=0;
    while(cnt_minor < Nminor){// 少数派に3の倍数のラベルをつける
      if(memo.at(i)==Cminor){
        cnt_minor++;
        memo.at(i)= labels.at(0).front();
        labels.at(0).pop();
      }
      i++;
    }
    for(int i=0; i<N; i++){// 多数派には余ったラベルをつける
      if(memo.at(i)==Cmajor){
        if(!labels.at(0).empty()){
          memo.at(i)= labels.at(0).front();
          labels.at(0).pop();
        }
        else if(!labels.at(1).empty()){
          memo.at(i)= labels.at(1).front();
          labels.at(1).pop();
        }
        else{
          memo.at(i)= labels.at(2).front();
          labels.at(2).pop();
        }
      }
    }
  }
  else{// 奇数距離,偶数距離が拮抗している場合
    int cnt_odd = 0;
    int i=0;
    while(cnt_odd < Nodd){// 片側で3の倍数+1のラベルを使い切る(足りない分は3の倍数のラベルをつける)
      if(memo.at(i)==Codd){
        cnt_odd++;
        if(!labels.at(1).empty()){
          memo.at(i)= labels.at(1).front();
          labels.at(1).pop();
        }
        else{
          memo.at(i)= labels.at(0).front();
          labels.at(0).pop();
        }
      }
      i++;
    }

    for(int i=0; i<N; i++){// 他方には余ったラベルをつける
      if(memo.at(i)==Ceven){
        if(!labels.at(0).empty()){
          memo.at(i)= labels.at(0).front();
          labels.at(0).pop();
        }
        else{
          memo.at(i)= labels.at(2).front();
          labels.at(2).pop();
        }
      }
    }
  }

  for(int i=0; i<N-1; i++){
    cout << memo.at(i) <<" ";
  }
  cout << memo.at(N-1) << endl;
}

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

const int M=105;
char a[M];
bool C=false,F=false;

int main()
{
	gets(a);
	int len=strlen(a);
	for (int i=0;i<len;++i)
		if (a[i]=='C')
			C=true;
		else if (C&&a[i]=='F')
			F=true;
	if (F)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	   public static void main(String[] args){
			
			Scanner scan = new Scanner(System.in);
			int[] num = new int[6];
			for(int i=0; i<6; i++){ //各6面の整数
				num[i] = scan.nextInt();
			}
			dice d = new dice(num);
			char[] b = scan.next().toCharArray(); //"S","N","W","E"を入力
			for(char ch: b){
				d.roll(ch);
			}
			System.out.println(d.Top()); //結果
	    }
	}

	class dice{
		int[] dice;
		public dice(int[] a){
			dice = new int[6];
			for(int i=0; i<6; i++){
				dice[i] = a[i];
			}
		}
		public void roll(char c){
			int tmp = 0;
			switch(c){
				case 'N':
					tmp = dice[0];
					dice[0] = dice[1];
					dice[1] = dice[5];
					dice[5] = dice[4];
					dice[4] = tmp;
					break;
				case 'W':
					tmp = dice[0];
					dice[0] = dice[2];
					dice[2] = dice[5];
					dice[5] = dice[3];
					dice[3] = tmp;
					break;
				case 'S':
					tmp = dice[0];
					dice[0] = dice[4];
					dice[4] = dice[5];
					dice[5] = dice[1];
					dice[1] = tmp;
					break;
				case 'E':
					tmp = dice[0];
					dice[0] = dice[3];
					dice[3] = dice[5];
					dice[5] = dice[2];
					dice[2] = tmp;
					break;
			}
		}
		public int Top(){
			return dice[0];  //上面の整数を戻り値として設定
		}
	}



Measured memory_bytes: 26356
n=int(input())
L=[]
for i in range(n):
    L.append(list(map(int,input().split())))

if n==2:
    print(((L[0][0]-L[1][0])**2+(L[0][1]-L[1][1])**2)**0.5)
else:
    s=0
    for p in range(n):
        for q in range(n):
            s+=((L[p][0]-L[q][0])**2+(L[p][1]-L[q][1])**2)**0.5
    print(s*((n-1)/(n*(n-1))))

Measured memory_bytes: 3188