akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#include <cassert>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define Cout(x) cout << x << endl;
#define check(v) rep(i,v.size()) cout << v[i] << endl;
#define vint(x) vector<int> x
#define vll(x) vector<long long> x
#define vstr(x) vector<string> x
const long long LLINF = 1LL<<60;
const int INF = 1e9;
const long long MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
#define pint pair<int,int>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    string u, d; cin >> u >> d;
    ll ans;
    int che;
    rep(i,n) {
        if(i==0) {
            if(u[i]==u[i+1]) {
                ans = 6;
                i++;
                che = 1;
            }
            else {
                ans = 3;
                che = 0;
            }
        }
        else {
            if(u[i]==u[i+1]) {
                if(che==1) {
                    ans *= 3;
                }
                else {
                    ans *= 2;
                }
                ans %= MOD;
                che = 1;
                i++;
            }
            else {
                if(che==1) che = 0;
                else {
                    ans *= 2;
                    ans %= MOD;
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (int &ai: a) cin >> ai;
    int q; cin >> q;
    while (q--) {
        int k; cin >> k;
        cout << binary_search(a.begin(), a.end(), k) << endl;
    }
    return 0;
}


Measured memory_bytes: 3124
import java.util.*;
import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    String s=sc.next();
    int max=0;
    int x=0;
    if(s.length()==n){
    for(int i=0;i<n;++i) {
      if(s.charAt(i)=='I'){
        ++x;
      } else {
        --x;
      }
      if(max<x){
        max=x;
      }
    }
    
    System.out.println(max);
  }
}
}

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

int main(){
    int n,d,x;
    int sum;
    int tmp;
    cin >> n >> d >> x;
    for(int i=0; i < n; i++){
        cin >> tmp;
        sum += (d -1) / (tmp);
    }
    sum += n * 1 + x;
    
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 256
import sys
N,M=map(int,input().split())
a=list(map(int,input().split()))

def gcd(a,b):
  if a==b:
    return a
  a,b=max(a,b),min(a,b)
  if a%b==0:
    return b
  else:
    return gcd(b,a%b)
  
def lcm(a,b):
  return a*b//gcd(a,b)

if N==1:
  v=M//int(a[0]*0.5)
  if v%2==0:
    print(v//2)
  else:
    print(v//2+1)
  sys.exit()
  
for i in range(N-1):
  if i==0:
    tmp=lcm(a[i]//2,a[i+1]//2)
    devider=min(a[i]//2,a[i+1]//2)
    if (tmp//devider)%2==0:
      print(0)
      sys.exit()
  else:
    tmp=lcm(tmp,a[i+1]//2)
    devider=min(tmp,a[i+1]//2)
    if (tmp//devider)%2==0:
      print(0)
      sys.exit()

v=M//tmp
if v%2==1:
  print(v//2+1)
else:
  print(v//2)

Measured memory_bytes: 14404
#include <iostream>

using namespace std;

#define int long long

const int N = 2e5 + 10, mod = 998244353;

int n, q, ten[N], seg[N << 2], lazy[N << 2];

int t(int l, int r) {
  return ((ten[n - l + 1] - ten[n - r]) % mod + mod) % mod;
}

void push(int n, int i, int j) {
  if (lazy[n]) {
    if (i != j) {
      lazy[n << 1] = lazy[n << 1 | 1] = lazy[n];
    }
    seg[n] = (lazy[n] * t(i, j)) % mod;
    lazy[n] = 0;
  }
}

int query(int i, int j, int l, int r, int n) {
  if (i > r || j < l) {
    return 0;
  }
  if (i >= l && j <= r) {
    //push(n, i, j);
    return seg[n];
  }
  int m = (i + j) >> 1;
  return (query(i, m, l, r, n << 1) + query(m + 1, j, l, r, n << 1 | 1)) % mod;
}

void update(int i, int j, int l, int r, int v, int n) {
  push(n, i, j);
  if (i > r || j < l) {
    return;
  }
  if (i >= l && j <= r) {
    lazy[n] = v;
    push(n, i, j);
    return;
  }
  int m = (i + j) >> 1;
  update(i, m, l, r, v, n << 1);
  update(m + 1, j, l, r, v, n << 1 | 1);
  seg[n] = (seg[n << 1] + seg[n << 1 | 1]) % mod;
}

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);    
  cin >> n >> q;
  ten[1] = 1;
  for (int i = 2; i <= n; ++i) {
    ten[i] = (ten[i - 1] * 10) % mod;
  }
  for (int i = 2; i <= n; ++i) {
    ten[i] = (ten[i - 1] + ten[i]) % mod;
  }
  update(1, n, 1, n, 1, 1);
  while (q--) {
    int l, r, d;
    cin >> l >> r >> d;
    update(1, n, l, r, d, 1);
    cout << query(1, n, 1, n, 1) << '\n';
  }
  return 0;
}


Measured memory_bytes: 13420
#include <bits/stdc++.h>
  template <size_t N>
  class sieve_of_eratosthenes {
    std::bitset<N> is_prime_;

  public:
    constexpr sieve_of_eratosthenes(){
      is_prime_ = ~is_prime_;
      is_prime_.reset(0), is_prime_.reset(1);
      for (size_t p = 2; p < N; p++) {
        if (!is_prime_.test(p)) continue;
        for (size_t j = 2; j * p < N; j++) {
          is_prime_.reset(p * j);
        }
      }
    }

    // Return the bitset testing if a number is prime.
    constexpr const auto& is_prime() const {return is_prime_;}

    // Returns the vector of prime numbers.
    template <typename T>
    auto primes() const {
      std::vector<T> primes{}; 
      for (size_t i = 0; i < N; i++) {
        if (is_prime_.test(i)) primes.push_back(i);
      }
      return primes;
    }
  };
  int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  auto primes = sieve_of_eratosthenes<10000000>{}.primes<long long>();
  auto make = [&] (int n) {
    auto ans = std::vector<std::vector<long long>>(n, std::vector<long long>(n, 0));
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        auto anti_diag = (i + j) / 2;
        auto diag = (i - j) >> 1;
        if ((i + j) % 2 == 0) {
          ans.at(i).at(j) =
            primes.at(anti_diag) *
            primes.at(n +  diag);
        } else {
          ans.at(i).at(j) =
            primes.at(anti_diag    ) *
            primes.at(anti_diag + 1) *
            primes.at(n +  diag    ) *
            primes.at(n +  diag + 1) + 1;
        }
      }
    }
    return ans;
  };
  int n; std::cin >> n;
  auto large = make(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      std::cout << (j > 0 ? " " : "") << large.at(i).at(j);
    }
    std::cout << std::endl;
  }
  return 0;
  }

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

public class Program
{
    public static void Main()
    {
        var s = Console.ReadLine();
        var t = Console.ReadLine();
        if ( s.CompareTo(t) < 0 )
        {
            Console.WriteLine("Yes");
            return;
        }
        var s2 = s.ToCharArray();
        Array.Sort(s2);
        var s_dash = new String(s2);
        var t2 = t.ToCharArray();
        t2 = t2.OrderByDescending( x => x ).ToArray();
        var t_dash = new String(t2);
        if ( s_dash.CompareTo(t_dash) < 0 )
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13536
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-05-11 17:44:50
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int flag = 0;
  for (auto e : vec) os << (flag++ ? ", " : "{") << e;
  return os << (vec.empty() ? "{}" : "}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int flag = 0;
  for (auto e : st) os << (flag++ ? ", " : "{") << e;
  return os << (st.empty() ? "{}" : "}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int flag = 0;
  for (auto e : mp) os << (flag++ ? ", " : "{") << e;
  return os << (mp.empty() ? "{}" : "}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

class Doubling {
 public:
  Doubling(int n, int64 k) : n_(n), lg_(64 - __builtin_clzll(k)) {
    table.assign(lg_, std::vector<int>(n_, -1));
  }

  void set_next(int pos, int value) { table[0][pos] = value; }

  void build() {
    for (int i = 0; i + 1 < lg_; ++i) {
      for (int j = 0; j < (int)table[i].size(); ++j) {
        table[i + 1][j] = (table[i][j] == -1 ? -1 : table[i][table[i][j]]);
      }
    }
  }

  int query(int pos, int64 k) {
    for (int i = lg_ - 1; i >= 0; --i) {
      if (k & (1LL << i)) {
        pos = table[i][pos];
      }
    }
    return pos;
  }

 private:
  int n_;
  int lg_;
  std::vector<std::vector<int>> table;
};

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

  int n;
  cin >> n;
  int64 k;
  cin >> k;
  Doubling db(n, k);

  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    --a;
    db.set_next(i, a);
  }

  db.build();

  cout << db.query(0, k) + 1 << endl;

  return 0;
}

Measured memory_bytes: 50952
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

s = input()

for i in range(len(s)):
	if s[i] == "C" and 1 <= s[i+1:].count("F") :
		print("Yes")
		break
else:
	print("No")

Measured memory_bytes: 10564
N, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

for i in range(K+1, N+1):
  # 0, ..., K-1
  #   1, ... ,  K
 # print(i-1, i-K-1)
  if A[i - 1] > A[i - K - 1]:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 94268
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
  string t;
  cin >> s >> t;
  int ans = 0;
  for(int i=0;i<s.size();i++){
  	if(s[i]!=t[i]){
    	ans++;
    }
  }
  cout << ans;
}

Measured memory_bytes: 3916
#include<bits/stdc++.h>
#define mz 998244353
#define pq priority_queue
using namespace std;



int main()
{
    int n,m,f;
    scanf("%d%d",&n,&m);
    if(n%2)
    {
        for(int i=1;i<=m;i++)
            printf("%d %d\n",i,n+1-i);
    }
    else
    {
        f=n/4+1;
        for(int i=1;i<=m;i++)
        {
            if(i>=f)
            {
                n--;
                f=1000000;
            }
            printf("%d %d\n",i,n+1-i);
        }
    }
    return 0;
}


Measured memory_bytes: 3836
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
using namespace std;
const int N=15;
char ss[N];
int main()
{
	scanf("%s",ss+1);
	int len=strlen(ss+1);
	bool tf=true;
	if (ss[1]!='A') tf=false;	//printf("%d\n",tf);
	int cnt=0;
	for (int u=3;u<len;u++)
		if (ss[u]=='C')
			cnt++;
	if (cnt!=1) tf=false;
	for (int u=1;u<=len;u++)
	{
		if (ss[u]=='A'||ss[u]=='C') continue;
		if (ss[u]>='a'&&ss[u]<='z') continue;
		tf=false;
	}
	if (tf) printf("AC\n");
	else printf("WA\n");
	return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from collections import deque 
def main():
    s = deque(readline().rstrip().decode())
    q = int(readline())
    dir = 1
    for _ in range(q):
        txt = readline().rstrip().decode()
        if txt[0] == '1':
            dir += 1
            dir%=2
        elif txt[0] == '2':
            f = txt[2]
            c = txt[4]
            if ((dir==1) and (f=='1')) or ((dir==0) and (f=='2')):
                s.appendleft(c)
            else:
                s.append(c)
    if dir==0:
        print(''.join(reversed(s)))
    else:
        print(''.join(s))
if __name__ == '__main__':
    main()


Measured memory_bytes: 8372
#include <stdio.h>
#include <math.h>
int IsPrime(int num)
{
    int k=(int)sqrt((double)num);
    for(int i=2;i<=k;i++)
    {
        if(num%i==0)
        {return 1;}//is not a prime number
    }
    return 0;
}
int main(int argc, const char * argv[]) {
    int a[10000]={0};
    int n = 0;
    int counter=0;
    scanf("%d", &n);
    for(int i=0;i<n;i++){scanf("%d", &a[i]);}
    for(int j=0;j<n;j++)
    {
        if(IsPrime(a[j])==0)
        {
            counter++;
        }
    }
    printf("%d\n", counter);
    return 0;
}



Measured memory_bytes: 2036
//JSd
#include<iostream>
#include<set>
using namespace std;
int main(){
int n;
string s,t;
cin>>n;
cin>>s>>t;
int i=0,j=0;
bool res=1;
while(i<s.length() or j<t.length()){
	if(res)
		cout<<s[i++];
	else
		cout<<t[j++];
	res=!res;
}
	return 0;
}

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

using namespace std;

int a[200010], n;

inline bool is_digit(char c) {
	return c <= '9' && c >= '0';
}

inline int read() {
	int tmp = 0;
	char c = getchar();
	while(!is_digit(c)) c = getchar();
	while(is_digit(c)) tmp = (tmp << 1) + (tmp << 3) + (c ^ 48), c = getchar();
	return tmp;
}

int main() {
	n = read();
	for(register int i = 1; i <= n; i++) a[i] = read();
	int cnt = 0;
	for(register int i = 1; i <= n; i++) {
		if(a[i] == cnt + 1) {
			cnt++;
		}
	}
	if(cnt) cout << n - cnt << endl;
	else puts("-1");
	return 0;
}

Measured memory_bytes: 1024
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int main(){
    int N=0;
    long double Ans=0;
    cin >> N;
    for(int i=0; i<N; ++i){
        long double x=0;
        cin >> x;
        string u="";
        cin >> u;
        if(u=="JPY") Ans += x;
        else Ans += x*380000;
    }
    cout << Ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << "[(" << __LINE__ << ") " << (#x) << "]: " << x << endl;

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

    int n;
    cin >> n;

    int x;
    int ans = 0;
    for (int i=0; i<n; i++) {
        cin >> x;
        if (i%2 == 0 && x % 2) ans++;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3628
import java.util.*;
import java.util.Collections;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    sc.close();
    System.out.println(Math.max(0, C - (A - B)));
  }
}


Measured memory_bytes: 21844
#include<stdio.h>
int main(){
  int a, b, c;
  char op;
  while(1){
    scanf("%d %c %d", &a, &op, &b);
	if(op == 63){
		break;
	}
    if(op == 43){
      c = a + b;
    }else if(op == 45){
      c = a - b;
    }else if(op == 42){
      c =a * b;
    }else if(op == 47){
      c = a / b;
    }
	printf("%d\n", c);
  }
  return 0;
}


Measured memory_bytes: 2076
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
int ctz(int x) { return __builtin_ctz(x); }
int clz(int x) { return __builtin_clz(x); }

bool f(int x){
  for(ll j = 2; j * j <= x; j++){
    if(x % j == 0) return 0;
  }
  return 1;
}

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  int x;
  cin >> x;
  for(int i = x; i < mod; i++){
    if(f(i)){
      cout << i;
      return 0;
    }
  }
}

Measured memory_bytes: 384
n = int(input())
persons_coordinates = list(map(int, input().split()))
max_coordinate = max(persons_coordinates)
min_coordinate = min(persons_coordinates)
min_stamina = float('inf')

for p in range(min_coordinate, max_coordinate + 1):
    stamina = 0
    for x in persons_coordinates:
        stamina += (x - p) ** 2
    if min_stamina >= stamina:
        min_stamina = stamina

print(min_stamina)

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
class Cube{
    int[] f;
    Cube(int[] Dice){
        f = new int[6];
        for(int i=0;i<6;i++){
            f[i] = Dice[i];
        }
    }
    
    void roll_z(){
        roll(1,2,4,3);
    }
    void roll_y(){
        roll(0,2,5,3);
    }
    void roll_x(){
        roll(0,1,5,4);
    }
    void roll(int i,int j,int k,int l){
        int t = f[i];
        f[i] = f[j];
        f[j] = f[k];
        f[k] = f[l];
        f[l] = t;
    } 
}

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<Cube> Lists = new ArrayList<>();
		
		int[] C = new int[6];
		int n = sc.nextInt();
		
		for(int i=0;i<n;i++) {
			for(int j=0;j<6;j++) {
				C[j] = sc.nextInt();
			}
			Lists.add(new Cube(C));
		}
		
		boolean Flag = true;
		//boolean[] Judge = new boolean[n];
		
		loop : for(int l=1;l<n;l++) {
		for(int i=0;i<4;i++) {
			for(int j=0;j<4;j++) {
				for(int k = 0;k<4;k++) {
					if(Arrays.equals(Lists.get(0).f,Lists.get(l).f)) {
						Flag = false;
						break loop;
					}
					Lists.get(l).roll_x();
				}
				Lists.get(l).roll_z();
			}
			Lists.get(l).roll_y();
		}
		}
		
		if(Flag) 
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}


Measured memory_bytes: 29084
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;

int h[100000] = {};

int main(){
    int n, i, flag = 0;
    cin >> n;
    for(i=0; i<n; i++){
        cin >> h[i];
    }
    for(i=n-1; i>0; i--){
        if(n == 1) break;
        if(h[i] < h[i-1]) h[i-1]--;
        if(h[i] < h[i-1]) flag = 1;
    }
    cout << (flag ? "No\n" : "Yes\n");
    return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int K = int.Parse(str[1]);
		//if((K+(K+N-1))*N/2 + (K+N+(K+N+N-1))*N/2 > ((K+N+N+(K+N+N+N-1))*N/2)){
		//	Console.WriteLine("-1");
		//} else {
			int[,]A = new int[N,3];
			for(var i=0;i<N;i++){
              	A[i,0] = K+i;
            }
          	int a1 = K+N+N-2;
          	int a2 = K+N+N+N-(N+1)/2-1;
			for(var i=0;i<N/2;i++){
              	A[i,1] = a1;
              	A[i,2] = a2;
              	a1 -= 2;
              	a2 -= 1;
            }
          	a1 = K+N+N-1;
          	a2 = K+N+N+N-1;
          	for(var i=N/2;i<N;i++){
              	A[i,1] = a1;
              	A[i,2] = a2;
              	a1 -= 2;
              	a2 -= 1;
            }
      		bool flag = true;
      		for(var i=0;i<N;i++){
              	if(A[i,0]+A[i,1]>A[i,2]){
                  	flag = false;
                }
            }
      		if(flag){
			for(var i=0;i<N;i++){
				Console.WriteLine(A[i,0]+" "+A[i,1]+" "+A[i,2]);
			}
            } else {
              	Console.WriteLine("-1");
            }
		//}
	}
}

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

using namespace std;
#define ll long long
#define ld long double
#define INF 0x3f3f3f3f
const int N=2e5 + 5;
const ll mod = 1e9 + 7;

int n;
string str[N];
char res[N];

void dfs(int i, int a, int b, int c) {
    if(i > n) {
        cout << "Yes" << endl;
        for(int idx=1;idx<=n;idx++) {
            cout << res[idx] << endl;
        }
        exit(0);
    }
    if(str[i] == "AB") {
        if(a) res[i] = 'B', dfs(i+1, a-1, b+1, c);
        if(b) res[i] = 'A', dfs(i+1, a+1, b-1, c);
    }
    else if(str[i] == "AC") {
        if(a) res[i] = 'C', dfs(i+1, a-1, b, c+1);
        if(c) res[i] = 'A', dfs(i+1, a+1, b, c-1);
    }
    else {
        if(b) res[i] = 'C', dfs(i+1, a, b-1, c+1);
        if(c) res[i] = 'B', dfs(i+1, a, b+1, c-1);
    }
}

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    int a, b, c;
    cin >> n >> a >> b >> c;
    for(int i=1;i<=n;i++) cin >> str[i];
    dfs(1, a, b, c);
    cout << "No" << endl;
    exit(0);
}


Measured memory_bytes: 17832
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using ll = long long;

ll N, P;

std::map<ll, ll> prime_factor( ll n )
{
  std::map<ll, ll> ret;

  for( ll i = 2; i*i <= n; ++i )
  {
    while( n % i == 0 )
    {
      n /= i;
      ++ret[i];
    }
  }

  if( n != 1 )
    ++ret[n];

  return ret;
}

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

  auto m = prime_factor( P );

  ll ans = 1;

  for( auto it = m.begin(); it != m.end(); ++it )
  {
    rep( i, (it->second / N) )
      ans *= it->first;
  }

  printf( "%lld\n", ans );
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int n;
string a[10000];
int as[100000];
int ok[5]={5,7,5,7,7};
bool check1(int a){
  int cnt=0;
  int tmp=0;

  for(int i=a;i<n;i++){
    //cout<<i<<" "<<tmp<<endl;
    tmp+=as[i];
      if(tmp==ok[cnt]){
        tmp=0;
        cnt++;
        if(cnt==5)return true;
      }
      //else if(tmp<ok[cnt])tmp+=as[i];
      else if(tmp>ok[cnt]){
        return false;
      }
  }
  //cout<<a<<" ok"<<endl;
  return false;
}

bool check2(int a){
  int cnt=0;
  int tmp=0;
  for(int i=a;i>=0;i--){
    tmp+=as[i];
    if(tmp==ok[cnt]){
      tmp=0;
      cnt++;
      if(cnt==5)return true;
    }
    else if(tmp>ok[cnt])return false;
  }
  return false;
}
int main(){

  while(cin>>n,n){
    for(int i=0;i<n;i++){
      cin>>a[i];
      as[i]=a[i].size();
    }
    int ans1=10000,ans2=10000;
    for(int i=0;i<n;i++){
      if(check1(i)){
        ans1=i;
        break;
      }
  }

  for(int i=n-1;i>=0;i--){
    if(check2(i))ans2=i;
  }
  //cout<<ans1<<endl;
  if(ans1<ans2)cout<<ans1+1<<endl;
  else cout<<ans2+1<<endl;
}
  return 0;
}

Measured memory_bytes: 3260
#include <stdio.h>

int main(){
  int x,y,tmp,r;

    scanf("%d %d",&x,&y);
    while(y>0){
    if(x<y){
      tmp=x;
      x=y;
      y=tmp;
    }
    r=x%y;
    x=y; 
    y=r;
      } 
    printf("%d\n",x);     
    
    return 0;

}

Measured memory_bytes: 592
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <list>
#include <algorithm>
#include <cmath>
#include <cinttypes>

using namespace std;

std::vector<uint64_t> PrimeFactorization(uint64_t n)
{
	std::vector<uint64_t> factors;

	while ((n & 1) == 0)
	{
		factors.push_back(2);
		n >>= 1;
	}

	for (uint64_t i = 3; i*i <= n; i += 2)
	{
		while((n%i) == 0)
		{
			factors.push_back(i);
			n /= i;
		}
	}

	if (n != 1)
		factors.push_back(n);

	return std::move(factors);
}

uint64_t solve(const std::vector<uint64_t> & factors, int i, uint64_t value, uint64_t n )
{
	if (i == factors.size())
	{
		return value + (n/value) - 2;
	}

	int begin = i;
	int end = i + 1;

	while (end < factors.size() && factors[end] == factors[begin])
		++end;

	uint64_t ans = UINT64_MAX;
	ans = std::min(ans, solve(factors, end, value, n));

	for (int j = begin; j < end; ++j)
	{
		value *= factors[j];
		ans = std::min(ans, solve(factors, end, value, n));
	}

	return ans;
}

int main()
{
	uint64_t n;
	cin >> n;

	auto factors = PrimeFactorization(n);
	std::reverse(factors.begin(), factors.end());

	uint64_t ans = n - 1;

	if (factors.size() >= 2)
	{
		ans = std::min(ans, solve(factors, 0, 1, n));
	}

	cout << ans << endl;

	return 0;
}

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

namespace arc075_a
{
    class Program
    {
        static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var sList = new List<int>();
            for (var i = 0; i < n; i++)
            {
                sList.Add(int.Parse(Console.ReadLine()));
            }

            sList.Sort();
            var total = sList.Sum();
            if (total % 10 != 0)
            {
                Console.WriteLine(total);
                Environment.Exit(0);
            }

            foreach (var s in sList)
            {
                if (s % 10 != 0)
                {
                    Console.WriteLine(total - s);
                    Environment.Exit(0);
                }
            }

            Console.WriteLine(0);
        }
    }
}

Measured memory_bytes: 13268
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int price = 0;
        boolean judge = false;
        
        for(int i=N; i>0; i--){
            price = i;
            if(Math.floor(price*1.08) == N){
                judge = true;
                break;
            }
        }
        
        if(judge) System.out.println(price);
        else System.out.println(":(");
        
    }
}


Measured memory_bytes: 35828
#include <bits/stdc++.h>
using namespace std;
int main()
{
    //freopen("input.txt", "r", stdin);
    int n;
    int st = 111;
    cin >> n;
    for(int i = 111; i <= 999; i+=111){
        if(n == i){
            cout << n << endl;
            break;
        }else if(n < i){
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;




int main(){
    char c;cin >> c;
    if(c=='A') puts("T");
    else if(c=='C') puts("G");
    else if(c=='G') puts("C");
    else puts("A");
    return 0;
}



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

using namespace std;

const int maxh = 13;
const int maxw = 1003;
const int inf = 1e9;

int h, w, k;
bool table[maxh][maxw];
void read()
{
    cin >> h >> w >> k;
    for (int i = 1; i <= h; i++)
        for (int j = 1; j <= w; j++)
        {
            char ch;
            cin >> ch;
            table[i][j] = ch - '0';
        }
}

int cnt_white[maxh][maxw];
void precalculate()
{
    for (int i = 1; i <= h; i++)
        for (int j = 1; j <= w; j++)
            cnt_white[i][j] = cnt_white[i][j-1] + cnt_white[i-1][j] - cnt_white[i-1][j-1] + table[i][j];
}

int query(int x1, int y1, int x2, int y2)
{
    return cnt_white[x2][y2] - cnt_white[x2][y1-1] - cnt_white[x1-1][y2] + cnt_white[x1-1][y1-1];
}

int dp[maxw];
void solve()
{
    precalculate();
    int ans = inf;
    for (int i = 0; i < (1 << (h-1)); i++)
    {
        vector <pair <int, int> > rects;
        int last = 0;
        for (int j = 1; j <= h-1; j++)
            if (i & (1 << (j-1)))
                rects.push_back({last+1, j}), last = j;

        rects.push_back({last+1, h});

        for (int i = 1; i <= w; i++)
        {
            bool can = true;
            for (auto j: rects)
                if (query(j.first, 1, j.second, i) > k)
            {
                can = false;
                break;
            }

            if (can)
                dp[i] = 0;

            else
            {
                dp[i] = inf;
                for (int j = i-1; j >= 1; j--)
                {
                    can = true;
                    for (auto p: rects)
                        if (query(p.first, j+1, p.second, i) > k)
                    {
                        can = false;
                        break;
                    }

                    if (can)
                        dp[i] = min(dp[i], dp[j] + 1);
                }
            }
        }

        ans = min(ans, dp[w] + __builtin_popcount(i));
    }

    cout << ans << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    read();
    solve();
}


Measured memory_bytes: 384
use proconio::{
   fastout, input,
   marker::{Bytes, Chars, Isize1, Usize1},
};

const INF: usize = 999999999999;

fn main() {
   input! {
      n:usize,m:usize,x:usize,
   }
   let mut c = vec![];
   let mut v = vec![];
   for _ in 0..n {
      input! {
         cs:usize,
         a:[usize;m]
      }
      c.push(cs);
      v.push(a);
   }

   let mut ans = INF;

   for i in 0..2_u64.pow(n as u32) {
      let mut cost = 0_usize;
      let mut level = vec![0_usize; m];
      for j in 0..n {
         if ((i >> j) & 1) == 1 {
            cost += c[j];
            for k in 0..m {
               level[k] += v[j][k];
            }
         }
      }
      //print!("{} ", *level.iter().min().unwrap());
      if *level.iter().min().unwrap() >= x {
         ans = std::cmp::min(cost, ans);
      }
   }
   println!("{}", if ans == INF { -1 } else { ans as isize });
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5 + 10;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int t;
bool a[1001][1001];
int f[1001][1001];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int h, w;
    cin >> h >> w;
    FOR(i, 1, h)
        FOR(j, 1, w)
            {
                char ch;
                cin >> ch;
                if(ch == '#') a[i][j] = 1;
            }
    f[1][1] = 1;
    FOR(i, 1, h)
    {
        FOR(j, 1, w)
        {
            if(i == 1 && j == 1) continue;
            if(a[i][j] == 0)
                f[i][j] = (f[i - 1][j] + f[i][j - 1]) % MOD;
        }
    }
    cout << f[h][w];
    return 0;
}


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

int main(){
	ll N;
	cin >> N;
	for(int h=1;h<=3500;h++){
		for(int n=1;n<=3500;n++){
			ll x = 4*h*n-N*n-N*h;
			ll y = N*h*n;
			if(x<=0)continue;
			if(y%x==0){
				printf("%ld %ld %ld\n",h,n,y/x);
				return 0;
			}
		}
	}
}


Measured memory_bytes: 256
#N,A,B=map(int, input().split())

#A=list(map(int, input().split()))

N=int(input())

F=[]
P=[]

for i in range(N):
    tmp=list(map(int, input().split()))
    F.append(tmp)

for i in range(N):
    tmp=list(map(int, input().split()))
    P.append(tmp)

max_sum=-1000000001

for i in range(1,1024):
    bin=[0]*10
    now=i
    for j in range(10):
        bin[j]=now%2
        now=now//2
    ans_sum=0
    for j in range(N):
        ans=0
        for h in range(10):
            if F[j][h]*bin[h]==1:
                ans+=1
        ans_sum+=P[j][ans]
    if max_sum<ans_sum:
        max_sum=ans_sum

print(max_sum)

Measured memory_bytes: 3064
N=int(input())
R=[list(map(int,input().split())) for i in range(N) ]
B=[list(map(int,input().split()))  for i in range(N) ]
R.sort(key=lambda x:x[1],reverse=1)
B.sort()
ans=0
for b in B:
    for r in R:
        if b[1]>r[1] and b[0]>r[0]:
            ans+=1
            R.remove(r)
            break
print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#pragma warning(disable : 4996)

using namespace std;

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

//最大公約数
long gcd(long a, long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}

//最小公倍数
long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;

const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-10;

char str[12];

int main(){
	char tmp;
	int f = 0;
	
	REP(i,3){
		scanf("%s", str);
		
		int len = strlen(str);
		
		if (i){
			if (tmp != str[0]){
				f = 1;
				break;
			}
		}
		
		tmp = str[len-1];
	}
	
	if (f) cout << "NO" << endl;
	else cout << "YES" << endl;
	
	return 0;
}

Measured memory_bytes: 256
/**
        Bismilla- hir rahma-nir rahi-m
    @uthor Md Hasibur Rahman (Evan)
                JKKNIU
*/


#include<bits/stdc++.h>
#define         ll              long long
#define         FI              freopen("input.txt","r",stdin)
#define         FO              freopen("output.txt","w",stdout)
#define         PrintCase(i)    printf("Case %d: ",i)
#define         sc(a)           scanf("%d",&a)
#define         scl(a)          scanf("%lld",&a)
#define         rep(i,n)        for(int i=0;i<n;i++)
#define         pb              push_back
#define         MAX             1000000
#define         fast            ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);



using namespace std;

bool isPrime(ll a)
{
    for(ll i=2;i*i<=a;i++)
        if(a%i==0)
            return false;
    return true;
}






bool isPowerOfTwo(ll a)
{
    if(a==1)
        return true;
    if(a&1)
        return false;
    while(a)
    {
        a/=2;
        if(a!=1 && a&1)
            return false;
        if(a==1)
            return true;
    }
    return true;
}




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



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



ll power(ll base, ll exponent)
{
    ll ans = 1;
    for(ll i=1;i<=exponent;i++)
        ans*=base;
    return ans;
}




bool isPowerOfX(ll x, ll value)
{
    if(value==1)
        return true;
    while(value)
    {
        value/=x;
        if(value%x && value!=1)
            return false;
    }
    return true;
}





int main()
{
    fast;
    string s,t;
    cin>>s>>t;
    int ans = INT_MAX;
    for(int i=0;i<=s.size()-t.size();i++)
    {
		int cnt = 0,indx = 0;
		for(int j=i;j<s.size()&& indx<t.size();j++)
		{
			if(s[j]!=t[indx])
				cnt++;
			indx++;
			//cout<<s[j]<<" "<<t[indx]<<" --> "<<cnt<<endl;
		}
		ans = min(ans,cnt);
	}
	cout<<ans<<endl;
    return 0;
}



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

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

    for(int i=0; i<=N; i++){
	for(int j=0; j<=N-i; j++){
	    for(int k=0; k<=N-i-j; k++){
		
		if(i+j+k == N && 10000*i+5000*j+1000*k==Y){
		    	cout << i << " " << j << " " << k << endl;
			return 0;
		}		
	    }
	}
    }

    cout << -1 << " " << -1 << " " << -1 << endl;    

}




Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int n;
    cin >> n;
    vi d(n);
    rp(i,n) cin >> d[i];
    sort(all(d));
    print(d[n/2]-d[n/2-1]);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
using namespace std;
using namespace std::chrono;
#define int long long
#define f(a,b,c) for(a=b;a<=c;a++)
#define frev(a,b,c) for(a=b;a>=c;a--)
#define rep(a,b,c) for(a=b;a<c;a++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define endl '\n'
#define ff first
#define ss second
#define ld long double
int M1=1000000007;
int M2=67280421310721;
int M3=998244353;
int INF=1e18;
int power(int a, int b, int mod)
{
    int ans=1;
    int prod=a;
    while(b)
    {
        if(b%2)
            ans=(ans*prod)%mod;
        prod=(prod*prod)%mod;
        b/=2;
    }
    return ans;
}
int inv(int a, int mod)
{
    return power(a, mod-2, mod);
} 
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int fact(int n,int mod){
	int f=1;
	for(int i=1;i<=n;i++) f=(f*i)%mod;
	return f;
}
int ncr(int n,int r,int mod){
	if(mod==1){
	return (fact(n,mod)/fact(r,mod))/fact(n-r,mod);
	}
	return (((fact(n,mod)*inv(fact(r,mod),mod))%mod)*inv(fact(n-r,mod),mod))%mod;
}
vector<int> adj[200005];
bool vis[200005]={0};
int par[200005]={0};
void solve(){
    //code starts here
    int n,m;
    cin>>n>>m;
    int i;
    for(i=0;i<m;i++){
    	int u,v;
    	cin>>u>>v;
    	adj[u].pb(v);
    	adj[v].pb(u);
    }	
    //bfs
    queue<int> q;


    q.push(1);
    vis[1]=true;
    par[1]=-1;
    int cnt=1;
    while(!q.empty()){
    	int s=q.front();
    	q.pop();
    	for(auto u:adj[s]){
    		if(vis[u]) continue;
    		vis[u]=1;
    		par[u]=s;
    		cnt++;
    		q.push(u);
    	}
    }
    if(cnt!=n){
    	cout<<"No"<<endl;
    	return ;
    }
    cout<<"Yes"<<endl;
    for(i=2;i<=n;i++){
    	cout<<par[i]<<endl;
    }
}
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout<<fixed<<setprecision(10);
    auto start = high_resolution_clock::now();
    int i,t=1;
    //cin>>t;
    f(i,1,t) solve();
    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
    //cout << duration.count() << endl;
}

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

int main(){
  int c;
  cin>>c;
  std::vector<int64_t> a(c+1);
  a.at(0)=2;
  a.at(1)=1;
  for(int i=2;i<=c;i++){
    a.at(i)=a.at(i-1)+a.at(i-2);
  }
  cout<<a.at(c);
}


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

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = long.Parse(line[0]);
        var x = long.Parse(line[1]);
        line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, long.Parse);
        var mina = Array.ConvertAll(line, long.Parse);
        var ans = getAns(a, mina, x);
        Console.WriteLine(ans);
    }
    public static long getAns(long[] a, long[] mina, long x)
    {
        var n = a.Length;
        var finret = mina.Sum();
        for (int i = 1; i < n; i++)
        {
            var ret = 0L;
            for (int j = 0; j < n; j++)
            {
                var ni = (j - i + n) % n;
                mina[j] = Math.Min(mina[j], a[ni]);
                ret += mina[j];
            }
            ret += i * x;
            finret = Math.Min(ret, finret);
        }
        return finret;
    }
}


Measured memory_bytes: 13268
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
 
struct P{
  int x,y;
  P(){}
  P(int x,int y):x(x),y(y){}
};
 
int x,y,sx,sy,gx,gy;
int dp[6][1001][1001];
 
vector<P> p[6];

int ttt;
 
int solve(int i,int x,int y){
  if(dp[i][x][y]>=0){
    return dp[i][x][y];
  }
  if(i==4){
    return dp[i][x][y] = abs(x-gx)+abs(y-gy);
  }
 
  int next = (ttt+i)%5+1;
  int ret = 1111111;
  for(int j=0;j<p[next].size();j++){
    ret = min(ret,solve(i+1,p[next][j].x,p[next][j].y)+abs(x-p[next][j].x)+abs(y-p[next][j].y));
  }
  return dp[i][x][y] = ret;
}

/*
int solve(int type,int x,int y){
  int ret = 1111111;
  int temp = 0;

  int typei = type%5+1;
  int xi = x;
  int yi = y;
  for(int i=0;i<p[typei].size();i++){
    x = p[typei][i].x;
    y = p[typei][i].y;
    temp += abs(x-p[typei][i].x)+abs(y-p[typei][i].y);

    int typei = type%5+1;
    int xi = x;
    int yi = y;
    for(int i=0;i<p[typei].size();i++){

      int typei = type%5+1;
      int xi = x;
      int yi = y;
      for(int i=0;i<p[typei].size();i++){
    
	int typei = type%5+1;
	int xi = x;
	int yi = y;
	for(int i=0;i<p[typei].size();i++){

	}

      }

    }

  }

}
*/
 
int main(void){
  while(1){
    scanf("%d %d",&x,&y);
    if(!x && !y) break;
 
    bool typef[6] ={false};
    int t=0;
    char m;
 
    for(int i = 1; i < 6; i++) {
      p[i].clear();
    }
 
    for(int j=1;j<=y;j++){
      for(int i=1;i<=x;i++){
	scanf(" %c",&m);
	if(m=='S'){
	  sx=i;
	  sy=j;
	}else if(m=='G'){
	  gx=i;
	  gy=j;
	} else if(m!='.'){
	  p[m-'0'].push_back(P(i,j));
	  if(!typef[m-'0']){
	    t++;
	    typef[m-'0']=true;
	  }
	}
      }
    }
    if(t<4) {
      puts("NA");
      continue;
    }

    int type,ret=1111111;
    if(t==4){
      for(int i=1;i<=5;i++){
	if(!typef[i]){
	  type = i;
	  break;
	}
      }
      memset(dp,-1,sizeof(dp));
      ttt = type;
      ret = solve(0,sx,sy);
    } else {
      for(int i=1;i<=5;i++){
	memset(dp,-1,sizeof(dp));
	//cout<< "owata:" << i << endl;
	ttt = i;
	int temp = solve(0,sx,sy);
	if(ret > temp){
	  ret = temp;
	  type = i;
	}
      }
    }
    printf("%d %d\n",type,ret);
  }
 
}

Measured memory_bytes: 24720
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace _001_FindingMissingCards
{

    class Program
    {
        static void Main()
        {
            string givenLine = Console.ReadLine();
            string []splitedWords = givenLine.Split(' ');
            double x1 = Convert.ToDouble(splitedWords[0]);
            double y1 = Convert.ToDouble(splitedWords[1]);
            double x2 = Convert.ToDouble(splitedWords[2]);
            double y2 = Convert.ToDouble(splitedWords[3]);

            double r = Math.Sqrt(Math.Pow(x1 - x2, 2) + Math.Pow(y1 - y2, 2));

            Console.WriteLine(r);

        }
    }
}

Measured memory_bytes: 9548
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <map>

using namespace std;


int main(int argc, const char * argv[]) {

    int n, k, ans = 0;
    
    cin >> n >> k;
    
    int h[n];
    
    for(int i=0; i<n; i++)
    {
        cin >> h[i];
        
        if (h[i] >= k) ans++;
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 640
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,g,ko;
    ll x,y,w;
    char hoge,fuga;
    cin>>a>>b;
  cout<<(a+b)%24<<endl;
    return 0;
}


Measured memory_bytes: 3624