akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n; 
  cin >>n;
  vector<long long>a(n),b(n);
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++)cin>>b[i];
  vector<long long>tasu,hiku;
  for(int i=0;i<n;i++){
    long long sa;
    sa=a[i]-b[i];
    if(sa>0)tasu.push_back(sa);
    else if(sa<0)hiku.push_back(sa);
  }
  if(hiku.size()==0){
    cout<<0<<endl;
    return 0;
  }
  long long kotae=hiku.size();
  sort(tasu.rbegin(),tasu.rend());
  long long wa=0;
  for(int i=0;i<hiku.size();i++){
    wa+=hiku[i];
  }
  //cout<<wa<<endl;
  for(int i=0;i<tasu.size();i++){
    wa+=tasu[i];
    kotae++;
    if(wa>0)break;
  }
  if(wa<0)cout<<-1<<endl;
  else cout<<kotae<<endl;
  return 0;
}
    

                               

Measured memory_bytes: 5792
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const int mx=1e6+777;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	map<int,int> ct;
	for (int i=0; i<=50; i++) {
		int cur=0;
		for (int j=1; cur<=i; j++)
			ct[i]=j-1, cur+=j;
	}
	ll N; cin>>N;
	vector<bool> flag(mx,true);
	flag[0]=flag[1]=false;
	for (int i=2; i*i<mx; i++)
		if(flag[i])
			for (int j=i; j*i<mx; j++)
				flag[i*j]=false;
	int ret=0;
	for (int i=2; i<mx; i++) {
		if(N%i==0) {
			int cur=0;
			while(N%i==0)
				cur++, N/=i;
			ret+=ct[cur];
		}
	}
	if(N>1) ret++;
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;
const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}
  
signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  string s;
  cin >> s;
  if(s == "RRR"){
    cout << "3\n";
  } else if(s == "RRS" || s == "SRR"){
    cout << "2\n";
  } else if(s == "SSS"){
    cout << "0\n";
  } else {
    cout << "1\n";
  }
  return 0;
}


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

using namespace std;
using ll = long long;

int main() {
    int n = 0;
    cin >> n;
    ll home[n];
    for(int i = 0; i < n ; i++){
        cin >> home[i];
    }

    ll Mini = 10000000000;

    for(int j = 1;j <= 100;j++){
        ll sum = 0;
        for(int i = 0; i < n ; i++){
            sum += (home[i] - j) * (home[i] - j);
        }
        Mini = min(sum,Mini);
    }

    cout << Mini << endl;
    return 0;
}

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

using namespace std;

void solve(int n, int p) {
  int c = p;
  vector<int> stones(n);
  
  int t = 0;
  while (true) {
    if (c > 0) {
      c--;
      stones[t]++;
      if (c == 0 && stones[t] == p) {
        cout << t << endl;
        return;
      }
    } else {
      c = stones[t];
      stones[t] = 0;
    }
    t = (t + 1) % n;
  }
}

int main() {
  int n, p;
  while (true) {
    cin >> n >> p;
    if (n + p == 0) break;
    solve(n, p);
  }
  return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
#define N 200005
using namespace std;
vector<int> G[N];
int n,d[N];
void GG(){ printf("First"); exit(0);}
int dfs(int t,int fa)
{
	int i,cnt=0;
	for(i=0;i<G[t].size();i++)
		if(G[t][i]!=fa)
			cnt+=dfs(G[t][i],t);
	if(cnt>=2) GG();
	if(cnt==1) return 0;
	else return 1;
}
int main()
{
	int i,x,y;
	scanf("%d",&n);
	for(i=1;i<n;i++){
		scanf("%d %d",&x,&y);
		G[x].push_back(y);
		G[y].push_back(x);
		d[x]++,d[y]++;
	  }
	if(n==2){
		printf("Second");
		return 0;
	  }
	for(i=n;i>=1;i--)
		if(d[i]>1) break;
	dfs(i,0);
	printf("Second");
	return 0;
}


Measured memory_bytes: 8576
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <numeric>
#include <algorithm>
#include <stdio.h>

int main(void){
  int n,s,c=0;
  std::cin >> n;
  for(int i=0;i<n;i++){
    std::cin >> s;
    if(s%2==1&&(i+1)%2==1){
      c++;
    }
  }
  std::cout << c;
  return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<long long>LC(N + 1);
  LC[0] = 2;
  LC[1] = 1;
  for (int i = 2; i <= N; i ++) LC[i] = LC[i - 1] + LC[i - 2];
  cout << LC[N] << endl;
}


Measured memory_bytes: 256
#include "iostream"
#include "iomanip"
#include "math.h"
using namespace std;

int n;
char member[10001];
int two_m[10001];
int dp[10001][8]{};
int ans;

bool check(int a, int b) {
	if (a == 1 && (b == 2 || b == 4 || b == 6))return false;
	if (a == 2 && (b == 1 || b == 4 || b == 5))return false;
	if (a == 3 && b == 4)return false;
	if (a == 4 && (b == 1 || b == 2 || b == 3))return false;
	if (a == 5 && b == 2)return false;
	if (a == 6 && b == 1)return false;
	return true;
}

int main() {
	cin >> n;
	two_m[0] = 1;
	dp[0][1] = 1;
	for (int i = 1; i <= n; i++) {
		cin >> member[i];
		if (member[i] == 'J')two_m[i] = 1;
		else if (member[i] == 'O')two_m[i] = 2;
		else two_m[i] = 4;
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j < 8; j++) {
			if (j % (two_m[i] * 2) >= two_m[i]) {
				for (int k = 1; k < 8; k++) {
					if (check(j, k)) {
						dp[i][j] += dp[i - 1][k];
						dp[i][j] %= 10007;
					}
				}
			}
		}
	}
	for (int i = 1; i < 8; i++) {
		ans += dp[n][i];
		ans %= 10007;
	}
	cout << ans << "\n";
	return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll a,b; cin >> a >> b;
  ll ma = max(a,b);
  ll mi = min(a,b);
  cout << ma+ max(ma-1,mi) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int h,w,i,j,k;
	
	while(1){
		scanf("%d %d",&h,&w);
		if(h==0&&w==0){
			break;
		}
		for(i=0;i<w;i++){
			printf("#");
		}
		printf("\n");
		for(j=0;j<h-2;j++){
			printf("#");
			for(i=0;i<w-2;i++){
				printf(".");
			}
			printf("#\n");
		}
		for(i=0;i<w;i++){
			printf("#");
		}
		printf("\n\n");
		
	}
	return 0;
}


Measured memory_bytes: 2088
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = s; i < (int)(n); i++)
#define print(a) cout << (a) << endl; 
typedef long long ll;
const int MOD = 1000000007; 

int main() {
    ll n, k;
    cin >> n >> k;
    ll k1 = n%k;
    cout << min(k - k1, k1) << endl;  
    return 0;
}

Measured memory_bytes: 256
n = int(input())
dic = {}
for _ in range(n):
  s = input()
  if s in dic.keys():
    dic[s] += 1
  else:
    dic[s] = 1
    
dic = [[k,v] for (k, v) in dic.items()]
dic.sort(key=lambda x:x[1], reverse=True)

n = dic[0][1]
dic = [k for (k,v) in dic if v == n]
dic.sort()
for s in dic:
  print(s)

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

int main() {
  ll n,m;
  cin >> n >> m;
  ll ans=0;
  if(n <= m/2){
    ans = n;
    m -= 2*n;
    ans += m/4;
  }
  else {
    ans = m/2;
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  string s;
  cin >> s;
  if(s[0] == '9' || s[1] == '9') cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

int pos[100007];

int n;

int main() {
	std::ios::sync_with_stdio(false);
	
	std::cin >> n;

	for (int i = 1; i <= n; i++) {
		int x; std::cin >> x;

		pos[x] = i;
	}

	for (int i = 1; i <= n; i++)
		std::cout << pos[i] << " ";
	std::cout << std::endl;
}

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


main()
{

   int a,b,c;

    int ct=0;
    scanf("%d%d%d",&a,&b,&c);

    if(a!=b)
    {
        ct++;
    }
    if(b!=c)
    {
        ct++;
    }
    if(c!=a)
    {
        ct++;
    }
    if(ct==0)cout<<1;
    else cout<<ct;



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define lint long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

int N, K;
string S;

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    cin >> N >> K >> S;
    vector<int> a;
    int l = 0, r = 0;
    int ans = 0;
    int num = 0;
    while (l < N) {
        while (r < N && S[l] == S[r]) r++;
        ans += r - l - 1;
        num++;
        l = r;
    }
    if (num == 1) {
        cout << ans << endl;
        return 0;
    }
    int cnt1 = 2;
    int cnt2 = max(0LL, num - 2);
    if (cnt2 % 2 == 0) {
        ans += 2 * min(K, cnt2 / 2);
        K -= cnt2 / 2;
        if (K > 0) ans += 1;
    } else {
        int c1 = min(K, (cnt2 + 1) / 2) * 2;
        int tmp = min(K, cnt2 / 2);
        K -= tmp;
        int c2 = tmp * 2;
        if (K > 0) c2 += min(K, 2LL);
        ans += max(c1, c2);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>
#include <vector>
#include <iomanip>

using namespace std;

int main(void) {
  int W, H, x, y;
  cin >> W >> H >> x >> y;
  cout << double(W) * double(H) / 2.0 << " ";
  if (x * 2 == W && y * 2 == H) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
//In the Name of Allah
// Ya Ali

#include <bits/stdc++.h>

using namespace std;

//#define int long long
#define F first
#define S second
#define all( x ) x.begin() , x.end()
#define pb push_back
#define mp make_pair

const int maxn = 2e5 + 10 ;
const int INF = 1e18 ;

int n , x ;

signed main()
{
 ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;

 cin >> x ;
 cout << 360/(__gcd( 360 , x ) ) ;

    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <numeric>
using namespace std;

int main()
{
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> A(N, K - Q);
    for (int i = 0; i < Q; ++i){
        int a;
        cin >> a;
        --a;
        ++A[a];
    }
    for (int i = 0; i < N; ++i){
        if(A[i] >0){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }

        return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int N,A,B,C;
VI l(8,0);

int eval(string s){
    VI used(4,0);
    REP(i,s.size()) used[s[i]-'0']++;
    if(used[1]==0 || used[2]==0 || used[3]==0) return INT_INF;

    int a = 0, b = 0, c = 0;
    REP(i,s.size()){
        if(s[i] == '1') a += l[i];
        else if(s[i] == '2') b += l[i];
        else if(s[i] == '3') c += l[i];
    }
    int res = abs(A-a) + abs(B-b) + abs(C-c);
    res += (used[1]-1)*10 + (used[2]-1)*10 + (used[3]-1)*10;
    return res;
}

int dfs(string s){
    int res;
    if(s.size() < N){
        int i = s.size();
        int v1 = dfs(s+'0');
        int v2 = dfs(s+'1');
        int v3 = dfs(s+'2');
        int v4 = dfs(s+'3');
        res = min(min(v1,v2), min(v3,v4));
    }
    else res = eval(s);

    return res;
}

int main(void){
    cin >> N >> A >> B >> C;
    REP(i,N) cin >> l[i];
    int ans = dfs("");
    cout << ans << endl;
    return 0;
}

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

int main() {
  int a, b, c;
  std::cin >> a >> b >> c;
  int max = std::max({a, b, c});
  int sum = a + b + c;
  if ((max * 3 - sum) % 2 == 0) {
    std::cout << (max * 3 - sum) / 2 << "\n";
  } else {
    std::cout << (max * 3 - sum + 3) / 2 << "\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

void add(ll &x,ll y){
    x=(x+y)%MOD;
}

void triple(ll &x){
    x=(x*3)%MOD;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin>>s;
    
    ll A=0,AB=0,ABC=0,num=1;
    rep(i,s.size()){
        char c=s[i];
        if(c=='?'){
            ll n=num;
            ll a=A;
            ll ab=AB;
            ll abc=ABC;
            triple(num);
            triple(A);
            triple(AB);
            triple(ABC);
            add(ABC,ab);
            add(AB,a);
            add(A,n);
            continue;
        }
        if(c=='C') add(ABC,AB);
        if(c=='B') add(AB,A);
        if(c=='A') add(A,num);
    }
    cout1(ABC)
}


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

int main() {
  int a, b;
  cin >> a >> b;

  if (a == 0) {
    if(b==100){
      cout<<101;
      return 0;
    }
    cout << b;
    
    return 0;
  }
  if (a == 1) {
    if(b==100){
      cout<<10100;
      return 0;
    }
    cout << b * 100;
    return 0;
  }
  if (a == 2) {
    if(b==100){
      cout<<1010000;
      return 0;
    }
    cout << b * 10000;
    return 0;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1e9+7;
const ll N=998244353;
ll power(ll x,ll n){ll res=1;while(n>0){if(n&1) res=res*x%MOD;x=x*x%MOD;n>>=1;}return res;}
ll modinverse(ll a){return power(a, MOD-2);}
vl adj[200010];
void solve()
{
    ll n;
    cin>>n;
    map<string, ll> mp1;
    ll maxm=0;
    forr(i, n)
    {
        string str;
        cin>>str;
        mp1[str]++;
        maxm=max(maxm, mp1[str]);
    }
    map<string, ll>:: iterator itr;
    vector<string> ans;
    for(itr=mp1.begin(); itr!=mp1.end(); itr++)
    {
        if(itr->second==maxm)
        ans.pb(itr->first);
    }
    sort(all(ans));
    forr(i, ans.size())
    cout<<ans[i]<<endl;
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
    {
        solve();
    }
}

Measured memory_bytes: 31920
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int m = scan.nextInt();
		int l = scan.nextInt();
		scan.nextLine();

		long[][] mat1 = new long[n][m];
		long[][] mat2 = new long[m][l];
		long[][] mat3 = new long[n][l];

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				mat1[i][j] = scan.nextInt();
			}
			scan.nextLine();
		}
		
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < l; j++) {
				mat2[i][j] = scan.nextInt();
			}
			scan.nextLine();
		}
		
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < l; j++) {
				for (int k = 0; k < m; k++) {
					mat3[i][j] += mat1[i][k] * mat2[k][j];
				}
			}
		}
				
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < l; j++) {
				System.out.print(mat3[i][j]);
				if(j!=l-1) {
					System.out.print(" ");
				}
			}
			System.out.println();
		}

		scan.close();
	}
}



Measured memory_bytes: 59008
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    string s;
    cin >> s;

    stack<char> st;
    int ans = 0;
    rep(i, SZ(s)){
        if(st.empty() || st.top() == s[i]){
            st.push(s[i]);
            continue;
        }
        st.pop();
        ans += 2;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;
#define MAX 100000000
#define J 100
int a[1010][2][2][2];

int main(){
	int n, x, y, z;
	string str;
	cin >> n >> str;
	if(str[0] == 'J')for(int i = 0;i < 4;i++)a[0][1][!!(i&2)][!!(i&1)] = 1;
	if(str[0] == 'O')for(int i = 0;i < 4;i++)a[0][1][1][!!(i&1)] = 1;
	if(str[0] == 'I')for(int i = 0;i < 4;i++)a[0][1][!!(i&1)][1] = 1;
	for(int i = 1;i < n;i++){
		x = y = z = 0;
		for(int j = 0;j < 2;j++){
			for(int k = 0;k < 2;k++){
				for(int h = 0;h < 2;h++)a[i][j][k][h] = 0;
				x += a[i-1][1][j][k];
				y += a[i-1][j][1][k];
				z += a[i-1][j][k][1];
			}
		}
		
		a[i][1][1][0] = (x + y -a[i-1][1][1][0]-a[i-1][1][1][1])%10007;
		a[i][1][0][1] = (x + z -a[i-1][1][0][1]-a[i-1][1][1][1])%10007;
		a[i][0][1][1] = (y + z -a[i-1][0][1][1]-a[i-1][1][1][1])%10007;
		for(int j = 0;j < 8;j++)a[i][1][1][1] += (a[i-1][!!(j&4)][!!(j&2)][!!(j&1)])%10007;
		
		if(str[i] == 'J'){
			a[i][1][0][0] = x%10007;
			a[i][0][1][1] = 0;
		}
		if(str[i] == 'O'){
			a[i][0][1][0] = y%10007;
			a[i][1][0][1] = 0;
		}
		if(str[i] == 'I'){
			a[i][0][0][1] = z%10007;
			a[i][1][1][0] = 0;
		}
	}
	int ans = 0;
	for(int i = 0;i < 8;i++)ans += (a[n-1][!!(i&4)][!!(i&2)][!!(i&1)]);
	cout << ans%10007 << endl;
	//for(int i = 0;i < 8;i++)cout << a[n-1][!!(i&4)][!!(i&2)][!!(i&1)] << " ";
	//cout << endl;
	//for(int i = 0;i < 8;i++)cout << !!(i&4) << !!(i&2) << !!(i&1) << " ";
	
	return 0;
}

Measured memory_bytes: 3184
N=gets.to_i
array=gets.chomp.split(" ").map(&:to_i)
ret=0
hash={}
array.each_with_index do |a,index|
    ret+= hash[a-index] || 0
    b=-a-index
    next if b + N <= 0
    hash[b] ||= 0
    hash[b] += 1
end
puts ret


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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    int n;
    cin >> n;
    vector<int> a(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;
    }

    return 0;
}

Measured memory_bytes: 17236
using System;
using System.Linq;
using System.Collections.Generic;
class c
{
    static void Main()
    {
        var nk = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
        var a = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
        var list = new List<long>();
        for (int i = 0; i < a.Length; i++)
        {
            long subSum = 0;
            for (int j = i; j < a.Length; j++)
            {
                subSum += a[j];
                list.Add(subSum);
            }
        }
        for (int i = 63; i >= 0; i--)
        {
            if (list.Count(x => (x >> i & 1) == 1) >= nk[1])
            {
                for (int j = 0; j < list.Count(); j++)
                {
                    if ((list[j] >> i & 1) != 1)
                    {
                        list[j] = 0;
                    }
                }
            }
        }
        list = list.OrderByDescending(L => L).ToList();
        long ans = long.MaxValue;
        for (int i = 0; i < nk[1]; i++)
        {
            ans &= list[i];
        }
        Console.WriteLine(ans);
    }
}

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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] l = new int [n];
        for (int i = 0 ; i < n ; i++) {
            l[i] = sc.nextInt();
        }
        Arrays.sort(l);
        int sum = 0;
        for (int i = 0 ; i < n - 1 ; i++) {
            sum += l[i];
        }
        if (sum >  l[n - 1]) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }


    }

}


Measured memory_bytes: 21844
class Dropping
  def initialize
    @drops = []
    @max = 0
    @count = 0
    @grid = Array.new(10).map{Array.new(10,0)}
    while input = $stdin.gets do
      x,y,s = input.chomp.split(',').map(&:to_i)
      case s
      when 1
        small_drop(x,y)
      when 2
        middle_drop(x,y)
      when 3
        large_drop(x,y)
      end
    end

    @grid.each do |line|
      @count += line.count(0)
      @max = [@max, line.max].max
    end

    puts @count
    puts @max
  end

  def small_drop(x,y)
    @grid[y][x] += 1 if checker(x,y)
    @grid[y-1][x] += 1 if checker(x,y-1)
    @grid[y+1][x] += 1 if checker(x,y+1)
    @grid[y][x-1] += 1 if checker(x-1,y)
    @grid[y][x+1] += 1 if checker(x+1,y)
  end

  def middle_drop(x,y)
    @grid[y-1][x-1] += 1 if checker(x-1,y-1)
    @grid[y-1][x] += 1 if checker(x,y-1)
    @grid[y-1][x+1] += 1 if checker(x+1,y-1)
    @grid[y][x-1] += 1 if checker(x-1,y)
    @grid[y][x] += 1 if checker(x,y)
    @grid[y][x+1] += 1 if checker(x+1,y)
    @grid[y+1][x-1] += 1 if checker(x-1,y+1)
    @grid[y+1][x] += 1 if checker(x,y+1)
    @grid[y+1][x+1] += 1 if checker(x+1,y+1)
  end

  def large_drop(x,y)
    @grid[y-1][x-1] += 1 if checker(x-1,y-1)
    @grid[y-1][x] += 1 if checker(x,y-1)
    @grid[y-1][x+1] += 1 if checker(x+1,y-1)
    @grid[y][x-1] += 1 if checker(x-1,y)
    @grid[y][x] += 1 if checker(x,y)
    @grid[y][x+1] += 1 if checker(x+1,y)
    @grid[y+1][x-1] += 1 if checker(x-1,y+1)
    @grid[y+1][x] += 1 if checker(x,y+1)
    @grid[y+1][x+1] += 1 if checker(x+1,y+1)

    @grid[y+2][x] += 1 if checker(x,y+2)
    @grid[y-2][x] += 1 if checker(x,y-2)
    @grid[y][x-2] += 1 if checker(x-2,y)
    @grid[y][x+2] += 1 if checker(x+2,y)
  end

  def checker(x, y)
    0 <= x && x < 10 && 0 <= y && y < 10
  end
end

d = Dropping.new

Measured memory_bytes: 2432
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
using namespace std;

#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define REPI(i, s, e) for (int i = (s); i <= (e); i++)
#define rep(i, n) REP(i, 0, n)
#define repi(i, n) REPI(i, 0, n)
#define ALL(v) (v).begin(), (v).end()

#define dump(x) (cout << #x << " = " << x << endl)
#define dump2(x, y) (cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl)
#define dump3(x, y, z) (cout << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", "<< z << ")" << endl)

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

int n, m, p;

#define MAX 8
int brd[MAX][MAX][MAX];
int height[MAX][MAX];

#define BLACK 0
#define WHITE 1

bool check(int turn)
{
	rep(x, n) rep(y, n) rep(z, n) {
		REPI(dx, -1, 1) REPI(dy, -1, 1) REPI(dz, -1, 1) {
			if ((dx|dy|dz) == 0) continue;

			rep(i, m) {
				int nx, ny, nz;
				nx = x+dx*i, ny = y+dy*i, nz = z+dz*i;
				if (!(0 <= nx && nx < n)) goto NEXT;
				if (!(0 <= ny && ny < n)) goto NEXT;
				if (!(0 <= nz && nz < n)) goto NEXT;
				if (brd[nx][ny][nz] != turn) goto NEXT;
			}
			return true;
NEXT:
			;
		}
	}
	return false;
}

int main(void)
{
	while (cin >> n >> m >> p, n|m|p) {
		memset(brd, -1, sizeof(brd));
		memset(height, 0, sizeof(height));

		vector<int> xs = vector<int>(p);
		vector<int> ys = vector<int>(p);
		rep(i, p) {
			cin >> xs[i] >> ys[i];
			xs[i]--, ys[i]--;
		}

		int turn = BLACK;
		rep(i, p) {
			brd[xs[i]][ys[i]][height[xs[i]][ys[i]]++] = turn;

			if (check(turn)) {
				printf("%s %d\n", (turn==BLACK?"Black":"White"), i+1);
				goto END;
			}

			turn = turn==BLACK?WHITE:BLACK;
		}
		printf("Draw\n");
END:
		;
	}
	return 0;
}

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

int high(int T, int x, int A){
  int k=T*1000-x*6;
  if(k>1000*A){
    return k-1000*A;
  }
  else return 1000*A-k;
}

int main(){
  int N, T, A; cin >> N >> T >> A;
  vector<int> MY(N);
  for(int i=0;i<N;i++){
    cin >> MY.at(i);
  }
  int where=1;
  int MIN=high(T,MY.at(0),A);
  for(int i=1;i<N;i++){
    if(MIN>high(T,MY.at(i),A)){
      MIN=high(T,MY.at(i),A);
      where=i+1;
    }
  }
  cout << where << endl;
  return 0;
}

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

int main() {
	int K, N;
	cin >> N >> K;
	vector<int> D(K);
	for (int i = 0; i < K; i++) {
		cin >> D[i];
	}
	for (int x = N; x < 99999; x++) {
		set<int> s;
		int tmp = x;
		while (tmp != 0) {
			s.insert(tmp % 10);
			tmp = tmp / 10;
		}
		bool flag = true;
		for (int i = 0; i < K; i++) {
			if (s.count(D[i]) != 0) {
				flag = false;
			}
		}
		if (flag) {
			cout << x;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <bitset>
using namespace std;
typedef long long int lli;
int main(void)
{
    lli A, v;
    lli B, w;
    lli T;
    cin >> A >> v >> B >> w >> T;
    if (w >= v)
    {
        cout << "NO" << endl;
    }
    else
    {
        if (abs(A - B) <= T * (v - w))
        {
            cout << "YES" << endl;
        }
        else
        {
            cout << "NO" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <stack>
#include <vector>
using namespace std;

int main() {
  int n, t; cin >> n >> t;
  vector<int> ts(n);
  for (int i = 0; i < n; ++i) cin >> ts[i]; 
  int ans = 0;
  stack<int> s;
  for (int i : ts) {
    if (s.empty() or i > s.top()) s.push(i);
    else s.pop();
    s.push(i + t);
  }
  while (not s.empty()) {
    int e = s.top(); s.pop();
    int b = s.top(); s.pop();
    ans += e - b;
  }
  cout << ans << endl;
  return 0;
}

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

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

    int current = 0;
    for(int i=0;i<N;i++){
        if(a[i]==current+1) current++;
    }
    if(current!=0) cout << N-current << endl;
    else cout << -1 << endl;
}

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

int main()
{
  int N, Y;
  cin >> N >> Y;
  Y /= 1000;
  for (int i = 0; i <= N; i++)
  {
    for (int j = 0; j <= N; j++)
    {
      if (i + j > N)
      {
        break;
      }

      int k = N - i - j;

      if (10 * i + j * 5 + k == Y)
      {
        cout << i << " " << j << " " << k << endl;
        return 0;
      }
    }
  }

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<list>
using namespace std;
static const int MAX = 100000;
static const int INFTY = (1<<29);

vector<int> G[MAX];
list<int> out;
bool V[MAX];
int N;
int indeg[MAX];

void bfs(int s) {
  queue<int> q;
  q.push(s);
  V[s] = true;
  while ( !q.empty() ) {
    int u = q.front(); q.pop();
    out.push_back(u);
    for ( int i = 0; i < G[u].size(); i++ ) {
      int v = G[u][i];
      indeg[v]--;
      if ( indeg[v] == 0 && !V[v] ) {
        V[v] = true;
        q.push(v);
      }
    }
  }
}

void tsort() {
  for ( int i = 0; i < N; i++ )
    indeg[i] = 0;

  for ( int u = 0; u < N; u++ )
    for ( int i = 0; i < G[u].size(); i++ ) {
      int v = G[u][i];
      indeg[v]++;
    }

  for ( int u = 0; u < N; u++ )
    if ( indeg[u] == 0 && !V[u] ) bfs(u);

  for ( list<int>::iterator it = out.begin(); it != out.end(); it++ )
    cout << *it << endl;
}

int main() {
  int s, t, M;

  cin >> N >> M;

  for ( int i = 0; i < N; i++ ) V[i] = false;

  for ( int i = 0; i < M; i++ ) {
    cin >> s >> t;
    G[s].push_back(t);
  }

  tsort();

  return 0;
}


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

using namespace std;

const int maxx = 2002;

bitset<maxx> a[maxx]; 
bool vis[maxx];
int ans = maxx, n, k, mx = -1, d[maxx][maxx];
vector<int> adj[maxx];

void dfs(int root, int id, int h = 0)
{
	vis[root] = true;
	d[id][root] = d[root][id] = h;
	mx = max(mx, h);
	for(int x : adj[root])
		if (!vis[x])
			dfs(x, id, h + 1);
}

int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	for(int i = 0; i < n - 1; i++)
	{
		int a, b;
		cin >> a >> b;
		a--, b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	for(int i = 0; i < n; i++)
	{
		memset(vis, false, sizeof vis);
		dfs(i, i);
	}
	if (mx <= k) return cout << 0 << endl, 0; 
//	for(int i = 0; i < n; i++)
//		for(int j = 0; j < n; j++)
//			cout << i << " " << j << " " << d[i][j] << " " << k << endl;
	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++)
			if (d[i][j] > k)
//				cout << i << " " << j << " " << d[i][j] << endl, 
				a[i].set(j, 1);
	for(int i = 0; i < n; i++)
	{
		for(int j = i + 1; j < n; j++)
		{
			if (d[i][j] != k) continue;
//			cout << i << " " << j << "     " << (int)(a[i] | a[j]).count() << endl;
 			ans = min(ans, (int)(a[i] | a[j]).count());
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 16640
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use itertools::Itertools;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    input! {
        n:usize,
        a:[usize;n],
    }
    
    println!("{}", a.iter().max().unwrap() - a.iter().min().unwrap());
}

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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (ll i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

void solve()
{
	int n; cin >> n;
	vector<set<int>> g(n + 7);
	forn(i, n) 
	{
		int x; cin >> x;
		x--;
		g[i].insert(x);
	}
	ll res = 0;
	for (int i = 0; i < n; ++i)
	{
		for (auto x: g[i])
		{
			if (g[x].find(i) != g[x].end()) res++;
		}	
	}
	cout << res / 2 << endl;
}

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


Measured memory_bytes: 12652
#include <cstdio>
#include <cstdint>

bool find_w(intmax_t N, intmax_t h, intmax_t n, intmax_t &w) {
  // 4/N = 1/h + 1/n + 1/w
  // 4 = N/h + N/n + N/w
  // 4*h*n*w = N * (n*w + h*w + h*n)
  // 4*h*n*w - N*h*w - N*n*w = N*h*n
  // (4*h*n - N*(h+n)) * w = N*h*n
  if (4*h*n == N*(h+n)) return false;
  if (N*h*n % (4*h*n-N*(h+n)) == 0) {
    w = N*h*n / (4*h*n-N*(h+n));
    return w > 0;
  }

  return false;
}

int main() {
  int N;
  scanf("%d", &N);

  for (int h=1; h<=3500; ++h)
    for (int n=1; n<=3500; ++n) {
      intmax_t w;
      if (find_w(N, h, n, w)) {
        printf("%d %d %jd\n", h, n, w);
        return 0;
      }
    }

  return 0;
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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

lli sum[200100];

void func(long long N, long long K, std::vector<long long> A){

    REP(i,0,N)sum[i+1] = sum[i]+A[i];
    REP(i,0,N+1){
        sum[i] -= i;
        sum[i] %= K;
    }
    map<lli,lli> cnt;
    REP(i,0,min(K,N+1))cnt[sum[i]]++;

    lli ans = 0;
    REP(i,0,N+1){
        lli now = sum[i];
        lli c = cnt[sum[i]];
        LOG3(i,now,c);
        ans += (c-1);
        cnt[sum[i]]--;
        if(i+K<=N)cnt[sum[i+K]]++;
    }
    cout<<ans<<endl;
}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    func(N, K, std::move(A));
    return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "OK" : "NG");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int K, A, B;
  cin >> K >> A >> B;
  bool is_ok = false;
  for(int i = A; i <= B; i++)
  {
    if(i % K == 0)
      is_ok = true;
  }
  printYesNo(is_ok);
  return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>

int main() {
    int debt = 100000;
    int rate;
    unsigned short int n;
    scanf("%hd", &n);

    for (int i=0; i<n; i++) {
        rate = debt * 0.05;
        if ( rate%1000 != 0 ) rate = rate - (rate%1000) + 1000;
        debt += rate;
    }
    
    printf("%d\n", debt);

    return 0;
}


Measured memory_bytes: 2032
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;

class P
{
  static void Main()
  {
    int N = int.Parse(Console.ReadLine());
    int r;
    int t;
    List<int> X = new List<int>();
    List<int> Y = new List<int>();
    X.Add(0);
    Y.Add(0);
    for(int i = 1; i < N+1; i++){
      t = i;
      r = 0;
      for(int j= 0; j<8; j++){
        r += t%6;t = t/6;
      }
      X.Add(r);
//      Console.WriteLine("{0} {1}",i,r);
      t=i;
      r = 0;
      for(int j= 0; j<8; j++){
        r += t%9;t = t/9;
      }
      Y.Add(r);
    }
    int R = 100000000;
    for(int i = 0; i < N+1; i++){
      R = Min(R, X[i] + Y[N-i]);
    }
    Console.WriteLine(R);
  }
}


Measured memory_bytes: 13024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(c) c.begin(),c.end()
#define PB push_back

using namespace std;
typedef long long ll;

int main()
{
  int N;
  cin >> N;
  vector<int> t(N + 1, 0), x(N + 1, 0), y(N + 1, 0);
  REP(i, N) cin >> t[i + 1] >> x[i + 1] >> y[i + 1];

  for (int i = 1; i <= N; i++) {
    int tm = t[i] - t[i - 1];
    int dist = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
    if (tm < dist || (tm - dist) % 2 == 1) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const int N = 3e3+6;
const int mod = 1e9+7;
const ll inf = 1e18;
int a[N];
void solve(){
    int k,s;
    cin>>k>>s;
    int ans = 0;
    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            int z = s-i-j;
            if(z>=0 and z<=k)ans++;
        }
    }
    cout<<ans<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
//    cin>>t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

const long long INF = 100000000000000000;

int main()
{
  long long a, b;
  cin >> a >> b;
  if(a%b==0){
    cout << -1 << endl;
  }
  else{
    cout << a << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
ll n;
cin>>n;
ll a[2][n];
for(ll j=0;j<2;j++){
for(ll i=0;i<n;i++){
cin >>a[j][i];
}
}
ll up[n];
ll down[n];
ll count =0;
ll count1=0;
for(ll i=0;i<n;i++){
count +=a[0][i];
count1 +=a[1][n-1-i];
up[i]=count;
down[i]=count1;
}
ll max=0;
for(ll i=0;i<n;i++){
if(up[i]+down[n-i-1]>max)
max=up[i]+down[n-i-1];

}
cout <<max;
return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e10;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> p(m);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    p[i] = make_pair(b, a);
  }
  sort(all(p));
  int ans = 0;
  int pos = 0;
  rep(i, m) {
    if (p[i].second >= pos) {
      pos = p[i].first;
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>

int main()
{
	int x, i, n;
	scanf("%d", &n);
	for (i = 1; i <= n; i++)
	{
		x = i;
		if (x % 3 == 0)
		{
			printf(" %d", i);
		} else {
			while (x)
			{
				if (x % 10 == 3){
					printf(" %d", i);
					x = 0;
				} else{
					x /= 10;
				}
			}
		}
	}
	printf("\n");
}


Measured memory_bytes: 2120
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int __int128
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	long long X, K, D;
	int x, k, d;
	int nx = 0;
	
	cin>>X>>K>>D;
	
	x = X;
	k = K;
	d = D;
	
	if(x < 0) x *= -1;
	
	if(x - d * k >= 0) {
		// cout<<"x"<<endl;
		cout<<(long long)(x - d * k)<<endl;
	} else {
		int con = x / d;
		
		// int con2 = (x + d - 1)/ d;
		
		// cout<<"con = "<<(long long)con<<endl;
		if((k - con)%2 == 0) {
			cout<<abs((long long)(x - con * d))<<endl;
		} else {
			cout<<abs((long long)(x - (con + 1) * d))<<endl;
		}
	}
	
	
	return 0;
}

Measured memory_bytes: 3648
def num_factors(n):
    res = 1
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            res *= (cnt + 1)    
    if temp != 1:
        res *= 2
    if res == 1:
        res = 2    
    return res


N = int(input())
ans = 0
for n in range(3, N+1, 2):
  if num_factors(n) == 8:
    ans += 1

print(ans)

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

using namespace std;

typedef long long ll;


int main()
{	
	int n,k;
	cin>>n>>k;

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

	if(n==k)cout<<1<<'\n';
	else
		cout<<(n-1)/(k-1)+(!((n-1)%(k-1)==0))<<'\n';

	return 0;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
  int n,r,fu[51];
  while(1){
    cin>>n>>r;
    if(n==0&&r==0)break;
    for(int i=1;i<=n;i++)fu[i]=n+1-i;
    for(int j=0;j<r;j++){
      int p,c,cp[50];
      cin>>p>>c;
      for(int k=0;k<c;k++){
	cp[k]=fu[p+k];
	}
      for(int k=p+c-1;k-c>=1;k--){
	fu[k]=fu[k-c];
      } 
      for(int k=1;k<=c;k++){
	fu[k]=cp[k-1];
	}
    }
    cout<<fu[1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  bool p=s[0]=='R';
  bool q=s[1]=='R';
  bool r=s[2]=='R';
  if(p&&q&&r) cout<<3<<endl;
  else if((p&&q)||(q&&r))cout<<2<<endl;
  else if(p||q||r)cout<<1<<endl;
  else cout<<0<<endl;
}
  

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

int main() {
  int N, K;
  cin >> N >> K;
  int num = 1;
  for(int i = 0; i < N; i++) {
    if(num * 2 < num + K) num = num * 2;
    else num = num + K;
  }

  cout << num;
  return 0;
}



Measured memory_bytes: 256