akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	
	int x, n;
	cin>>x>>n;
	
	
	if(n == 0) {
		cout<<x<<endl;
		return 0;
	}
	
	int A[n+1];
	
	int contains[101];
	
	bool isXPartOfSeq = false;
	
	memset(contains, 0, sizeof(contains));
	
	for(int i = 1; i<= n; i++) {
		int a;
		cin>>a;
		contains[a] = 1;
	}
	
	if(contains[x] != 1) {
		cout<<x<<endl;
		return 0;
	}
	
	
	int low = x-1;
	int high = x+1;
	
	
	while(low >= 0 || high <= 101) {
		
		
		if(low >= 0) {
		
		if(contains[low] != 1) {
			cout<<low<<endl;
			return 0;
		} else {
			low--;
		}
		
		}
		
		if(high <= 101 && contains[high] != 1) {
			cout<<high<<endl;
			return 0;
		} else {
			high++;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3616
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	N := nextInt()
	S := nextBytes()

	c := 0

	for i := 0; i < N-2; i++ {
		if S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C' {
			c++
		}
	}

	fmt.Println(c)
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


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

int main()
{
	string s;
	cin >> s;
	
	int cnt = 0;
	int ans = 0;

	for (int i = 0; i < s.size(); i++) {

		if (s[i] == 'S') {
			cnt = 0;
		}
		else
		{
			cnt++;
			if (cnt>ans)
			{
				ans = cnt;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3596
#include<iostream>
using namespace std;
#include<stdio.h>
#include<cctype>

int main() {
        int r[26], i, j;
        char ch;
        for(i = 0; i < 26; i++) {
                r[i] = 0;
        }
        for(i = 0; i < 26; i++) {
                while( cin >> ch ) {
                        if(isupper(ch)) ch = (char)(tolower(ch));
                        j = ch - 'a';
                        if (j < 26 && j >= 0) r[j]++;
                }
        }
        for(i = 0; i < 26; i++) {
                cout << (char)('a' + i) << " : " << r[i] << endl;
        }
        return 0;
}

Measured memory_bytes: 3076
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

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

void test() {
    long long n, k;
    cin >> n >> k;
    int a[n + 1];
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    bool vis[n + 1] = {false};
    int val[n + 1] = {0}, res[n + 1] = {0}, cur = 1, j = 0, m = 0, tot = 0;
    while (true) {
        ++tot;
        vis[cur] = true;
        res[j] = cur;
        val[cur] = j++;
        cur = a[cur];
        if (vis[cur]) {
            m = j - val[cur];
            break;
        }
    }
    if (k >= tot) {
        k -= (tot - m);
        cout << res[tot - m + k % m] << "\n";
    } else {
        cout << res[k] << "\n";
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifdef HOME
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin >> t;
    for (int i = 0; i < t; ++i) {
        test();
    }
    return 0;
}


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

using namespace std;

#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"

#define DEBUG(x) cout << "> " << #x << ": " << x << endl;

typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
const int inf = 1e9+7;
const ll longinf = 1LL<<60;

// Start Coding...

void solve() {
    ll N, K;
    cin >> N >> K;
    if (N == 0) {
        cout << "0" << endl;
        return;
    }
    N = N % K;
    ll res1 = N, res2 = N - K;
    if (abs(res1) > abs(res2)) {
        cout << abs(res2) << endl;
    }
    else cout << abs(res1) << endl;
    return;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int x, z;
	int sum = 0;
	cin >> x;
	z = x;
	while (z > 0) {
		sum += (z % 10);
		z /= 10;
	}
	if (x%sum == 0)
		cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define TASK "C-large"
#pragma comment(linker, "/STACK:1710886400")
#include <stdio.h>
#include <iostream>
#include <iomanip> 
#include <math.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <functional>
#include <assert.h>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <random>
#include <complex>
using namespace std;

const int MOD = 1000000007;
const int INF = 1000000007;
const long double EPS = 1e-6;
const int HASH_POW = 29;
const long double PI = acos(-1.0);
mt19937_64 rnd(1);

double workTime()
{
	return double(clock()) / CLOCKS_PER_SEC;
}

void my_return(int code)
{
#ifdef MYDEBUG
	cout << "\nTime = " << fixed << setprecision(3) << workTime() << endl;
#endif
	exit(code);
}

int r, c, n;
pair <int, int> u[100010], v[100010];

bool border(pair <int, int> foo)
{
	return foo.first == 0 || foo.first == r || foo.second == 0 || foo.second == c;
}

struct pt
{
	int x, y, id;
	pt(int _x, int _y, int _id)
	{
		x = _x;
		y = _y;
		id = _id;
	}
};
vector <pt> lst;

inline long long dist(pt a)
{
	return a.x * 1ll * a.x + a.y * 1ll * a.y;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifdef MYDEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	/*freopen(TASK".in", "r", stdin);
	freopen(TASK".out", "w", stdout);*/
#endif

	scanf("%d %d %d", &r, &c, &n);
	for (int i = 1; i <= n; ++i)
	{
		scanf("%d %d", &u[i].first, &u[i].second);
		scanf("%d %d", &v[i].first, &v[i].second);
	}

	/*int p[10][10];
	memset(p, 0, sizeof p);
	for (int i = 1; i <= n; ++i)
	{
		p[u[i].first][u[i].second] = i;
		p[v[i].first][v[i].second] = i;
	}
	for (int i = 0; i <= r; ++i)
	{
		for (int j = 0; j <= c; ++j)
		{
			if (p[i][j])
				printf("%d", p[i][j]);
			else
				printf(" ");
		}
		printf("\n");
	}*/

	for (int i = 1; i <= n; ++i)
	{
		if (border(u[i]) && border(v[i]))
		{
			lst.push_back(pt(u[i].first, u[i].second, i));
			lst.push_back(pt(v[i].first, v[i].second, i));
		}
	}
	for (int i = 1; i < lst.size(); ++i)
		if (lst[i].x == 0 && lst[i].y == 0)
			swap(lst[0], lst[i]);
	sort(lst.begin() + ((lst[0].x == 0 && lst[0].y == 0) ? 1 : 0), lst.end(), [](pt a, pt b) {
		long long foo = a.x * 1ll * b.y - a.y * 1ll * b.x;
		return foo < 0 || foo == 0 && (a.x == 0 ? dist(a) < dist(b) : dist(a) > dist(b));
	});
	stack <int> st;
	for (int i = 0; i < lst.size(); ++i)
	{
		int foo = lst[i].id;
		if (!st.empty() && st.top() == foo)
			st.pop();
		else
			st.push(foo);
	}
	if (st.empty())
		printf("YES\n");
	else
		printf("NO\n");

	my_return(0);
}


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

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

const int Maxn = 100005;

int n;
ii LR[Maxn];
bool tk[Maxn];

ll Solve(bool lft)
{
	priority_queue <ii> L, R;
	for (int i = 0; i < n; i++) {
		L.push(ii(-LR[i].second, i));
		R.push(ii(LR[i].first, i));
		tk[i] = false;
	}
	int cur = 0;
	ll dist = 0;
	while (true) {
		if (lft) {
			while (!L.empty() && tk[L.top().second]) L.pop();
			if (L.empty()) break;
			int cand = -L.top().first;
			if (cand <= cur) { dist += cur - cand; cur = cand; tk[L.top().second] = true; }
			else break;
		} else {
			while (!R.empty() && tk[R.top().second]) R.pop();
			if (R.empty()) break;
			int cand = R.top().first;
			if (cur <= cand) { dist += cand - cur; cur = cand; tk[R.top().second] = true; }
			else break;
		}
		lft = !lft;
	}
	dist += abs(cur);
	return dist;
}

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d %d", &LR[i].first, &LR[i].second);
	ll res1 = Solve(true);
	ll res2 = Solve(false);
	cout << max(res1, res2) << endl;
	return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m;
  cin >> n >> m;
  vector<pair<bool, int>> v;
  rep(i, n + 1){
    v.pb(mp(false, 0));
  }
  int k;
  string s;
  rep(i,m){
    cin >> k >> s;
    if(v[k].fi) continue;
    if(s == "WA"){
      v[k].se++;
    }
    else{
      v[k].fi = true;
    }
  }
  int a,p =0;
  rep(i,n + 1){
    if(v[i].fi){
      a++;
      p += v[i].se;
    }
  }
  cout << a << ' ' << p << endl;
  return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
inline deque<P> doit(vector<int> vec){
    deque<P> ans;
    vec.push_back(-1);
    int cnt=0;
    rep(i,vec.size()-1){
        cnt++;
        if(vec.at(i)!=vec.at(i+1)){
            ans.push_back(P(vec.at(i),cnt));
            cnt=0;
        }
    }
    return ans;
}
signed main(){
    int n; cin>>n;
    vector<int> a(n);
    rep(i,n){
        cin>>a.at(i);
    }
    sort(a.begin(),a.end());
    deque<P> sum=doit(a);
    sum.push_front(P(-2,1));
    sum.push_back(P(-2,1));
    int ans=0,cnt=0;
    for(int i=1; i<sum.size()-1; i++){
        cnt+=sum.at(i).second;
        if(sum.at(i).first==sum.at(i-1).first+1) cnt+=sum.at(i-1).second;
        if(sum.at(i).first==sum.at(i+1).first-1) cnt+=sum.at(i+1).second;
        ans=(cnt>ans?cnt:ans);
        cnt=0;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2800
inn = int(input())
ina = [list(map(int,input().split())) for i in range(inn)]

arr = [[-1] * 101 for i in range(101)]
arr0 = [[False] * 101 for i in range(101)]
for xi in range(101):
  for yi in range(101):
    arr[xi][yi] = ina[0][2]+abs(ina[0][0]-xi)+abs(ina[0][1]-yi)
    if ina[0][2] == 0:
      arr0[xi][yi] = True

arrTF = [[True] * 101 for i in range(101)]
for i in range(1,inn):
  for xi in range(101):
    for yi in range(101):
      if arrTF[xi][yi]:
        if arr0[xi][yi]:
          if ina[i][2] == 0:
            if arr[xi][yi] > ina[i][2] + abs(ina[i][0]-xi)+abs(ina[i][1]-yi):
              arr[xi][yi] = ina[i][2] + abs(ina[i][0]-xi)+abs(ina[i][1]-yi)
          else:
            if arr[xi][yi] < ina[i][2] + abs(ina[i][0]-xi)+abs(ina[i][1]-yi):
              arrTF[xi][yi] = False
            else:
              arr[xi][yi] = ina[i][2] + abs(ina[i][0]-xi)+abs(ina[i][1]-yi)
              arr0[xi][yi] = False
        else:
          if ina[i][2] == 0:
            if arr[xi][yi] > ina[i][2] + abs(ina[i][0]-xi)+abs(ina[i][1]-yi):
              arrTF[xi][yi] = False
          else:
            if arr[xi][yi] != ina[i][2] + abs(ina[i][0]-xi)+abs(ina[i][1]-yi):
              arrTF[xi][yi] = False

for xi in range(101):
  for yi in range(101):
    if arrTF[xi][yi]:
      print(str(xi)+" "+str(yi)+" "+str(arr[xi][yi]))

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
void rcmb(ll *x,ll s,ll r,function<void(ll *)>f){if(r==0){f(x);}else{if(s<0)return;rcmb(x,s-1,r,f);x[r-1]=s;rcmb(x,s-1,r-1,f);}}
void cmb(ll n,ll k,function<void(ll *)>f){ll x[k];rcmb(x,n-1,k,f);}
void prm(ll n,function<void(ll *)>f){ll x[n];for(ll i=0;i<n;i++)x[i]=i;do{f(x);}while(next_permutation(x,x+n));}
void prm(ll n,ll k,function<void(ll *)>f){cmb(n,k,[&](ll *c){prm(k,[&](ll *p){ll x[k];for(ll i=0;i<k;i++){x[i]=c[p[i]];}f(x);});});}
// prm(4, 2, [](ll *x){ cout << x[0] << "," << x[1] << "\n"; });


void solve(long long N, long long K, std::string S){
	REP(i, N) {
		char s = S[i];
		if (i+1 == K) s += 32;
		cout << s;
	}
	cout << "\n";
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::string S;
    std::cin >> S;
    solve(N, K, S);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 100000000
#define MOD 100000007
#define SIZE 100005
#define pi 	3.14159265358979323846

int main(){
	string c;
	getline(cin,c);
	REP(i,c.size()){
		if(c[i]<91&&c[i]>64){
			c[i] += 32;
		}else if(c[i]<123&&c[i]>96){
			c[i] -= 32;
		}
		cout << c[i];
	}
	cout << endl;
	return 0;
}


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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    string S, T;
    cin >> S >> T;

    int ans = 0;
    REP(i, 3) {
        if (S[i] == T[i]) ans++;
    }
    print(ans);
}

signed main() {
    solve();
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			int in = Integer.parseInt(br.readLine());
			 System.out.println(in<1200?"ABC"
					 		   :in<2800?"ARC"
					 		   :"AGC");
		}
	}
}

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

int main() {
    int N;
    cin >> N;
    vector <int> p(N);
    for (int i=0; i<N; i++) cin >> p.at(i);
    sort(p.begin(), p.end());
    int res=0;
    for (int i=0; i<N-1; i++) {
        res += p.at(i);
    }
    cout << res+p.at(N-1)/2;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 string str1,str2,str3;
  cin>>str1>>str2>>str3;
  int i=0,j=-1,k=-1;
  char x= str1.at(i);
  while(true){
     if(x=='a'){
      i++;
       if(i==str1.size()){
         cout<<"A"<<endl;
         break;
       }
      x=str1.at(i);
     }
    else if(x=='b'){
      j++;
        if(j==str2.size()){
         cout<<"B"<<endl;
         break;
       }
      x=str2.at(j);
    }
    else if(x=='c'){
      k++;
        if(k==str3.size()){
         cout<<"C"<<endl;
         break;
       }
      x=str3.at(k);
    }
  }
}
      
      
  

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

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ll long long

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

    int sum = 1;
    for (int i = 0; i < n; i++)
    {
        int multi = sum * 2;
        int addK = sum + k;
        if (multi > addK)
        {
            sum += k;
            continue;
        }
        sum *= 2;
    }
    
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define INF 0x3f3f3f3f
#define pii pair<int, int>
#define mem(x, a) memset(x, a, sizeof(x))
#define AC ios_base::sync_with_stdio(0),cin.tie(0)
using namespace std;
const int maxn = 2e5 + 50;
int h[maxn], a[maxn], dp[maxn];
set<int> mque;
main(){
	AC;
	int n;
	cin >> n;
	for(int i = 1; i <= n; i ++) cin >> h[i];
	for(int i = 1; i <= n; i ++) cin >> a[h[i]];
	mque.insert(0);
	for(int i = 1; i <= n; i ++){
		auto it = prev(mque.upper_bound(h[i]));
		dp[h[i]] = dp[*it ++] + a[h[i]];
		while(it != mque.end() && dp[h[i]] >= dp[*it]){
			it = mque.erase(it);
		}
		mque.insert(h[i]);
	}
	cout << dp[*mque.rbegin()] << "\n";
}

Measured memory_bytes: 17532
c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))

if c1[0]-c2[0] == c1[1]-c2[1] == c1[2]-c2[2] and \
   c2[0]-c3[0] == c2[1]-c3[1] == c2[2]-c3[2]:
  print("Yes")
else:
  print('No')

Measured memory_bytes: 3064
int main(void){
  long int a,b,i=1,j=1;
  
  scanf("%ld %ld",&a,&b);

  while(1){
  
  	if(a*i == b*j){
    	printf("%ld",a*i);
    	break;
    }
    
    if(a*i < b*j)
      i ++;
    else
      j ++;
  }
}

Measured memory_bytes: 128
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}
int gcd(ll(a), ll(b)) {
	ll q = a;
	ll w = b;
	ll e = q;
	while (q % w != 0) {
		e = q % w;
		q = w;
		w = e;
	}
	return w;

}





int main() {
	ll N,K,g,m;
	cin >> N>>K ;
	vector<ll> A(N);
	string s = "IMPOSSIBLE";
	g = A.at(0);
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
		g = gcd(g, A.at(i));
		if (A.at(i) == K) {
			s = "POSSIBLE";
		}
		m = max(m, A.at(i));
		
	}
	if (K % g == 0) {
		s = "POSSIBLE";
	}
	if (m < K) {
		s = "IMPOSSIBLE";
	}
	
	cout << s << endl;

	
	
}

Measured memory_bytes: 1024
let nxm = readLine()!.split(separator: " ").map {Int($0)!}
let n = nxm[0], x = nxm[1], m = nxm[2]

var sum = 0
var now = x
var nowHistory = [Int]()

var i = 1
while i <= n {
    if nowHistory.contains(now) {
        let firstOfLoop = nowHistory.firstIndex(of: now)!
        let loopCount = i - (firstOfLoop+1)
        var loopSum: Int {
            var localSum = 0
            for j in firstOfLoop..<i-1 {
                localSum += nowHistory[j]
            }
            return localSum
        }
        let quotient = ( n - i ) / loopCount
        sum += quotient * loopSum
        i += quotient * loopCount
        nowHistory = []
    } else {
        nowHistory.append(now)
    }
    sum += now
    i += 1
    now = (now * now) % m
}

print(sum)



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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
#define curtime chrono::steady_clock::now().time_since_epoch().count
#define rep(i, beg, n, s) for (int i = beg; i < n; i += s)
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m = M) {
  int ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}

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

int exp(int n, int k) {
  if (k == 0) return 1;
  if (k == 1) return n;
  int ax = exp(n, k / 2);
  ax = mod(ax * ax);
  if (k % 2) ax = mod(ax * n);
  return ax;
}

namespace Combinatorics {
vector<int> fat;
vector<int> ifat;

void precalculate(int n) {
  fat.resize(n + 1, 1);
  ifat.resize(n + 1, 1);
  for (int i = 1; i <= n; i++) {
    fat[i] = mod(fat[i - 1] * i);
    ifat[i] = exp(fat[i], M - 2);
  }
}

int C(int n, int k) { return mod(mod(fat[n] * ifat[n - k]) * ifat[k]); }
}  // namespace Combinatorics

// #define MULTIPLE_TEST_CASE
void solution() {
  int k;
  cin >> k;
  string s;
  cin >> s;
  int ans = 0;
  int n = s.size() + k;
  int sz = s.size();
  Combinatorics::precalculate(n);
  for (int i = 0; i < sz; i++) {
    int tot = mod(Combinatorics::C(n, i) * exp(25, n - i));
    ans = mod(ans + tot);
  }
  cout << mod(exp(26, n) - ans) << endl;
}

int32_t main() {
  DESYNC;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int t = 1;
#ifdef MULTIPLE_TEST_CASE
  cin >> t;
#endif
  while (t--) solution();
}


Measured memory_bytes: 35616
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
const int w=3e5+5;
const ll mod=1e9+7;
int main()
{
    int i,j;
    int flag=0;
    int n;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        int x;
        scanf("%d",&x);
        if(x%2==1)
            continue;
        if(x%3==0||x%5==0)
            continue;
        else
            flag=1;
    }
    if(flag==0)
        puts("APPROVED");
    else
        puts("DENIED");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 200005
#define eps 1e-12
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9') {
        res = res * 10 + c - '0';
        c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
        out(x / 10);
    }
    putchar('0' + x % 10);
}
const int MOD = 1000000007;
int N,M,K;
int A[405],B[405],C[405],w[25][25];
int dp[2][21][(1 << 19) + 5];
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
    return 1LL * a * b % MOD;
}
void update(int &x,int y) {
    x = inc(x,y);
}
int lowbit(int x) {
    return x & (-x);
}
void Solve() {
    read(N);read(M);read(K);
    memset(w,-1,sizeof(w));
    for(int i = 1 ; i <= K ; ++i) {
        read(A[i]);read(B[i]);read(C[i]);
        w[A[i]][B[i]] = C[i];
    }
    int cur = 0;
    dp[0][1][0] = 1;
    for(int i = 1 ; i <= M ; ++i) {
        for(int j = 1 ; j < N ; ++j) {
            for(int s = 0 ; s < (1 << N - 1) ; ++s) {
                if(!dp[cur][j][s]) continue;
                if(w[i][j] != 1 && !(s >> (j - 1) & 1)) update(dp[cur][j + 1][s],dp[cur][j][s]);
                if(w[i][j] != 0) {
                    if(s >> (j - 1) & 1) update(dp[cur][j + 1][s],dp[cur][j][s]);
                    else {
                        int t = s - (s & (1 << j) - 1);
                        t -= t & (-t);
                        t ^= (1 << j - 1);
                        t += s & (1 << j) - 1;
                        update(dp[cur][j + 1][t],dp[cur][j][s]);
                    }
                }
            }
        }
        memset(dp[cur ^ 1],0,sizeof(dp[cur ^ 1]));
        for(int s = 0 ; s < (1 << N - 1) ; ++s) dp[cur ^ 1][1][s] = dp[cur][N][s];
        cur ^= 1;
    }
    int ans = 0;
    for(int s = 0 ; s < (1 << N - 1) ; ++s) ans = inc(ans,dp[cur][1][s]);
    out(ans);enter;
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 86272
S=input()
N=len(S)
acnt=0
bcnt=0
for i in range(N):
  if i%2==0:
    if S[i]=='0':
      acnt+=1
  else:
    if S[i]=='1':
      acnt+=1
 
for i in range(N):
  if i%2==1:
    if S[i]=='0':
      bcnt+=1
  else:
    if S[i]=='1':
      bcnt+=1
      
print(min(acnt,bcnt))

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

using ll = long long int;

ll k;

ll s(ll n) {
  string strn = to_string(n);
  ll sum = 0;
  for (int i = 0; i < strn.size(); ++i) {
    sum += ((int)strn[i] - 48);
  }
  return sum;
}

ll f(ll n) {
  string strn = to_string(n);

  ll bestn = 1e15 + 5;

  auto bestnresult = lldiv(bestn, s(bestn));
  ll quot = bestnresult.quot;
  ll rem = bestnresult.rem;

  for (int i = 0; i < strn.size(); ++i) {
    string curstrn = strn;
    for (int j = 0; j <= i; ++j) {
      curstrn[strn.size() - 1 - j] = '9';
    }

    ll curn = stoll(curstrn);
    auto curnresult = lldiv(curn, s(curn));

    if (curnresult.quot < quot) {
      quot = curnresult.quot;
      rem = curnresult.rem;
      bestn = curn;
    }
    else if (curnresult.quot == quot) {
      double comp = (double)curnresult.rem / (double)s(curn);
      double base = (double)rem / (double)s(bestn);

      // cout << comp << "?" << base << endl;
      // cout << curn << "_" << quot << "_" << rem << "|" << curnresult.quot << "_" << curnresult.rem << endl;

      if (comp < base) {
        quot = curnresult.quot;
        rem = curnresult.rem;
        bestn = curn;
      }
    }
  }

  return bestn;
}

int main(void) {
  // Here your code !
  scanf("%lld", &k);

  ll i = 0;
  while (i < min((ll)9, k)) {
    printf("%lld\n", i + 1);
    i += 1;
  }

  ll last = 9;
  while (i < k) {
    ll next = f(last + 1);
    printf("%lld\n", next);
    last = next;
    i += 1;
  }

	return 0;
}

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

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

ll N;
ll C[501],S[501],F[501];
ll ans[501];

int main(){
  cin>>N;
  N--;
  for(int i=0;i<N;i++){
    cin>>C[i]>>S[i]>>F[i];
  }

  ans[N]=0;
  C[N]=0;
  S[N]=0;
  F[N]=1;
  
  for(int i=0;i<N;i++){

    ll t=0;
    for(int j=i;j<N;j++){
      if(t<=S[j]){
        t=S[j]+C[j];
      }else{
        ll d=t-S[j];
        if(d%F[j]==0)t=t+C[j];
        else t=t+C[j]+(F[j]-d%F[j]);
      }
    }
    cout<<t<<endl;
  }
  cout<<0<<endl;
  return 0;
}


Measured memory_bytes: 256
from functools import reduce
X,Y = map(int,input().split())
x = (-X+2*Y) /3
y = (2*X-Y) /3
#ans=0のときをどっかで書く。indentめんどいからどうする？
MOD = 10**9+7
if int(x) == x and int(y) == y and x>=0 and y>=0 :
  sum1 = int(x+y)
  bunbo = min([int(x),int(y)])
  n1 = reduce(lambda a,b : (a*b) % MOD  ,range(sum1,sum1-bunbo,-1),1)
  n2 = reduce(lambda a,b : (a*b) % MOD ,range(bunbo,1,-1),1)
  n2inv = pow(n2,MOD-2,MOD) 
  print((n1*n2inv) % MOD)
else:
  print(0)

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

ans = [0] * n

for i in range(1, n + 1):
  for j in range(i + 1, n + 1):
    min_dis = min([
      j - i, 
     abs(j - y) + 1 + abs(x - i),
    ])
    ans[min_dis] += 1

for i in range(1, n):
  print(ans[i])

Measured memory_bytes: 46684
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7, mxK = 5e3 + 3;

int d[mxK];

signed main()
{
	IO_OP;
	
	int k, q;
	cin >> k >> q;
	for(int i=0;i<k;i++) cin >> d[i];
	while(q--) {
		int n, x, m, cnt = 0;
		cin >> n >> x >> m;
		for(int i=0;i<k;i++) if(d[i] % m == 0) cnt += (n - 1) / k + (i < (n-1) % k);
		ll sum = 0;
		for(int i=0;i<k;i++) sum += d[i] % m;
		ll y = x % m + (n - 1) / k * sum;
		for(int i=0;i<(n-1)%k;i++) y += d[i] % m;
		cnt += y / m;
		cout << n - 1 - cnt << endl;
	}
	
}





Measured memory_bytes: 384
#include <stdio.h>

int main(int argc, char** argv)
{
	int num1, num2;
	scanf("%d %d", &num1, &num2);

	printf("%d %d %.5f\n", num1 / num2, num1 % num2, (double)num1 / (double)num2);
	return 0;
}

Measured memory_bytes: 640
def bubble_sort(array)
  length = array.length
  for i in 0..(length-2)
    (length-1).downto(i+1){|j|
      if array[j][1] < array[j-1][1]
        tmp = ""
        tmp = array[j]
        array[j] = array[j-1]
        array[j-1] = tmp
      end
      }
  end
  return array
end

def selection_sort(a)
  n = a.length
  min_index = 0
  (0..n-1).each do |i|
    min_index = i
    (i..n-1).each do |j|
      if a[j][1] < a[min_index][1]
        min_index = j
      end
    end
    if a[min_index][1] < a[i][1]
      tmp = a[i]
      a[i] = a[min_index]
      a[min_index] = tmp
    end
  end
  return a
end

# def selection_sort(array)
#   length = array.length
#   p "before_array = #{array}"
#   for i in 0..(length-1)
#     min = i
#     for j in i..(length-1)
#       p "array = #{array}"
#
#       if array[j][1] < array[min][1]
#         min = j
#       end
#       if array[min][1] <= array[i][1]
#         tmp = ""
#         tmp = array[i]
#         array[i] = array[min]
#         array[min] = tmp
#       end
#     end
#   end
#   return array
# end

# ---------
# def sortBySelection(a, n)
#   n.times do |i|
#     minj = i
#     i.upto(n-1) do |j|
#       minj = j if a[j][1] < a[minj][1]
#     end
#     a[i], a[minj] = a[minj], a[i]
#   end
#   puts a.join(' ')
# end
# --------


def check_stable(bubblesort_array, selectionsort_array)
  bubblesort_array_suits = []
  b_length = bubblesort_array.length
  for i in 0..b_length
    bubblesort_array_suits.push(bubblesort_array[i])
  end
  selectionsort_array_suits = []
  s_length = selectionsort_array.length
  for i in 0..s_length
    selectionsort_array_suits.push(selectionsort_array[i])
  end
  if bubblesort_array_suits == selectionsort_array_suits
    return "Stable"
  else
    return "Not stable"
  end
end

n = gets.chomp.to_i
input_cards = gets.chomp.split.map(&:to_s)
cards = []
for i in 0..(n-1)
  card = input_cards[i].split("")
  card[1] = card[1].to_i
  cards.push(card)
end
cards2 = cards.dup
bubblesort_array = bubble_sort(cards)
selectionsort_array = selection_sort(cards2)
length = bubblesort_array.length
for i in 0..(length-1)
  print bubblesort_array[i][0]
  print bubblesort_array[i][1]
  if i != (length-1)
    print " "
  end
end
print "\n"
puts "Stable"
len = selectionsort_array.length
for i in 0..(len-1)
  print selectionsort_array[i][0]
  print selectionsort_array[i][1]
  if i != (len-1)
    print " "
  end
end
puts "\n"
puts check_stable(bubblesort_array, selectionsort_array)

Measured memory_bytes: 8852
using System;
class Program
{
  static void Main(string[] args)
  {
    // スペース区切りの整数の入力
    string[] input = Console.ReadLine().Split(' ');
    int a = int.Parse(input[0]);
    int b = int.Parse(input[1]);
    //出力
    Console.WriteLine(a*b%2 == 0? "Even":"Odd");
  }
}

Measured memory_bytes: 11092
#include<stdio.h>
int main(void){

int i, a, b, c;
scanf("%d", &i);
	
a = i / 3600;
b = ( i % 3600 )/ 60;
c = ( i % 3600 )% 60;
	
printf("%d:%d:%d\n", a, b, c);
	
return 0;
}


Measured memory_bytes: 2132
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int> > Matrix;


int main(){
  int n, m;
  cin >> n >> m;
  vector<P> p(n);
  rep(i, n) cin >> p[i].first >> p[i].second;
  sort(ALL(p));
  ll ans = 0;
  for (int i = 0; m > 0; i++){
    int a = p[i].first, b = p[i].second;
    if (m > b){
      ans += (ll)a * b;
      m -= b;
    } else {
      ans += (ll)a * m;
      m = 0;
      break;
    }
  }
  cout << (ll)ans << "\n";

}

Measured memory_bytes: 1024
//#include <map>
//#include <set>
//#include <deque>
//#include <queue>
//#include <stack>
//#include <cmath>
//#include <bitset>
//#include <vector>
//#include <cstdio>
//#include <cstring>
//#include <iostream>
//#include <algorithm>
//#include<bits/stdc++.h>
//using  namespace std;
//typedef long long ll;
//#define pd(x) printf("%d\n",x)
//#define cls(a,x) memset(a,x,sizeof(a))
//const double eps=1e-8;
//const double PI=acos(-1.0);
//const int INF=1e9+10;
//const ll MOD=1e18+7;
//const int N   =1e6+10;
//inline int sc()
//{
//    char c;
//    int ret=0;
//    if(c=getchar(),c==EOF) return 0;
//    while(c!='-'&&(c<'0'||c>'9')) c=getchar();
//    ret=(c=='-')?0:(c-'0');
//    while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');
//    return ret;
//}
//int main()
//{
//
//}



#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include<bits/stdc++.h>
using  namespace std;
typedef long long ll;
#define pd(x) printf("%d\n",x)
#define cls(a,x) memset(a,x,sizeof(a))
const double eps=1e-8;
const double PI=acos(-1.0);
const int INF=1e9+10;
const ll MOD=1e18+7;
const int N=1e6+10;
inline int sc()
{
    char c;
    int ret=0;
    if(c=getchar(),c==EOF) return 0;
    while(c!='-'&&(c<'0'||c>'9')) c=getchar();
    ret=(c=='-')?0:(c-'0');
    while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');
    return ret;
}
int n;
ll p,a[N],b[N],ha[N],sum[N];
int lowbit(int x)
{
    return x&(-x);
}
void update(int i,int x,int n)
{
    while(i<=n)
    {
        sum[i]+=x;
        i+=lowbit(i);
    }
}
ll getsum(int i)
{
    ll ans=0;
    while(i)
    {
        ans+=sum[i];
        i-=lowbit(i);
    }
    return ans;
}
void getB(int n)
{
    for(int i=1; i<=n; i++)
    {
        b[i]=getsum(a[i]);
        update(a[i],1,n);
    }
}
int main()
{
   while(~scanf("%d%lld",&n,&p))
   {
        memset(sum,0,sizeof(sum));
        a[0]=0;
        ll ans=0;
        for(int i=1; i<=n; i++)
        {
            a[i]=sc();
//            if(a[i]>=p) ans++;
            a[i]-=p;
            a[i]+=a[i-1];
            if(a[i]>=0) ans++;
            ha[i]=a[i];
        }
//        for(int i=1;i<=n;i++)
//            printf("%d %d\n",i,a[i]);
//        puts("YES");
        sort(ha+1,ha+n+1);
        int k=unique(ha+1,ha+n+1)-ha-1;
        for(int i=1; i<=n; i++) a[i]=lower_bound(ha+1,ha+k+1,a[i])-ha;
        getB(n);
        for(int i=1; i<=n; i++) ans+=b[i];
        printf("%lld\n",ans);
    }
    return 0;
}



Measured memory_bytes: 18688
N,K=map(int,input().split())
A=list(map(int,input().split()))
for _ in range(K):
  B=[0]*(N+1)
  for i in range(N):
    B[max(0,i-A[i])]+=1
    B[min(N,i+A[i]+1)]-=1
  for i in range(1,N):
    B[i]+=B[i-1]
  if A==B:
    break
  A=B[:]
print(*A[:-1])

Measured memory_bytes: 169500
#include <iostream>
using namespace std;
int main(){
    int n,x;
    cin>>n;
    for(int i=1;i<=n;i++){
        if(i%3==0){
            cout<<" "<<i;
        }
        else{
            x=i;
            while(x>0){
                if(x%10==3){
                    cout<<" "<<i;
                    break;
                }
                x=x/10;
            }
        }
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3100
n,m,k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

a,b = [0],[0]
for i in range(n):
    a.append(a[i] + A[i])
for i in range(m):
    b.append(b[i] + B[i])

ans,j = 0,m
for i in range(n+1):
    if a[i] > k:
        break
    while b[j] > k - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)


Measured memory_bytes: 134320
#include<stdio.h>
#include<stdlib.h>

int calc(int a,int b,int c){
	if(a>=b){
		if(a>=c){
			if(b*b+c*c==a*a){
				return 1;
			}
		}
		else{
			if(a*a+b*b==c*c){
				return 1;
			}
		}
	}
	else{
		if(b>=c){
			if(a*a+c*c==b*b){
				return 1;
			}
		}
		else{
			if(a*a+b*b==c*c){
				return 1;
			}
		}
	}
	return 0;
}


int main(){
	int num;
	int **data;
	int i,j;
	int cnt = 0;
	
	scanf("%d",&num);
	
	data = malloc(sizeof(int *) * num);
	for(i=0;i<num;i++){
		data[i] = malloc(sizeof(int) * 3);
	}
	
	for(i=0;i<num;i++){
		scanf("%d %d %d",&data[i][0],&data[i][1],&data[i][2]);
	}
	
	for(i=0;i<num;i++){
		cnt=calc(data[i][0],data[i][1],data[i][2]);
		if(cnt==1){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
		//printf("%d %d %d\n",data[i][0],data[i][1],data[i][2]);
	}
	
	
	
	return 0;
}

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

int main(){
    int N; cin >> N;
    vector<int> X(N), Y(N);
    for(int i = 0; i < N; i++){
        cin >> X[i];
        Y[i] = X[i];
    }
    sort(Y.begin(), Y.end());
    int med_min = Y[N/2 - 1], med_max = Y[N/2];
    for(int i = 0; i < N; i++){
        if(X[i] <= med_min) cout << med_max << endl;
        else cout << med_min << endl;
    }
}

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

typedef long long ll;

ll n;

ll solve(ll x, ll y, ll z){
    return ((x*x+y*y+z*z)+(x*y+y*z+z*x));
}

// void binSearch(){
//     ll val = 99999;
//     ll left = 0, right = 99999;
//     ll mid,ans;
//     while (left<right)
//     {
//         mid = left+(right-left)/2;
//         if(6*mid*mid>=val){
//             right=mid;
//             ans=mid;
//         }else{
//             left=mid+1;
//             ans=mid+1;
//         }
//     }
//     cout<<ans<<'\n';
// }

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> n;
    ll arr[n+1];
    for(ll i=0; i<=n; i++) arr[i]=0;

    ll x;
    for(ll i=1; i<=130; i++){
        for(ll j=1; j<=130; j++){
            for(ll k=1; k<=130; k++){
                x = solve(i,j,k);
                if(x<=n){
                    arr[x]++;
                }
                if(x>n) break;
            }
        }
    }
    for(int i=1; i<=n; i++) cout<<arr[i]<<'\n';

    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, l, r) for (int i = l; i <= (int)(r); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define all(v) v.begin(), v.end()
#define MOD (int) (1e9+7)
#define INF (int) 1e9
#define LLINF (ll) 1e18

int main(){
    int n;
    cin >> n;
    int cnt = 0;
    rep(i, n){
        int a;
        cin >> a;
        if(i%2==0 && a%2==1) cnt++;
    }
    cout << cnt << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 3604
from itertools import permutations
from copy import deepcopy

N,M = [int(i) for i in input().split()]
links  = set([input().strip() for _ in range(M)])

ans = 0

for path in permutations(range(2,N+1)):
    l = deepcopy(links)
    p_node = 1
    for n_node in path:
        e_l = " ".join([str(s) for s in sorted([p_node,n_node])])
        if e_l in l:
            l.remove(e_l)
            p_node = n_node
            continue
        else:
            break
    else:
        ans += 1 

print(ans)

Measured memory_bytes: 3440
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long t = sc.nextLong();
        long a = 100;
        int res = 0;
        while(a < t) {
            a += a/100;
            res++;
        }
        System.out.println(res);
    }
}

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

int get_heal(vector<int> v) {
    int result = 0;
    for (int n = 0; n < v.size(); ++n) {
        for (int m = n+1; m < v.size(); ++m) {
            result += (v[n] * v[m]);
        }
    }
    return result;
}

int main() {
    int length;
    cin >> length;
    vector<int> v;
    int n;
    for (; length > 0; --length) {
        cin >> n;
        v.push_back(n);
    }
    cout << get_heal(v);
}

Measured memory_bytes: 256
N,K,*A = `dd`.split.map &:to_i
Mod = 1e9.to_i+7
dp = Array.new(K+1,0)
sp = Array.new(K+2,0)
sp[1] = dp[0] = 1
(0...N).each{ |i|
  a = A[i]
  q = sp[1]
  (1..K).each{ |k|
    sp[k+1] = q += dp[k]
    m = k-a > 0 ? k-a : 0
    dp[k] = (q - sp[m]) % Mod
  }
}
p dp[-1]


Measured memory_bytes: 3464
def myabs(n):
    n = int(n)
    if n>0:
        return [n,1]
    else:
        return [abs(n),-1]


N,K = map(int,input().split())
A = list(map(myabs, input().split()))
A.sort(reverse=True)
Mod = 10**9+7

def main(n,k,a,mod):
    flag = True
    for i in a:
        if i[1]==1:
            flag = False
            break
    if k%2==0:
        flag = False

    #All elements are negative and odd k
    if flag:
        ans = 1
        for i in range(n-1,n-1-k,-1):
            ans *= (a[i][0]*(-1))%mod
            ans %= mod
        print(ans)
    else:
        ans = [1,1]
        neg_flag = False
        min_neg = -1
        min_pos = -1
        for i in range(k):
            if a[i][1]==-1:
                if neg_flag == True:
                    neg_flag = False
                    ans[1] *= a[i][0]
                    ans[0] = ans[1]
                else:
                    neg_flag = True
                    ans[1] *= a[i][0]
                    min_neg = i
            else:
                ans[0] *= a[i][0]
                ans[1] *= a[i][0]
                min_pos = i
            ans[0] %= mod
            ans[1] %= mod

        if neg_flag and n!=k:
            next_pos = -1
            next_neg = -1
            for i in range(k,n):
                if next_pos==-1 and a[i][1]==1:
                    next_pos = a[i][0]
                elif next_neg==-1 and a[i][1]==-1:
                    next_neg = a[i][0]
                if next_pos>=0 and next_neg>=0:
                    break
            if min_pos==-1:
                ans[0] *= next_pos%mod
                ans[0] %= mod
                print(ans[0])
            elif a[min_neg][0]*next_neg>a[min_pos][0]*next_pos:
                fin_ans = 1
                for i in range(k):
                    if i!=min_pos:
                        fin_ans *= a[i][0]%mod
                        fin_ans %= mod
                fin_ans *= next_neg%mod
                fin_ans %= mod
                print(fin_ans)
            else:
                fin_ans = 1
                for i in range(k):
                    if i!=min_neg:
                        fin_ans *= a[i][0]%mod
                        fin_ans %= mod
                fin_ans *= next_pos%mod
                fin_ans %= mod
                print(fin_ans)
        elif n==k and neg_flag:
            print((ans[1]*-1)%mod)
        else:
            print(ans[1])




if __name__=="__main__":
    main(N,K,A,Mod)

Measured memory_bytes: 48248
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((int)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;


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


int main() {
    string s, t; cin >> s >> t;
    for(int i = sz(s)-sz(t); i >= 0; i--){
        bool f = true;
        rep(j, 0, sz(t)){
            if(s[i+j]!='?'&&s[i+j]!=t[j]){
                f = false; break;
            }
        }
        if(!f) continue;
        rep(j, 0, sz(t)) s[i+j] = t[j];
        rep(j, 0, sz(s)){
            if(s[j] == '?') s[j] = 'a';
        }
        co(s);
        return 0;
    }
    co("UNRESTORABLE");

    return 0;
}


Measured memory_bytes: 256
n = int(input())
v = list(map(int, input().split()))

odd = [[0, i] for i in range(100001)]
even = [[0, i] for i in range(100001)]

for i in range(0, n, 2):
  odd[v[i]][0] += 1
for i in range(1, n, 2):
  even[v[i]][0] += 1

odd.sort()
even.sort()

if odd[-1][1] != even[-1][1]:
  print(n - odd[-1][0] - even[-1][0])
else:
  print(n - max(odd[-2][0] + even[-1][0], odd[-1][0] + even[-2][0]))

Measured memory_bytes: 34052
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
int kaijo(int n){
	int ans=1;
	for(int i=2;i<=n;i++){
		ans*=i;
		ans%=MOD;
	}
	return ans;
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int k,a,b;
signed main(){
	cin>>k>>a>>b;
	if(a+2>b){
		cout<<k+1<<endl;
		return 0;
	}
	k-=a-1;
	int ans=a;
	if(k==1){
		cout<<a+1<<endl;
		return 0;
	}
	else{
		ans+=(k/2)*(b-a);
	}
	cout<<ans+(k%2)<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace Aizu
{
    public class OnlineJudge
    {
        static void Main()
        {
            for (string i; (i = Console.ReadLine()) != null;)
            {
                var p = i.Split(' ').Select(q => double.Parse(q)).ToArray();
                
                var abx = p[0] - p[2];
                var aby = p[1] - p[3];

                var bpx = p[2] - p[6];
                var bpy = p[3] - p[7];

                var bcx = p[2] - p[4];
                var bcy = p[3] - p[5];

                var cpx = p[4] - p[6];
                var cpy = p[5] - p[7];

                var cax = p[4] - p[0];
                var cay = p[5] - p[1];

                var apx = p[0] - p[6];
                var apy = p[1] - p[7];

                var z1 = abx * bpy - aby * bpx;
                var z2 = bcx * cpy - bcy * cpx;
                var z3 = cax * apy - cay * apx;

                if ((z1 > 0 && z2 > 0 && z3 > 0) || (z1 < 0 && z2 < 0 && z3 < 0))
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }
        }
    }
}

Measured memory_bytes: 9496
#include <algorithm>
#include <iostream>
#include <vector>

int main(int argc, char *argv[]) {
  int N, M;
  std::cin >> N >> M;

  // favorite food for all
  std::vector< bool > fav_food(M, true);

  for (int n = 0; n < N; ++n) {
    int K;
    std::cin >> K;

    std::vector< bool > this_fav_food(M, false);
    for (int k = 0; k < K; ++k) {
      int a;
      std::cin >> a;
      this_fav_food[a - 1] = true;
    }

    for (int m = 0; m < M; ++m) {
      if (this_fav_food[m] == false) {
        fav_food[m] = false;
      }
    }
  }

  std::cout << std::count(fav_food.begin(), fav_food.end(), true) << std::endl;

  return 0;
}

Measured memory_bytes: 256