akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iterator>
#include<algorithm>
#include<vector>

template<class Iterator>
auto bubble(const Iterator first, const Iterator last) {
	auto it = first;
	int c{0};
	auto time = last - first;
	for (int i{}; i < time; i++) {
		for (int j{ 0 }; j < time - (i + 1); j++) {
//			std::cout << "i, j = " << i << "," << j << "\n";
			auto& x = *(it + j);
			auto& y = *(it + j + 1);
			if (y < x) {
				std::swap(x,y);
				c++;
			}
		}
	}

	return c;
}
/*
template<class Iterator>
auto is_sorted(const Iterator first, const Iterator last) {
	auto it = first;
	while (it + 1 != last) {

	}
}*/
int main() {
	int N{};
	std::cin >> N;
	/*
	for (int i{ 0 }; i < 5; i++) {
//		std::cout << "i, j = " << i << "\n";

		for (int j{ 0 }; j<5-(i+1); j++) {
			std::cout <<"i, j = "<< i << "," << j << "\n";
		}
	}*/

	
	std::vector<int> v;
	for (int i{ 0 }; i < N; i++) {
		int tmp{};
		std::cin >> tmp;
		v.emplace_back(tmp);
	}

	auto n = bubble(std::begin(v), std::end(v));

	std::cout << v[0];
	for (int i{ 1 }; i < N; i++ ) {
		std::cout << " " << v[i] ;
	}std::cout << "\n";
	std::cout << n << "\n";
	
//	int n_;
//	std::cin >> n_;
}


Measured memory_bytes: 3160
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();
	auto S=in<string>();
	vector<int> B(N+1,0);

	REP(i,N){
		B[i+1] = B[i];
		if(S[i]=='#') B[i+1]++;
	}

	int minS=1<<30;
	REP(i,N+1){
		int LB=B[i];
		int RW=N-i-(B[N]-B[i]);
		minS = min(minS,LB+RW);
	}
	out(minS);
	return 0;
}


Measured memory_bytes: 1428
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}


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


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

typedef pair<int,int> P;
const int INF = 500000000;

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

int main(){
    int k;
    cin >> k;
    vector<int> v;
    for (int i = 1; i <= k; i++){
        for (int j = 1; j <= k; j++){
            v.push_back(gcd(i, j));
        }
    }
    ll sum = 0;
    for (int i = 0; i < v.size(); i++){
        for (int j = 1; j <= k; j++){
            sum += gcd(v[i],j);
        }
    }
    cout << sum << "\n";
}

Measured memory_bytes: 3756
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 1999999999;

long long int N,M,P,X[200],sum=0;
int main()
{
    cout << fixed << setprecision(18);
    cin>>N>>M>>P;
    while(N!=0){
        sum=0;
        for(long long int i = 1; i <= N; i++){
            cin>>X[i];
            sum+=(100-P)*X[i];
        }
        for(long long int i = 1; i <= N; i++){
            if(M==i){
                if(X[i]!=0)cout<<sum/X[i]<<endl;
                else{cout<<0<<endl;}
            }
        }
        cin>>N>>M>>P;
    }
}




Measured memory_bytes: 2996
N,M,K = gets.split.map(&:to_i)
Mod = 998244353

D,U = [1],[1]
[K,N/2].min.times{|i| i+=1
	D << D[-1] *(N-i) % Mod
	U << U[-1] *  i   % Mod
}
U.map!{|_| _.pow(Mod-2,Mod) }
Com = lambda{|r| r = [N-1-r,r].min
	D[r] * U[r] % Mod
}

p (0..K).inject(0){|a,k|
	(a + Com[k] * M * (M-1).pow(N-1-k,Mod)) % Mod
}


Measured memory_bytes: 16212
while True:
    codes  = input().split()
    a,op,b = int(codes[0]), codes[1], int(codes[2])
    
    if op == "?":
        break

    if op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(a // b)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,x;cin>>n>>x;
    ll ans = 0;
    rep(i,n){
        ll y;cin>>y;
        ans = __gcd(ans,y-x);
    }
    cout<<abs(ans)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>
#include <bitset>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    string s;
    cin >> s;
    ll n = s.size();
    vector<int> sa = suffix_array(s);
    vector<int> la = lcp_array(s, sa);
    ll ans = n - sa[0];
    rep(i, n-1) ans += (n - sa[i+1]) - la[i];
    cout << ans << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 15684
#include<stdio.h>
int main(){
	int a,b,c,d,p,x,y;
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);
scanf("%d",&d);
scanf("%d",&p);
x=a*p;
if(p<=c){
y=b;
}
else{
y=b+d*(p-c);
}
if(x<=y){
printf("%d\n",x);
}
else{
printf("%d\n",y);
}
return 0;
}

Measured memory_bytes: 596
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }
    let mut cnts = [0; 100002];
    for i in a.into_iter() {
        count(i, &mut cnts);
    }
    let ans = cnts.into_iter().max().unwrap();
    println!("{}", ans);
}

fn count(x: usize, cnts: &mut [usize]) {
    if x == 0 {
        cnts[x] += 1;
        cnts[x+1] += 1;
    } else if x == 100000 {
        cnts[x-1] += 1;
        cnts[x] += 1;
    } else {
        cnts[x] += 1;
        cnts[x-1] += 1;
        cnts[x+1] += 1;
    }
}

Measured memory_bytes: 7164
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;

ll dp[110000];

int main(){
  ll N;
  cin>>N;
  cout<<N*(N-1)/2<<endl;
}


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

typedef long long ll;
#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prt_dbl(i,var) cout<<fixed<<setprecision(i)<<var<<endl;

//---------------------------------------------------------------

int main(){
  int N;
  cin>>N;
  int t = 0;
  int x = 0;
  int y = 0;
  string ans = "Yes";
  rep(i,N){
    int T,X,Y;
    cin>>T>>X>>Y;
    if(ans=="Yes"){
      if(((T-t)-(X-x)-(Y-y))<0)ans = "No";
      else if(((T-t)-(X-x)-(Y-y))%2==1)ans = "No";
    }
  }

  cout<<ans<<endl;

}


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

using LD = long double;

struct vec2 {
	LD x, y;
	vec2(LD x = 0, LD y = 0) : x(x), y(y) {}
	vec2 operator + (const vec2 &rhs) const {
		return vec2(x + rhs.x, y + rhs.y);
	}
	vec2 operator - (const vec2 &rhs) const {
		return vec2(x - rhs.x, y - rhs.y);
	}
	LD operator * (const vec2 &rhs) const {
		return x * rhs.x + y * rhs.y;
	}
	LD operator ^ (const vec2 &rhs) const {
		return x * rhs.y - y * rhs.x;
	}
	vec2 operator * (const LD rhs) const {
		return vec2(x * rhs, y * rhs);
	}
	friend vec2 operator * (const LD lhs, const vec2 rhs) {
		return vec2(lhs * rhs.x, lhs * rhs.y);
	}
	vec2 operator / (const LD rhs) const {
		return vec2(x / rhs, y / rhs);
	}
	LD norm2() const {
		return x * x + y * y;
	}
	LD norm() const {
		return std::sqrt(norm2());
	}
	friend std::istream& operator >> (std::istream &cin, vec2 &v) {
		return cin >> v.x >> v.y;
	}
	friend std::ostream& operator << (std::ostream &cout, const vec2 v) {
		return cout << std::fixed << std::setprecision(10) << v.x << ' ' << std::fixed << std::setprecision(10) << v.y;
	}
};
int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	vec2 v1, v2, v;
	std::cin >> v1 >> v2, v2 = v2 - v1, v2 = v2 / v2.norm();
	int q; std::cin >> q;
	for (int i = 1; i <= q; ++i) {
		std::cin >> v, v = v - v1;
		vec2 p = v1 + (v * v2) * v2;
		std::cout << 2 * p - (v + v1) << '\n';
	}
}



Measured memory_bytes: 3304
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, c,d, e;
    scanf("%d %d %d %d %d",&a, &b, &c, &d, &e);
    int f = (c-a)*60;
    f +=(d-b);
    int g = f - e;
    printf("%d\n", g);
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
#include<math.h>
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main() {
  long N;
  cin>>N; 
  vector<int>a(N);
  for (int i = 0; i < N; i++) {
    cin>>a.at(i);
  }
  sort(a.begin(),a.end());
  
  int ans=0;
  int b=a.at(0);
  for (int i = 1; i < N; i++) {
    
    if(a.at(i)==b){
      ans++;
    }
    else{
      b=a.at(i);
    }
  }
    if(ans%2==0){
      cout<<N-ans<<endl;
    }else{
      cout<<N-ans-1<<endl;
    }
 
  
 
}









Measured memory_bytes: 640
import sys
from io import StringIO
import unittest
import os

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


# 実装を行う関数
def resolve(test_def_name=""):
    # 数値取得サンプル
    #   1行1項目 n = int(input())
    #   1行2項目 x, y = map(int, input().split())
    #   1行N項目 x = [list(map(int, input().split()))]
    #   N行1項目 x = [int(input()) for i in range(n)]
    #   N行N項目 x = [list(map(int, input().split())) for i in range(n)]

    # 文字取得サンプル
    #   1行1項目 x = input()
    #   1行1項目(1文字ずつリストに入れる場合) x = list(input())
    n, k = map(int, input().split())
    p_s = list(map(int, input().split()))

    p_s.sort()

    print(sum(p_s[0:k]))



# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """5 3
50 100 80 120 80"""
        output = """210"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """1 1
1000"""
        output = """1000"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


Measured memory_bytes: 70828
#include <stdio.h>

int main(void){
  char s[3];
  char t[3];
  scanf("%s",s);
  scanf("%s",t);
  int i=0;
  for(int j=0;j<3;j++)
    if(!(s[j]^t[j]))
      i++;
  printf("%d",i);
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<algorithm>
using namespace std;
typedef unsigned long long wolf;
char in[100][100];
char str[100][100];
wolf t[100];
wolf u[100];
int tmp[100][100];
int main(){
	int T;
	scanf("%d",&T);
	while(T--){
		int a,b;scanf("%d%d",&a,&b);
		for(int i=0;i<a;i++)scanf("%s",str[i]);
		int tr=9999;
		int tc=9999;
		int br=0;
		int bc=0;
		for(int i=0;i<a;i++){
			for(int j=0;j<b;j++){
				if(str[i][j]=='#'){
					tr=min(tr,i);
					tc=min(tc,j);
					br=max(br,i);
					bc=max(bc,j);
				}
			}
		}
		int h=br-tr+1;
		int w=bc-tc+1;
		for(int i=0;i<100;i++)t[i]=u[i]=0;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(str[i+tr][j+tc]=='#')t[i]+=(1LL<<j);
			}
		}
		scanf("%d%d",&a,&b);
		for(int i=0;i<a;i++){
			scanf("%s",in[i]);
		}
		for(int i=0;i<a;i++)for(int j=0;j<b;j++){
			if(in[i][j]=='#')u[i]+=(1LL<<j);
		}
		wolf f=0;
		for(int i=0;i<b;i++)f+=(1LL<<i);
		int ret=-1;
		for(int r=0;r<4;r++){
			for(int i=0;i<=a-h;i++){
				for(int j=0;j<=b-w;j++){
					bool ok=true;
					for(int k=0;k<h;k++){
						if((t[k]<<j)&u[i+k])ok=false;
					}
					if(!ok)continue;
					int cnt=0;
					for(int k=0;k<h;k++){
						if(((t[k]<<j)|u[i+k])==f)cnt++;
					}
					ret=max(ret,cnt);
				}
			}
			for(int i=0;i<100;i++)for(int j=0;j<100;j++)tmp[i][j]=0;
			for(int i=0;i<h;i++)for(int j=0;j<w;j++){
				if(t[i]&(1LL<<j))tmp[j][h-1-i]=1;
			}
			swap(h,w);
			for(int i=0;i<100;i++)t[i]=0;
			for(int i=0;i<h;i++)for(int j=0;j<w;j++){
				if(tmp[i][j])t[i]+=(1LL<<j);
			}
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 1084
#include <algorithm>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef vector<vector<ll>> matrix;

int parity[100005];
int n, m;
void solve() {
  cin >> n >> m;
  while(m--) {
    int a, b;
    cin >> a >> b;
    parity[a]++;
    parity[b]++;
  }
  for(int i = 1; i <= n; i++) {
    if(parity[i]%2) {
      cout << "NO\n";
      return;
    }
  }
  cout << "YES\n";
}

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


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

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        String s = sc.next();

        System.out.println(a >= 3200 ? s : "red");
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 22228
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	N := nextInt()
	buttons := make([]int, N)
	for i := 0; i < N; i++ {
		buttons[i] = nextInt()
	}
	// zeroIndex := buttons[0] - 1
	next := buttons[0] - 1
	set := make(map[int]bool)
	count := 1
	for next != 1 {
		set[next] = true
		next = buttons[next] - 1
		count++
		if set[next] {
			break
		}
	}
	if next == 1 {
		fmt.Println(count)
	} else {
		fmt.Println(-1)
	}
}


Measured memory_bytes: 5632
#include <iostream>
#include <cstdio>
using namespace std;
int m, d;
int ans = 0;
int main(){
	register int i, j, k;
	cin >> m >> d;
	for(i = 1; i <= m; ++i){
		for(j = 2; j <= 9; ++j){
			for(k = 2; k <= 9; ++k){
				if(j * k == i && j*10+k <= d)++ans;
			}
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>

using namespace std;

#define PRINT(a) cout<<(a)<<endl;

int main() {
	int ans;
	long x;
	cin >> x;
	for (long i = 1; i < 10000000; i++) {
		x = x - i;
		if (x <= 0) {
			ans = i;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define  forloop for(int i=0;i<n;i++)
#define pb push_back 
#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define MOD 998244353;
#define unmap unordered_map
#define pi 3.1415926536
#define testcases ll t;cin>>t;while(t--)
#define  mp make_pair
#define  vcp vector<pair<ll,ll>>
#define preci(x,y)  fixed<<setprecision(y)<<x
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define fast ios::sync_with_stdio(false);   cin.tie(0); cout.tie(0);
#define preinc priority_queue <ll, vector<ll>, greater<ll>>
#define predec priority_queue<ll> 
#define vll vector<ll>
#define f(a,b) for(ll i=a;i<=b;i++)
int frog(int a[],int ind,int k,int n,vector<ll>&v)
{
    if(ind==n-1)
    {
        return 0;
    }
    if(v[ind]!=-1)
    {
        return v[ind];
    }
  int ans=INT_MAX;
    for(int  j=1;j+ind<n&&j<=k;j++)
    {
       
            ans=min(ans,frog(a,ind+j,k,n,v)+abs(a[ind]-a[ind+j])); 
    }
    v[ind]=ans;
    //cout<<ans<<"\n";
    return ans;
}
int main() {
    #ifndef ONLINE_JUDGE
   freopen("inp.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
   #endif
   fast
   int n;
   cin>>n;
   int k;
   cin>>k;
   int a[n];
   forloop
   cin>>a[i];
   vector<ll>v(n+1,-1);
   cout<<(frog(a,0,k,n,v));
    // your code goes here
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, e) for (int i = (int)(s); i < (int)(e); i++)
#define _rep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define _REP(i, e, s) for (int i = (int)(e - 1); i >= (int)(s); i--)

#define yes cout << "yes" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;

#define no cout << "no" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;

#define out(s) cout << s << endl;

#define ll long long
#define ull unsigned long long
#define vi vector<int>

const double PI = 3.14159265358979323846;

int main() {
    int a, b, sum = 0;
    cin >> a >> b;
    for (int i = 1; i <= b - a; i++) {
        sum += i;
    }
    cout << sum - b << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

vector<Int> get_div(Int x) {
    vector<Int> ans;
    for(Int i = 1;i*i <= x;i++) {
        if(x % i == 0) {
            ans.push_back(i);
            if(i*i != x)
                ans.push_back(x/i);
        }
    }
    
    return ans;
}

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

    auto D = get_div(N);
    auto D2 = get_div(N-1);
    Int ans = 0;
    for(auto u: D) {
        if(u == 1)
            continue;
        Int t = N;
        while(t%u == 0)
            t/=u;
        if(t % u == 1)
            ans++;
    }
  
    ans += D2.size()-1;
    cout<<ans<<endl;

    return 0;
}




Measured memory_bytes: 504
import sys
import math as m
n=int(input())
out=100000
for i in range(n):
	out=m.ceil(out*1.05/1000)*1000
print(out)

#for i in sys.stdin:
#	a,b=map(int,i.split())
#	print(gcd(a,b),lcm(a,b))

Measured memory_bytes: 7584
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[] a = new int[N];
        long sum = 0;
        int plus = 0;
        for(int i = 0; i < N; i++){
            a[i] = sc.nextInt();
            if(a[i]>=0) plus++;
            sum += Math.abs(a[i]);
        }
        sc.close();

        Arrays.sort(a);
        long ans = sum;
        if(plus == N)
            ans -= 2*a[0];
        else if(plus == 0)
            ans += 2*a[N-1];
        System.out.println(ans);
        if(plus == N) plus--;
        if(plus == 0) plus++;
        int xy = a[N-1];
        for(int i = 1; i < N-plus; i++){
            System.out.println(xy + " " + a[i]);
            xy = xy - a[i];
        }
        int yx = a[0];
        for(int i = N-2; i >= N-plus; i--){
            System.out.println(yx + " " + a[i]);
            yx = yx - a[i];
        }
        System.out.println(xy + " " + yx);
    }
}

Measured memory_bytes: 70324
/*
ID: Aman Raj
LANG: C++
TASK: milk3
*/
#include<iostream>
#include <stdio.h>
//#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#include<math.h>
typedef long long ll;
 #include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
//#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//#define flush fflush(stdout)
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <fstream>
// find_by_order()  // order_of_key
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
ll ans=0;
vector<vector<ll> > v;
vector<ll> visited;
void aman(ll i)
{
    visited[i]=1;
      for(ll j=0;j<v[i].size();j++)
      {
          if(!visited[v[i][j]]){aman(v[i][j]);}
      }
}
int main()
{    ifstream fin ("milk3.in");
     ofstream fout ("milk3.out");
     ll n,m;cin>>n;cin>>m;
     v.resize(n+1);visited.resize(n+1);
       for(ll i=0;i<m;i++)
       {
           ll a,b,c;cin>>a>>b>>c;
           v[a].push_back(b);
            v[b].push_back(a);
       }
       for(ll i=1;i<=n;i++)
       {
           if(!visited[i]){aman(i);ans++;}
       }

       cout<<ans;



    return 0;

}


Measured memory_bytes: 9600
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        long n = sc.nextLong();
        long[] arr = new long[5];
        long max = 0;
        for (int i = 0; i < 5; i++) {
            arr[i] = sc.nextLong();
            long sum = 0;
            if (n % arr[i] == 0) {
                sum = n / arr[i];
            } else {
                sum = n / arr[i] + 1;
            }
            if (sum > max) {
                max = sum;
            }
        }
        System.out.println(max + 4);
    }
}


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

int main() {
  int n;
  cin >> n;
  vector<vector<int>> g(n, vector<int>(n));
  rep(i, n) rep(j, n) g[i][j] = -1;
  rep(i, n) {
    int a;
    cin >> a;
    rep(j, a) {
      int to, is;
      cin >> to >> is;
      to--;
      g[i][to] = is;
    }
  }
  int ans = 0;
  rep(i, 1 << n) {
    vector<int> d(n);
    rep(j, n) {
      if (i >> j & 1) {
        d[j] = 1;
      }
    }
    bool isok = true;
    rep(j, n) {
      if (d[j]) {
        rep(k, n) {
          if (g[j][k] == -1) continue;
          if (g[j][k] != d[k]) isok = false;
        }
      }
    }
    if (isok) ans = max(ans, __builtin_popcount(i));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ffl(i,a,b) for(int i=a; i<b; i++)
#define fast ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
using namespace std;
int max(int a, int b)
{
    return a>b ? a : b;
}
int main()
{
    fast;
    int n;
    cin>>n;
    int arr[n][3];
    ffl(i,0,n)
        ffl(j,0,3)
            cin>>arr[i][j];
    ffl(i,1,n)
    {
        arr[i][0] += max(arr[i-1][1], arr[i-1][2]);
        arr[i][1] += max(arr[i-1][0], arr[i-1][2]);
        arr[i][2] += max(arr[i-1][1], arr[i-1][0]);
    }
    cout<<max(arr[n-1][0], max(arr[n-1][1], arr[n-1][2]))<<endl;
}

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

int main() {
    int N,C,s,t,c,r=0;
    cin >> N >> C;
    vector<vector<int>> tt(100010, vector<int>(C,0));
    set<int> p,pp;

    rep(i,N) {
        cin >> s >> t >> c;
        --s, --c;
        tt.at(s).at(c) += 1;
        tt.at(t).at(c) += 1;
    }

    rep(i,100010) {
        rep(j,C)
            if(tt.at(i).at(j)%2)
                if(p.count(j))
                    p.erase(j);
                else
                    p.insert(j);
        r = max(r, (int)p.size());
    }

    cout << r << endl;
}

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

int main(int argc, char const *argv[])
{
	int n,m;
	cin>>n>>m;
	pair<int,int> a[m];
	for (int i = 0; i < m; ++i)
	{
		cin>>a[i].second>>a[i].first;
		--a[i].second;--a[i].first;
	}
	sort(a,a+m);
	int ans=0,now=-1;
	for (auto v:a)
	{
		if (now<=v.second)
		{
			++ans;
			now=v.first;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
#define rreps(i, n) for(int i=((int)(n)); i>0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pl(s) cout << (s) << "\n";
#define pls(...) {bool space = false; for(auto i : __VA_ARGS__) (cout << (space?" ":"") << i), space = true; cout << "\n";}
#define plexit(s) {cout << (s) << "\n"; exit(0);}
#define yes(s) cout << ((s)?"Yes":"No") << "\n";
#ifdef __LOCAL
#include <dump.hpp>
#define dump(...) DUMPOUT << "  " << string(#__VA_ARGS__) << ": " << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl << "    ", dump_func(__VA_ARGS__)
#else
#define dump(...)
#endif
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct IOInit { IOInit() { cin.tie(nullptr); ios::sync_with_stdio(false); dump("READY"); /*cout << unitbuf;*/} } IO_INIT;
using ll = long long; using ull = unsigned long long; using ld = long double;
template<typename T = int> using V = vector<T>; template<typename T = int> using P = pair<T, T>;
using Vi = V<int>; using Vl = V<ll>; using Vd = V<ld>; using VVi = V<Vi>; using VVl = V<Vl>; using Pi = P<int>; using Pl = P<ll>; using Pd = P<ld>;
constexpr ll MOD = 1000000007; constexpr int INF = (1 << 30) - 1; constexpr ll INFL = 1LL << 60; constexpr ld EPS = 1e-12; constexpr ld PI = 3.141592653589793238462643383279;



signed main(void) {
  int h,w; cin >> h >> w;
  V<string> a(h);
  V<bool> rows(h);
  V<bool> cols(w);
  rep(i,h) {
    cin >> a[i];
    bool ok = false;
    rep(j,w) if (a[i][j] == '#') { ok = true; break; }
    rows[i] = ok;
  }
  rep(j,w) {
    bool ok = false;
    rep(i,h) if (a[i][j] == '#') { ok = true; break; }
    cols[j] = ok;
  }
  rep(i,h) {
    if (rows[i]) {
      rep(j,w) if (cols[j]) cout << a[i][j];
      cout << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3604
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let [r, d, x2000] = nextIntArray()
    let prev = r*x2000-d
    for(let i = 1; i<=10;i++){
        console.log(prev)
        prev = r*prev - d
    }
}
Main()


Measured memory_bytes: 30812
using System;
class Program {
  static void Main(string[] args) {
    string[] values = Console.ReadLine().Split();
    int K = int.Parse(values[0]);
    int S = int.Parse(values[1]);
    int ans = 0;
    for (int x = 0; x <= K; ++x) {
      for (int y = 0; y <= K; ++y) {
        int z = S - (x + y);
        if (0 <= z && z <= K) ++ans;
      }
    }
    Console.WriteLine(ans);
  }
}


Measured memory_bytes: 13140
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		ARC069ASolve system = new ARC069ASolve();
		system.main();
	}
}

class ARC069ASolve {
	
	long S;
	long C;
	
	ARC069ASolve() {
		Scanner cin = new Scanner(System.in);
		S = cin.nextLong();
		C = cin.nextLong();
	}
	
	void main() {
		long count = 0;	
		if (S * 2 <= C) {
			count += S;
			C -= 2 * S;
			count += C / 4;
		} else {
			count += C / 2;
		}
		System.out.println(count);
	}
}


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

public class Main {
    public static int maxN = (int) 2e5 + 5;
    public static int mod = 2019;

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        int n = s.length(), x = 0, y = 1;
        int[] cnt = new int[mod];
        for (int i = n - 1; i >= 0; i--) {
            x = (x + (s.charAt(i) - '0') * y) % mod;
            y = y * 10 % mod;
            cnt[x]++;
        }
        long ans = 0;

        for (int i = 1; i < 2019; i++) {
            if (cnt[i] > 1) {
                ans += (long) (cnt[i] - 1 + 1) * (cnt[i] - 1) / 2;
            }
        }
        ans += (long) cnt[0] * (cnt[0] + 1) / 2;

        System.out.println(ans);

    }
}


Measured memory_bytes: 37040
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int h = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        double result = (double)w * h / 2;
        if ((double)w / 2 == x && (double)h / 2 == y) {
            System.out.println(result + " " + 1);
        } else {
            System.out.println(result + " " + 0);
        }
        sc.close();
    }
}

Measured memory_bytes: 23764
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<int,int>;
using Graph=vector<vector<int>>;
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();}
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;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,M,K,ans=0LL;
  cin>>N>>M>>K;
  
  ll A[N],B[M],sa=0,sb=0;
  vector<ll> SA,SB;
  
  REP(i,N){
    cin>>A[i];
    sa+=A[i];
    SA.PB(sa);
  }
  
  REP(i,M){
    cin>>B[i];
    sb+=B[i];
    SB.PB(sb);
  }
  
  REP(i,N){
    if(SA[i]>K) continue;
    if(SB[0]>K-SA[i]){
      chmax(ans,i+1ll);
      continue;
    }
    auto it=upper_bound(ALL(SB),K-SA[i]);
    ll index=it-SB.begin();
    chmax(ans,i+1LL+index);
  }
  
  auto it=upper_bound(ALL(SB),K);
  ll index=it-SB.begin();
  chmax(ans,index);
  
  co(ans);
  return 0;
}

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

int N;
int X[100];

int main(int argc, char const *argv[])
{
    scanf("%d", &N);
    for(int i=0;i<N;i++)
    {
        scanf("%d", &X[i]);
    }

    int avg = 0;
    for (int i = 0; i < N; i++)
    {
        avg += X[i];
    }
    avg /= N;
    
    int sql = 0;
    for (int i = 0; i < N; i++)
    {
        sql += (X[i]-avg)*(X[i]-avg);   
    }

    int sqg = 0;
    for (int i = 0; i < N; i++)
    {
        sqg += (X[i]-avg-1)*(X[i]-avg-1);   
    }

    int sq = (sql < sqg) ? sql : sqg;
    printf("%d", sq);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};
int main(){
    SCIN(N);
    REP(a,3){
        if(N.at(a) == '1')cout<<"9";
        if(N.at(a) == '9')cout<<"1";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
//B - Substring
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>

#define LL long long
#define Lowbit(X) (X&(-X))
#define Lson (X<<1)
#define Rson (X<<1|1)
#define Cl(X,Y) memset((X),(Y),sizeof(X))
#define FOR(i,A,B) for(LL i=A;i<=B;i++)
#define BOR(i,A,B) for(LL i=A;i>=B;i--)
#define FOR_SIDE(i,A) for(LL i=Head[A];i;i=Next[i])
#define INF 0x7fffffff
using namespace std;

inline void File() {
    freopen(".in","r",stdin);
    freopen(".out","w",stdout);
}

int ans=INF;
char s[1100],t[1100];

int main() {
    //File();
	scanf("%s%s",s+1,t+1);
	int n = strlen(s+1),m = strlen(t+1);
	FOR(i,0,n-m) {
		int sum = 0;
		for(int j = 1;j <= m;j++){
			if(s[i+j] != t[j]) sum++; 
		}
//		cout << sum << endl;
		ans = min(sum,ans);
	}
	printf("%d\n",ans);
    //fclose(stdin); fclose(stdout);
  //  system("pause");
    return 0;
}


Measured memory_bytes: 3824
N, Q = map(int, input().split())
S = input()

ans = [0] * N

for i in range(1, N):
    ans[i] = ans[i-1]
    if S[i-1]=="A" and S[i]=="C":
        ans[i] += 1

for i in range(Q):
    l, r = map(int, input().split())
    print(ans[r-1] - ans[l-1])

Measured memory_bytes: 6060
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define int long long int
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define INF 1e9+7
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
int mpow(int base, int exp);
void ipgraph(int m);
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
const int mod = 1e9 + 7;
//const int N = 2e5+5, M = N;
//=========================================

// This problem is a variation of Longest Increasing Subsequence

const int MAXN = 2e5 + 10;
int N;
int dp[MAXN], h[MAXN], a[MAXN];
int bit[MAXN];

// update the fenwick tree
void update(int idx, int val){
    while(idx <= N){
        bit[idx] = max(bit[idx], val);
        idx += (idx & -idx);
    }
}

// answer the query for idx
int query(int idx){
    int result = 0;
    while(idx > 0){
        result = max(result, bit[idx]);
        idx -= (idx & -idx);
    }
    return result;
}

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> N;

    for(int i = 1; i <= N; ++i)
        cin >> h[i];

    for(int i = 1; i <= N; ++i)
        cin >> a[i];

    for(int i = 1; i <= N; ++i){
        // dp[i] --> stores the max total beauty if the increasing sequence
        // ended at a tree of height i.

        // query(h[i] - 1) --> returns the maximum value of beauty of a sequence in range [0, h[i] - 1].
        dp[i] = query(h[i] - 1) + a[i]; // add beauty of the current tree to the max sequence

        // update the max beauty value at index h[i] i.e, the value for increasing sequence ending at this tree
        update(h[i], dp[i]);
    }

    int best = 0;
    for(int i = 1; i <= N; ++i){
        // find the max value by traversing through total beauty values
        // of each flower height.
        best = max(best, dp[i]);
    }

    // Print the max possible answer.
    cout << best << "\n";

    return 0;
}


Measured memory_bytes: 9888
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>

template <class Int>
Int gcd(Int a, Int b) {
    while (b > 0) {
        a %= b;
        std::swap(a, b);
    }
    return a;
}

std::vector<int> primes(int n) {
    std::vector<bool> isp(n + 1, true);
    for (int i = 2; i * i <= n; ++i) {
        if (isp[i]) {
            for (int j = i; i * j <= n; ++j) {
                isp[i * j] = false;
            }
        }
    }

    std::vector<int> ret;
    for (int p = 2; p <= n; ++p) {
        if (isp[p]) ret.push_back(p);
    }
    return ret;
}

using lint = long long;

int main() {
    lint a, b;
    std::cin >> a >> b;
    lint g = gcd(a, b);

    auto ps = primes(1e6);
    std::set<lint> ans{1};

    for (auto p : ps) {
        if (g % p != 0) continue;
        ans.insert(p);
        while (g % p == 0) g /= p;
    }
    ans.insert(g);

    std::cout << ans.size() << std::endl;
    return 0;
}


Measured memory_bytes: 1020
function main(input) {
    const splitedTexts = input.split(/\s/);
    const a = parseInt(splitedTexts[0], 10);
    const b = parseInt(splitedTexts[1], 10);

    if ((a * b) % 2 === 0) {
        console.log('Even');
    } else {
        console.log('Odd');
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7500
n = int(input())
stations = [list(map(int, input().split())) for _ in range(n-1)]
for idx in range(n-1):
    t = 0
    for idx2 in range(idx, n-1):
        c, s, f = stations[idx2]
        t = max(t, s)
        if t <= f:
            t = f
        else:
            if t%f > 0:
                t += f - t%f
        t += c
    print(t)
print(0)

Measured memory_bytes: 3188
n,m=map(int,input().split())
a=[input() for _ in range(n)]
b=[input() for _ in range(m)]
ans="No"
for i in range(n-m+1):
    for k in range(n-m+1):
        for M in range(m):
            # print(f"i:{i}")
            # print(f"k:{k}")
            # print(f"a:{a[i+M][k:k+m]}")
            # print(f"b:{b[M]}")
            if a[i+M][k:k+m]!=b[M]:
                break
        else:
            ans="Yes"
print(ans)

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

long long getMaxVal(int *w, long long *v, int W, int N) {
	
	long long memo[N+1][W+1];
	
	for(int i=0; i<=N; i++) {
		for(int j=0; j<=W; j++) {
			if(i == 0 || j == 0) {
				memo[i][j] = 0;
			} else if(w[i-1] <= j) {
				memo[i][j] = max(v[i-1] + memo[i-1][j-w[i-1]], memo[i-1][j]);
			} else {
				memo[i][j] = memo[i-1][j];
			}
		}
	}
	
	return memo[N][W];
}

int main() {
	int n,w;
	cin>>n>>w;
	
	int weight[n];
	long long value[n];
	for(int i=0; i<n; i++) {
		cin>>weight[i]>>value[i];
	}
	
	cout<<getMaxVal(weight, value, w, n);
	
	return 0;
}


Measured memory_bytes: 82468
import std.stdio,std.conv, std.algorithm, std.container,std.array,std.range,std.string,std.typecons;
const dx = [1,0,-1,0];
const dy = [0,1,0,-1];
void read(T...)(auto ref T args){ 
	auto line = readln().split(); 
	foreach(i,ref arg; args) arg = line[i].to!(typeof(arg));
}
int sum(int n){return n * (n + 1)/ 2;}
int tax(int per,int yen) {return yen * (100 +per) / 100;}
void main(){
	int x,y,s;
	while(read(x,y,s),x|y|s){
		int ans ;
		foreach(i;1..s){
			foreach(j;i..s){
				if (tax(x,i) + tax(x,j) == s ){
					ans = max(ans,tax(y,i) + tax(y,j));break;
				}
			}
		}
		ans.writeln;
	}
}

Measured memory_bytes: 2392