akhauriyash/Code-Regression huggingface dataset:
fun main(args: Array<String>) = yorukatsu21e()

fun yorukatsu21e() {
    val n = readLine()!!.toInt()
    val s = readLine()!!
    val q = readLine()!!.toInt()

    val st = SegmentTree(s.map { it.toNum() }.toLongArray(), 0, Long::or)
    val sb = StringBuilder()

    repeat(q) {
        val (qt, a, b) = readLine()!!.split(' ')
        when (qt) {
            "1" -> st[a.toInt() - 1] = b[0].toNum()
            else -> {
                sb.appendln(java.lang.Long.bitCount(st.get(a.toInt() - 1 until b.toInt())))
            }
        }
    }

    val answer = sb.toString()

    print(answer)
}

private fun Char.toNum() = Math.pow(2.0, (this - 'a' + 1).toDouble()).toLong()

private class SegmentTree(init: LongArray, val initValue: Long, val monad: (Long, Long) -> Long) {
    val indices: Int
    val nodes: LongArray

    init {
        var indices = 1
        while (indices < init.size) indices = indices shl 1
        val nodes = LongArray(2 * indices - 1) { initValue }
        for (i in init.indices) nodes[i + indices - 1] = init[i]
        for (i in indices - 2 downTo 0) nodes[i] = monad(nodes[2 * i + 1], nodes[2 * i + 2])
        this.indices = indices
        this.nodes = nodes
    }

    operator fun set(x: Int, value: Long) {
        var index = x + indices - 1
        nodes[index] = value
        while (index > 0) {
            index = (index - 1) / 2
            nodes[index] = monad(nodes[2 * index + 1], nodes[2 * index + 2])
        }
    }

    operator fun get(range: IntRange) = get(range.first, range.last + 1)

    fun get(a: Int, b: Int, k: Int = 0, l: Int = 0, r: Int = indices): Long {
        if (r <= a || b <= l) return initValue
        if (a <= l && r <= b) return nodes[k]
        return monad(
            get(a, b, 2 * k + 1, l, (l + r) / 2),
            get(a, b, 2 * k + 2, (l + r) / 2, r)
        )
    }
}


Measured memory_bytes: 94012
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define bitcount(x)  __builtin_popcount(x)
#define bitcountll(x)  __builtin_popcountll(x)
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000007
#define N 100005  //check the limits, man
int main()
{
    int a,b,g;
    in2(a,b);
    g=gcd(a,b);
    ll l=a;
    l*=b,l/=g;
    llout(l);
}




Measured memory_bytes: 256
n = int(input())
w_list = list(map(int, input().split()))
w_sums = [w_list[0]]
for i in range(1, len(w_list)):
    w_sums.append(w_sums[i-1] + w_list[i])
ans = 1000000
for t in range(len(w_list) - 1):
    s1 = w_sums[t]
    s2 = w_sums[-1] - w_sums[t]
    score = abs(s1 - s2)
    if score < ans:
        ans = score
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long



int main(){
  LINT N;
  cin >> N;
  LINT a[N];
  LINT x;
  REP(i, N) {
    cin >> x;
    if(i) a[i] = a[i-1] + x;
    else a[i] = x;
  }

  LINT ans=0;
  map<LINT, LINT> mp;
  REP(i, N) ++mp[a[i]];
  ans += mp[0];
  LINT t;
  for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
    t = itr->second;
    ans += t*(t-1)/2;
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 14336
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int INF=1e9;
const ll MOD=1e9+7;

ll gcd(ll x,ll y){
    if(y==0) return 0;
    return gcd(y,x%y);
}

int dis2(int x1,int y1,int x2,int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}

int main(){
    ll x,y;cin>>x>>y;
  if(x%y==0){
    cout<<-1<<endl;
    return 0;
  }
    for(ll i=1;true;i++){
        if(x<=1000000000000000000/i){
            if((x*i)%y!=0){
                cout<<x*i<<endl;
                return 0;
            }else continue;
        }else{
            cout<<-1<<endl;
            return 0;
        }
    }
}

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

using namespace std;


int main(){

    int n,k;
    int ans = 0;

    //freopen("input.txt","r",stdin);

    cin >> n >> k;

    for(int i=0; i<=n; i++){
        for(int j=0;j<=n; j++){
            int s = k - i - j;
            if(s>=0 && s<=n){
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

int gcd(int a, int b)
{
    if(a<b) swap(a,b);
    if(a%b == 0) return(b);
    else return(gcd(b, a%b));
}

int lcm(int a, int b)
{
   return a * b / gcd(a, b);
}

int main()
{
    int n;
    cin >> n;
    cout << lcm(n,2) << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

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

typedef unsigned int uint;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef map<int, string> mis;
typedef pair<int, ii> edge;


#define sc(x)  scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(arr,val) memset(arr,val,sizeof arr)
#define sz(v) (int)v.size()
#define rsz(v) v.resize
#define clr(v) v.clear()
#define rev(v) reverse(all(v))
#define lop(i,end) for(int i=0; i<end; i++)
#define rlop(i,start) for(int i=start-1; i>=0; i--)
#define loop(i,start,end) for(int i=start; i<end; i++)
#define rloop(i,start,end) for(int i=start-1; i>=end; i--)
#define PB push_back
#define pb pop_back
#define mP make_pair
#define f first
#define s second

const ll OO = (4e18) + 9;
const int MOD = (1e9) + 7;
const int oo = 2147483647;
const double EPS = 1e-8;
const double PI = acos(-1.0);

//enum dir { r, d, l, u };
int dx[] = { 0, 1, 0,-1 };
int dy[] = { 1, 0,-1, 0 };

//enum diR { d, r, u, l , dr, ur, dl, ul };
int dX[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
int dY[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

string abc = "abcdefghijklmnopqrstuvwxyz";
string vowels = "aeiou"; //and sometimes "aeiouy"

int dcmp(ld d1, ld d2) { return fabs(d1 - d2) <= EPS ? 0 : d1 > d2 ? 1 : -1; } //Compare Double Numbers
ll gcd(ll x, ll y) { return !y ? x : gcd(y, x%y); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
//convert index from 2D matrix to 1D array. (Zero-indexed)
int ord(int r, int c, int nCol) { return (nCol*r) + c + 1; }
//convert index from 1D array to 2D matrix . (One-indexed)
ii rord(int n, int nCol) {
	int r = n%nCol, c = n / nCol;
	if (n%nCol == 0) c--, r = nCol;
	return ii(r, c);
}

ll poww(ll num, ll p, ll md = MOD) {
	num %= md;
	ll ret = 1;
	while (p > 0) {
		if (p & 1) ret = (ret * num) % md;
		num = (num * num) % md;
		p >>= 1;
	}
	return ret;
}

const int N = 2000010;

ll power(ll base, ll exp, ll mod=MOD) { 
ll ans = 1; 
base %= mod; 
while (exp > 0) { 
if (exp & 1) ans = (ans * base) % mod; 
exp >>= 1; 
base = (base * base) % mod; 
} 
return ans;
} 

ll modInverse(ll a, ll m) { return power(a, m - 2, m);} 

ll fact[N]; 

void init(int n, int mod=MOD) { 
fact[0] = 1; 
for (int i = 1; i <= n; ++i) fact[i] = (fact[i - 1] * 1LL * i) % mod;
} 
int nCr(int n, int r, int mod=MOD) { 
return (fact[n] * modInverse(fact[r] * 1LL * fact[n - r], mod + 0LL)) % mod;
}

int main()
{

init(2e6+5);
int k;
string s;
cin>>k>>s;
ll ans = 0;
int n = k+sz(s);
for(int i=sz(s); i <= n; i++) {
ans += ((nCr(n, i) %MOD) * power(25LL, n-i)) %MOD;
ans %= MOD;
} 
cout<<ans<<endl;

	return 0;
}


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


int main(){
    long long int N;
    long long int A,B;
    string s;
    bool flag=true;
    cin>>s;
    N=s.size();
    string sv=s;
    reverse(sv.begin(),sv.end());
    if(s!=sv)flag=false;

    for(int i=0;i<(N-1)/2/2;i++){
        int i_sita=i;
        int i_ue=(N-1)/2-1-i;
        if(s.at(i_sita)!=s.at(i_ue)){
            flag=false;
        }
    }
    for(int i=0;i<(N-1)/2/2;i++){
        int i_sita=i+(N+1)/2;
        int i_ue=N-1-i;
        if(s.at(i_sita)!=s.at(i_ue)){
            flag=false;
        }
    }

    if(flag==true)cout<<"Yes"<<endl;
    else{cout<<"No"<<endl;}


}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, m, p, y;
    vector<pii> a[100005] = {};
    pii z[100005] = {};
    cin >> n >> m;
    for (int i = 1; i <= m; i++) cin >> p >> y, a[p].push_back({y, i});
    for (int i = 1; i <= n; i++) {
        sort(a[i].begin(), a[i].end());
        for (int j = 0; j < a[i].size(); j++) z[a[i][j].second] = {i, j + 1};
    }
    for (int i = 1; i <= m; i++) {
        string s = to_string(z[i].first), t = to_string(z[i].second);
        while (s.length() < 6) s = '0' + s;
        while (t.length() < 6) t = '0' + t;
        cout << s << t << '\n';
    }
}


Measured memory_bytes: 7808
/* Don't try to hack it :|
 
            _/﹋\_
            (҂`_´)
            <,︻╦╤─҉- - - - - - - - - - - - - - -
            _/﹋\_
*/

#include <bits/stdc++.h>
#define ll long long 
#define all(v) v.begin() , v.end()
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define tr(con) for(auto it = con.begin(); it!= con.end() ; it++)
#define INF 1e9+7   // 1 * 10^9+ 7
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define fo(i,n) for(ll i=0;i<n;i++)
using namespace std;

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string str ;
	cin >> str ;
	int n = str.length();
	int count =0 ;
	for(int i=0;i<str.length()/2;i++){
		if(str[i] !=str[n-1-i]) count++;
	}
	cout << count ;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    int K;
    cin >> K;
    int limit = K;
    int val = 0;
    rep(i, limit){
        val = (10*val + 7) % K;
        if(val == 0){
            cout << i+1 << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>










string s,s2;
int sz,sz2;



void solve()
{
	s2="AKIHABARA";
	sz2=s2.length();
	cin>>s;
	sz=s.length();
	if(sz>sz2)
	{
		cout<<"NO\n";
		return;
	}
	for(int i=0,j=0;i<sz2;i++)
	{
		if(j==sz&&i<sz2-1)
		{
			cout<<"NO\n";
			return;
		}
		if(s2[i]==s[j])
		{
			j++;
		}
		else
		{
			if(s2[i]!='A')
			{
				cout<<"NO\n";
				return;
			}
		}
	}
	cout<<"YES\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

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

int main() {
  int H,W; cin>>H>>W;
  vector<vector<char>> data(H, vector<char>(W));
  for(int i=0; i<H; i++)for(int j=0; j<W; j++) cin>>data.at(i).at(j);
  
  for(int i=0; i<H; i++){
    bool check=false;
    for(int j=0; j<W; j++){
      if(data.at(i).at(j)=='.') check=true;
      else{
        check=false;
        break;
      }
    }
    if(check) for(int j=0; j<W; j++) data.at(i).at(j)='x';
    check=false;
  }
  
  for(int i=0; i<W; i++){
    bool check=false;
    for(int j=0; j<H; j++){
      if(data.at(j).at(i)=='.' || data.at(j).at(i)=='x') check=true;
      else{
        check=false;
        break;
      }
    }
    if(check==true) for(int j=0; j<H; j++) data.at(j).at(i)='x';
    check=false;
  }
  
  bool test=false;
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(data.at(i).at(j)=='x') continue;
      else{
        cout<<data.at(i).at(j);
        test=true;
      }
    }
    if(test){
      cout<<endl;
      test=false;
    }
  }
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100000
int main()
{
    int a[N],n,b,c,i;
    int sum[N];
    scanf("%d%d%d",&n,&b,&c);
    for(i=0;i<c;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++){
        sum[i]=b;
    }
    for(i=0;i<c;i++)
    {
        sum[a[i]-1]++;
    }
    for(i=0;i<n;i++)
    {
        sum[i]=sum[i]-c;
        if(sum[i]>0){
            printf("Yes\n");
        }else{
        printf("No\n");
        }
    }

}


Measured memory_bytes: 1280
#include<iostream>
#include<vector>
typedef unsigned long long ull;
using namespace std;

#define INF 0x7FFFFFFFFFFFFFFF

int main()
{
  ull i,j,n,m;
  string s,t;
  cin >> s >> t;
  vector<vector<string>> dp;
  n=s.size();
  m=t.size();
  dp.resize(2);
  for(i=0;i<2;++i)
  {
    dp[i].resize(m+1);
  }
  for(j=0;j<=m;++j)
  {
  	dp[0][j]="";
  }
  for(i=1;i<=n;++i)
  {
    dp[1][0]="";
    for(j=1;j<=m;++j)
    {
      dp[1][j]=dp[1][j-1];
      if(dp[0][j].size()>dp[1][j].size())dp[1][j]=dp[0][j];
      if(s[i-1]==t[j-1])
      {
        if(dp[0][j-1].size()==dp[1][j].size())
        {
          dp[1][j]=dp[0][j-1]+s[i-1];
        }
      }
    }
    for(j=1;j<=m;++j)
    {
      dp[0][j]=dp[1][j];
    }
  }
  cout << dp[1][m];
  return 0;
}

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

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i, k , n) for(int i = k; i <= n; i++)
typedef long long ll;

const char nl = '\n' ;
const ll MOD = 1e9 + 7;


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

   int ans =0;
   int n, d, x; cin >> n >> d >> x;
   rep(i, n)
   {
      int a; cin >> a;
      ans += 1 + (d-1)/a;
   }


   cout << ans + x<< nl;
   return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<ll,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;

template<class T> struct factorizaion {
    using NP = pair<T,int>;
    T n;
    explicit factorizaion(T n):n(n) {
        assert(n > 0);
    }
    vector<NP> factorlist() {
        if(n == 1) return {};
        T nn = n;
        vector<NP> ret;
        T i = 2;
        while (i*i <= n) {
            if(nn%i == 0) {
                nn /= i;
                if(!ret.empty() && ret[ret.size()-1].first == i) ret[ret.size()-1].second++;
                else ret.emplace_back(i,1);
            } else i++;
        }
        if(nn != 1) ret.emplace_back(nn,1);
        return ret;
    }
    int divisor() {
        int ret = 1;
        vector<NP> fl = factorlist(n);
        for(auto p : fl) {
            ret *= p.second+1;
        }
        return ret;
    };
};

int main() {
    ll a,b;
    cin >> a >> b;
    ll g = __gcd(a,b);
    factorizaion<ll> f(g);
    cout << f.factorlist().size()+1 << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.util.*;
public class Main {
	String s;
	String rank= "23456789TJQKA";
	
	public int compare(String a,String b,String s,String l){
		
		int ai = a.indexOf(s);
		int bi = b.indexOf(s);
		
		if((ai == -1 && bi == -1) || (ai != -1 && bi != -1)){
			if(ai == -1 && bi == -1){
				int aj = a.indexOf(l);
				int bj = b.indexOf(l);
				if((aj == -1 && bj == -1) || (aj != -1 && bj != -1)){
					return rank.indexOf(a.substring(0,1)) - rank.indexOf(b.substring(0,1));
				}else if(aj != -1 && bj == -1){
					return 1;
				}else if(aj == -1 && bj != -1){
					return -1;
				}else{
					return 0;
				}
			}
			return rank.indexOf(a.substring(0,1)) - rank.indexOf(b.substring(0,1));
		}else if(ai != -1 && bi == -1){
			return 1;
		}else if(ai == -1 && bi != -1){
			return -1;
		}else{
			return 0;
		}
	}
	public void solve(){
		while(true){
			s = next();
			if(s.equals("#"))break;
			
			int ns = 0;
			int ew = 0;
			String[][] cards = new String[4][13];
			for(int i = 0;i < 4;i++){
				for(int j = 0;j < 13;j++){
					cards[i][j] = next();
				}
			}
			int lead = 0;
			for(int i = 0;i < 13;i++){
				int max = 0;
				for(int j = 0;j < 4;j++){
					int res = compare(cards[max][i],cards[j][i],s,cards[lead][i].substring(1,2));
					if(res < 0){
						max = j;
					}
				}
				if(max == 0 || max == 2){
					ns++;
				}else{
					ew++;
				}
				lead = max;
			}
			if(ns < ew){
				out.println("EW " + (ew - 6));
			}else{
				out.println("NS " + (ns - 6));
			}
		}
	}
 
	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: 26748
#include <stdio.h>
#define MOD (int)(1e9+7)
typedef long long ll;

int re(ll a){
  int m=MOD-2;
  ll res=1;
  while(m){
    if(m%2){
      res = res*a%MOD;
    }
    m /= 2;
    a = a*a%MOD;
  }
  return res;
}

int main(){
  int x,y;
  long long ans=1;
  
  scanf("%d%d",&x,&y);  
  if(x>y){int t=y;y=x;x=t;}
  if(2*x<y||(2*x-y)%3){printf("0\n");return 0;}
  
  int t = (2*x-y)/3;
  int sum = 2*t+(y-x);
  for(int i=0;i<t;i++){
    ans = ans*(sum-i)%MOD;
    ans = ans*re((ll)i+1)%MOD;
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>
#include <set>
#include<stack>

const long long MOD = 1000000007;
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

int main(){
    llong N;
    cin >> N;
    llong ans=0;
    for(int i=0; i<=25; i++){
        for(int j=0; j<=25; j++){
            if(i*4+j*7==N){
                ans++;
            }
        }
    }
    if(ans>0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

int main(){
	int n;
	cin>>n;
	
	int ans=1;
	int sm;
	cin>>sm;
	for(int i=0;i<n-1;i++){
		int nx;
		cin>>nx;
		
		if(sm>=nx){
			ans++;
			sm=min(sm,nx);
		}
	}
		cout << ans << endl;
}

Measured memory_bytes: 256
//--------ROMAN ITERATION -------------
#include <bits/stdc++.h>
#define ll  long long int
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define br cout <<"\n";
#define all(x)  (x).begin(),(x).end()
#define rall(x)  (x).rbegin(),(x).rend()
#define tr(c,i) for(auto i :c)
#define pii pair< int,int >
#define Fast_IO() ios_base::sync_with_stdio(false);cin.tie(0)
#define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
#define er(x) cout << x << " "
#define err(x,y) cout << x << " "<<y
#define fix( x ) cout << fixed << setprecision( x ) ;
const int MOD = 1000 * 1000 * 1000 + 7; // odd modulus
const int eps = 1e-9;
using namespace std;
clock_t time_p=clock();
void dem()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
int main()
{
    Fast_IO();
     int  n , d ;
     cin >> n >> d ;
     int cnt = 1 ;
     int i ;
     for ( i = 2*d + 2 ; i <= n ; i += 2 *d + 1 )
         cnt ++ ;
       
     cout << cnt ;
}


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

#define ri register int
#define mod 1000000007

int bit[60];
int N, x, y, z;
int f[43][140005];

int main() {
    cin >> N >> x >> y >> z;
    for(ri i = 0; i <= 25; i ++) bit[i] = 1 << i;
    
    int ans = 1;
    for(ri i = 1; i <= N; i ++) 
    ans = 1ll * ans * 10 % mod;
    
    f[0][0] = 1;
    int gg = bit[z - 1] | bit[y + z - 1] | bit[x + y + z - 1];
    int lim = bit[x + y + z] - 1;

    for(ri i = 1; i <= N; i ++)
    for(ri S = 0; S <= lim; S ++)
    for(ri v = 1; v <= 10; v ++) {
        int T = (S << v) | bit[v - 1]; T &= lim;
        if((T & gg) != gg) f[i][T] = (f[i][T] + f[i - 1][S]) % mod;
    }
    
    for(ri S = 0; S <= lim; S ++)
    if((S & gg) != gg) ans = (ans - f[N][S] + mod) % mod;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 22144
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a)) 

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s,_s;
	cin>>s>>_s;
	for(int i=0;i<3;i++)
	{
		if(s[i]!=_s[3-i-1])
		{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	return 0;
}

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

int h[200000 + 1];

int main(void){
    int k,n;
    long long sum=0;
    
    cin >> n >> k;
    
    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    
    sort(h,h+n);
    
    for(int i=n-k-1;i>=0;i--){
        sum+=h[i];
    }
    
    cout << sum << endl;
    
    return 0;
    
}


Measured memory_bytes: 1024
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
 
int n,m;
 
int p[100][3][50];
int pp[3][50];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool ok[100];
bool check(int c){
    //cout<<"N"<<n<<" "<<m<<endl;
 
     
    for(int k=0;k<4;k++){
    for(int i=0;i<m;i++)pp[0][i]=p[c][0][i],pp[1][i]=p[c][1][i];
        int a=p[0][0][0],b=p[0][1][0];
        for(int i=0;i<m;i++){
            int nx=pp[0][i],ny=pp[1][i];
            pp[0][i]=(nx-a)*dx[k]-(ny-b)*dy[k];
            pp[1][i]=(nx-a)*dy[k]+(ny-b)*dx[k];
        }
 
        //if(c==3)rep(j,m)cout<<"A"<<pp[0][j]<<" "<<pp[1][j]<<" "<<p[0][0][j]<<" "<<p[0][1][j]<<endl;
        bool ok=1,ok2=1;
        int ax1,ax2,ay1,ay2;
        for(int i=1;i<m;i++){
             
            ax1=p[0][0][i]-p[0][0][i-1];
            ay1=p[0][1][i]-p[0][1][i-1];
 
            ax2=pp[0][i]-pp[0][i-1];
            ay2=pp[1][i]-pp[1][i-1];
            //if(c==3)cout<<ax2<<" "<<ay2<<" "<<ax1<<" "<<ay1<<endl;
            if(ax1!=ax2||ay1!=ay2)ok=0;
        }
 
        for(int i=m-1;i>=1;i--){
            ax1=p[0][0][i]-p[0][0][i-1];
            ay1=p[0][1][i]-p[0][1][i-1];
 
            ax2=pp[0][m-i]-pp[0][m-i-1];
            ay2=pp[1][m-i]-pp[1][m-i-1];
            //if(c==3)cout<<ax2<<" "<<ay2<<" "<<ax1<<" "<<ay1<<endl;
            if(ax1!=ax2||ay1!=ay2)ok2=0;
        }
 
        //cout<<endl;
        if(ok||ok2)return 1;
    }
    return 0;
}
 
int main(){
 
while(cin>>n,n){
 
rep(i,70)rep(j,2)rep(k,60)p[i][j][k]=0;
 rep(i,100)ok[i]=0;
int ms=0;
rep(i,n+1){
    cin>>m;
		if(i==0)ms=m;
		if(ms!=m)ok[i]=1;
    rep(j,m){
        cin>>p[i][0][j]>>p[i][1][j];
    }
    //if(i>=1&&check(i))cout<<i<<endl;
}
for(int i=0;i<=n;i++){
	int sx=p[i][0][0],sy=p[i][1][0];
	for(int j=0;j<m;j++){
		p[i][0][j]-=sx;
		p[i][1][j]-=sy;
	}
}
 
for(int i=1;i<=n;i++)if(check(i)&&!ok[i])cout<<i<<endl;
cout<<"+++++\n";
}
 
    return 0;
}



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

int main(){
  long long N , X ;
  cin >> N >> X ; 
  vector<long long> x(N+1) ; 
  
  for(int i = 0 ; i < N ; i++){
    cin >> x.at(i) ; 
  }
  x.at(N) = X ; 
  sort(x.begin(),x.end()) ; 
  
  vector<long long> y(N) ; 
  
  for(int i = 0 ; i < N ; i++){
    y.at(i) = x.at(i+1) - x.at(i) ; 
    //cout << y.at(i) << endl  ;
  }
  
  long long ans = gcd(y.at(0) , y.at(0)) ; 
  for(int i = 0 ;  i < N ; i++){
    ans = gcd(ans , y.at(i) ) ; 
  }

  cout << ans << endl ; 
  
}

Measured memory_bytes: 4844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll len(ll x){
  ll a=1,k=0,j=1;
  while(a*10<=x) k+=9*a*j,a*=10,j++;
  k+=(x-a+1)*j;
  return k;
}
int main(){
  ll n,k;
  while(cin>>n>>k,n||k){
    ll l=0,r=1000000000LL,m,i;
    string s;
    while(l+1<r) (len(m=(l+r)/2)<n)?l=m:r=m;
    for(i=1;i<100;i++) s+=to_string(l+i);
    for(i=0;i<k;i++) cout << s[n-len(l)-1+i];
    cout << endl;      
  }
  return 0;
}

Measured memory_bytes: 3220
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    ll a[102];
    for(int i = 1; i <= n; i++) cin >> a[i];
    while(true){
        int i = n;
        for(; i > 0; i--){
            ll s = 0;
            for(int j = i; j <= n; j += i){
                s += a[j];
            }
            if(s < 0){
                for(int j = i; j <= n; j += i){
                    a[j] = 0;
                }
                break;
            }
        }
        if(i == 0) break;
    }
    while(true){
        int i = n / 2;
        for(; i > 0; i--){
            for(int j = i - 1; j > 0; j--){
                ll s = 0;
                for(int k = 1; k <= n; k++){
                    if(k % i == 0 || k % j == 0) s += a[k];
                }
                if(s < 0){
                    for(int k = i; k <= n; k += i) a[k] = 0;
                    for(int k = j; k <= n; k += j) a[k] = 0;
                    goto onemore1;
                }
            }
        }
    onemore1:
        if(i == 0) break;
    }
    while(true){
        int i = n / 6;
        for(; i > 0; i--){
            for(int j = i - 1; j > 0; j--){
                for(int k = j - 1; k > 0; k--){
                    ll s = 0;
                    for(int l = 1; l <= n; l++){
                        if(l % i == 0 || l % j == 0 || l % k == 0) s += a[l];
                    }
                    if(s < 0){
                        for(int l = i; l <= n; l += i) a[l] = 0;
                        for(int l = j; l <= n; l += j) a[l] = 0;
                        for(int l = k; l <= n; l += k) a[l] = 0;
                        goto onemore2;
                    }
                }
            }
        }
    onemore2:
        if(i == 0) break;
    }
    ll ans = 0;
    for(int i = 1; i <= n; i++) ans += a[i];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A;
  cin >> A;
  
  if(A%10==3){
    cout << "bon" << endl;
  }
  else if(A%10==0 ||A%10==1 ||A%10==6||A%10==8){
    cout << "pon" << endl;
  }
  else{
    cout << "hon" << endl;
  }
}

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

class GameStatus{
public:
	int score;
	int out;
	queue<int> base;

	GameStatus(){
		score = 0;
		out = 0;
		for (int i = 0; i < 3; i++)
			base.push(0);
	}

	void Hit(){
		score += base.front();
		base.pop();
		base.push(1);
	}

	void Homerun(){
		for (int i = 0; i < 3; i++){
			score += base.front();
			base.pop();
			base.push(0);
		}

		score++;
	}
};

int main(){
	const string es[3] = { "HIT", "HOMERUN", "OUT" };
	int n;
	cin >> n;

	while (n){
		GameStatus gs;
		string e;
		while (gs.out < 3){
			cin >> e;
			if (e == es[0])
				gs.Hit();
			else if (e == es[1])
				gs.Homerun();
			else if (e == es[2])
				gs.out++;
		}
		cout << gs.score << endl;
		n--;
	}

	return 0;
}

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

int main(){
    int x;
    cin >>x;
    for(int i=-119;i<=120;i++){
        for(int j=-120;j<i;j++){
            int y=pow(i,5)-pow(j,5);
            if(x==y){
                cout << i << " " << j <<endl;
                return 0;
            }
        }
    }
    return 0;
}

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

using namespace std ;

int main ()
{
    string s ;
    int cnt = 0 ;
    cin >> s ;
    for ( int i = s . size () - 2 ; i >= 0 ; -- i ){
        if ( s [ i ] != s [ i + 1 ] ){
            cnt ++ ;
        }
        s [ i + 1 ] = s [ i ] ; 
    }
    cout << cnt ;
}


Measured memory_bytes: 512
use std::io::BufRead;
fn main() {
    let stdin = std::io::stdin();
    let mut lines: Vec<Vec<i64>> = stdin
        .lock()
        .lines()
        .map(|l| {
            l.unwrap()
                .split_whitespace()
                .map(|w| w.parse().unwrap())
                .collect()
        })
        .collect();
    let (_n, k, mut al, mut fl) = (lines[0][0], lines[0][1], lines.remove(1), lines.remove(1));
    if al.iter().sum::<i64>() <= k {
        println!("0");
        return;
    } else {
        al.sort();
        al.reverse();
        fl.sort();
        let mut list: Vec<_> = al.iter().zip(fl.iter()).collect();
        let mut lp: i64 = 1;
        let mut rp: i64 = 1 << 60;
        let mut mp: i64 = (lp + rp) / 2;
        while (lp != mp) || (mp != rp) {
            let cnt: i64 = list
                .iter()
                .filter(|&&(a, f)| (a * f) > mp)
                .map(|&(a, f)| a - (mp / f))
                .sum();
            if k < cnt {
                lp = mp + 1;
            } else {
                rp = mp;
            }
            mp = (lp + rp) / 2;
        }
        println!("{}", mp);
    }
}


Measured memory_bytes: 13420
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;

int main(){
	string str;
	while(cin >> str){
		int ans = 0;
		vector<int> array;
		for(int i = 0; i < str.size(); i++){
			if(str[i] == 'I'){
				array.push_back(1);
			}
			else if(str[i] == 'V'){
				array.push_back(5);
			}
			else if(str[i] == 'X'){
				array.push_back(10);
			}
			else if(str[i] == 'L'){
				array.push_back(50);
			}
			else if(str[i] == 'C'){
				array.push_back(100);
			}
			else if(str[i] == 'D'){
				array.push_back(500);
			}
			else{
				array.push_back(1000);
			}
		}
		for(int i = 0; i < array.size()-1; i++){
			if(array[i] < array[i+1]){
				array[i] = -1*array[i];
			}
		}
		for(int i = 0; i < array.size(); i++){
			ans = ans+array[i];
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
int main(){
	int times=0;
	int input,money[4]={10,50,100,500};
	while(cin>>input,input){
		if(times!=0)cout<<endl;
		int cnt[4],sum=0,ans[4];
		for(int i=0;i<4;i++){
			cin>>cnt[i];
			sum+=money[i]*cnt[i];
		}
		sum-=input;
		for(int i=3;i>=0;i--){
			ans[i]=sum/money[i];
			if(ans[i]<cnt[i]){
				ans[i]=cnt[i]-ans[i];
			}else ans[i]=0;
			sum%=money[i];
		}
		for(int i=0;i<4;i++){
			if(ans[i]>0)cout<<money[i]<<" "<<ans[i]<<endl;
		}
		times++;
	}
}

Measured memory_bytes: 1160
from collections import deque


def main():
    N, D, A = map(int, input().split())
    enemies = [None] * N
    for i in range(N):
        enemies[i] = tuple(map(int, input().split()))
    enemies.sort()
    q = deque()
    cur = 0
    ans = 0
    for x, h in enemies:
        while len(q) and q[0][0] < x:
            cur -= q.popleft()[1]
        remain = max(h - cur * A, 0)
        tmp = -(-remain//A)
        q.append((x + 2 * D, tmp))
        ans += tmp
        cur += tmp
    print(ans)


if __name__ == "__main__":
    main()


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

int main(){
  int n;
  cin >> n;
  vector<long long> m(n * 3);
  for(int i = 0; i < 3 * n; i++){
    cin >> m[i];
  }
  long long ans = 0;
  sort(m.begin(),m.end(),greater<int>());
  for(int i = 1; i < 2 * n; i+=2){
    ans += m[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 5588
<?php 

//最大公約数
function gcd($m, $n){
    if($n > $m) list($m, $n) = array($n, $m);
     
    while($n !== 0){
        $tmp_n = $n;
        $n = $m % $n;
        $m = $tmp_n;
    }
    return $m;
}
 
//最小公倍数
function lcm($m, $n){
    return ($m/gcd($m, $n))*($n/gcd($m, $n))*gcd($m,$n);
}

$t_li = array();
fscanf(STDIN,"%d",$n);
  $t = trim(fgets(STDIN));

for($i=0;$i<$n-1;$i++){
  $t = lcm($t,trim(fgets(STDIN)));
}

//echo $t
  printf("%s",$t);



Measured memory_bytes: 4604
X, Y = gets.chomp.split(" ").map(&:to_i)
ONE = '1'.freeze
MOD = (10**9) + 7

def inv(x)
    res = 1 
    beki = x
    (MOD - 2).to_s(2).reverse.chars do |digest|
      res = (beki * res) % MOD if digest == ONE
      beki = (beki * beki) % MOD
    end
    res
end

def fact(s, e)
    (s..e).reduce(1) { |r, i| (r * i) % MOD }
end

def nCk(n, k)
    (fact(k + 1, n) * inv(fact(1, n - k) % MOD)) % MOD
end

if (2 * Y - X) % 3 == 0 && (2 * X - Y) % 3 == 0 && 2 * Y >= X && 2 * X >= Y
    a = (2 * Y - X) / 3
    b = (2 * X - Y) / 3
    puts nCk(a + b, a)
else
    puts 0
end

    

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

using namespace std;

typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
    ll N,M;
    cin>>N>>M;
    if(N==1 && M==1){
        cout<<1<<endl;
    }else if(N==1 || M==1){
        cout<<max(N,M)-2<<endl;
    }else{
        cout<<(N-2)*(M-2)<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[200];
int main()
{
    ll i,j,k,l,f=0;
    char s[100001];
    scanf("%s",s);
    l=strlen(s);
    for(i=0;i<l;i++)
    {
        a[s[i]]++;
    }
    for(i=97;i<=122;i++)
    {
        if(a[i]==0)
        {
            f=1;
            break;
        }
    }
    if(f==1)
    {
        printf("%c\n",i);
    }
    else
    {
        printf("None\n");
    }
    return 0;
}


Measured memory_bytes: 384
using System;
using static System.Console;
using static System.Convert;
class Program
{
    static void Main(string[] args)
    {
        var num = ToUInt64(ReadLine());
        ulong result = 1;
        var mod = (ulong)(Math.Pow(10, 9) + 7);
        for(ulong i = 0; i < num; i++)
        {
            result *= (num - i) % mod;
            result %= mod;
        }
        WriteLine(result);
    }
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    int freq[1000005];
    int ls[1000005];
    for (int i=0;i<1000005;i++){
        freq[i]=0;
        ls[i]=0;
    }
    int a[n];
    for (int i=0;i<n;i++){
        cin>>a[i];
        freq[a[i]]++;
    }
    for (int i=0;i<1000005;i++){
        if(freq[i]){
            for (int j=2*i;j<1000005;j+=i)
                freq[j]+=freq[i];
        }
    }
    int ans=0;
    for (int i=0;i<n;i++){
        if(freq[a[i]]==1)
            ans++;
    }
    cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 8344
import java.util.*;
public class Main{
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int cnt1= 0;
        int cnt2= 0;int a,b,c;
        while(sc.hasNext()){
            String[] mm = sc.nextLine().split(",");
            a = Integer.parseInt(mm[0]); b = Integer.parseInt(mm[1]); c = Integer.parseInt(mm[2]);
            cnt1 += c*c==a*a+b*b?1:0;
            cnt2 += a==b?1:0;
        }
        System.out.println(cnt1);System.out.println(cnt2);
    }
}

Measured memory_bytes: 17324
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

bool solve(){
  int n,k;
  cin>>n>>k;
  vector<int> vec(n);
  rep(i,n) cin>>vec[i];

  if(n==1){ return vec[0]==k; }
  int g = __gcd(vec[0], vec[1]);
  rep(i,n) g= __gcd(g, vec[i]);

  rep(i,n) if(vec[i]==k) return true;

  rep(i,n) if(vec[i]>k){
    if((vec[i]-k)%g==0) return true;
  }

  return false;
}

int main(){
  if(solve()) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;

int main(){
        int n;
        cin>>n;
        vector <int> a;
        for(int i=0;i<n;i++){
                int aa;
                cin>>aa;
                a.push_back(aa);
        }
        ll res=0, res2=0;
        ll now=0, now2=0;
        for(int i=0;i<n;i++){
                if(now+a[i]>=0&&i%2==0){
                        res+=abs(-1-(now+a[i]));
                        now=-1;
                }
                else if(now+a[i]<=0&&i%2==1){
                        res+=abs(1-(now+a[i]));
                        now=1;
                }
                else{
                        now+=a[i];
                }
                if(now2+a[i]>=0&&i%2==1){
                        res2+=abs(-1-(now2+a[i]));
                        now2=-1;
                }
                else if(now2+a[i]<=0&&i%2==0){
                        res2+=abs(1-(now2+a[i]));
                        now2=1;
                }
                else{
                        now2+=a[i];
                }
                //cout<<"res"<<res<<":"<<res2<<endl;
                //cout<<now<<":"<<now2<<endl;

        }
        cout<<min(res, res2)<<endl;
        return 0;
}


Measured memory_bytes: 892
var lines = [];
var a, b, q, s, t, x;

var readline = require("readline");

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var A = Number(lines[0].split(" ")[0]);
    var B = Number(lines[0].split(" ")[1]);
    var Q = Number(lines[0].split(" ")[2]);
    var S = []; var T = []; var X = [];

    for (var i = 1; i < A + 1; i++) { S[i - 1] = Number(lines[i]); }
    for (var i = A + 1; i < B + A + 1; i++) { T[i - (A + 1)] = Number(lines[i]); }
    for (var i = B + A + 1; i < B + A + 1 + Q; i++) { X[i - (B + A + 1)] = Number(lines[i]); }

    var ans = Infinity;

    /* ------ 処理 ------ */


    // 全てのスタート地点に対して探索
    for (var i = 0; i < Q; i++) {

        for (var j = 0; j < 2; j++) {
            if (j === 0) { a = S, b = T } // 神社に行った後，寺院に行く
            else { a = T, b = S }         // 寺院に行った後，神社に行く

            // 2(左 or 右) * 2(神社 * 寺院)の4通り探索
            for (var k = 0; k < 2; k++) {

                var a_pos = binary_search(a, X[i]) + k; // 一番近くの神社 or 寺院を探索  / binary_searchはx地点の左側を返す．x地点の右側も探索したいので+k
                var ax = a[a_pos];　                    // 一番近くの神社 or 寺院の座標をセット

                if (ax === undefined) { break; }

                for (var l = 0; l < 2; l++) {
                
                    var b_pos = binary_search(b, ax) + l;// 一番近くの神社 or 寺院を探索  / binary_searchはx地点の左側を返す．x地点の右側も探索したいので+l
                    var bx = b[b_pos]                    // 一番近くの神社 or 寺院の座標をセット

                    if (bx === undefined) { break; }

                    var distance = Math.abs(X[i] - ax) + Math.abs(ax - bx);
                    ans = Math.min(ans, distance)

                }
            }
        }
        console.log(ans);
        ans = Infinity
    }

});

// 地点xの左隣にある神社，寺院を探索
function binary_search(v, x) {
    var ok = 0;
    var ng = v.length;

    while (1 < Math.abs(ok - ng)) {
        var mid = Math.floor((ok + ng) / 2);
        if (v[mid] <= x) ok = mid;
        else { ng = mid }
    }

    // 地点xの左隣を返す
    return (ok);
}


Measured memory_bytes: 67512
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: i64,
        p: i64,
    }
    let ans = (a * 3 + p) / 2;
    println!("{}", ans);
}


Measured memory_bytes: 4352