akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e3+10;
int n,d1,d2,m;
bool vis[maxn][maxn];
void solve(int c)
{
	int tim=0;
	while(c%4==0)c/=4,tim++;
	if(c&1)
	{
		for(int i=0;i<m;i++)
		for(int j=0;j<m;j++)
		if(((i>>tim)+(j>>tim))&1)vis[i][j]=1;
	}
	else 
	{
		for(int i=0;i<m;i++)
		for(int j=0;j<m;j++)
		if((i>>tim)&1)vis[i][j]=1;
	}
}
int main()
{
	scanf("%d%d%d",&n,&d1,&d2);
	m=n<<1,solve(d1),solve(d2);
	int cnt=0;
	for(int i=0;i<m;i++)
	for(int j=0;j<m;j++)
	{
		if(!vis[i][j])printf("%d %d\n",i,j),cnt++;
		if(n*n==cnt)return 0;
	}
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int n;
  cin >> n;
  vl a(n);
  REP(i, n) { cin >> a[i]; }
  int ma = -1000001, mai = -1;
  int mi = 1000001, mii = -1;
  REP(i, n) {
    if (ma < a[i]) {
      ma = a[i];
      mai = i;
    }
    if (mi > a[i]) {
      mi = a[i];
      mii = i;
    }
  }
  int ans = 2 * n - 2;
  vector<pair<int, int>> xy;
  bool isPositive = abs(ma) > abs(mi);
  if (isPositive) {
    REP(i, n) {
      if (mai == i)
        continue;
      a[i] += ma;
      xy.push_back(make_pair(mai + 1, i + 1));
    }
  } else {
    REP(i, n) {
      if (mii == i)
        continue;
      a[i] += mi;
      xy.push_back(make_pair(mii + 1, i + 1));
    }
  }

  if (isPositive) {
    FOR(i, 1, n) { xy.push_back(make_pair(i, i + 1)); }
  } else {
    for (int i = n - 1; i > 0; i--) {
      xy.push_back(make_pair(i + 1, i));
    }
  }

  cout << ans << endl;
  REP(i, ans) { cout << xy[i].first << " " << xy[i].second << endl; }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define M (L+R)/2
#define N 500009
#define inf 99999999999
#define ll long long
#define mod 1000000007
#define sz size();
using namespace std;
ll n,m,a[N],sum,ans;
int main(){
 
	ios::sync_with_stdio(0);
	
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	sort(a+1,a+1+n);

	
	if((a[n-m+1]*4*m)<sum)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
 
	return 0;
}
 

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

int main(){
    int h,w;cin>>h>>w;
    char ans[h+2][w+2];
    for(int i=0;i<h+2;i++){
        for(int j=0;j<w+2;j++){
            ans[i][j]='#';
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            char a;cin>>a;
            ans[i+1][j+1]=a;
        }
    }
    for(int i=0;i<h+2;i++){
        for(int j=0;j<w+2;j++){
            cout<<ans[i][j];
        }
        cout<<endl;
    }        
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()
#define fcout cout << setprecision(10)

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

template <typename T>
void DEBUG(vector<T> &vec) {
    for (auto x : vec) {
        cout << x << " ";
    }
    cout << endl;
    return;
}

template <typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

template <typename T>
void ADD(T &a, const T &b) {
    T val = ((a % MOD) + (b % MOD)) % MOD;
    a = val;
}

int n, k, s;

long long solve(int sum, int depth, int cnt) {
    long long ans = 0;

    if (cnt == k) {
        ans = (sum == s ? 1 : 0);
    } else if (depth < n) {
        ans = solve(sum + depth + 1, depth + 1, cnt + 1) + solve(sum, depth + 1, cnt);
    }

    return ans;
}

int main() {
    while (cin >> n >> k >> s && n) {
        cout << solve(0, 0, 0) << endl;
    }

    return 0;
}


Measured memory_bytes: 3064
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var l = Console.ReadLine().Split(' ');
            var nums = new int[2*n];
            var result = 0;
            for(int i = 0; i < 2*n; i++)
            {
                nums[i] = int.Parse(l[i]);
            }
            Array.Sort(nums);
            for (int i = 0; i < 2*n; i++)
            {
                if(i % 2 == 0)
                {
                    result += nums[i];
                }
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 11092
use std::io::{self, BufRead};
use std::cmp::max;

fn abs(x: usize, y: usize) -> usize {
  if x < y { y - x } else { x - y }
}

fn main() {
  let stdin = io::stdin();
  let mut lines = stdin.lock().lines();
  let line = lines.next().unwrap().unwrap();
  let n: usize = line.parse().unwrap();
  let line = lines.next().unwrap().unwrap();
  let mut xs: Vec<(usize, usize)> = line.split(' ').map(|x| x.parse().unwrap()).enumerate().collect();
  xs.sort_by(|x, y| y.1.cmp(&x.1));
  let mut memo: Vec<Vec<usize>> = vec![vec![0; n+1]; n+1];
  for k in 1..=n {
    let (p, a) = xs[k-1];
    for i in 0..=k {
      let j = k - i;
      if i == 0 {
        memo[i][j] = memo[i][j-1] + a * abs(p, n-j);
      } else if j == 0 {
        memo[i][j] = memo[i-1][j] + a * abs(p, i-1);
      } else {
        memo[i][j] = max(memo[i][j-1] + a * abs(p, n-j), memo[i-1][j] + a * abs(p, i-1));
      }
    }
  }
  let ans = (0..=n).map(|k| memo[k][n-k]).max().unwrap();
  println!("{}", ans);
}

Measured memory_bytes: 33472
let char_list_of_string str =
  let rec loop i list =
    if i > 0 then loop (i-1) (str.[i-1]::list)
    else list
  in
  loop (String.length str) []
;;                   

let myrev list a b =
  let rdiv list n =
    let rec loop l1 l2 i =
      if i > 0 then
        match l2 with
          [] -> l1,[]
        | hd::td ->  loop (hd::l1) td (i-1)
      else l1,l2
    in
    loop [] list n
  in
  let front, mid, back =
    let x, yz = rdiv list a in
    let y, z = rdiv yz (b-a+1) in
    x, y, z
  in
  let rec reverse_append acu = function
      [] -> acu
    | hd::tl -> reverse_append (hd::acu) tl
  in
  let mid_front =  
    reverse_append front mid
  in
  reverse_append back mid_front
;;

let my_replace str a b p =
  let rec loop str i =
    if i < a then
      match str with
        [] -> []
      | hd::tl -> hd::loop tl (i+1)
    else if i <= b then loop (List.tl str) (i+1)
    else p @ str
  in
  loop str 0
;;

let my_print str a b =
  let rec print_loop i = function
      [] -> ()
    | hd::tl -> if i < a then print_loop (i+1) tl
                else if i < b then (print_char hd;print_loop (i+1) tl)
                else if i = b then (print_char hd;print_char '\n')
                else ()
  in
  print_loop 0 str;;

let () =
  let ch_list =
    let str = read_line () in
    char_list_of_string str
  in
  let q = read_int () in
  let rec loop ch_list = function
      0 -> ()
    | i ->
       let command, a, b, p' = Scanf.sscanf (read_line()) "%s %d %d %s" (fun x y z w ->x,y,z,w) in
       match command with
         "print" ->  my_print ch_list a b;
                     loop ch_list (i-1)
       | "reverse" -> loop (myrev ch_list a b) (i-1)
       | "replace" -> let p =
                        char_list_of_string p'
                      in
                      loop (my_replace ch_list a b p) (i-1)
       | _ -> ()
  in
  loop ch_list q
;;


Measured memory_bytes: 4388
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int n, m;
  cin >> n >> m;
  int L = 0, R = n + 1;
  rep(i, m) {
    int Li, Ri;
    cin >> Li >> Ri;
    L = max(L, Li);
    R = min(R, Ri);
  }
  cout << max(0, (R - L + 1)) << endl;
  return 0;
}

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

using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;
    if (n % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }
    string x = s.substr(0, n / 2);
    string y = s.substr(n / 2, n / 2);
    cout << (x == y ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<iostream>
#include<math.h>
using namespace std;
char s[500003];
int a[500003],dp[500003];
int main(){
    int n;
    cin>>n>>s+1;
    for(int i=1;i<=n;i++)
    {
        if(s[i]=='0')
        {
        	a[i]=i;
        }else
        {
        	a[i]=a[i-1];
        }
    }
    for(int i=3;i<=n;i++)
    {
        dp[i]=dp[i-1];
        if(s[i]=='1')
        {
            if(s[i-1]=='0'&&s[i-2]=='1')
            {
                dp[i]=max(dp[i],dp[a[i-2]]+(i-2)-a[i-2]);
                dp[i]=max(dp[i],dp[a[i-2]+1]+(i-2)-(a[i-2]+1));
            }else if(a[i]>1) if(s[a[i]-1]=='1')
            {
            	dp[i]=max(dp[i],dp[a[i]-2]+i-a[i]);
			}
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 4608
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<stdio.h>
#define rep(i,n)for(int i=0;i<n;i++)
//printf("%.yf\n",x); xを小数点以下y桁で
using namespace std;
int main() {
    int x;
    cin >> x;
    cout << x*x*x << endl;
    return 0;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; for(auto v : V) os << v << " "; return os << "]"; }
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; for(auto s:S) os<<s<<" ";return os<<"}"; }
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) { return os << "(" << P.first << "," << P.second << ")";}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) { os << "{ "; for(auto m:M) os<<"("<<m.first<<":"<<m.second<<") "; return os<<"}"; }
#ifdef LMAO
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){ const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | "; __f(comma+1, args...); }
#else
    #define trace(...) 42
#endif
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define tcase int tt; cin>>tt; while(tt--)
#define tcase2 int tt; cin>>tt; for(int qq=1;qq<=tt;qq++)
#define all(x) x.begin(), x.end()
typedef long long int ll;
typedef  unsigned long long int ull;
typedef long double ld;
const int MAX = 1000010;
const int MOD2 = 998244353;
const int MOD = 1000000007; 
const int INF = 1e8;    
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-7;
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)   
/*****************start************/
void solve()
{   
    int A,B,C;
    cin>>A>>B>>C;
    int k;
    cin>>k;
    int lo=0;
    while(B<=A)
    {
        lo++;
        B*=2;
    }
    while(C<=B)
    {
        lo++;
        C*=2;
    }
    if(lo<=k)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout<<fixed<<setprecision(25);cerr<<fixed<<setprecision(10);
    auto start = std::chrono::high_resolution_clock::now();
    // tcase{
        solve();
    // }
    auto stop = std::chrono::high_resolution_clock::now(); 
    auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start); 
    // cerr << "Time taken : " << ((long double)duration.count())/((long double) 1e9) <<"s "<< endl;     
    return 0;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,W;cin>>H>>W;
  vector<vector<int>>C(10,vector<int>(10));
  for(int i=0;i<10;i++)for(int j=0;j<10;j++)cin>>C[i][j];
  
  //ベルマンフォード法
  vector<int>costs(10,1000);costs[1]=0;
  for(int t=0;t<10;t++){
    for(int i=0;i<10;i++){
      for(int j=0;j<10;j++)costs[i]=min(costs[i],costs[j]+C[i][j]);
      //cout<<costs[i]<<" ";
    }
    //cout<<endl;
  }
  
  int ans=0;
  for(int i=0;i<H*W;i++){int a;cin>>a;if(a!=-1)ans+=costs[a];}
  cout<<ans;
  
  
  
}

Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC opatimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"
#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0); }


int main() {
//    freopen("in.txt","r", stdin);
//    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int n;
    cin >> n;
    vector<int> a(n);
    for (int& x : a)
        cin >> x;

    int sum = accumulate(begin(a), end(a), 0);

    int t = sum / n;
    long long l = 0;
    long long r = 0;
    for (int x : a) {
        l += (x - t) * (x - t);
        r += (x - t - 1) * (x - t - 1);
    }
    cout << min(l, r) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <time.h>
#include<stdlib.h>
#include<string.h>

int main(void) {
    int n, l, i, j;
    char s[101][101];

    scanf("%d %d", &n, &l);

    for (i = 0; i < n; i++) {
        scanf("%s", s[i]);
    }
    for (i = 0; i < n; i++) {
        for (j = i + 1; j < n; j++) {
            if (strcmp(s[i], s[j]) > 0) {
                char a[101];

                strcpy(a, s[i]);
                strcpy(s[i], s[j]);
                strcpy(s[j], a);
            }
        }
    }
    for (i = 0; i < n; i++)
    {
        printf("%s", s[i]);
    }
}

Measured memory_bytes: 1748
s = input()
t = input()
ans = len(t)
for i in range(len(s) - len(t) + 1):
    ss = s[i:i + len(t)]
    # print(ss)
    cnt = 0
    for i,e in enumerate(ss):
        if e != t[i]:
            cnt += 1
    # print(cnt)
    ans = min(ans,cnt)

print(ans)


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

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    int total = 0;
    for (int i = 1; i <= n; i++)
    {
        int sum = 0, temp = i;
        while (temp > 0)
        {
            sum += temp % 10;
            temp /= 10;
        }
        if (sum >= a && sum <= b)
        {
            total += i;
        }
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 3616
n,m,X,Y=map(int,input().split())
x=[0]*n
y=[0]*m
x=list(map(int,input().split()))
y=list(map(int,input().split()))
left=max(x)
right=min(y)
#print(left,right)
for i in range(X+1,Y+1):
  if (left<i<=right):
    print("No War")
    break
else:
  print("War")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

template<class T, class Cond>
struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  bool operator()(T& a, const T& b) const {
    if(cond(a, b)) { a = b; return true; }
    return false;
  }
};
template<class T, class Cond>
chain<T, Cond> make_chain(Cond cond) { return chain<T, Cond>(cond); }

int main() {
  i64 N, M, X;
  cin >> N >> M >> X;
  vector<i64> C(N);
  vector<vector<i64>> A(N);
  rep(i,0,N) {
    cin >> C[i];
    A[i].resize(M);
    rep(j,0,M) {
      cin >> A[i][j];
    }
  }
  i64 ans = 1e9;
  for(int s = 0; s < (1 << N); s++) {
    i64 sum = 0;
    vector<i64> cnt(M);
    rep(i,0,N) {
      if(s & (1 << i)) {
        sum += C[i];
        rep(j,0,M) {
          cnt[j] += A[i][j];
        }
      }
    }
    bool OK = true;
    rep(i,0,M) {
      if(cnt[i] < X) OK = false;
    }
    if(OK) {
      ans = std::min(ans, sum);
    }
  }
  if(ans == 1e9) {
    ans = -1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>

using namespace std;

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

    if(a==b){
        cout<<c<<endl;
    }
    else if(b==c) cout<<a<<endl;
    else cout<<b<<endl;
}


Measured memory_bytes: 384
/*
[exawizards2019] A - Regular Triangle
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

int A, B, C;

bool solve() { return A == B && B == C; }

int main() {
    cin >> A >> B >> C;

    cout << (solve() ? "Yes" : "No") << endl;

    return 0;
}


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

int main(){
  int n;
  double ans = 0.0, nowv = 0.0, nowt = 0.0, lim = 0.0;
  cin >> n ;
  int t[n+1], sumt=0;
  int cnt = 1;
  t[0] = 0;
  int v[n+2];
  v[n+1] = 0;
  v[0] = 0;
  for(int i=1;i<=n;i++){
    cin >> t[i];
    sumt += t[i];
    t[i] = sumt;
  }
  for(int i=1;i<=n;i++){
    cin >> v[i];
  }
  for(double i = 0.5; i<=sumt;i+=0.5){
    if(i > t[cnt]) cnt++;
    double lim = v[cnt];
    double tmp;
    for(int j=0;j<=n;j++){
      if(j < cnt){
        tmp = v[j] + i - t[j];
      }else{
        tmp = v[j+1] + t[j] - i;
      }
      lim = min(lim, tmp);
    }
    if(nowv<lim){
      ans += (nowv/2) + 0.25;
      nowv += 0.5;
    }else if(nowv>lim){
      ans += (nowv/2) - 0.25;
      nowv -= 0.5;
    }else{
      ans += (nowv/2);
    }
  }
  cout << fixed << setprecision(8) <<  ans << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            char letter = in.next().charAt(0);
            letter++;
            out.print(letter);
        }

    }
}



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

long long N;
vector<pair<long long, long long> >BA;

int main(){
	cin >> N;
	for(long long i = 0; i < N; i++){
		long long a, b;
		cin >> a >> b;
		BA.push_back(make_pair(b, a));
	}
	sort(BA.begin(), BA.end(), greater<pair<long long, long long> >());

	long long cur = 1e9;

	for(long long i = 0; i < N; i++){
		if(cur > BA[i].first){
			cur = BA[i].first - BA[i].second;
		} else {
			cur -= BA[i].second;
		}
	}
	if(cur < 0){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
}

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

int main(){
	string s;
	cin >> s;
	long long sum=0;
	for(int i=0;i<s.length();i++) sum+=int(s[i])-48;
	(sum%9==0)?cout<<"Yes":cout<<"No";
	return 0;
}

Measured memory_bytes: 3764
#include <stdio.h>
#include <math.h>

#define N 10000

int main(){
    int n, i, j, num[N], cnt = 0, flg;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        scanf("%d", &num[i]);
    }
    
    for (i = 0; i < n; i++) {
        flg = 0;
        for (j = 2; j <= sqrt(num[i]); j++) {
            if (num[i] % j == 0) {
                flg = 1;
                break;
            }
        }
        if (!flg) cnt++;
    }
    
    printf("%d\n", cnt);
    
    return 0;
}



Measured memory_bytes: 2128
#include <bits/stdc++.h> 
using namespace std;
const long INF=1000000000000000;
const long MOD=1000000007;

int main() {
    string s;
    cin>>s;
    
    vector<bool> alp(26,false);
    for(int i=0;i<s.size();i++){
        if(alp.at(s.at(i)-'a')){
            cout<<"no"<<endl;
            return 0;
        }
        
        alp.at(s.at(i)-'a')=true;
    }
    
    cout<<"yes"<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int form, mais10;
    scanf("%d %d", &form, & mais10);
    
    if (form < 10){
        printf("%d\n", (100*(10-form)) + mais10);
    }
    else
        printf("%d\n", mais10);
    
    return 0;
}


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

int main() {
    ll h;cin>>h;
    ll number=1;
    ll count=0;
    while(true){
        if(h==1){
            count+=number;
            break;
        }else if(h%2==0){
            count+=number;
            number*=2;
            h/=2;

        }else{
            count+=number;
            number*=2;
            h=(h-1)/2;

        }
    }

    cout<<count<<endl;
}

Measured memory_bytes: 256
while True:
    d = input().split()
    a,b =int(d[0]),int(d[2])
    if d[1] == "?":
        break
    if d[1] == "+":
        print(a+b)
    if d[1] == "-":
        print(a-b)
    if d[1] == "*":
        print(a*b)
    if d[1] == "/":
        print(a//b)

    


Measured memory_bytes: 5596
# AOJ 0119: Taro's Obsession
# Python3 2018.6.20 bal4u

def topological_sort(V, to):
	cnt = [0]*V
	for i in range(V):
		for j in to[i]:	cnt[j] += 1
	Q = []
	for i in range(V):
		if cnt[i] == 0:
			Q.append(i)
	while len(Q) > 0:
		i = Q[0]
		del Q[0]
		print(i+1)
		for k in to[i]:
			cnt[k] -= 1
			if cnt[k] == 0:	Q.append(k)

m = int(input())
to = [[] for i in range(m)]
n = int(input())
for i in range(n):
	x, y = list(map(int, input().split()))
	to[x-1].append(y-1)
topological_sort(m, to)


Measured memory_bytes: 5604
using System;

namespace A
{
    class Calc
    {
        public int fib(int n, ref int[] f)
        {
            if (n <= 1)
            {
                return 1;
            }
            else
            {
                if (f[n]!=0)
                {
                    return f[n];
                }
                else
                {
                    f[n] = fib(n - 1, ref f) + fib(n - 2, ref f);
                }
            }
            return f[n];
        }
    }

    class A
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int n = int.Parse(input);
            int[] f = new int[n+1];
            Calc calc = new Calc();
            Console.WriteLine(calc.fib(n,ref f));
        }
    }
}



Measured memory_bytes: 17848
def examA():
    S = SI()
    T = SI()
    if S==T[:len(S)]:
        if len(S)+1==len(T):
            print("Yes")
            return
    print("No")
    return

def examB():
    A, B, C, K = LI()
    ans = 0
    if A>=K:
        ans = K
    else:
        ans += A
        K -= A
        if K>B:
            K -= B
            ans -= K
    print(ans)
    return

def examC():
    N, M, X = LI()
    C = [LI()for _ in range(N)]
    loop = 2**N
    ans = inf
    for l in range(loop):
        cur = 0
        A = [0]*M
        for j in range(N):
            if (1<<j)&l>0:
                cur += C[j][0]
                for k in range(M):
                    A[k] += C[j][k+1]
        flag = True
        for i in range(M):
            if A[i]<X:
                flag = False
                break
        if flag:
            ans = min(ans,cur)
    if ans==inf:
        print(-1)
        return
    print(ans)
    return

def examD():
    N, K = LI()
    A = LI()
    locat_doubling = [[0]*N for _ in range(100)]
    for i in range(N):
        locat_doubling[0][i] = i
        locat_doubling[1][i] = A[i]-1
    for k in range(2,100):
        for i in range(N):
            locat_doubling[k][i] = locat_doubling[k-1][locat_doubling[k-1][i]]
    #print(locat_doubling)
    ans = [i for i in range(N)]
    for k in range(100):
        for i in range(N):
            if K&(1<<k)>0:
                ans[i] = locat_doubling[k+1][ans[i]]
    print(ans[0]+1)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examD()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 250536
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main() {
  ll n;
  cin >>n;
  ll a[n],b[n],sum=0;
  for(ll i=0;i<n;i++) {
    cin >>a[i];
    a[i]*=2;
    b[i]=a[i];
  }
  ll k;
  for(ll i=n-1;i>=4;i-=2){
    a[i-2]=a[i]+a[i-1]+a[i-2]-a[i-1]*2;
  }
  k=(a[0]+a[1]+a[2])/2-a[1];
  cout <<k<<" ";
  for(ll i=0;i<n-1;i++) {
    if(i==n-2) cout <<b[i]-k;
    else cout <<b[i]-k<<" ";
    k=b[i]-k;
  }
  cout<<endl;
  return 0;
}


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

int main(void)
{
    vector <int> a;
    int b;

    for (int i = 0; i < 10; i++){
    cin>>b;
a.push_back(b);
}

for (int i = 0; i < 100000; i++){
	for (int j = 0; j < 100; j++){
		b = 0;
	}
}

sort(a.begin(), a.end());
cout << a[9] << endl << a[8] << endl << a[7] << endl;

return 0;
}

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

int main()
{
    int a,b;
    cin >> a >> b;
    if(a <= 0 && b >= 0){
        cout << "Zero";
    }else if(a >= 1){
        cout << "Positive";
    }else{
        int d = a - b + 1;
        if(d % 2 == 0){
            cout << "Positive";
        }else{
            cout << "Negative";
        }
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		for (int i = 1; ; i++){
			int x = sc.nextInt();
			if (x == 0){
				break;
			}
			System.out.printf("Case %d: %d\n",i,x);
		}
 	}
}


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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

const int dx[4] = {+1, 0, -1, 0};
const int dy[4] = {0, -1, 0, +1};

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll a, b, n;
    cin >> a >> b >> n;
    ll x = min(b - 1, n);
    cout << (a * x / b) << endl;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

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

template<typename T> class BinaryIndexedTree
{
private:
    int N = 0;
    vector<T> Data;

public:
    BinaryIndexedTree(int n) : N(n) { Data.assign(N + 1, 0); }

    // BIT内は1-indexed, 引数は0-indexed, (i&-i)は最下位ビット
    void add(int k, T x)
    {
        for (int i=k+1;i<=N;i+=(i&-i)) { Data[i] += x; }
    }

    // [0,k]の総和を求める
    int sum(int k)
    {
        T res = 0;
        for (ll i=k+1;i>0;i-=(i&-i)) { res += Data[i]; }
        return res;
    }

    // [l,r]の総和を求める
    int sum(int l, int r) { return sum(r) - (l >= 1 ? sum(l - 1) : 0); }

    // [0, k] >= x となる最小の k を求める
    int lowerBound(T x)
    {
        int k = 1, t = 0;
        while ((k << 1) <= N) { k <<= 1; }

        for (;k>0;k>>=1) if (t + k <= N && Data[t + k] < x)
        {
            x -= Data[t + k];
            t += k;
        }

        return t + 1;
    }
};

struct Query
{
    ll ID, L, R;
};

int main()
{
    ll N, Q;
    cin >> N >> Q;

    vector<ll> C(N);
    rep (i, N) { cin >> C[i]; --C[i]; }

    vector<Query> queries(Q);
    rep (i, Q)
    {
        auto& query = queries[i];
        query.ID = i;

        cin >> query.L >> query.R;
        --query.L;
        --query.R;
    }

    sort(queries.begin(), queries.end(), [](const auto& a, const auto& b)
    {
        return a.R < b.R;
    });

    vector<ll> ans(Q, -1);
    vector<ll> last(N, -1);

    // SegmentTree<ll> seg(N, 0LL, [](ll a, ll b) { return a + b; });
    BinaryIndexedTree<ll> bit(N);

    ll index = 0;

    for (const auto& query : queries)
    {
        while (index <= query.R)
        {
            auto& prev = last[C[index]];

            if (prev != -1) { bit.add(prev, -1); }
            bit.add(index, 1);

            prev = index;
            ++index;
        }

        ans[query.ID] = bit.sum(query.L, query.R);
    }

    for (const auto& x : ans) { cout << x << endl; }

    return 0;
}


Measured memory_bytes: 31112
local N = io.read("*n")
local K = io.read("*n")

local A = {}
for i = 1, N do
	A[i] = io.read("*n")
end

local function goToK(town, rem_times)
	if rem_times <= 0 then
		return town
	else
		return goToK(A[town], rem_times - 1)
	end
end

local last_times = {}
local function teleport(town, times)
	if times == K then
		return town
	end

	local last_time = last_times[town]
	if last_time ~= nil then
		local loop_times = times - last_time
		local K_in_loop = K - last_time
		K_in_loop = K_in_loop % loop_times

		return goToK(town, K_in_loop)
	else
		last_times[town] = times

		return teleport(A[town], times + 1)
	end
end

print(teleport(1, 0))

Measured memory_bytes: 14640
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>
using namespace std;

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define llrp(i,n) for(long long i=0;i<n;i++)
#define llrep(i,m,n) for(long long i=m;i<=n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define vcin(a); rp(i,a.size()){cin>>a[i];}
#define vcout(a); rp(i,a.size()){cout<<a[i]<<endl;}
#define allchar(c) for(char c='a';c<='z';c++)

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef long long ll;
typedef string S;
typedef pair<int,int> P;
typedef queue<int> qi;

const int mod=1e9+7;

ll modpow(ll a,ll b,ll p){
    if(b==0){
        return 1;
    }elif(b%2==0){
        return modpow((a*a)%p,b/2,p);
    }else{
        return (a*modpow(a,b-1,p))%p;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,k;
    cin >> a >> b >> k;
    rp(i,k){
        if(i%2==0){
            a-=(a%2==1?1:0);
            b+=a/2;
            a/=2;
        }else{
            b-=(b%2==1?1:0);
            a+=b/2;
            b/=2;
        }
    }
    cout << a << ' ' << b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
main(){
  int i,j,n,x,y,w,h,xx,yy,c,m;
  scanf("%d",&m);
  for(i=0;i<m;i++){
    c=0;
    scanf("%d%d%d%d%d",&x,&y,&w,&h,&n);
    for(j=0;j<n;j++){
      scanf("%d%d",&xx,&yy);
      if(x<=xx && xx<=x+w && y<=yy && yy<=y+h) c++;
    }
    printf("%d\n",c);

  }
  return 0;
}

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

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ll x,y,a,b,c;
  cin>>x>>y>>a>>b>>c;
  vector<ll>R(a),G(b),C(c);
  for(ll i=0;i<a;i++) cin>>R[i];
  for(ll i=0;i<b;i++) cin>>G[i];
  for(ll i=0;i<c;i++) cin>>C[i];
  sort(R.begin(), R.end(), greater<ll>());
  sort(G.begin(), G.end(), greater<ll>());
  sort(C.begin(), C.end(), greater<ll>());
  vector<ll>res;
  for(ll i=0;i<x;i++)
  {
    res.push_back(R[i]);
  }
  for(ll i=0;i<y;i++)
  {
    res.push_back(G[i]);
  }
  ll ans=0;
  sort(res.begin(), res.end(), greater<ll>());
  for(ll i=(x+y-1),j=0;i>=0;i--)
  {
    if(j<c && C[j]>res[i])
    {
      ans+=C[j];
      j++;
    }
    else
      ans+=res[i];
    
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 4852
#include <iostream>
using namespace std;
int main(void){
    int x,y;
    cin >> x >> y;
    if(x<y){
        cout << "a < b" << endl;
    }else if(x>y){
        cout << "a > b" << endl;
    }else{
        cout << "a == b" << endl;
    }
}

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

typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
const double pi = 3.141592653589793238;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

void printV(vector<int> &v);
void printVV(vector<vector<int>> &vv);


int main() {
  string S;
  cin >> S;

  if(S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


// ベクターの中身を全部出力
void printV(vector<int> &v) {
  cout << "  [ ";
  for(int i = 0; i < (int)v.size(); i++) {
    cout << v.at(i) << " ";
  }
  cout << "]" << endl;
}

void printVV(vector<vector<int>> &vv) {
  cout << "{" << endl;
  for(int i = 0; i < (int)vv.size(); i++) {
    cout << "  [ ";
    for(int j = 0; j < (int)vv.at(i).size(); j++) {
      cout << vv.at(i).at(j) << " ";
    }
    cout << "]," << endl;
  }
  cout << "}" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define ll long long
#define pii pair<int, int>
using namespace std;

set<int> s;
int n, x;

int main(){
    #ifdef DEBUG
       freopen("input.txt", "r", stdin);
    #endif // DEBUG
    cin >> n;
    for(int i = 1; i <= n; ++i){
        cin >> x;
        s.insert(x);
    }
    cout << (int)s.size() << endl;
    return 0;
}



Measured memory_bytes: 256
I=input;n,m=map(int,I().split());a=[I()for _ in[0]*n];b=[I()for _ in[0]*m];r=n-m+1;print('YNeos'[sum(sum(b==[t[j:j+m]for t in a[i:i+m]]for j in range(r))for i in range(r))<1::2])

Measured memory_bytes: 39792
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<ll,ll>;


ll m=1000000007;

ll mod=1e9+7;
ll dp[2000+4];


int main()
{
 ll n;
 cin>>n;
 vector<ll>a(n);
 rep(i,n)cin>>a[i];
 vector<ll>v(1000007,-1);
 rep(i,n){
     if(v[a[i]]==-1){
         for(ll l=a[i];l<=1000007;l+=a[i]){
            if(v[l]==-1){v[l]=1;}
             else{v[l]=2;}
         }
     }else{
         v[a[i]]=2;}
 }
 ll ans=0;
 rep(i,n)if(v[a[i]]==1){
     ans++;}
 cout<<ans<<endl;
 }

 


 

 




Measured memory_bytes: 12684
#include <bits/stdc++.h>
#define rep( i, n ) for (long long i = 0; i < ( long long )(n); i++)

using namespace std;
typedef long long ll;
typedef pair< int , int > P;
typedef tuple<int, int, int> T;


int main(){
  ll n,m;
  ll sum=0;
  ll ans;
  cin>>n>>m;

  rep(i,m){
    ll a;
    cin>>a;
    sum+=a;
  }

  if(sum>n){
    ans=-1;
  }
  else{
    ans=n-sum;
  }
  cout<<ans;
} 


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

int main()
{
	int a[3][3];
	for (int i = 0; i < 3; ++i)
	{
		for (int j = 0; j < 3; ++j)
		{
			cin >> a[i][j];
		}
	}
	int n;
	cin >> n;
	int b;
	int bingo[3][3] = {};
	for (int i = 0; i < n; ++i)
	{
		cin >> b;
		for (int j = 0; j < 3; ++j)
		{
			for (int k = 0; k < 3; ++k)
			{
				bingo[j][k] += (a[j][k] == b);
			}
		}
	}
	int ans = 0;
	int now;
	for (int i = 0; i < 3; ++i)
	{
		now = 0;
		for (int j = 0; j < 3; ++j)
		{
			now += bingo[i][j];
		}
		ans += now / 3;
		now = 0;
		for (int j = 0; j < 3; ++j)
		{
			now += bingo[j][i];
		}
		ans += now / 3;
	}
	now = 0;
	for (int i = 0; i < 3; ++i)
	{
		now += bingo[i][i];
	}
	ans += now / 3;
	now = 0;
	for (int i = 0; i < 3; ++i)
	{
		now += bingo[i][2 - i];
	}
	ans += now / 3;
	cout << (ans != 0?"Yes":"No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>

using namespace std;

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

    vector<int> L;

    int ma = 0;
    int mp;

    for(int i = 0; i < N; i++){
        int l;
        cin >> l;

        L.push_back(l);

        if(l > ma){
            ma = l;
            mp = i;
        }
    }

    int sum = 0;
    for(int i = 0; i < N; i++){
        if(i != mp){
            sum += L[i];
        }
    }

    if(sum > ma){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {

	var S string

	fmt.Scan(&S)

	result := SliceInt(len(S))

	for i:=0;i<len(S);i++{

		cnt:=0
		max :=0

		if i!=len(S)-1{

			for j:=i;j<len(S);j++{


				if S[j:j+1] == "A" || S[j:j+1] == "C" || S[j:j+1] == "G"||S[j:j+1] == "T"{

					cnt++

				}else{

					if cnt >= max{

					max = cnt
					cnt =0
					}
				}

			}

			if cnt > max{

				max = cnt
			}


			result[i] = max
			
		}else{

			if S[i:i+1] == "A" || S[i:i+1] == "C" || S[i:i+1] == "G"||S[i:i+1] == "T" { 


				cnt++

			}

			result[i] = cnt
		}

	}

	sort.Sort(sort.IntSlice(result))

	fmt.Println(result[len(result)-1])
}

//SliceInt 引数サイズのSliceを返す
func SliceInt(a int) []int{

	 IntSample :=  make([]int, a)

	 return IntSample
	
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int N,R=1;
	string S;
	cin >> N >> S;
	for (int i=0; i<N-1; i++) {
		if (S.at(i) != S.at(i+1)){
			R++;
		}
	}
	cout << R << endl;
	
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int N=2005;
typedef long long ll;
int n,a[N];
int gcd(int x,int y){
    if(!y) return x;
    return gcd(y,x%y);
}
int G[N][N];
struct node{
    int u,v,nxt;
}e[N<<1];
int head[N],cnt;
inline void add(int u,int v){
    e[++cnt].u=u;
    e[cnt].v=v;
    e[cnt].nxt=head[u];
    head[u]=cnt;
}
bool vis[N];
int rudu[N];
inline void dfs(int u){
    vis[u]=1;
    for(int v=1;v<=n;v++)
        if(G[u][v]&&!vis[v]){
            add(u,v);
            rudu[v]++;
            dfs(v);
        }
}
int ans[N];
typedef pair<int,int>pi;
priority_queue<pi>q;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
            if(gcd(a[i],a[j])>1) G[i][j]=G[j][i]=1;
    for(int i=1;i<=n;i++)
        if(!vis[i]) dfs(i);
    int cnt=0;
    for(int i=1;i<=n;i++)
        if(!rudu[i]) q.push(pi(a[i],i));
    while(!q.empty()){
        int w=q.top().first,u=q.top().second;
        q.pop();
        ans[++cnt]=w;
        for(int i=head[u];i;i=e[i].nxt){
            int v=e[i].v;
            rudu[v]--;
            if(!rudu[v]) q.push(pi(a[v],v));
        }
    }
    for(int i=1;i<n;i++) printf("%d ",ans[i]);
    printf("%d\n",ans[n]);
    return 0;
}

Measured memory_bytes: 16128
/*input
z
*/

#include <bits/stdc++.h>

using namespace std;

int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  char s;
  cin >> s;
  if (isupper(s)) {
    cout << 'A';
  } else {
    cout << 'a';
  }


  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1<<17,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    map<int,int> MA;
    
    for(int i=1;i<=1000;i++){
        int sum=i;
        for(int j=i+1;j<=1000;j++){
            sum+=j;
            MA[sum]++;
        }
    }
    
    while(1){
        int N;cin>>N;
        
        if(N==0) return 0;
        
        cout<<MA[N]<<endl;
    }
}



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

#define INF int(1e9)
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=105;
const int maxm=20005;
int n,m;
int a[maxn][maxn],b[maxn][maxn],c[maxn][maxn],id[maxn][maxn];
vector<int>val[maxn][maxn];

namespace Flow{
	int S,T,V,tot;
	int head[maxn*2],nxt[maxm*2],to[maxm*2],cap[maxm*2];
	int lvl[maxn*2],cur[maxn*2],q[maxn*2];
	void init(){
		tot=0;
		memset(head,-1,sizeof(head));
	}
	int addedge(int u,int v,int c){
		nxt[tot]=head[u];to[tot]=v;cap[tot]=c;head[u]=tot++;
		nxt[tot]=head[v];to[tot]=u;cap[tot]=0;head[v]=tot++;
		return tot-2;
	}
	void bfs(){
		rep(i,V)lvl[i]=-1;
		lvl[S]=0;
		int l=0,r=0;
		q[r++]=S;
		while(l<r){
			int x=q[l++];
			for(int i=head[x];~i;i=nxt[i]){
				if(cap[i]&&lvl[to[i]]<0){
					lvl[to[i]]=lvl[x]+1;
					q[r++]=to[i];
				}
			}
		}
	}
	int dfs(int x,int f){
		if(x==T)return f;
		for(int &i=cur[x];~i;i=nxt[i]){
			if(cap[i]&&lvl[to[i]]==lvl[x]+1){
				int d=dfs(to[i],min(f,cap[i]));
				if(d>0){
					cap[i]-=d;
					cap[i^1]+=d;
					return d;
				}
			}
		}
		return 0;
	}
	int work(){
		int res=0;
		for(;;){
			bfs();
			if(lvl[T]<0)break;
			rep(i,V)cur[i]=head[i];
			for(;;){
				int f=dfs(S,INF);
				if(!f)break;
				res+=f;
			}
		}
		return res;
	}
}

int main(){
	scanf("%d%d",&n,&m);
	REP(i,n)REP(j,m){
		scanf("%d",&a[i][j]);
		val[i][(a[i][j]-1)/m+1].pb(a[i][j]);
	}
	REP(i,m){
		Flow::init();
		Flow::S=0;Flow::T=n+n+1;Flow::V=Flow::T+1;
		REP(j,n)Flow::addedge(Flow::S,j,1);
		REP(j,n)Flow::addedge(j+n,Flow::T,1);
		REP(j,n)REP(k,n)if(!val[j][k].empty())id[j][k]=Flow::addedge(j,k+n,1);
		assert(Flow::work()==n);
		REP(j,n)REP(k,n)if(!val[j][k].empty()&&!Flow::cap[id[j][k]]){
			b[j][i]=val[j][k].back();
			val[j][k].pop_back();
		}
	}
	REP(i,m){
		vector<int>tmp;
		REP(j,n)tmp.pb(b[j][i]);
		sort(tmp.begin(),tmp.end());
		REP(j,n)c[j][i]=tmp[j-1];
	}
	REP(i,n)REP(j,m)printf("%d%c",b[i][j],j==m?'\n':' ');
	REP(i,n)REP(j,m)printf("%d%c",c[i][j],j==m?'\n':' ');
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 998244353;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	string S;
	cin >> S;
	int C[3];
	C[0] = C[1] = C[2] = 0;
	int res = 1;
	for (int i = 0; i < 3 * N; i++) {
		int X, Y, Z;
		if (S[i] == 'R') {
			X = 0; Y = 1; Z = 2;
		}
		else if (S[i] == 'G') {
			X = 1; Y = 0; Z = 2;
		}
		else {
			X = 2; Y = 1; Z = 0;
		}

		if (C[Y] > 0 && C[Z] > 0) {
			res = (res * min(C[Y], C[Z])) % MOD;
			C[Y]--;
			C[Z]--;
		}
		else {
			if (C[Y] == 0) {
				swap(Y, Z);
			}

			if (C[X] < C[Y]) {
				res = (res * (C[Y] - C[X])) % MOD;
			}
			C[X]++;
		}
	}
	for (int i = 1; i <= N; i++) {
		res = (res * i) % MOD;
	}
	cout << res << endl;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

#define MAX_V 3200
 
struct Edge
{
    int to, cap, rev;
    Edge(){};
    Edge(int to, int cap, int rev) : to(to), cap(cap), rev(rev){};
};
 
vector<Edge> G[MAX_V];
bool used[MAX_V];
 
void add_edge(int from, int to, int cap){
    G[from].push_back({to, cap, (int)G[to].size()});
    G[to].push_back({from, 0, (int)G[from].size()-1});
}
 
int dfs(int v, int t, int f){
    if(v == t) return f;
    used[v] = true;
    for(int i = 0; i < G[v].size(); i++){
        Edge& e = G[v][i];
        if(!used[e.to] && e.cap > 0){
            int d = dfs(e.to, t, min(f, e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}
 
int max_flow(int s, int t){
    int flow = 0;
    while(1){
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF);
        if(f == 0) return flow;
        flow += f;
    }
}

//エラトステネスの篩を使用
const int MAX_PRIME = 1e7 + 10;
 
vector<int> is_prime(MAX_PRIME,1);
 
void calcPrime(){
    is_prime[0]=is_prime[1]=0;
    for(int i=2; i<MAX_PRIME; i++){
        if(is_prime[i]==1){
            for(int j=i*2; j<MAX_PRIME; j+=i){
                is_prime[j]=0;
            }
        }
    }
}

int main(){
	calcPrime();
	int n;
	cin >> n;
	vi x(n);
	rep(i, n) cin >> x[i];
	map<int, int> mp;
	rep(i, n) {
		mp[x[i]]^=1;
		mp[x[i]+1]^=1;
	}
	vi odd, even;
	for(auto& p : mp) if(p.se) (p.fi&1?odd:even).pb(p.fi);
	rep(i, odd.size()) rep(j, even.size()) {
		if(is_prime[abs(odd[i]-even[j])]) add_edge(1000+i, 2000+j, 1);
	}
	rep(i, odd.size()) add_edge(0, 1000+i, 1);
	rep(i, even.size()) add_edge(2000+i, 1, 1);
	int f = max_flow(0, 1);
	int ans = f + (((int)odd.size()-f)/2)*2 + (((int)even.size()-f)/2)*2;
	if(((int)odd.size()-f)&1) ans += 3;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 39552
/*
AizuOnline A1135
Title Ohgas' Fortune
*/
#include <stdio.h>
#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
int n,m;
//
int calc_compound(int amount,int years,double rat,int chg)
{
        int i;

        for(i=0;i<years;i++)
        {
                amount = amount*(1.0 + rat);
                amount -= chg;
        }
        return(amount);
}
int calc_simple(int amount,int years,double rat,int chg)
{
        int i;
        int interest;

        interest=0;
        for(i=0;i<years;i++)
        {
               interest+=amount*rat;
               amount -= chg;
        }
        return(amount+interest);
}
int calc(int amount,int years,int s_or_c,double rate,int charge)
{
        int i,ret;
 
        if(s_or_c==0)
                ret=calc_simple(amount,years,rate,charge);
        else
                ret=calc_compound(amount,years,rate,charge);
        return(ret);
}
main()
{
        int i,j,ret;
        int max_final_amount;
        int final_amount;
        int init_fund;
        int op_years;
        int s_or_c;
        double rate;
        int  charge;

        scanf("%d",&m);

        for(i=0;i<m;i++)
        {
                scanf("%d",&init_fund);
                scanf("%d",&op_years);
                scanf("%d",&n);

                max_final_amount=0;
                for(j=0;j<n;j++)
                {
                        scanf("%d %lf %d",
                              &s_or_c,
                              &rate,
                              &charge);

                        final_amount=calc(init_fund,op_years,s_or_c,rate,charge);
                        if(final_amount>max_final_amount)
                                max_final_amount=final_amount;
                }
                printf("%d\n",max_final_amount);
        }
return(0);
}

Measured memory_bytes: 632