akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)
#define fi first
#define se second

using ll = long long;
using v_int = std::vector<int>;
using v2_int = std::vector<v_int>;
using v_ll = std::vector<ll>;
using v2_ll = std::vector<v_ll>;
using v_string = std::vector<std::string>;
using v_bool = std::vector<bool>;
using v2_bool = std::vector<v_bool>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;

const double PI = 3.1415926535897932;
const int INF = (int)1e9;
const ll LINF = (ll)1e18;
const ll MOD = 1000000007;
const int dr[4] = {1, 0, -1, 0};
const int dc[4] = {0, 1, 0, -1};

using namespace std; 

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p)
{
    return o << "{" << p.first << "," << p.second << "}";
}

template<typename T, typename U, typename V> inline
ostream& operator<<(ostream &o, tuple<T,U,V> &p)
{
    return o << "{" << get<0>(p) << "," << get<1>(p) << "," << get<2>(p) << "}";
}

template<typename T> inline
istream& operator>>(istream &is, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) {
        is >> v[i]; 
    }
    return is;
}

template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) { 
        os << v[i];
        if(i != len-1) { os << ","; } 
    } 
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }

template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

void solve(int n, v_int &a) 
{
    for(int i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            a[i] += 1;
            if(i * i != n) { 
                a[n/i] += 1;
            }
        }
    }
}

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

    v_int a(n+1);
    irep(i, n) {
        cin >> a[i+1];
    }
    
    v_int sum(n+1);
    v_int b(n+1);
    
    int m = 0;
    for(int i = n; i > 0; i--) {
        if(sum[i]%2 != a[i]) {
            solve(i, sum);
            b[i] = 1;
            m++;
        }
    }
    
    cout << m << endl;
    for(int i = 1; i <= n; i++) {
        if(b[i]) {
            cout << i << " ";
        }
    }
    
    return 0;
}


/*atcoder*/


Measured memory_bytes: 5556
/* Simplicity and Goodness */
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 1e3+2;

/*  dp[i][j] : minimum cost rerquired to put the monster's health to j 
               using first i spells.
*/

const int H = 1e4+2;

int dp[N][H];

void solve()
{
    int h, n;
    scn(h); scn(n);

    pair<int, int> p[n+1];

    rep(i, 1, n+1)
    scn(p[i].F), scn(p[i].S);

    rep(i, 0, H)
    dp[0][i] = 1e9;

    dp[0][0] = 0;

    for(int i=1; i<=n; i++) {
        for(int j=0; j<=h; j++) {
            if(j == 0) {
                dp[i][0] = 0;
            } else if(p[i].F <= j) {
                dp[i][j] = min(dp[i-1][j], dp[i-1][j - p[i].F] + p[i].S);
            } else {
                dp[i][j] = min(dp[i-1][j], p[i].S);
            }
            // Using the same spell multiple times.
            if(p[i].F <= j) {
                dp[i][j] = min(dp[i][j], dp[i][j - p[i].F] + p[i].S);
            }
        }
    }

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

    prin(dp[n][h]);
}

int main()
{
    int t = 1;
    // scn(t);

    while(t --) {
        solve();
    }
    return 0;
}

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

class segtree{
    public:
        int size;
        int node[(1<<18)-1];
        segtree(int n_){
            size=1;
            while (size<n_) size*=2;
            for (int i=0; i<2*size-1; i++) node[i]=INT_MAX;
        }

        void update(int k,int a){
            k+=size-1;
            node[k]=a;
            while (k>0){
                k=(k-1)/2;
                node[k]=min(node[2*k+1],node[2*k+2]);
            }
        }

        int get_min(int queryL,int queryR,int k=0,int nodeL=0,int nodeR=-1){
            if (nodeR==-1) nodeR=size;
            if (nodeR<=queryL or queryR<=nodeL) return INT_MAX;
            if (queryL<=nodeL and nodeR<=queryR) return node[k];
            else{
                int nodeM=(nodeL+nodeR)/2;
                int vl=get_min(queryL,queryR,k*2+1,nodeL,nodeM);
                int vr=get_min(queryL,queryR,k*2+2,nodeM,nodeR);
                return min(vl,vr);
            }
        }
    };

int n,q,c,x,y;
int main(){
    cin >> n >> q;
    segtree seg(n);
    for(int i=0; i<q; i++){
        cin >> c >> x >> y;
        if (c==0) seg.update(x,y);
        else cout << seg.get_min(x,y+1) << endl;
    }
    return 0;
}

Measured memory_bytes: 4108
import queue
#queue.Queue()
#que.put(i)
#que.get()

N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
    A, B = map(int, input().split())
    G[A-1].append(B-1)
    G[B-1].append(A-1)

sign = [-1] * N
que = queue.Queue()
que.put(0)

while not que.empty():
    v = que.get()
    for nv in G[v]:
        if sign[nv] != -1:
            continue
        sign[nv] = v
        que.put(nv)

print("Yes")
for i in sign[1:]:
    print(i+1)

Measured memory_bytes: 97668
#include<bits/stdc++.h>
using namespace std;
#define optimizar_io ios_base::sync_with_stdio(0); cin.tie(0);
#define fore(i, a, b) for(int i = a; i < b; i++)
#define fori(i, a, b) for(int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb push_back
#define popb pop_back
#define mk make_pair
#define fi first
#define se second
#define endl '\n'
#define MAX 1000000000000000000
typedef long long int lli;
typedef long double ld;
const double PI = acos(-1.0);
ld eps = 1e-9;

int convert(string s) {
	int i; 
	istringstream(s) >> i;
	return i;
}
int main() {
	optimizar_io
	lli a;
	string b, fi = "";
	cin >> a >> b;

	int i = 0;
	while(b[i] != '.') fi += b[i], i++;
	
	string sec = b.substr(i+1, 2);
	int B = convert(fi);
	int dec = convert(sec);
	lli ans = a * B + ((a * dec) / 100ll);
	cout << ans << endl;
}

Measured memory_bytes: 3640
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    ll n,k,ans=1; cin>>n>>k;
    rep(i,3)
        ans*=n/k;
    if(k%2==0){
    ll cnt=1;
    rep(i,3)
        cnt*=(n+k/2)/k;
        ans+=cnt;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <stdio.h>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
    ll x,flag,i,t,ans=0,j,k,l,n;
    scanf("%lld %lld",&n,&k);
    if(n<=10)
    {
        ans=k+(10-n)*100;
    }
    else
    {
        ans=k;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 256
N=int(input())
S=input()

b,k=0,0
for i in range(N):
  if S[i]=="(":
    b+=1
  else:
    k+=1
    if b>0:
      k-=1
      b-=1
  #print(b,k)

print("("*k+S+")"*b)

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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

int main(){
    int N;
    cin >> N;
    vector<int> h(N);
    rep(i, N) cin >> h[i];

    vector<int> dp(N);
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    FOR(i, 2, N){
        dp[i] = min(dp[i-2]+abs(h[i] - h[i-2]), dp[i-1]+abs(h[i] - h[i-1]));
    }

    cout << dp[N-1] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int T;
    cin >> T;
    rep(i,T){
        ll a,b,c,d;
        cin >> a >> b >> c >> d;
        if(a < b || d < b){
            cout << "No\n";
            continue;
        }
        if(c >= b-1){
            cout << "Yes\n";
            continue;
        }
        ll pr = a%b, nx;
        ll cnt = (a-c-1)/b+1;
        nx = (a-cnt*b+d)%b;
        ll ad = (nx+b-pr)%b;
        ll g = gcd(b,ad);
        if(pr>=c+1){
            cout << "No\n";
            continue;
        }
        if((b-1-pr)/g - (c-pr)/g >= 1){
            cout << "No\n";
        }else{
            cout << "Yes\n";
        }
    }
    return 0;
}


Measured memory_bytes: 256
program answer
  implicit none
  integer(16) :: i, j, N, s, t
  integer(16), allocatable :: A(:)
  read(*,*) N
  allocate(A(N))
  read(*,*) A
  s=0
  T=sum(A)
  do i = 1, N-1
     T=T-A(i)
     s=s+mod(A(i),10**9+7)*mod(T,10**9+7)
     s=mod(s,10**9+7)
        !s=s+mod(mod(A(i),10**9+7)*mod(A(j),10**9+7),10**9+7)
        !s=mod(s,10**9+7)
  end do

  write(*,*) s
  stop
 end program answer

Measured memory_bytes: 6160
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

vector<int> graph[8];

int dfs(int n,int m, bool *vis)
{
	if(count(vis,vis+n,true)==n)
		return 1;
	int ans = 0;
	for(int it:graph[m])
		if(!vis[it])
		{
			vis[it]= 1;
			ans += dfs(n,it,vis);
			vis[it]= 0;
		}
	return ans;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m;
	cin>>n>>m;
	for(int i= 0; i<m;i++)
	{
		int g,h;
		cin>>g>>h ,--g,--h;
		graph[g].push_back(h);
		graph[h].push_back(g);
	}
	bool vis[n]={0};
	vis[0]=1;
	cout<<dfs(n,0,vis)<<endl;
	return 0;
}

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

int main()
{
    int A,B,K;
    cin >> A >> B >> K;
    for(int i = 0 ; i < K ; i++)
    {
        if(i%2 == 0)//A开始
        {
            if(A%2 == 0)//偶数
            {
                A/=2;
                B+=A;
            }
            else{//奇数
                A--;
                A/=2;
                B+=A;
            }
        }
        else{
            if(B%2 == 0)//偶数
            {
                B/=2;
                A+=B;
            }
            else{//奇数
                B--;
                B/=2;
                A+=B;
            }
        }
        //cout<< "a = "<< A <<" b = " <<B<<endl;
    }
    printf("%d %d\n",A,B);
    return 0;
}


Measured memory_bytes: 256
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(v)";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var h = o.a();
  var w = o.a();
  var c = o.m(10);
  var x = xArray(0,10);
  for(var i = 0; i < h; i++){
    var t = o.l();
    for(var j = 0; j < w; j++){
      if(t[j] === -1)continue;
      x[t[j]]++;
    }
  }
  c = wf(c);
  var ans = 0;
  for(var i = 0; i <= 9; i++)ans += x[i] * c[i][1];
  return ans;
}

function wf(c){
  for(var k = 0; k <= 9; k++)
  for(var i = 0; i <= 9; i++)
  for(var j = 0; j <= 9; j++){
    if(c[i][k] + c[k][j] < c[i][j]){
      c[i][j] = c[i][k] + c[k][j];
    }
  }
  return c;
}

Measured memory_bytes: 9416
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#include <sstream>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007
#define M 998244353

using namespace std;

int main() {
    lli a,b,cnt=0;
    string s;
    lli i,j;
    cin>>s;
    a=0;
    b=s.size()-1;
    while(a<b){
        if(s[a]!=s[b]){
            if(s[a]=='x'){
                a++;
                cnt++;
            }
            else if(s[b]=='x'){
                b--;
                cnt++;
            }
            else{
                cnt=-1;
                break;
            }
        }
        else{
            a++;
            b--;
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 512
from fractions import gcd 

A, B, C, D = map(int,input().split(' '))

total = B - A + 1

lcg = (C*D) // gcd(C,D)

Cdiv = B // C - (A-1) // C
Ddiv = B // D - (A-1) // D
lcgdiv = B // (lcg) - (A-1) // (lcg)

print(total - Cdiv - Ddiv + lcgdiv)

Measured memory_bytes: 5048
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      String[] nyu=sc.nextLine().split(" ");

  //   String nyu=sc.nextLine();
//int[] num=new int[6];
//int A=Integer.parseInt(nyu[0]);
//int B=Integer.parseInt(nyu[1]);
//int C=Integer.parseInt(nyu[2]);
double A=Double.parseDouble(nyu[0]);
double B=Double.parseDouble(nyu[1]);


System.out.println(A/B) ;
	}
}

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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif

int modpow(int a, int k, int p){
    int ans = 1;
    while (k > 0){
        if (k % 2 == 1){
            ans *= a;
            ans %= p;
        }
        a = (a*a) % p;
        k = k / 2;
    }
    return ans;
}
signed main() {

    int a[3];
    rep(i,3) cin >> a[i];
    sort(a, a+3);
    int k;
    cin >> k;
    cout << a[0] + a[1] + a[2]*modpow(2,k,mod) << endl;
    
    return 0;
}


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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> h(n), a(m), b(m);
    rep(i, n) cin >> h[i];
    rep(i, m) cin >> a[i] >> b[i];
    vector<bool> flug(n, true);
    rep(i, m) {
        if (h[a[i]-1] > h[b[i]-1]) flug[b[i]-1] = false;
        else if (h[a[i] - 1] < h[b[i] - 1]) flug[a[i]-1] = false;
        else if (h[a[i] - 1] == h[b[i] - 1]) flug[b[i] - 1] = false, flug[a[i] - 1] = false;
    }
    int cnt = 0;
    rep(i, n) {
        if (flug[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 4532
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <deque>
#include <numeric>
#include <utility>
#define sign(a) ((a>0)-(a<0))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define LL long long
#define INF (LL)(1LL<<60)
#define all(a) a.begin(), a.end()
#define gr greater<LL>()

using namespace std;

template <class T>
class SegTree{
public:
    vector<T> arr;
    function<T(T,T)> f;
    T ini;
    uint n;
    SegTree(int N, function<T(T,T)> func, T ini_){
        f=func;
        ini=ini_;
        n=1;
        while(n<N)n<<=1u;
        arr.assign(2*n-1, ini);
    }

    void update(uint i, T val){
        i+=n-1;
        arr[i]=val;
        while(i>0){
            i=(i-1)/2;
            arr[i]=f(arr[2*i+1],arr[2*i+2]);
        }
    }

    T find(uint s, uint t){
        return __find(s,t,0,0,n);
    }
private:
    T __find(uint s, uint t, uint k, uint l, uint r){
        if(t<=l || s>=r)return ini;
        if(s<=l && t>=r)return arr[k];
        T vl=__find(s,t,2*k+1,l,(l+r)/2);
        T vr=__find(s,t,2*k+2, (l+r)/2, r);
        return f(vl,vr);
    }
};

const string YES = "YES";
const string NO = "NO";

void solve(std::string S, std::string T, long long q, std::vector<long long> a, std::vector<long long> b, std::vector<long long> c, std::vector<long long> d){
    auto f = [](char c1, char c2){
        string s={c1, c2};
        sort(all(s));
        if(s[0]==' ')return s[1];
        if(s=="AB")return ' ';
        if(s=="AA")return 'B';
        if(s=="BB")return 'A';
        throw 0;
    };

    int ns=S.length(), nt=T.length();
    SegTree<char> sts(ns, f, ' '), stt(nt, f, ' ');
    rep(i,ns)sts.update(i,S[i]);
    rep(i,nt)stt.update(i,T[i]);
    rep(i,q){
        cout << (sts.find(a[i]-1,b[i])==stt.find(c[i]-1,d[i]) ? YES : NO) << endl;
    }
}

int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    long long q;
    scanf("%lld",&q);
    std::vector<long long> a(q);
    std::vector<long long> b(q);
    std::vector<long long> c(q);
    std::vector<long long> d(q);
    for(int i = 0 ; i < q ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
        scanf("%lld",&c[i]);
        scanf("%lld",&d[i]);
    }
    solve(S, T, q, std::move(a), std::move(b), std::move(c), std::move(d));
    return 0;
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e9;
const LL INF = 1e9;

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int x;
    cin>>x;
    x = x ^ 1;
    cout<<x<<'\n';

    /*
    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int a[n];
        loop(i,0,n)
        {
            cin>>a[i];
        }
    }
    */

    /*
    int n;
    cin>>n;
    int a[n];
    loop(i,0,n)
    {
        cin>>a[i];
    }
    */

    /*
    cout<<ans<<'\n';

    if(f) cout<<"YES\n";
    else cout<<"NO\n";

    if(f) cout<<"Yes\n";
    else cout<<"No\n";
    */

    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#define M 30001
using namespace std;
int main(){
	int p[M]={0},t,r;
	for(int i=2;i*i<M;i++)if(!p[i])for(int j=i+i;j<M;j+=i)p[j]=1;
	while(cin>>t,t){
		r=0;
		for(int a=2;a*3<=t;a++)if(!p[a])for(int b=a;t-a-b>=b;b++)if(!p[b]&&!p[t-a-b]&&t-a-b<a+b)r++;
		cout<<r<<endl;
	}
	return 0;
}

Measured memory_bytes: 980
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String S = scan.next();
        int length = S.length();
        int count = 0;
        for (int i = 0; i < length / 2; i++) {
            if (S.charAt(i) != S.charAt(length - 1 - i)) count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 23764
n, y = map(int, input().split())

ans = 0
for i in range(n+1):
    for j in range(n+1):
        k  =max(0, (n - i - j))
        otoshidama = 10000 * i + 5000 * j + 1000 * k
        if (i + j + k) == n and otoshidama == y:
            ans += 1
            break
        else:
            continue
    else:
        continue
    break

if ans > 0:
    print(i, j, k)
else:
    print('-1 -1 -1')

Measured memory_bytes: 9056
import bisect
n = int(input())
lines = list(int(i) for i in input().split())
lines.sort()
counter = 0

for i in range(n-2):
  for j in range(i+1, n-1):
    counter += bisect.bisect_left(lines, lines[i] + lines[j]) - (j + 1)
    
print(counter)

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

int main() {
    int K, N;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    int s = 0;
    for (int j = 0; j < K; ++j) {
        s += A[j];
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a,b;
	cin>>a>>b;
	bool ok = true;
	
	string aa=a+a;
	
	//如果长度不等，返回 
	if (a.size() !=b.size())
	{
		cout<<"No";
		return 0;
	}
	
	/* 
	for(int i=0;i<a.size();i++)
	{
		if(x||a[i]!=b[i])
		{
			cout<<"No";
			return 0;
		}
	}
	*/ 
	
	
	for(int i=0;i<aa.size();i++)
	{
		if(aa[i]=b[0])
		{
			int js=0;
			ok=true;
			
			for(int j=1;j<b.size();j++)
			{
			
	
				if(aa[i+j]==b[j])
				{
					js++;
				}else{
					j=b.size();
					ok=false;
				}
			}
				
				if(js == b.size()-1 &&ok == true)
				{
					cout<<"Yes";
					return 0;
				}
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
a_ary = gets.split(' ').map(&:to_i)
b_ary = gets.split(' ').map(&:to_i)

kill_count = 0

a_ary.each_with_index.reverse_each do |monster_count, idx|
  if b_ary[idx] != nil && b_ary[idx] > 0
    if b_ary[idx] >= monster_count
      b_ary[idx] -= monster_count
      kill_count += monster_count
      next
    else
      kill_count += b_ary[idx]
      monster_count -= b_ary[idx]
    end
  end

  if idx != 0 && b_ary[idx - 1] != nil && b_ary[idx - 1] > 0
    if b_ary[idx - 1] >= monster_count
      b_ary[idx - 1] -= monster_count
      kill_count += monster_count
    else
      kill_count += b_ary[idx - 1]
      b_ary[idx - 1] = 0
    end
  end
end

puts kill_count


Measured memory_bytes: 22288
#!/usr/bin/env python3

def main():
    A,B = map(int, input().split())
    sasikomi = 1
    tap = 0
    while(True):
        if sasikomi >= B:
            break
        sasikomi += (A-1)
        tap += 1
    print(tap)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define sf scanf
#define pf printf
#define INF (ll)1e15
#define mod 1000000007

///#define isValid(n,m,nx,ny)nx>=0&&nx<n&&ny>=0&&ny<m
///int kx[]={1, 1, -1, -1, 2, 2, -2, -2}; //knight moves
///int ky[]={2,-2,  2, -2, 1,-1,  1, -1}; //knight moves
///int dx[]={1,-1,0,0,1,-1,1,-1};//eight direction
///int dy[]={0,0,1,-1,1,-1,-1,1};//eight direction
 
///using namespace __gnu_pbds;
using namespace std;
 
///inline double toRad(double deg){return deg*PI/180;}
///inline double toDeg(double rad){return rad*180/PI;}
///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
 
const int S=123456;
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    #endif
    int ara[5];
    while(sf("%d %d %d",&ara[0],&ara[1],&ara[2])==3)
    {
        sort(ara,ara+3);
        int ans=(ara[2]-ara[1]);
        ara[0]+=ans;
        ans+=(ara[2]-ara[0])/2;
        if((ara[2]-ara[0])%2)ans+=2;
        pf("%d\n",ans);
    }
    return 0;
}
 









 




























Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll ans=0;
    FOR(i,1,n+1){
      string s=to_string(i);
      if(len(s)%2==1) ans++;
    }
    cout<<ans<<endl;
}

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

using namespace std;

int N;
string S;
vector<int> v;
vector<string> all;

string getmax(bool type, const string &p) {
	if (p.empty())
		return "";
	string res;
	vector<int> posa, posb;
	for (int i = 0; i < (int)p.size(); ++i)
		if (p[i] == 'a') posa.push_back(i);
		else posb.push_back(i);
	if (type) {
		int lst = posb[0];
		res = "ab";
		for (int i = 1; i < (int)posa.size(); ++i)
			if (posa[i] > lst) {
				lst = posb[i];
				res += "ab";
			}
		return res;
	}
	vector<int> pos;
	for (int suf = (int)posa.size() - 1; suf >= 0; --suf) {
		pos.insert(upper_bound(pos.begin(), pos.end(), posa[suf]), posa[suf]);
		pos.insert(upper_bound(pos.begin(), pos.end(), posb[suf]), posb[suf]);
		string tmp;
		for (int x : pos) tmp += p[x];
		res = max(res, tmp);
	}
	return res;
}

int main() {
	cin >> N >> S;
	bool type;
	int b = 0;
	string now;
	for (int i = 0; i < 2 * N; ++i) {
		type = b > 0;
		b += S[i] == 'a' ? 1 : -1;
		now += S[i];
		if (!b) {
			all.push_back(getmax(type, now));
			now.clear();
		}
	}
	string s;
	for (int i = (int)all.size() - 1; i >= 0; --i)
		s = max(s, all[i] + s);
	cout << s << '\n';
	return 0;
}


Measured memory_bytes: 384
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

enum MP = [
    [0,0],
    [9,10],
    [9,11],
    [3,4],
    [9,13],
    [9,14],
    [3,5],
    [9,16],
    [9,17],
    [0,0]
];

void main()
{
    auto M = readln.chomp.to!int;
    long[] ds;
    long r;
    foreach (_; 0..M) {
        auto dc = readln.split.to!(long[]);
        auto d = dc[0];
        auto c = dc[1];
        if (d == 0) {
            r += c-1;
            c = 1;
        } else if (d == 9) {
            r += (c-1)*2;
            c = 1;
        } else {
            void calc(long m, long p) {
                if (c%m == 0) {
                    r += (c/m-1)*p;
                    c = m;
                } else {
                    r += c/m*p;
                    c %= m;
                }
            }
            calc(MP[d][0], MP[d][1]);
        }
        while (c--) ds ~= d;
    }
    while (ds.length > 1) {
        ++r;
        auto c = ds[0]+ds[1];
        if (c >= 10) {
            ds[0] = 1;
            ds[1] = c%10;
        } else {
            ds[1] = c;
            ds = ds[1..$];
        }
    }
    writeln(r);
}

Measured memory_bytes: 13400
import java.util.*;

public class Main {
	
		public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
			int x = sc.nextInt();
			int y = sc.nextInt();
			
			
			for(int k = 0; k<=x; k++) {
				int z = x-k;
				int total = k * 2 + z * 4;
				if(total == y) {
					System.out.println("Yes");
					return;
				}
				
			}
	        
	        
	        
 
	        System.out.println("No");
	}
}

Measured memory_bytes: 35796
fun main(args: Array<String>) {
    val abc = nextIntList()
    var a = abc[0]
    var b = abc[1]
    var c = abc[2]

    val k = next().toInt()

    for(i in 1..k){
        if(c <= b || c <= a){
            c *= 2
            continue
        }
        if(b <= a){
            b *= 2
            continue
        }
        c *= 2
    }

    if(c > b && c > a && b > a){
        println("Yes")
    }else{
        println("No")
    }
}
fun next() = readLine()!!
fun nextIntList() = next().split(" ").map{ it.toInt() }

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main()
{
   int n;
   cin>>n;
   map<int,int> mp;
   for(int i=1;i<n;i++)
   {
       int x;
       cin>>x;
       mp[x]++;
   }
   for(int i=1;i<=n;i++)
    cout<<mp[i]<<endl;
    
}

Measured memory_bytes: 16128
from itertools import combinations
from copy import deepcopy

def readinput():
    h,w,k=list(map(int,input().split()))
    c=[]
    for _ in range(h):
        l=list(input())
        c.append(l)
    return h,w,k,c

def main(h,w,k,c):
    gyo=[]
    for i in range(1,h+1):
        for cmb in combinations(range(1,h+1),i):
            gyo.append(cmb)
    gyo.append(())

    retsu=[]
    for i in range(1,w+1):
        for cmb in combinations(range(1,w+1),i):
            retsu.append(cmb)
    retsu.append(())

    ans=0
    for g in gyo:
        for r in retsu:
            cc=deepcopy(c)
            #print(cc)
            #print(g,r)
            
            for i in g:
                for j in range(1,w+1):
                    cc[i-1][j-1]='*'

            for j in r:
                for i in range(1,h+1):
                    cc[i-1][j-1]='*'
            #print(cc)
            count=0
            for i in range(1,h+1):
                for j in range(1,w+1):
                    if cc[i-1][j-1]=='#':
                        count+=1
            if count==k:
                ans+=1

    return ans

if __name__=='__main__':
    h,w,k,c=readinput()
    ans=main(h,w,k,c)
    print(ans)


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

#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int k, s;
  cin >> k >> s;
  int res = 0;
  for (int x = 0; x <= k; ++x) {
    for (int y = 0; y <= k; ++y) {
      int z = s - x - y;
      if (z >= 0 && z <= k) {
        res++;
      }
    }
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
S=input()
T='ATCG'
 
flag =0
ans =0
 
for i in range(len(S)):
    flag =0
    for j in range(i,len(S)):
        if S[j] == 'A' or S[j] == 'G' or S[j] == 'T' or S[j] == 'C':
            flag +=1
            ans = max(ans,flag)
        else:
            break
        
print(ans)

Measured memory_bytes: 9032
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <array>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)

double Reciprocal(double *n) 
{
    return *n = 1.0 / *n;
}

int main(void)
{
    int n = 0;

    cin >> n;

    double ar[n] = {};

    rep(i, n) {
        cin >> ar[i];
        Reciprocal(&ar[i]);
    }

    double sum = 0;

    rep(i, n) {
        sum += ar[i];
    }

    cout << 1.0 / sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)o.size())
#define run(x) for(int k=head[x];k;k=e[k].ne)
#define v e[k].t
#define all(a) o.begin(),o.end()
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef double db;
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<int,int> pa;
const int N=1e6+5,M=1e7+5,INF=1e9,mod=1e9+7;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("dato.in","r",stdin);
	freopen("dato.out","w",stdout);
}
int n;
struct edge{int t,ne;}e[N];
int head[N],cnt=1,p[N],st[N],top,mp[N],vis[N],a[N],o=1;
void adde(int a,int b){e[++cnt]=(edge){b,head[a]};head[a]=cnt;}
int dex;
void dfs(int x){
	run(x)if(!vis[v]){dfs(v);}
	dex++;
	run(x)if(!vis[v])mp[a[v]]=dex;
	a[x]=0;while(mp[a[x]]==dex)a[x]++;
}
int main(){
	read(n);rep(i,1,n){read(p[i]);adde(p[i],i);}
	int x=1;while(!vis[x]){vis[x]=1;st[++top]=x;x=p[x];}
	while(st[o]!=x)o++;
	st[top+1]=st[o];
	if((top-o+1)%2==0)return puts("POSSIBLE"),0;
	clr(vis);
	rep(i,o,top)vis[st[i]]=1;
	rep(i,o,top)dfs(st[i]);
	rep(i,o,top)if(a[st[i]]!=a[st[i+1]])return puts("POSSIBLE"),0;
	puts("IMPOSSIBLE");
}

Measured memory_bytes: 18688
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#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
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	string s;
	int k;
	cin >> s >> k;
	vector<string> v;
	rep(i,0,s.size()){
		string ss = "";
		int lim = min(i+5,(int)s.size());
		rep(j,i,lim){
			ss += s[j];
			v.push_back(ss);
		}
	}

	vsort(v);
	v.erase(unique(v.begin(),v.end()),v.end());
	
	cout << v[k-1] << endl;

	ret 0;
}

Measured memory_bytes: 1660
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

class LongerString
{
public:
	bool operator () ( const string &a, const string &b ) const
	{
		return a.length() < b.length();
	}
};

int main()
{
	string word;
	map<string,int> wordsCount;
	vector<string> words;

	while ( cin >> word )
	{
		wordsCount[ word ]++;
		words.push_back( word );
	}

	int max = 0;
	for ( map<string,int>::iterator it = wordsCount.begin(); it != wordsCount.end(); it++ )
	{
		if ( max < (*it).second )
		{
			max = (*it).second;
		}
	}

	for ( map<string,int>::iterator it = wordsCount.begin(); it != wordsCount.end(); it++ )
	{
		if ( max == (*it).second )
		{
			cout << (*it).first << ' ';
		}
	}

	sort( words.begin(), words.end(), LongerString() );

	cout << *words.rbegin() << endl;

	return 0;
}

Measured memory_bytes: 0
n, y = list(map(int, input().split()))
for i in range(n+1):
    for j in range(n+1-i):
        k = n-i-j
        if(i*10000 + j*5000 + k*1000 == y):
            print(i,j,k)
            break
        else:
            continue
        break
    else:
        continue
    break
else:
    print(-1, -1, -1)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  ll a,b,n;
  cin>>a>>b>>n;
  cout<<(a*min(b-1,n))/b<<endl;
}

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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#pragma endregion Macros

int main()
{
    int K, S;
    cin >> K >> S;

    ll ans = 0;
    for (int x = 0; x <= K; x++) {
        for (int y = 0; y <= K;y++){
            int z = S - (x + y);
            if (0 <= z && z <= K) ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3544
#include<iostream>
#include<bits/stdc++.h>
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main()
{
int k;
cin>>k;
int a,b;
cin>>a>>b;
int flag=0;
for(int i=a;i<=b;i++)
{
	if(i%k==0)
	{
		flag=1;
		cout<<"OK";
		break;
	}
}
if(flag==0)
{
	cout<<"NG";
}
}


Measured memory_bytes: 3600
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define Rev(a) reverse(a.begin(), a.end())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;


signed main() {
    ll n;
    cin >> n;
    
    string s;
    cin >> s;
    vi s2(n);
    
    ll r = 0;
    ll g = 0;
    ll b = 0;
    
    ll ans = 0;
    
    
    rep(i, n) {
        if (s[i] == 'R') {
            r++;
            s2[i] = 1;
        }
        if (s[i] == 'G') {
            g++;
            s2[i] = 2;
        }
        if (s[i] == 'B') {
            b++;
            s2[i] = 4;
        }
    }
    
    ans = r*g*b;
    
    rep(i, n) {
        for (int j = 1; j < n; j++) {
            if (i+j >= n || i+2*j >= n) continue;
            if (s2[i] + s2[i+j] + s2[i+2*j] == 7) ans--;
        }
    }
    
    mes(ans);
    
    
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int64_t A,B,K;
cin >> A >> B >> K;

if (A >= K) cout << A-K << " " << B << endl;
else if (A < K && K - A < B) cout << 0 << " " << A+B-K << endl;
else cout << 0 << " " << 0 << endl;


return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int w,h,n,x,y,a,i;cin >> w >> h >> n;
  int xmin = 0,xmax = w,ymin = 0,ymax = h;
  for(i=0;i<n;i++){
    cin >> x >> y >> a;
    if(a==1) xmin = max(xmin,x);
    else if(a==2) xmax = min(xmax,x);
    else if(a==3) ymin = max(ymin,y);
    else ymax = min(ymax,y);
  }
  if(xmin >= xmax || ymin >= ymax) cout << 0 << endl;
  else cout << (xmax-xmin)*(ymax-ymin) << endl;
}

Measured memory_bytes: 256
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;

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

  s -= (s / 100) * 100;
  s -= (s / 10) * 10;
  // cout << s;
  if (s == 3) {
    cout << "bon";
  } else if (s == 0 || s == 1 || s == 6 || s == 8) {
    cout << "pon";
  } else {
    cout << "hon";
  }
}


Measured memory_bytes: 3636
#include<stdio.h>

#define MAX 150

int length(int h, int w) {return h * h + w * w;}

int lessOrEqual(int h1, int w1, int h2, int w2) {
    int l1 = length(h1, w1);
    int l2 = length(h2, w2);
    if(l1 != l2) return l1 < l2;
    return h1 <= h2;
}

int main(void) {
    int h, w;
    int answerH, answerW;
    int i, j;
    while(scanf("%d %d", &h, &w), h | w) {
        answerH = answerW = MAX;
        for(i = 1; i <= MAX; i++) {
            for(j = i + 1; j <= MAX; j++) {
                if(lessOrEqual(i, j, h, w)) continue;
                if(lessOrEqual(answerH, answerW, i, j)) continue;
                answerH = i;
                answerW = j;
            }
        }
        printf("%d %d\n", answerH, answerW);
    }
    return 0;
}

Measured memory_bytes: 600
import java.util.*;

public class Main {
    private static double solve(int N, int[] a) {
        int[] state = new int[4];
        for (int i = 0; i < N; i++)
            state[a[i]] += 1;

        return solve(N, state, new double[301][301][301]);
    }

    private static double solve(int N, int[] state, double[][][] memo){
        double e = memo[state[1]][state[2]][state[3]];
        if (e > 0) return e;

        for (int s = 1; s <= 3; s++){
            if (state[s] == 0) continue;

            int current = state[s];
            int nonZero = N - state[0];

            state[s] -= 1;
            state[s-1] += 1;
            e += ((double)current/nonZero)*(solve(N, state, memo) + (double)N/nonZero);
            state[s-1] -= 1;
            state[s] += 1;
        }

        memo[state[1]][state[2]][state[3]] = e;

        return e;
    }

    public static double run(Scanner scanner) {
        int N = scanner.nextInt();
        int[] a = new int[N];
        for (int i=0; i < N; i++) a[i] = scanner.nextInt();

        return solve(N, a);
    }

    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            System.out.println(run(scanner));
        }
        //Tests.run();
    }
}

Measured memory_bytes: 308692
def main():
    inf=float("inf")
    h,w=map(int,input().split())
    lst=[list(map(int,input().split())) for _ in range(10)]
    dp1=[[inf]*10 for _ in range(10)]
    
    for i in range(10):
        for j in range(10):
            dp1[i][j]=lst[i][j]
    
    for k in range(1,11):
        dp2=[dp1[i][:] for i in range(10)]
        for i in range(10):
            for j in range(10):
                if dp2[i][j]>dp2[i][k-1]+dp2[k-1][j]:
                    dp1[i][j]=dp2[i][k-1]+dp2[k-1][j]

    wall=[list(map(int,input().split())) for _ in range(h)]
    sm=0
    for i in range(h):
        for j in range(w):
            if wall[i][j]==-1 : continue
            sm+=dp1[wall[i][j]][1]

    print(sm)
    
main()

Measured memory_bytes: 9592