akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define INF (1LL<<57)
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define whoami(x) cerr<<#x<<" "<<x<<"\n";
#define mp make_pair
#define ins insert
#define sz size

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

const int MOD = 1000000007;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
//ordered_set = order_of_key(.)
//ordered_set = find_by_order(.)
typedef ordered_set<int> OSI;
typedef ordered_set<ll> OSL;
typedef ordered_multiset<int> MOSI;
typedef ordered_multiset<ll> MOSL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	ll l;
	cin>>l;
	ld rx = (1.0*l * 1.0*l * 1.0*l)/(ld)27.0;
	SETF();
	cout<<setprecision(13)<<rx<<"\n";
	UNSETF();
	return;
}

int main(void)
{
	FLASH();
	int T;
	T = 1;

// #ifndef ONLINE_JUDGE
// 	time_t time_t1, time_t2;
// 	time_t1 = clock();
// #endif

	while(T--)
	solve(T);

// #ifndef ONLINE_JUDGE
// 	time_t2 = clock();
// 	SETF();
// 	cout<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
// 	UNSETF();
// #endif

	return 0;
}

Measured memory_bytes: 256
n = int(input())

taro = 0
hanako = 0
for ni in range(n):
    t, h = input().split()

    if t < h:
        hanako += 3
    elif t > h:
        taro += 3
    else:
        hanako += 1
        taro += 1

print(taro,hanako)

Measured memory_bytes: 7648
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_B&lang=jp
sample_input = list(range(3))
sample_input[0] = '''5
1 2 3 4 5
3
3 4 1'''
sample_input[1] = '''3
1 2 3
1
5'''
sample_input[2] = ''''''
give_sample_input = None
if give_sample_input is not None:
    sample_input_list = sample_input[give_sample_input].split('\n')
    def input():
        return sample_input_list.pop(0)
        
# main
num_of_S = int(input())
S = list(map(int, input().split(' ')))
num_of_T = int(input())
T = list(map(int, input().split(' ')))

def binary_search(increasing_list, elem):
    index_min = 0
    index_max = num_of_S-1
    
    while index_max - index_min >= 2:
        index_middle = int((index_min + index_max) / 2)
        if increasing_list[index_middle] == elem:
            return True
        elif increasing_list[index_middle] > elem:
            index_max = index_middle
        else:
            index_min = index_middle
            
    if increasing_list[index_min] == elem:
        return True
    elif increasing_list[index_max] == elem:
        return True
    else:
        return False

count = 0
for t in T:
    if binary_search(S, t):
        count += 1
print(count)

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

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

int main(){
    int K;
    cin >> K;
    int temp, ans;
    ans = 0;

    for(int a = 1; a <= K; a++){
        for(int b = 1; b <= K; b++){
            for(int c = 1; c <= K; c++){
                temp = gcd(a, b);
                ans += gcd(temp, c);
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
int main(void){
  int n,x,l[101],i,sum=0,b=0;
  scanf("%d %d",&n,&x);
  for(i=1;i<=n;i++)
    scanf("%d",&l[i]);
  for(i=1;i<=n;i++){
    sum=sum+l[i];
    if(sum<=x)
    b++;
    }
    printf("%d",b+1);
    return 0;
}

Measured memory_bytes: 128
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Diagnostics;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using static System.Math;

class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] a = Enumerable.Repeat(0, n).Select(_ => int.Parse(Console.ReadLine()) / 10).ToArray();

        int maxDist = 0;
        for (int i = 0; i < n; i++)
        {
            if (i > maxDist) goto no;
            maxDist = Max(maxDist, i + a[i]);
        }
        maxDist = n - 1;
        for (int i = n - 1; i >= 0; i--)
        {
            if (i < maxDist) goto no;
            maxDist = Min(maxDist, i - a[i]);
        }
        Console.WriteLine("yes");
        return;
        no:;
        Console.WriteLine("no");
    }
}


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

int main() {
  std::string str;
  std::cin >> str;
  std::queue<char> kisu;
  for(int a = 0; a < (int)str.size(); a = a + 2) {
    kisu.push(str[a]);
  }
  while(!kisu.empty()) {
    std::cout << kisu.front();
    kisu.pop();
  }
}

Measured memory_bytes: 512
from collections import Counter
n = int(input())
l = []
for i in range(n):
    l.append(int(input()))

c = Counter(l)
cnt = len(c)
l = list(c.most_common(len(c)))
for t in l:
    i = t[1]
    if i % 2 == 0:
        cnt -= 1
print(cnt)


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

using namespace std;

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

	vector<int> a(3); cin >> a[0] >> a[1] >> a[2];
	int k; cin >> k;

	long long ans = 0;

	sort(a.begin(),a.end());

	ans += a[0]+a[1];

	long long m = a[2];

	for (int i = 0;i < k;i++){
		m*= 2;
	}	

	cout << ans + m << endl;

	return 0;

}


Measured memory_bytes: 256
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations, combinations_with_replacement
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])


def main():
    n,m = inpm()
    g = [[] for _ in range(n)]
    for _ in range(m):
        a,b = inpm()
        a -= 1
        b -= 1
        g[a].append(b)
        g[b].append(a)
    did = [0 for _ in range(n)]
    did[0] = 1
    que = deque()
    que.append(0)
    ans = [0 for _ in range(n-1)]
    while que:
        next_que = deque()
        while que:
            go = que.pop()
            for i in range(len(g[go])):
                if did[g[go][i]]:
                    continue
                ans[g[go][i]-1] = go + 1
                did[g[go][i]] = 1
                next_que.append(g[go][i])
        que = next_que
    if 0 in ans:
        print('No')
        return
    print('Yes')
    for i in range(n-1):
        print(ans[i])

if __name__ == "__main__":
    main()

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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

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

  ll s; cin >> s;

  vvll dp(s+1, vll(s+1, 0));
  dp[0][0] = 1;

  REP(i, s) {
    vll su(s+2);
    REP(j, s+1) {
      su[j+1] = (su[j] + dp[i][j]) % MOD;
    }

    for(int j=3*(i+1);j<=s;++j) {
      dp[i+1][j] = su[j-2];
    }
  }

  ll ans = 0;
  REP(i, s+1) {
    ans += dp[i][s];
    ans %= MOD;
  }

  cout << ans << endl;

  return 0;
}








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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 10;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef pair<char, int> P;

void print_line(vector<P> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i].second;
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;
const int mod = 1000000007;


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

    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int min_e = *min_element(a.begin(), a.end());
    int max_e = *max_element(a.begin(), a.end());
    vector<int> b = a;
    sort(b.begin(), b.end());

    vector<bool> used(n, false);
    vector<int> index_cache(max_e + 1);
    rep(i, n) index_cache[b[i]] = i;

    int ans = 0;
    rep(i, n) {
        if (used[i]) continue;
        int cur = i;
        int cost = 0;
        int mi = INF;
        int cycle_len = 0;

        while (true) {
            used[cur] = true;
            cycle_len++;
            int v = a[cur];
            cmin(mi, v);
            cost += v;
            cur = index_cache[v];
            if (used[cur]) break;
        }
        int c1 = cost + (cycle_len - 2) * mi;
        int c2 = mi + cost + (cycle_len + 1) * min_e;

        ans += min(c1, c2);
    }

    cout << ans << endl;
}




Measured memory_bytes: 3204
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
using namespace std;

const long M = 1046527;
const long NIL = -1;
const long L = 14;

string H[M];

long getChar(char ch){
	if (ch == 'A') return 1;
	else if (ch == 'C') return 2;
	else if (ch == 'G') return 3;
	else if (ch == 'T') return 4;
	else return 0;
}

long getKey(string str){
	long sum = 0, p = 1, i;
	for (long i = 0; i < str.size(); i++){
		sum += p * (getChar(str[i]));
		p *= 5;
	}
	return sum;
}

long h1(long key){return key % M;}
long h2(long key){return 1 + (key % (M - 1));}

long find(string str){
	long key, h;
	key = getKey(str);
	for (long i = 0; ; i++){
		h = (h1(key) + i * h2(key)) % M;
		if (H[h] == str) return 1;
		else if (H[h].size() == 0) return 0;
	}
	return 0;
}

long insert(string str){
	long key, h;
	key = getKey(str);
	for (long i = 0; ; i++){
		h = (h1(key) + i * h2(key)) % M;
		if (H[h] == str) return 1;
		else if (H[h].size() == 0){
			H[h] = str;
			return 0;
		}
	}
}

int main(){
	long n, h;
	string str, com(9, 'a');
	cin >> n;
	for (long i = 0; i < n; i++){
		cin >> com >> str;
		if (com[0] == 'i') insert(str);
		else {
			if (find(str)) cout << "yes" << endl;
			else cout << "no" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 25880
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;

int main(){
	int t, h;
	string wt, wh;
	int n;
	cin >> n;
	t=0;
	h=0;
	for(int i=0; i<n; i++){
		cin >> wt >> wh;
		if(wt==wh){
			t++;
			h++;
		}else if(wt>wh){
			t+=3;
		}else{
			h+=3;
		}
	}
	cout << t << " " << h << endl;
	return 0;
}

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

#define ll long long
#define rep(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

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

ll L,R,D;

ll i, j, k;

int main(){
    scanf("%lld%lld%lld", &L, &R,&D);
    printf("%lld\n", R / D - (L - 1) / D);
    return 0;
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll > ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<endl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<a[zz]<<" ";cerr<<endl
#define trii(x) cerr<<#x<<": ("<<x.F<<","<<x.S<<")\n";
#define trvii(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<"("<<a[zz].F<<","<<a[zz].S<<") ";cerr<<nl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<"\n"
#define trsetii(s) cerr<<#s<<": ";for(auto &i:s) trii(i);
#define epsilon 0.000000001L
#define mod 1000000007ll
#define inf 9999999999999999ll// ~ 10^16
#define nl endl
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define modulo 998244353ll


int main()
{
    fast();
    ll h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    m1+=60*h1;
    m2+=60*h2;

    if(m2-m1>=k)
    {
        ll ans=m2-m1-k;
        cout<<ans<<endl;
    }
    else
        cout<<0<<endl;
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>

int main() {
	int m, d; std::cin >> m >> d;
	int count = 0;
	for (auto i = 22; i <= d; ++i) {
		auto d1 = i % 10;
		auto d10 = i / 10;
		if (d1 >= 2 && d10 >= 2 && d1 * d10 <= m) {
			++count;
		}
	}
	std::cout << count << std::endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int x0,y0,x1,y1,cx0,cy0;

int main()
{
    cin >> x0 >> y0 >> x1 >> y1;
    cx0 = x0, cy0 = y0;
    while(cy0 < y1)
        cout << "U",cy0++;
    while(cx0 < x1)
        cout << "R",cx0++;
    while(cy0 > y0)
        cout <<"D",cy0--;
    while(cx0 > x0)
        cout <<"L",cx0--;
    cx0--;
    cout <<"L";
    while(cy0 <= y1)
        cout << "U",cy0++;
    while(cx0 < x1)
        cout << "R",cx0++;
    cx0++,cy0--;
    cout <<"DR";
    while(cy0 >= y0)
        cout <<"D",cy0--;
    while(cx0 > x0)
        cout <<"L",cx0--;
    cout<<"U";
    return 0;
}


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

int main()
{
    int n;
    int k;
    char s[50];
    
    scanf("%d %d", &n, &k);
    scanf("%s", s);
    
    s[k-1] += 32; 

    printf("%s", s);
    return 0;
}


Measured memory_bytes: 128
import heapq, collections

n = int(input())
distance = collections.defaultdict(dict)
for _ in range(n - 1):
    a, b, c = map(int, input().split())
    distance[a - 1][b - 1] = c
    distance[b - 1][a - 1] = c
q, k = map(int, input().split())
k -= 1
queries = []
for _ in range(q):
    x, y = map(int, input().split())
    queries.append((x - 1, y - 1))

d = [float('inf')] * (n + 1)
d[k] = 0
queue = [(0, k)]
while queue:
    cost, current = heapq.heappop(queue)
    for nxt in distance[current]:
        if cost + distance[current][nxt] < d[nxt]:
            d[nxt] = cost + distance[current][nxt]
            heapq.heappush(queue, (d[nxt], nxt))

for x, y in queries:
    print(d[x] + d[y])

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF INT_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

ll modpow(ll x,ll n){
  if(n==0)return 1;
  if(n%2)return (modpow(x,n-1)*x)%MOD;
  else {
    ll half=n/2;
    ll halfpow=modpow(x,n/2)%MOD;
    return (halfpow*halfpow)%MOD;
  }
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int N,M,K;
  cin>>N>>M>>K;
  vector<ll>fac(N*M+1);
  fac[0]=1;
  for(int i=1;i<=N*M;i++)fac[i]=(fac[i-1]*i)%MOD;

  ll inv=modpow((fac[N*M-2-(K-2)]*fac[K-2])%MOD,MOD-2)%MOD;
  ll comb=(fac[N*M-2]*inv)%MOD;

  ll x=0;
  for(int i=1;i<N;i++)x+=((M*M)%MOD*((N-i)*(i*comb)%MOD)%MOD)%MOD;
  ll y=0;
  for(int i=1;i<M;i++)y+=((N*N)%MOD*((M-i)*(i*comb)%MOD)%MOD)%MOD;

  cout<<(x+y)%MOD<<endl;
  return 0;
}


Measured memory_bytes: 1792
#pragma comment(linker, "/STACK:10240000")
#include <bits/stdc++.h>

using namespace std;

char s[100];

int main()
{
    int n;
    scanf("%d", &n);
    scanf("%s", &s);
    int ans = 0;
    for (int i = 0; i < n; i ++)
    {
        if ((s[i] == 'A') && (s[i + 1] == 'B') && (s[i + 2] == 'C'))
        {
            ans ++;
        }
    }
    printf("%d\n", ans);
    return 0;
}


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

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

  int X;
  int sum = 0; 
  cin >> X;
  for(int i=1;i<=1000000;i++){
    sum += i;
    if(X <= sum){
      cout << i << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
num = int(input())
K = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"
l = K.split(',')
print(l[num-1])

Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main(){
  int a,d,n,so[1000000]={},c,i,j;
  so[1]=1;
  for(i=2;i<500000;i++)if(so[i]==0)for(j=2;i*j<1000000;j++)so[i*j]=1;
  while(1){
    cin>>a>>d>>n;
    if(n==0)break;
    c=0;
    for(i=a;c<n;i+=d)if(so[i]==0)c++;
    cout<<i-d<<endl;
  }
  return 0;
}

Measured memory_bytes: 5072
N, M = map(int, input().split())

A = [input() for i in range(N)]
B = [input() for i in range(M)]

res = False
count = 0
for i in range(N - M + 1):
    if res:
        break
    for j in range(N - M + 1):
        count = 0
        for m in range(M):
            if A[i + m][j:j + M] != B[m]:
                res = False
                break
            else:
                count += 1
        if count == M:
            res = True
            break

if res:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std; 
#define LIM 1000003

#define M 1000000007
#define inf 99999999999999999LL	//long long inf
typedef long long ll;

#define sc(x) scanf("%d",&x);
#define sc2(x,y) scanf("%d%d",&x,&y);
#define sc3(x,y,z) scanf("%d%d%d",&x,&y,&z);
#define scl(x) scanf("%lld",&x);
#define scl2(x,y) scanf("%lld%lld",&x,&y);
#define scl3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z);

#define pb push_back
#define mp make_pair
#define fi first
#define se second 
ll power(ll x,ll y,ll z) {	ll ret = 1;	while(y > 0) {	if(y & 1) ret = (ret*x)%z;x = (x*x)%z;y >>= 1;}return ret;}


#define debug(x) cerr<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define debug4(x,y,z,a) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#a<<" :: "<<a<<"\n";




int n, k ;
int main() {
	int i, j, t;
	sc2(n, k) ;
	char ch[100020] ;
	scanf("%s", 1+ch) ;
	ch[k] = tolower(ch[k]) ;
	printf("%s\n", 1+ch) ;	
	return 0;
}




Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $n,$m);
for($i=0; $i<$n; $i++){
    $arr[] = explode(" ",trim(fgets(STDIN)));
    unset($arr[$i][0]);
}

$check = 0;
$count = 0;

for($s=1; $s<=count($arr[0]); $s++){
    for($i=1; $i<$n; $i++){
        if(in_array($arr[0][$s],$arr[$i])){
            $check++;
        }else{
            break;
        }
    }
    if($check == $n-1){
        $count++;
        $check = 0;
    }else{
        $check = 0;
    }
}
echo $count;

?>

Measured memory_bytes: 4728
#include<bits/stdc++.h>
#define ll long long
#define rgt register
using namespace std;
const int N=200007;
struct Edge{
	int to,cost,nxt;
	Edge(int a,int b,int c):to(a),nxt(b),cost(c){ }
	Edge() { }
}b[N];
int n,m,t,v[N],head[N];
bool vis[N],r;
ll ans,res,sum,c[5];
inline int read() {
	rgt int s=0;
	rgt char c=getchar();
	while(!isdigit(c)) c=getchar();
	while(isdigit(c)) s=(s<<1)+(s<<3)+c-'0',c=getchar();
	return s;
}
inline void add(rgt int x,rgt int y,rgt int cost) {
	b[++t]=Edge(y,head[x],cost),head[x]=t;
}
inline int Imp(rgt int x) {return (x>=3)?x-3:((x<0)?x+3:x);}
inline void Dfs(rgt int k) {
	rgt int i,to;
	++c[v[k]],++res,vis[k]=1;
	for(i=head[k];i;i=b[i].nxt) {
		to=b[i].to;
		if(b[i].cost==1) sum++;
		if(!vis[to]) v[to]=Imp(v[k]+b[i].cost),Dfs(to);
		else if(v[to]!=Imp(v[k]+b[i].cost)) r=1;
	}
}
int main()
{
	int i,x,y,cost;
	n=read(),m=read();
	for(i=1;i<=m;++i)
		x=read(),y=read(),add(x,y,1),add(y,x,-1);
	for(i=1;i<=n;++i) {
		if(vis[i]) continue;
		c[0]=c[1]=c[2]=0;
		res=sum=r=0;
		Dfs(i);
		if(r) ans+=res*res;
		else if(c[0]&&c[1]&&c[2]) ans+=c[0]*c[1]+c[0]*c[2]+c[1]*c[2];
		else ans+=sum;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 5248
#include <stdio.h>

int main(){
    bool sub[30]={};
    for(int i =0;i<28;i++){
        int n;
        scanf("%d",&n);
        sub[n-1]=true;
    }
    for(int i =0;i<30;i++){
        if(!sub[i]) printf("%d\n",i+1);
    }
    return 0;
}

Measured memory_bytes: 2752
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdlib>
using namespace std;
int main() {
	string s;
	int s2,m,sa=1000;
	cin >> s;
	string s1;
	for (int i = 0; i < s.size() - 2;i++) {
		s1 = s.substr(i, 3);
		//cout << s1 << endl;
		m = stoi(s1);
		//cout << m << endl;
		s2 = abs(m - 753);
		sa = min(sa, s2);
	}
	cout << sa<< endl;
}

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

#define M 1000005
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return /* your task */ key % M; }
int h2(int key){ return /* your task */ 1 + key % (M-1); }

int find(char str[]){
  /* your task */
  long long abc;
  int i = 0;
  long long sum = getKey(str);
  while(1){
    abc = (h1(sum) + h2(sum)*i) %M;
    if(strcmp(H[abc],str) == 0) return 1;
    if(H[abc][0] == '\0') return 0;
    i++;
  }
  return 0;
}

void insert(char str[]){

    /* your task */
 int  i = 0;
  long long abcd;
  long long sum = getKey(str);
 
  while(1){
    abcd = (h1(sum) + h2(sum) *i) %M;
    if(H[abcd][0] == '\0' || strcmp(H[abcd],str) == 0){
      strcpy(H[abcd],str);
      break;
    }
    i++;
  }
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}

Measured memory_bytes: 14280
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#define fol(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int A,B,C;
    cin >>A>>B>>C;
    if (C>=A&&C<=B) cout <<"Yes"<<endl;
    else cout << "No"<<endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

template <typename T>
struct WeightedGraph {
  struct Edge {
    int to;
    T cost;
  };
  vector<vector<Edge>> edges;
  int n;
  WeightedGraph(int n) : n(n) {
    edges = vector<vector<Edge>>(n);
  }
  void add_edge(int from, int to, T cost = 0) {
    edges[from].push_back((Edge) { to, cost });
  }
  vector<Edge>& operator[](int x) {
    return edges[x];
  }
};

void solve() {
  int N, M; cin >> N >> M;
  auto g = WeightedGraph<int>(N);

  rep(i, M) {
    int l, r, d; cin >> l >> r >> d;
    l--, r--;
    g.add_edge(l, r, d);
    g.add_edge(r, l, -d);
  }

  vi32 dist(N, 1e9);
  function<void(int)> dfs = [&](int v) {
    each(e, g[v]) {
      if (dist[e.to] != 1e9) {
        if (dist[v] + e.cost != dist[e.to]) no();
        continue;
      }
      dist[e.to] = dist[v] + e.cost;
      dfs(e.to);
    }
  };

  rep(i, N) {
    if (dist[i] != 1e9) continue;
    dist[i] = 0;
    dfs(i);
  }

  yes();
}


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

long juurui[10]={1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000};

long pow(int x, int n){
    long ans=1;
    for(int i=0;i<n;i++){
        ans*=x;
    }
    return ans;
}

long sg(int n,int k){
    switch(k){
        case 0:
            return pow(3,n)-3*pow(2,n)+3;//753su
            break;
        case 1:
            return pow(3,n)-2*pow(2,n)+1;//53su
            break;
        case 2:
            return pow(3,n)-pow(2,n);//3su
            break;
        case 3:
            return pow(3,n);//nandemosu
            break;
        default:
            return 0;
            break;
    }
}

long mketa(long N){
    for(int i=9;i>0;i--){
        if(pow(10,i)>N && pow(10,i-1)<N){
            return i;
            break;
        }
    }
}

pair<long,bool> sansin(int x,int n){
    bool cnt[3]={false,false,false};
    int seg[3]={3,5,7};
    int tmp;
    long ans=0;
    for(int i=0;i<n;i++){
        tmp=x%3;
      	x/=3;
        ans+=juurui[i]*seg[tmp];
      	cnt[tmp]=true;
    }
	bool ret=cnt[0] && cnt[1] && cnt[2];
    return pair<long,bool>(ans,ret);
}

int main(){
	long N;
    cin >> N ;
    
    int nn=mketa(N);
    long ans=0;
    for(int i=3;i<nn;i++){
        ans+=sg(i,0);
      //cout << ans << endl;
    }
  	pair<long,bool> ret;
  	for(long i=0;i<pow(3,nn)-1;i++){
      ret=sansin(i,nn);
      if(ret.first > N)break;
      if(ret.second){
        ans++;
        //if(i==pow(3,nn+1)-1)cout << ret.first <<endl;
      }
    }
    //nnketano753suworekkyo(tiisaijun)

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



Measured memory_bytes: 256
import sys


def main():
    # input = sys.stdin.readline
    n = int(input())
    input_s = input()

    alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

    answer = ''

    for s in input_s:
        new_s = alphabet[alphabet.index(s)+n]
        answer += new_s

    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x, n;
    cin >> x >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    vector<pair<int, int>> v;
    for (int i = 0; i <= x; i++)
    {
        if (count(a.begin(), a.end(), i) == 0)
        {
            v.push_back({abs(x - i), i});
        }
    }
    int i = x + 1;
    while (true)
    {
        if (count(a.begin(), a.end(), i) == 0)
        {
            v.push_back({abs(x - i), i});
            break;
        }
        i++;
    }
    sort(v.begin(), v.end());
    cout << v[0].second;
}

Measured memory_bytes: 3628
n = input()
A = sorted(map(int, raw_input().split()), reverse=True)

x = 0
y = 0

def is_lose(x, y):
    return x >= n or y >= A[x]
    
while not is_lose(x+1, y+1):
    x += 1
    y += 1

x_ = x
count_x = 0
while not is_lose(x_+1, y):
    x_ += 1
    count_x += 1
    
count_y = A[x] - 1 - y

if (count_x%2 == 0) and (count_y%2 == 0):
    print "Second"
else:
    print "First"

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

void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}

int N, A, B, C, D;
string S;

bool check2(int s, int e, int o = -1)
{
    bool f = false;
    for (int i = s; i < e - 1; i++) {
        if (S[i] == '.') {
            f = false;
        } else if (S[i] == '#' || i == o) {
            if (f) {
                return false;
            } else {
                f = true;
            }
        }
    }
    return true;
}

bool check1()
{
    //Bを両サイドが空いているマスまで移動させる
    bool b_ok = false;
    int my_B;
    for (int i = B; i <= D;) {
        if (S[i-2]=='.'&&S[i]=='.') {
            my_B = i;
            b_ok = true;
            break;
        }
        if (S[i] == '.')
            i++;
        else if (S[i+1] == '.')
            i+=2;
        else
            break;
    }
    return b_ok && check2(A,C,my_B) && check2(my_B, D);
}

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

    cin >> N >> A >> B >> C >> D >> S;

    bool f;

    if (D < C) {
        // A-C が B-Dを内包する場合
        f = check1();
    } else if (A < B && C < D) {
        // A-Cの一部とB-Dの一部が重なる場合
        f = check2(B, D) && check2(A, C);
    } else {
        // A-C, B-Dが重ならない場合        
        f = check2(A,C) && check2(B,D);
    }
    
    Yes(f);
}


Measured memory_bytes: 592
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;

int main() {
    ll m[5] = {0};
    char v[] = {'M','A','R','C','H'};
    int n;  cin >> n;
    string s;    
    for (int i = 0; i < n; i++) {
        cin >> s;
        for (int i = 0; i < 5; i++) {
            if (s[0] == v[i])
                m[i]++;
        }
    }

    ll ans = 0;

    for (int bit = 0; bit < (1<<5); bit++) {
        vector<int> se;
        for (int i = 0; i < 5; i++) {
            if (bit & (1<<i))
                se.push_back(i);
        }
        if (se.size() != 3)
            continue;
        
        ll a = se[0], b = se[1], c = se[2];
        ll x =  m[a] * m[b] * m[c];
        ans += x;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define G(x, i) get<i>(x)
#define BITL(x, i) ((x) << (i))
#define BITR(x, i) ((x) >> (i))

using namespace std;

typedef tuple<int, int> i2;
typedef tuple<int, int, int> i3;
typedef tuple<int, int, int, int> i4;
typedef vector<int> vi;
typedef vector<i2> vi2;
typedef vector<i3> vi3;
typedef vector<vi> v2i;
typedef long long ll;
typedef tuple<ll, ll> l2;
typedef tuple<ll, ll> l3;
typedef vector<ll> vl;
typedef vector<l2> vl2;
typedef unsigned long long ull;

int main() {
  ull a, b, c;
  cin >> a >> b >> c;
  ull x = b + c;
  ull k = a / x;
  ull h = a % x;
  cout << (k * b + min(h, b)) << endl;
  return 0;
}

Measured memory_bytes: 256
# B
N, T = [int(x) for x in input().split()]
cost = 9999
time = 9999
for i in range(N):
    c, t = [int(x) for x in input().split()]
    if t<=T and c<cost:
        cost = c
if cost==9999: cost = 'TLE'
print(cost)

    

Measured memory_bytes: 2940
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
string a, b, c;

int main(){
    INIT;
    cin >> n >> a >> b >> c;
    int ans = 0;
    REP(i, n){
        set<char> st;
        st.insert(a[i]);
        st.insert(b[i]);
        st.insert(c[i]);
        ans += (int)st.size() - 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int x[3000];
  int y[3000];
  int i=0;
  int _x;
  int _y;
  do{
    cin>>_x>>_y;
    if(_x>_y){
      x[i]=_y;
      y[i]=_x;
    }
    else{
      x[i]=_x;
      y[i]=_y;
	}
    i++;
    
  }
  while(_x!=0 || _y!=0);
  
  for(int j=0;j<i-1;j++){
    cout<<x[j]<<" "<<y[j]<<endl;
  }
  return 0;
}

Measured memory_bytes: 3080
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
typedef pair<int,int> P;
const int inf=1e+9;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

#define NIL -1
#define MAX 100005

int n,pos;
vector<int> pre, in, post;

void rec(int l, int r) {
  if(l >= r) return;
  int root = pre[pos++];
  int m = distance(in.begin(), find(all(in),root));
  rec(l,m);
  rec(m+1,r);
  post.push_back(root);
}

void solve() {
  rec(0,n);
  rep(i,n){
    if(i) {
      cout << " " <<  post[i];
    }
    else cout << post[i];
  }
  cout << endl;
}


int main() {
  cin >> n;
  pre.resize(n);
  in.resize(n);
  rep(i,n) cin >> pre[i];
  rep(i,n) cin >> in[i];

  solve();
  
  return 0;
}






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

using namespace std;

#define MAX 1200
#define LIMIT 1000100
typedef pair<int,int> pii;

int M,N;
int caves[MAX][MAX];
int dp[MAX][MAX];
map<int,pii> mp;
bool prime[LIMIT];

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

void makePrime(){
  fill(prime,prime+LIMIT,true);
  prime[0] = prime[1] = false;
  for(int i = 2 ; i*i < LIMIT ; i++){
    if(prime[i]){
      for(int j = i*2 ; j < LIMIT ; j+=i){
        prime[j] = false;
      }
    }
  }
}

void makeCaves(){
  int x = 600,y = 600,dir = 0;
  int num = 1,cnt = 1;
  while(true){
    if(cnt == LIMIT) break;
    for(int i = 0 ; i < 2 ; i++){
      for(int j = 0 ; j < num ; j++){
        mp[cnt] = pii(y,x);
        caves[y][x] = cnt++;
        if(cnt == LIMIT){
          return;
        }
        x += dx[dir];
        y += dy[dir];
      }
      dir = (dir+1)%4;   
    }
    num++;
  }
}

void solve(int sx,int sy){
  dp[sy][sx] = prime[caves[sy][sx]];
  for(int i = 0 ; i < MAX-1 ; i++){
    for(int j = 1 ; j < MAX-1 ; j++){
      if(dp[i][j] >= 0 && caves[i][j] <= M){
        if(caves[i+1][j-1] <= M){
          dp[i+1][j-1] = max(dp[i+1][j-1],dp[i][j]+prime[caves[i+1][j-1]]); 
        }
        if(caves[i+1][j] <= M){
          dp[i+1][j] = max(dp[i+1][j],dp[i][j]+prime[caves[i+1][j]]); 
        }
        if(caves[i+1][j+1] <= M){
          dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j]+prime[caves[i+1][j+1]]); 
        }
      }
    }
  }
  int res = 0, num = 0;
  for(int i = 0 ; i < MAX ; i++){
    for(int j = 0 ; j < MAX ; j++){
      if(caves[i][j] <= M && prime[caves[i][j]]){
        if(res < dp[i][j]){
          res = dp[i][j];
          num = caves[i][j];
        }else if(res == dp[i][j]){
          if(num < caves[i][j]){
            num = caves[i][j];
          }
        }
      }
    }
  }
  cout << res << " " << num << endl;
}

int main(){
  makeCaves();
  makePrime();
  while(cin >> M >> N, M){
    pii src = mp[N];
    memset(dp,-1,sizeof(dp));
    solve(src.second,src.first);
  }
  return 0;
}

Measured memory_bytes: 75472
// 1の方を引く方針だけど、0を数える方がいい
#include<stdio.h>
typedef long long int ll;

int MAX(int a, int b){return a>b?a:b;}

int main(void){
    ll n,m;
    scanf("%lld%lld", &n,&m);

    ll ans = 0;

    if(n==1 && m==1){
        ans = 1;
    }else if(n==1 && m!=1){
        ans = m-2;
    }else if(n!=1 && m==1){
        ans = n-2;
    }else{
        ans = n*m;

        //両端は必ず1
        ans -= (n-2)*2+(m-2)*2+4;

        // //両端を覗く行、列数
        // ll space_line = n-2;
        // ll space_column = m-2;

        // これじゃ引く方逆や
        // if(space_line!=0 && space_column!=0){
        //     ans -= space_line * space_column;
        // }
    }

    printf("%lld\n", ans);
    // int map[n][m];
    // // 1:表 0:裏
    // for(int i=0; i<n; i++){
    //     for(int j=0; j<m; j++){
    //         map[i][j] = 1;
    //     }
    // }

    // printf("\n");
    // for(int i=0; i<n; i++){
    //     for(int j=0; j<m; j++){
    //         printf("%d ", map[i][j]);
    //     }
    //     printf("\n");
    // }

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

    // int tmpx,tmpy;
    // for(int i=0; i<n; i++){
    //     for(int j=0; j<m; j++){
            
    //         for(int k=0; k<9; k++){
    //             tmpx = i+dx[k];
    //             tmpy = j+dy[k];

    //             if(0<=tmpx && tmpx<n && 0<=tmpy && tmpy<m){
    //                 map[tmpx][tmpy] = (map[tmpx][tmpy])^1;
    //             }
    //         }
    //     }
    // }

    // printf("\n");
    // for(int i=0; i<n; i++){
    //     for(int j=0; j<m; j++){
    //         printf("%d ", map[i][j]);
    //     }
    //     printf("\n");
    // }

    return 0;
}

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

int main(){
  string s;
  cin>>s;
  int log,a=s.size();
  for(int i=0;i<a;i++){
    if(s.at(i)=='C'){
      log=i;
      break;
    }
    else if(i==a-1){
      cout<<"No"<<endl;
      return 0;
    }
  }
  for(int i=log;i<a;i++){
    if(s.at(i)=='F'){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<cstdio>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

inline int f(const char *s){
	if(s[0]=='C' && s[1]=='\0') return 0;
	if(s[0]=='C' && s[1]=='#' ) return 1;
	if(s[0]=='D' && s[1]=='\0') return 2;
	if(s[0]=='D' && s[1]=='#' ) return 3;
	if(s[0]=='E' && s[1]=='\0') return 4;
	if(s[0]=='F' && s[1]=='\0') return 5;
	if(s[0]=='F' && s[1]=='#' ) return 6;
	if(s[0]=='G' && s[1]=='\0') return 7;
	if(s[0]=='G' && s[1]=='#' ) return 8;
	if(s[0]=='A' && s[1]=='\0') return 9;
	if(s[0]=='A' && s[1]=='#' ) return 10;
	return 11;
}

inline int dist(int t1,int t2){ return (t1-t2+12)%12; }

int main(){
	int T; scanf("%d",&T);
	while(T--){
		int n,m; scanf("%d%d",&n,&m);
		static int t[50000],s[50000];
		rep(i,n){ char in[3]; scanf("%s",in); t[i]=f(in); }
		rep(i,m){ char in[3]; scanf("%s",in); s[i]=f(in); }
// rep(i,n) printf("%2d ",t[i]); puts("");
// rep(i,m) printf("%2d ",s[i]); puts("");

		if(dist(s[m-1],t[n-1])<=1 || dist(s[m-1],t[n-1])==11){
// puts("hoge1");
			int pos=n-1;
			int i;
			for(i=m-1;i>=0;i--){
				int d=dist(s[i],t[pos]);
				if     (d== 0) pos--;
				else if(d== 1) pos-=2;
				else if(d==11) pos++;
				else break;

				if(i==0 && (pos<-1 || n<=pos)
				|| i!=0 && (pos< 0 || n<=pos)) break;
			}

			if(i==-1 && pos==-1) goto FOUND;
		}

		if(n-2>=0 && (dist(s[m-1],t[n-2])<=1 || dist(s[m-1],t[n-2])==11)){
// puts("hoge2");
			int pos=n-2;
			int i;
			for(i=m-1;i>=0;i--){
				int d=dist(s[i],t[pos]);
				if     (d== 0) pos--;
				else if(d== 1) pos-=2;
				else if(d==11) pos++;
				else break;

				if(i==0 && (pos<-1 || n<=pos)
				|| i!=0 && (pos< 0 || n<=pos)) break;
			}

			if(i==-1 && pos==-1) goto FOUND;
		}

		puts("No");
		continue;

		FOUND:
		puts("Yes");
	}

	return 0;
}

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

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

  int rate;
  rate = N/500;
  int resid;
  resid = N - rate*500;
  
  if (resid <= A){
    cout << "Yes" << endl;
  }
  else {
  	cout << "No" << endl;
  }

  
}

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

int main(){
    string S;  cin >> S;
    int N = S.length();
    int k = 1e9;
    for(int i=0; i<N-1; i++){
        if(S[i] != S[i+1]){
            k = min(k, max(i+1, N-i-1));
        }
    }
    if(k==1e9){
        cout << N << endl;
    }else{
        cout << k << endl;
    }
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
using namespace std;
//---------------------------------------
int wa(string inp);   //????????????????±?????????¢??°
//---------------------------------------

int main(void)
{
	string inp1;  //int, longlongint??§????????°????¶??????????
	
	getline(cin, inp1);  //???????????????????????????????????????
	
	while(inp1[0] - '0'){
		cout << wa(inp1) << endl;
		getline(cin, inp1);  //???????????????????????????????????????
	}

	
	return 0;
}

//------------------------------------------
int wa(string inp)
{	
	int len = inp.size(); //= inp.length();
	int wa = 0;
	
	for(int i = 0; i < len; i++){
		wa += (inp[i] - '0');
	}
	return wa;
}

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

main(){
int n,sum = 0;
cin>>n;
for(int i = 1;i<=n;i++){
    if(i%3==0 || i%5==0)
        continue;
    sum +=i;
}
cout<<sum<<endl;
}



Measured memory_bytes: 3636
using System;

class IDONTKNOWCSHARP
{
    public static void Main()
    {
        string[] values = Console.ReadLine().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);

        int num = int.Parse(values[0]);
        int leg = int.Parse(values[1]);

        int count = 0;

        while (num >= count)
        {
            if (4 * count + 2 * (num - count) == leg)
            {
                Console.WriteLine("Yes");
                return;
            }

            count++;
        }
        Console.WriteLine("No");
    }


}

Measured memory_bytes: 27176