akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#define MAX 100001
#define SENTINEL 2000000000
using namespace std;

int solved[MAX];
int d[1001][1001];

void lcs(string a, string b)
{
    int m = a.size();
    int n = b.size();
    a = ' ' + a;
    b = ' ' + b;
    for (int i = 1; i <= m; i++)
    {
        d[i][0] = 0;
    }
    for (int i = 1; i <= n; i++)
    {
        d[0][i] = 0;
    }

    int max_lcs = 0;

    for (int i = 1; i <= m; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            if (a[i] == b[j])
            {
                d[i][j] = d[i - 1][j - 1] + 1;
            }
            else
            {
                d[i][j] = max(d[i - 1][j], d[i][j - 1]);
            }
            max_lcs = max(max_lcs, d[i][j]);
        }
    }
    cout << max_lcs << endl;
}

int main()
{
    int q;
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        string a, b;
        cin >> a >> b;
        lcs(a, b);
    }
    return 0;
}


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

int main() {
  int h, w;
  cin>>h>>w;
  string s[h];
  for (int i=0; i<h; i++) cin>>s[i];
  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      if (s[i][j] == '#') {
        cout<<'#';
        continue;
      }
      int cnt = 0;
      for (int di=-1; di<2; di++) {
        for (int dj=-1; dj<2; dj++) {
          if (i+di > -1 && i+di < h && j+dj > -1 && j+dj < w) {
            if (s[i+di][j+dj] == '#') {
              ++cnt;
            }
          }
        }
      }
      cout<<cnt;
    }
    cout<<endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class B { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		var ptn = "ACGT";
		var S = GetString();
		long N = S.Length;

		long max = 0;
		for(int i = 0; i < N; i++)
		{
			for(int j = i + 1; j <= N; j++)
			{
				if(S.Substring(i, j - i).Any(x => !ptn.Contains(x)))
					continue;

				chmax(ref max, j - i);
			}
		}
		WriteLine(max);
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


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

int main(){
    int N,M;cin>>N>>M;
    vector<int> array(N,1);
    vector<bool> red(N,0); 
    int ans=0;
    red[0]=1;
    for(int i=0;i<M;i++){
        int x,y;cin>>x>>y;
        if(red[x-1])red[y-1]=1;
        if(array[x-1]<=1)red[x-1]=0;
        array[x-1]--;
        array[y-1]++;
    }
    for(int i=0;i<N;i++)if(red[i])ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 640
n = int(raw_input())

def isprime(m):
	if m == 2:
		return 1
	elif m < 2 or m % 2 == 0:
		return 0
	else:
		p = 3
		while p <= m**0.5:
			if m % p == 0:
				return 0
			p = p + 2
		return 1

cnt = 0
for i in range(n):
	cnt += isprime(int(raw_input()))
	#print("*{:}".format(cnt))

#print("")
print cnt

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

using namespace std;

int vec[3][3];

int main(){
    for (int i = 0; i < 3; i++){
        for (int j = 0; j < 3; j++){
        
        cin >> vec[i][j];

        }
        
    }
    int a ,x;

    cin >> a;

    for (int i = 0; i < a; i++){
        cin >> x;
       for (int i = 0; i < 3; i++){
        for (int j = 0; j < 3; j++){
        
            if(x==vec[i][j]) vec[i][j] = 0;

        }
        
    }
    }
    if(vec[0][0] == 0 && vec[1][1] == 0 && vec[2][2] == 0)
        printf("Yes\n"); 
    else if(vec[0][1] == 0 && vec[1][1] == 0 && vec[2][1] == 0)
        printf("Yes\n"); 
    else if(vec[0][2] == 0 && vec[1][2] == 0 && vec[2][2] == 0)
        printf("Yes\n"); 
    else if(vec[0][0] == 0 && vec[1][0] == 0 && vec[2][0] == 0)
        printf("Yes\n");
    else if(vec[1][0] == 0 && vec[1][1] == 0 && vec[1][2] == 0)
        printf("Yes\n"); 
    else if(vec[2][0] == 0 && vec[2][1] == 0 && vec[2][2] == 0)
        printf("Yes\n");
    else if(vec[0][0] == 0 && vec[0][1] == 0 && vec[0][2] == 0)
        printf("Yes\n");
    else if(vec[2][0] == 0 && vec[1][1] == 0 && vec[0][2] == 0)
        printf("Yes\n"); 
    else{
        printf("No\n");
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long ll;
ll modinv(ll a, ll m) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0)
    u += m;
  return u;
}
int main() {
  ll n, m, s, M = 0, Mod = 1e9 + 7;
  cin >> n >> m;
  map<ll, ll> mp;
  while (m % 2 == 0) {
    M = max(M, ++mp[2]);
    m /= 2;
  }
  s = sqrt(m);
  for (ll j = 3; j <= s; j += 2) {
    while (m % j == 0) {
      M = max(M, ++mp[j]);
      m /= j;
    }
  }
  if (m != 1)
    M = max(M, ++mp[m]);
  ll c[n + M + 1];
  rep(i,n)
    c[i] = 1;
  c[n] = n;
  for (int i = n + 1; i < n + M + 1; i++) {
    c[i] = c[i - 1] * modinv((i - n + 1), Mod) % Mod * i % Mod;
  }
  ll ans = 1;
  for (auto i : mp) {
    ans = ans * c[i.second + n - 1] % Mod;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#include <random>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1'000'000'007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

int main(){
  int N,x;
  cin >> N >> x;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  reverse(A.begin(),A.end());
  vector<vector<int>> G(N,vector<int>(N,inf+10));
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      if(j){
        chmin(G[i][j],G[i][j-1]);
      }
      chmin(G[i][j],A[(i+j)%N]);
    }
  }
  ll ans = INF;
  for(int i=0; i<N; i++){
    ll now = 0;
    for(int j=0; j<N; j++){
      now += G[j][i];
    }
    now += (ll)x*i;
    chmin(ans,now);
  }
  cout << ans << "\n";
  return 0;
}

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

using ll=long long;
const ll z=0;

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> k(M);
  vector<vector<int>> h(M);
  vector<int> p(M);
  for(int i=0;i<M;i++){
    cin >> k[i];
    h[i].resize(k[i]);
    for(int j=0;j<k[i];j++){
      cin >> h[i][j];
      h[i][j]--;
    }
  }
  for(int i=0;i<M;i++){
    cin >> p[i];
  }
  int ans=0;
  for(int i=0;i<(1<<N);i++){
    bool AC=true;
    for(int j=0;j<M;j++){
      int cnt=0;
      for(int l=0;l<k[j];l++){
        if(i>>h[j][l]&1){
          cnt++;
        }
      }
      if(cnt%2!=p[j]){
        AC=false;
      }
    }
    if(AC)
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll d[5];

int main() {
	clr(d,0);
	string s1 = "MARCH";
	ll n;
	cin>>n;
	rep(i,0,n){
		string s;
		cin>>s;
		rep(j,0,5){
			if(s[0]==s1[j]){
				d[j]++;
			}
		}
	}
	ll ans = 0;
	rep(i,0,5){
		rep(j,i+1,5){
			rep(k,j+1,5){
				ans += d[i]*d[j]*d[k];
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define mp make_pair
#define pb push_back
#define fill(a) memset(a,0,sizeof(a))

typedef long long ll;
typedef long double ld;




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

    int n; cin>>n;
    string s; cin>>s;
    int rc = 0;
    for (int i=0;i<n;i++)
    {
        if(s[i]=='R') rc++;
    }
    int m = rc;
    for(int i=0;i<m;i++)
    {
        if(s[i]=='R') rc--; 
    }
    cout<<rc<<"\n";
    return 0;
}

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

#define rep(i,n) for (int i=0; i< (n); i++)
typedef std::pair<int, int> P;
typedef long long int ll;

using namespace std;

int main(){
    string s;
    std::cin >> s;
    set<char> ss;
    for(auto c: s){
        ss.insert(c);
    }
    if(ss.size() == 2){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 256
N,C,K = map(int, raw_input().split(" "))
timelist = []
for i in range(0, N):
    timelist.append(int(raw_input()))
timelist.sort()


class Foo:

    timelist = []
    buslist = []
    firstId = 0
    capacity = 0

    def __init__(self, timelist):
        self.timelist = timelist

    def addBus(self, i):
        self.buslist.append(self.timelist[i])
        self.firstId  = i + 1
        self.capacity = 0

    def calc(self):
        for i in range(0, N):

            if i == N - 1:
                self.addBus(i)
                break

            nexttime = self.timelist[i + 1]

            self.capacity += 1
            # timeover
            if nexttime > timelist[self.firstId] + K:
                self.addBus(i)
                continue

            # capacity over
            if self.capacity >= C:
                self.addBus(i)
                continue


    def printBusList(self):
        for bus in self.buslist:
            print(bus)

    def printTotalBusNum(self):
        print(len(self.buslist))


foo = Foo(timelist)
foo.calc()
foo.printTotalBusNum()

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

using namespace std;

typedef long long LL;

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define fin "\n"


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

template <typename T>
inline void chmin(T &l,T r){l=min(l,r);}

template <typename T>
inline void chmax(T &l,T r){l=max(l,r);}

string ans[]={"First","Second"};
int main(){
    string s;
    cin>>s;
    if(s.front()==s.back()){
        cout<<ans[s.size()%2]<<endl;
    }
    else{
       cout<<ans[1-s.size()%2]<<endl;
    }
    return 0;
}


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

public class Main {
	public static void main(String[] args){
		int a, b, cnt = 0, i;
		String o;
		ArrayList<Integer> ans = new ArrayList<Integer>();
		Scanner sc = new Scanner(System.in);
		while(cnt < 20000){
			a = sc.nextInt();
			o = sc.next();
			b = sc.nextInt();
			char op = o.charAt(0);
			if(op == '?'){
				break;
			}else{
				switch(op){
					case '+': ans.add(new Integer(a + b));
								break;
					case '-': ans.add(new Integer(a - b));
								break;
					case '*': ans.add(new Integer(a * b));
								break;
					case '/': ans.add(new Integer(a / b));
								break;
				}
			}
			cnt++;		
		}
		for(i = 0; i != cnt; i++){
			System.out.println(ans.get(new Integer(i)));
		}
	}
}

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

using namespace std;

int main()
{
	string inp[3];
	
	while (cin >> inp[0], inp[0] != "0")
	{
		cin >> inp[1] >> inp[2];

		for (int i = 0; i < 3; i++)
		{
			int a_ten = 0, b_ten = 0;

			for (int j = 0; j < inp[i].length(); j++)
			{
				if (j == 0) continue;
				if (inp[i][j] == 'A')
				{
					a_ten++;
				}
				else if (inp[i][j] == 'B')
				{
					b_ten++;
				}
			}

			if (a_ten > b_ten)
			{
				a_ten++;
			}
			else
			{
				b_ten++;
			}

			cout << a_ten << " " << b_ten << endl;
		}
	}
}

Measured memory_bytes: 1188
#include<iostream>
#include<iomanip>
#include<stdlib.h>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<limits>
#include<numeric>
#include<unordered_map>
#include<functional>
#include<bitset>
using namespace std;

#define rep(i,s,n) for(int i=s;i<n;i++)
#define dow(i,n,s) for(int i=n-1;i>=s;i--)
#define all(a) a.begin(),a.end()
#define Sort(a) sort(a.begin(),a.end())
#define rng(a,b,e) a.begin()+b,a.begin()+e
//#define DEBUG
typedef pair<int,int> II;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;
bool compare_by_second(II a,II b) {
  if(a.second != b.second) return a.second < b.second;
  else return a.first < b.first;
}
int compare_int(const void *a,const void *b){ return *(int *)a - *(int *)b; }

const int INF = 1e+9;
const int MAX_N = 5e+3;
const int MAX_V = 1e+9;

int n;
int a_i;
int d;
int sum,mx;
unordered_map<int, int> um;
//vector<int> v;

int main() {

  cin>>n;
  int v[n];
  //v.resize(n);
  mx = 2;
  rep(i,0,n) { cin>>v[i]; um[v[i]] = 1; }
  qsort(v,n,sizeof(*v),compare_int);
#ifdef DEBUG
  rep(i,0,n) cout<<v[i]<<" , ";
  cout<<endl;
#endif
  //Sort(v);
  rep(i,0,n-2) {
    rep(j,i+1,n-1) {
      d = v[j] - v[i];
      a_i = v[j] + d;
      sum = 2;
#ifdef DEBUG
      rep(k,j+1,n) {
        if(v[k] == a_i) { a_i += d; sum++; }
        if(v[k] > a_i) break;
      }
#endif
      rep(k,0,MAX_N-2) {
        if(um.find(a_i+d*k) == um.end() || k>=MAX_N-2) break;
        //cout<<k<<boolalpha<<num[k-1]<<" , ";
        sum++;
      }
      //cout<<endl;
      //mx = max(mx,sum);
      if(sum > mx) mx = sum;
      if(mx >= n-j-1) break;
    }
    if(mx >= n-i-1) break;
  }

  cout<<mx<<endl;
  return 0;
}



Measured memory_bytes: 3504
#include <stdio.h>

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

    int b,f,r,v,n,j,i;

    int house1[3][10] = {};
    int house2[3][10] = {};
    int house3[3][10] = {};
    int house4[3][10] = {};

    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        scanf("%d %d %d %d",&b,&f,&r,&v);

        if(b == 1){
            house1[f - 1][r - 1] += v;
            if(house1[f - 1][r - 1] < 0){
                house1[f - 1][r - 1] = 0;
            }
            if(house1[f - 1][r - 1] > 9){
                house1[f - 1][r - 1] = 9;
            }

        }
        if(b == 2){
            house2[f - 1][r - 1] += v;
            if(house2[f - 1][r - 1] < 0){
                house2[f - 1][r - 1] = 0;
            }
            if(house2[f - 1][r - 1] > 9){
                house2[f - 1][r - 1] = 9;
            }
        }
        if(b == 3){
            house3[f - 1][r - 1] += v;
            if(house3[f - 1][r - 1] < 0){
                house3[f - 1][r - 1] = 0;
            }
            if(house3[f - 1][r - 1] > 9){
                house3[f - 1][r - 1] = 9;
            }
        }
        if(b == 4){
            house4[f - 1][r - 1] += v;
            if(house4[f - 1][r - 1] < 0){
                house4[f - 1][r - 1] = 0;
            }
            if(house4[f - 1][r - 1] > 9){
                house4[f - 1][r - 1] = 9;
            }
        }

    }

    for(i = 0; i < 3; i++){
        for(j = 0; j < 10; j++){
            printf(" %d", house1[i][j]);
        }
        printf("\n");
    }
    printf("####################\n");
    for(i = 0; i < 3; i++){
        for(j = 0; j < 10; j++){
            printf(" %d", house2[i][j]);
        }
        printf("\n");
    }
    printf("####################\n");
    for(i = 0; i < 3; i++){
        for(j = 0; j < 10; j++){
            printf(" %d", house3[i][j]);
        }
        printf("\n");
    }
    printf("####################\n");
    for(i = 0; i < 3; i++){
        for(j = 0; j < 10; j++){
            printf(" %d", house4[i][j]);
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2072
/*

    author : s@if

*/

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

#define 		NIL 			-1
#define		 	fi	 		    first
#define 		sec 			second
#define 		MAX 			INT_MAX
#define			INF 			99999999
#define 		ll 			    long long
#define 		PI 			    acos(-1.0)
#define			MOD 			1000000007
#define 		PLL 			pair<ll,ll>
#define 		PII			    pair<int,int>
#define 		ull 			unsigned long long
#define 		For(i,a,b) 		for(int i=a;i<=(int)b;i++)


bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hr[]={-2,-2,-1,+1,+2,+2,-1,+1};
int hc[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)1e5+9;

int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */

    ll i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

    ll a,b,c,d,e;
    cin>>a>>b>>c>>d;

    v = __gcd(c,d);

    e = (c*d)/v;
   // e = c*d;

    ll cnt1 = b/c;
    ll cnt2 = a/c;

    if(a%c==0)
        cnt2--;

    ll tmp1 = cnt1-cnt2;

    cnt1 = b/d;
    cnt2 = a/d;

    if(a%d==0)
        cnt2--;

    ll tmp2 = cnt1-cnt2;

    cnt1 = b/e;
    cnt2 = a/e;

    if(a%e==0)
        cnt2--;

    ll tmp3 = cnt1-cnt2;

    ll tmp = tmp1+tmp2-tmp3;

    tmp = (b-a+1) - tmp;

    cout<<tmp<<endl;

  //  main();

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(inti=a;i<=b;i++)

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



int main()
{

ll k ;
cin>>k;

ll ans =0;
for(int a = 1 ; a <=k;a++)
    for(int b = 1 ; b<=k ; b++)
    for(int c = 1 ; c<= k ; c++)
    ans += __gcd(a,__gcd(b,c));





cout<<ans<<endl;


 return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>
#include <algorithm>

using namespace std;

const int maxn = 120000;
int n;
int a[maxn] , f[maxn];
int first , last , tot;
void work () {
	int i;
	scanf ( "%d" , &n );
	for ( i = 1 ; i <= n ; i++ ) {
		scanf ( "%d" , &a[i] );
		f[a[i]]++;
	}
	tot = 0;
	first = 9999999;
	for ( i = 1 ; i <= 100000 ; i++ ) if ( f[i] >= 2 ) {
		tot += f[i] - 1;
		first = min ( first , i );
		last = i;
	}
	if ( tot == 0 ) {
		printf ( "%d\n" , n );
		return ;
	}
	if ( tot == 1 ) {
		printf ( "%d\n" , n - 2 );
		return ;
	}
	if ( tot % 2 == 0 ) {
		printf ( "%d\n" , n - tot );
	}
	else {
		printf ( "%d\n" , n - tot - 1 );
	}
}
int main () {
	work ();
	return 0;
}

Measured memory_bytes: 896
n, m = map(int, input().split())
transit_a = set()
transit_b = set()
for _ in range(m):
    a, b = map(int, input().split())
    if a == 1:
        transit_b |= {b}
    elif b == n:
        transit_a |= {a}

print('POSSIBLE' if len(transit_a & transit_b) else 'IMPOSSIBLE')

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

using namespace std;

int main()
{
    int n, k;

    cin >> n >> k;

    vector <int> h(n, 0);

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

    sort(h.begin(), h.end());
    reverse(h.begin(), h.end());

    long long int ans = 0;

    for (int i = k; i < n; i++)
    {
        ans = ans + h[i];
    }

    cout << ans << "\n";

    return 0;
}

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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;

struct edge{
    lint to, cost;
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q, k;
    cin >> n;
    vector<vector<edge>> G(n, vector<edge>(0));
    for(int i = 0; i < n - 1; ++i){
        lint a, b, c;
        cin >> a >> b >> c;
        --a; --b; //0インデックス
        edge e;
        e.cost = c;//入力した辺の重み
        e.to = b;//入力した辺が行く先
        G[a].push_back(e);//これらをa辺目のところに入れておく
        e.to = a;
        G[b].push_back(e);
    }
    cin >> q >> k;
    --k;
    vector<lint> d(n, -1); // 拡張店のkからの最短距離
    queue<int> que;
    que.push(k);
    d[k] = 0;
    while(!que.empty()){
        int s = que.front();//queの一番先頭（始めに入れたやつ）をｓとおく
        que.pop();//queの銭湯を削除
        for(auto &e : G[s]){// a = [1, 2, 3, 4]  for i, item in enumulate(a):
            if(e.to == s || d[e.to] != -1) continue;
            d[e.to] = d[s] + e.cost;
            que.push(e.to);
        }
    }
    for(int i = 0; i < q; ++i){
        int x, y;
        cin >> x >> y;
        --x; --y;
        cout << d[x] + d[y] << endl;
    }
    return 0;
}

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

#pragma GCC optimize("unroll-loops,no-stack-protector")

#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define watch(x) cout <<(#x)<<" is "<<(x)<<endl

#define debug cout <<"hi"<<endl

using namespace std;

typedef long long ll;

typedef long double ld;

typedef pair<int, int> pii;

const int MOD=1e9+7;

const int INF32=1<<30;

const ll INF64=1LL<<60;

void solve(){

  int n; cin >>n;

  n-=400; n/=200;

  cout <<8-n;

}

int main(){

  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  solve();

return 0;}

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

using namespace std;


int main(){
  // input
  string S;
  cin >> S;
  int N = S.size();

  for(int bit = 0; bit < (1 << N - 1); ++bit) {
    string s = S.substr(0,1);
    int tmp = stoi(s);

    for(int i = N - 1; i > 0; --i) {
      string t = S.substr(N - i,1);
      if (bit & 1 << i - 1) {
        tmp += stoi(t);
        s += "+" + t;
      } else {
        tmp -= stoi(t);
        s += "-" + t;
      }
    }

    if (tmp == 7) {
      cout << s + "=7" << endl;
      break;
    }
  }
  return 0;
}


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

struct edge{
    int from, to; lint cost;
    edge(int f, int t, lint c) : from(f), to(t), cost(c) {}
    edge(int t, lint c) : from(-1), to(t), cost(c) {}
};

struct dijkstra{
    vector<vector<edge> > G;
    vector<lint> d;
    int V, s;
    dijkstra(vector<vector<edge> > _G, int _s) : G(_G), s(_s){
        init();
    }
    void init(){
        V = G.size();
        d = vector<lint>(V, INF);
        priority_queue<P, vector<P>, greater<P> > que; que.push(P(0, s));
        d[s] = 0;
        while(!que.empty()){
            P p = que.top(); que.pop();
            int v = p.second;
            if(d[v] < p.first) continue;
            for(int i = 0; i < G[v].size(); i++){
                edge e = G[v][i];
                if(d[e.to] > d[v] + e.cost){
                    d[e.to] = d[v] + e.cost;
                    que.push(P(d[e.to], e.to));
                }
            }
        }
    }
    int dist(int t){
        return d[t];
    }
};

int main(){
    int v, e, r; cin>>v>>e>>r;
    vector<vector<edge>> g(v);
    rep(i,e){
        lint s,t,d; cin>>s>>t>>d;
        g[s].push_back(edge(t,d));
    }
    dijkstra dij(g,r);
    rep(i, v){
        if(dij.d[i]==INF) out("INF");
        else out(dij.d[i]);
    }

}


Measured memory_bytes: 42296
#include <bits/stdc++.h>
using namespace std;
long long x,y,z;
int main()
{
	cin>>x>>y>>z;
	for(int i=0;i<=1000;i++)
	{
		if(i*x%y==z)
		{
		    printf("YES");
		    return 0;
		}
	}
	cout<<"NO";
	return 0;
}


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

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ALL(a) (a).begin(),(a).end()
const int INF = INT_MAX/3;
const double EPS = 1e-14;

template<typename U, typename T>
void chmin(U &x, T y) { x = min(x, y); }

template<typename U, typename T>
void chmax(U &x, T y) { x = max(x, y); }

typedef long long int lli;
typedef long double ld;
typedef tuple<int,int,int,int> square;
typedef pair<int,int> P;

const int WMAX = 2500;
bool field[WMAX][WMAX];

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

int xmax, ymax;

int dfs(int x, int y) {
  if (field[x][y]) return 0;
  stack<P> s;
  s.push(P(x,y));
  while (!s.empty()) {
    P p = s.top(); s.pop();
    int x = p.first, y = p.second;
    if (x < 0 || xmax <= x || y < 0 || ymax <= y || field[x][y]) continue;
    field[x][y] = true;
    REP(dir,4) s.push(P(x + dx[dir], y + dy[dir]));
  }
  return 1;
}

int main() {
  int w, h, n;
  while (cin >> w >> h and w) {
    REP(x, WMAX) REP(y, WMAX) field[x][y] = false;
    cin >> n;
    vector<square> tapes;
    vector<int> xs, ys;
    xs.push_back(w);
    xs.push_back(0);
    ys.push_back(h);
    ys.push_back(0);
    REP(i, n) {
      int x_[2];
      int y_[2];
      cin >> x_[0] >> y_[0] >> x_[1] >> y_[1];
      tapes.push_back(make_tuple(x_[0], y_[0], x_[1], y_[1]));
      REP(i, 2) REP(d, 2) {
        xs.push_back(x_[i] + d);
        ys.push_back(y_[i] + d);
      }
    }
    sort(ALL(xs));
    xs.erase(unique(ALL(xs)));
    sort(ALL(ys));
    ys.erase(unique(ALL(ys)));
    REP(i, n) {
      get<0>(tapes[i]) = find(ALL(xs), get<0>(tapes[i])) - xs.begin();
      get<1>(tapes[i]) = find(ALL(ys), get<1>(tapes[i])) - ys.begin();
      get<2>(tapes[i]) = find(ALL(xs), get<2>(tapes[i])) - xs.begin();
      get<3>(tapes[i]) = find(ALL(ys), get<3>(tapes[i])) - ys.begin();
    }
    REP(i, n) 
      FOR(x, get<0>(tapes[i]), get<2>(tapes[i])) 
      FOR(y, get<1>(tapes[i]), get<3>(tapes[i])) {
        field[x][y] = true;
      }
    xmax = find(ALL(xs), w) - xs.begin(), ymax = find(ALL(ys), h) - ys.begin();
    REP(y, ymax + 1) { field[xmax][y] = true; }
    REP(x, xmax + 1) { field[x][ymax] = true; }
    int ans = 0;
    REP(x, xmax) REP(y, ymax) { ans += dfs(x, y); } 
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 12492
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main() {
  int n;
  cin >> n;
  int ans=0,ma=0,hold;
  rep(i, n){
  cin>>hold;
    ma=max(ma,hold);
    ans+=hold;
  }
  cout << ans-ma/2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
int qmax(int a, int b){
	return (a > b) ? a : b;
}

int n, m;
char pic[22][22];
int dist[22][22][22][22];

void bfs(int i, int j){
	queue< pair<int, int> > q;
	memset(dist[i][j], 0x3f, sizeof(dist[i][j]));
	q.push(make_pair(i, j));
	dist[i][j][i][j] = 0;
	while(!q.empty()){
		int x = q.front().first, y = q.front().second;
		q.pop();
		rep(dir, 4){
			int nx = x + dx[dir], ny = y + dy[dir];
			if(nx < 0 || nx >= n || ny < 0 || ny >= m || pic[nx][ny] == '#' || dist[i][j][nx][ny] <= dist[i][j][x][y] + 1) continue;
			dist[i][j][nx][ny] = dist[i][j][x][y] + 1;
			q.push(make_pair(nx, ny));
		}
	}
}

int main(){
	scanf("%d%d", &n, &m);
	rep(i, n){
		scanf("%s", pic[i]);
	}
	rep(i, n){
		rep(j, m){
			if(pic[i][j] == '.') bfs(i, j);
		}
	}
	int ans = 0;
	rep(i, n){
		rep(j, m){
			if(pic[i][j] == '#') continue;
			rep(i2, n){
				rep(j2, m){
					if(pic[i2][j2] == '#') continue;
					ans = qmax(ans, dist[i][j][i2][j2]);
				}
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1024
n,m,x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()

cl = 0
for i in range(len(a)):
    if a[i] <= x:
        cl += 1

cr = 0
for i in range(len(a)):
    if a[i] >= x:
        cr += 1
print(min(cl,cr))


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int t[300],i;

int main() 
{
    string s;
    cin>>s;
    for (int i=0; i<s.length(); i++)
        t[s[i]]++;
    for (i=97; i<97+26; i++)
        if (t[i]==0) return cout<<(char)i,0;
    cout<<"None";
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define SZ(a) ((int)a.size())
//#pragma GCC optimize(2)
using namespace std;
//const double eps=1e-6;
//typedef complex<double>C;
//const double PI(acos(-1.0));
//for(int mask=i;mask>0;mask=(mask-1)&i)
//int a[25]= { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 };
//__gcd, atan2(y,x)=y/x , __int128
//c(n,k)=c(n-1,k-1)+c(n-1,k)
//c(i,r),i for r to n =c(n+1,r+1)
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//int sum(int x){int s=0;while(x){s+=BIT[x];x-=x&-x;}return s;}
//int find(int x){return x==p[x]?x:p[x]=find(p[x]);}
//LL pw(LL a,LL b){LL t=1;for(;b;b>>=1,a=a*a%M)b&1?t=t*a%M:0;return t;}
//log() = ln() , log(x)/log(y)=log(y)-base-x
//INT_MAX 127,INT_MIN 128
//isalnum() decimal digit or an uppercase or lowercase letter
//int dw[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
//int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
//cout<<fixed<<setprecision(12)<<ans<<endl;
//__builtin_popcount(mask)
const int N=150;
const int M=1e9+7;

int n,m;
char p[N][N];
int vis[N][N];
int dw[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
int main() {
	Re(vis,1);
	cin>>n>>m;
	FOR(i,1,n)
		FOR(j,1,m){
			cin>>p[i][j];
			if(p[i][j]=='#')vis[i][j]=0;
		}
	FOR(i,1,n)
		FOR(j,1,m)
			if(!vis[i][j]){
				vis[i][j]=1;
				int c=0;
				queue<PII>q;
				q.push(MP(i,j));
				while(q.size()){
					PII u=q.front();q.pop();
					REP(k,4){
						int tx=u.F+dw[k][0],ty=u.S+dw[k][1];
						if(vis[tx][ty])continue;
						c++;
						vis[tx][ty]=1;
						q.push(MP(tx,ty));
					}
				}
				if(!c){
					cout<<"No\n";
					return 0;
				}
			}
	cout<<"Yes\n";
}

Measured memory_bytes: 384
/*  -*- coding: utf-8 -*-
 *
 * c.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  int cnt = 0;
  for (int i = 0, j = s.size() - 1; i < j;) {
    if (s[i] == s[j]) i++, j--;
    else if (s[i] == 'x') cnt++, i++;
    else if (s[j] == 'x') cnt++, j--;
    else {
      cnt = -1;
      break;
    }
  }

  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using LL = int64_t;
const int maxn=1e5+5;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
const LL LLINF=1e14;
const double pi=acos(-1.0);
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<s.length();i++) ans+=s[i]-'0';
    for(int i=0;i<s.length();i++) {
        if(s[i]=='0') continue;
        int temp=s[i]-'0'-1;
        for(int j=0;j<i;j++) temp+=s[j]-'0';
        for(int j=i+1;j<s.length();j++) temp+=9;
        ans=max(ans,temp);
    }
    cout<<ans;
    return 0;
}


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

using namespace std;

int main()
{
    long long a, b, c, k;
    cin >> a >> b >> c >> k;
    if (k % 2 == 0) cout << a-b << '\n';
    else cout << b-a << '\n';
    
    return 0;
}

Measured memory_bytes: 3616
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.stream.IntStream;

public class Main {

    static int h, w;

    public static void main(String[] args) throws NumberFormatException, IOException{

        try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            while (true) {

                int[] arr = Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();

                h = arr[0];
                w = arr[1];

                if (h == 0 && w == 0) {
                    break;
                }

                IntStream.range(0, h).forEach(i -> System.out.println(generateLineString(w, new StringBuilder())));
                System.out.println();
            }
        }
    }

    public static String generateLineString(int n, StringBuilder sb) {
        if(n == 0) {
            return sb.toString();
        }else {
            sb.append("#");
            return generateLineString(n - 1, sb);
        }
    }
}


Measured memory_bytes: 31948
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <utility>
#include <string>
#include <numeric>
#include <iterator>
using namespace std;

int main()
{
    long long int n, m, ans = 0;
    cin >> n >> m;
    vector<pair<long long int, long long int>> shop;
    long long int a, b;
    for (int i = 0; i < n; i++) {
        cin >> a >> b;
        shop.push_back(make_pair(a, b));
    }
    sort(shop.begin(), shop.end());
    for(int i = 0; i < n; i++) {
        if(shop[i].second < m) {
            ans += shop[i].first*shop[i].second;
            m -= shop[i].second;
        } else {
            ans += m*shop[i].first;
            break;
        }
    }
    cout << ans << '\n';
}


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

int main() {
  int M, D;
  cin >> M >> D;

  int ans = 0;
  int d1, d2;
  for (int i = 1; i <= M; i++) {
    for (int j = 1; j <= D; j++) {
      if (j <= 10) continue;
      
      d1 = j / 10;
      d2 = j % 10;
      if (d1>=2 && d2>=2 && i==d1*d2) ans++;
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	string str;
	cin >> str;
	char dummy;
	dummy = str[0];
	int answer = 0;
	for (int i = 1; i < str.size(); ++i) {
		if (dummy != str[i]) {
			++answer;
			dummy = str[i];
		}
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 512
import sys


def _s(): return sys.stdin.readline().strip()


def main():
    _ = _s()
    s = _s()

    rc = 0
    wc = s.count("R")
    m = wc
    for c in s:
        if c == "R":
            wc -= 1
        else:
            rc += 1
        m = min(m, max(wc, rc))
    return m


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 68056
#include<stdio.h>
int main()
{
	int n,a[100];
	double x=0;
	int i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		x+=(double)1/a[i];
	}
	printf("%lf\n",1/x);
	return 0;
}

Measured memory_bytes: 1740
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int cal(int, int, int);

int main(void){
	int n;

	while(cin >> n, n){
		int t[n], p[n], q[n], r[n];
		rep(k, n){
			cin >> t[k] >> p[k] >> q[k] >> r[k];
		}
		int P, Q, R, C;
		cin >> P >> Q >> R >> C;
		int cnt = 0;
		rep(k, n){
			if(p[k] <= P&& q[k] <= Q && r[k] <= R && cal(p[k],q[k],r[k]) <= C){
				cout << t[k] << endl;
				cnt++;
			}
		}
		if(cnt == 0){
			cout << "NA" << endl;
		}

	}

	return 0;
}

int cal(int a, int b, int c){
	return 4*a+9*b+4*c;
}


int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

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

using namespace std;

typedef long long ll;

const int N = 1000;

char a[N][N];

int d[N][N];

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int h, w, k;
    cin >> h >> w >> k;
    int sx, sy;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> a[i][j];
            if (a[i][j] == 'S') {
                sx = i;
                sy = j;
                a[i][j] = '.';
            }
            d[i][j] = h * w + 2;
        }
    }
    queue<pair<int, int>> q;
    q.push({ sx, sy });
    d[sx][sy] = 1;
    int dx[4] = { 0, 0, -1, 1 };
    int dy[4] = { -1, 1, 0, 0 };
    while (!q.empty()) {
        auto v = q.front();
        q.pop();
        int x = v.first;
        int y = v.second;
        for (int i = 0; i < 4; ++i) {
            if (x + dx[i] >= 0 && x + dx[i] < h && y + dy[i] >= 0 && y + dy[i] < w && d[x + dx[i]][y + dy[i]] == h * w + 2 && a[x + dx[i]][y + dy[i]] == '.') {
                d[x + dx[i]][y + dy[i]] = d[x][y] + 1;
                q.push({ x + dx[i], y + dy[i] });
            }
        }
    }
    int ans = 1000;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (d[i][j] - 1 <= k) {
                int len = min(i, h - i - 1);
                len = min(len, min(j, w - j - 1));
                ans = min(ans, (len + k - 1) / k + 1);
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 4992
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
#include<cmath>
#include<queue>
#include<map>
#define rep(i,n) for (int i=0; i<n; i++)
using namespace std;
typedef long long ll;

ll gcd(ll a,ll b){
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

int main(){

  int a,b; cin >> a >> b;
  if ((a+b)%2==0){cout << (a+b)/2;}
  else {cout << "IMPOSSIBLE";}

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<string>
#include<map>
#include<set>
#include<functional>
#include<list>
#include<bitset>
#include<numeric>
#include<utility>
#define INF (int)1e9
#define DINF (double)1e9
#define MOD 1000000007
#define MAX 210000
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> p;





int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int ans = 0;
	int x = 1;
	while (n) {
		int a = n % 10;
		if (a == 1) {
			ans += x *9;
		}
		else {
			ans += x ;
		}
		n /= 10;
		x *= 10;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def sums(a, N): 
    ans = ((N//a)*((N//a)+1)//2)*a
    return ans 


def solve():
    N = read_int()
    return N*(N+1)//2-(sums(3, N)+sums(5, N)-sums(15, N)) 


if __name__ == '__main__':
    print(solve())


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

#define rep(i,n) for(int i=0; i<(n); ++i)
#define rrep(i,n) for(int i=1; i<=(n); ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define foreach(it, v) for(typeof(v.begin()) it=v.begin(); it!=v.end(); ++it)
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second

typedef unsigned int uint;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef set<int> si;

int N;
int A[100010];
int l[100010];
int r[100010];

int gcd(int x, int y) {
  if (x < y) swap(x, y);
  while (y) {
    x = x % y;
    swap(x, y);
  }
  return x;
}

int main(){
  scanf("%d",&N);
  rep(i,N) {
    scanf("%d",&A[i]);
  }
  l[0] = A[0];
  for (int i=1; i<N; ++i) l[i] = gcd(l[i-1], A[i]);
  r[N-1] = A[N-1];
  for (int i=N-2; i>=0; --i) r[i] = gcd(r[i+1], A[i]);
  int ans = max(l[N-2], r[1]);
  for (int i=1; i<N-1; ++i) ans = max(ans, gcd(l[i-1], r[i+1]));
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 1408
N,K=map(int,input().split())
if K%2==1:
    n=N//K
    print(n**3)
else:
    n=N//K
    m=0
    for i in range(1,N+1):
        if i%K==K//2:
            m+=1
    print(n**3+m**3)
    

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

int main (){
  int N,D;
  cin >> N >> D;
  long long x,y;
  int count=0;
  for(int i=0; i<N ;i++ ){
    cin >> x >> y;
   
    if(sqrt((x*x+y*y))<=D)
      count++;
  }
  cout << count <<endl;
}

Measured memory_bytes: 3672
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
pre = -1
for a in A:
  ans += B[a-1]
  if a==pre+1:
    ans += C[pre-1]
  pre = a
  
print(ans)

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

int main(){
  string S,T;
  cin >> S >> T;
  
  int ans = T.size();
  for(int i=0;i<=S.size()-T.size();i++){
    int now = T.size();
    for(int j=0;j<T.size();j++){
      if(S[i+j]==T[j]) now--;
    }
    ans = min(now,ans);
  }
  
  cout << ans << endl;
  return 0;
}


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

int main() {
	int N;
	string s, t;
	cin >> N >> s >> t;
	int i = N;
	while (s.substr(N-i, i) != t.substr(0,i)) {
		i--;
	}
	cout << 2 * N - i << endl;
	return 0;
}


Measured memory_bytes: 256
import itertools
n,m=map(int,input().split())
K={"K"+str(i+1):list(map(int,input().split())) for i in range(m)}
P=list(map(int,input().split()))
for item in K.keys():
  K[item].pop(0)
#print(K)
#print(P)
l=list(itertools.product([0,1],repeat=n))
#print(l)
c=0
for item in l:
  f=0
  for i in range(m):
    l_s=[item[K["K"+str(i+1)][j]-1] for j in range(len(K["K"+str(i+1)]))]
    if sum(l_s)%2==P[i]:
      f+=1
  if f==m:
    c+=1
print(c)

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

int main () {
	int	n,m;
  	cin >> n >> m;
  	for (int i=0;i<m;i++) {
    	int a;
      	cin >> a;
      	n -= a;
    }
  	if (n>=0) cout << n << endl;
  	else cout << -1 << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define st first
#define INF 1e9 + 7
#define nd second
using namespace std;
typedef long long int lo;
map <lo,lo> dp;
lo f(lo n){
    if(n == 1) return 1;
    if(n < 1) return 0;
    if(dp[n] != 0) return dp[n];
    return dp[n] = f(n / 2) + f(n / 2) + 1;
}
int main(){
    //freopen("kenar.gir","r",stdin);
    //freopen("kenar.cik","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);

    lo n;
    cin >> n;
    cout << f(n);
    
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll N, mod = 1000000007;

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

ll Combi(ll n, ll r) {
	ll ret = 1;
	rep(i, n) {
		ret *= i + 1;
		ret %= mod;
	}
	rep(i, r) {
		ret *= modinv(i + 1, mod);
		ret %= mod;
	}
	rep(i, n - r) {
		ret *= modinv(i + 1, mod);
		ret %= mod;
	}
	return ret;
}

int main() {

	cin >> N;

	ll ans = 0;

	rep(i, N / 3) {
		ll n = i + 1;
		ll r = N - 3 * n;

		ans += Combi(n + r - 1, r);
		ans %= mod;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3596
N, M, *_PY = map(int, open(0).read().split())
PY = []

for i in range(M):
    PY.append([_PY[i*2],_PY[i*2+1], i+1])
    
now_p = 0

for py in sorted(PY):
    if py[0] != now_p:
        now_p = py[0]
        cnt = 1
    else:
        cnt += 1

    py.append(str(py[0]).zfill(6) + str(cnt).zfill(6))
    
for py in PY:
    print(py[3])

Measured memory_bytes: 45880
#include<bits//stdc++.h>
using namespace std;
int main(){
  double x,h;
  while(cin >> x>> h,x,h){
      double hh = sqrt(x*x/4+h*h);
      cout << fixed << setprecision(10)<<x*x + x*hh*2<<endl;
  }
}


Measured memory_bytes: 3184