akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int ctoi(char c) {
	switch (c)
	{
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default:
		cout << "ERR_ctoi" << endl;
		return -1;
	}
}
int main() {
	
	int a, b,c,d,e;
	cin >> a >> b >> c >> d >> e;
	int k;
	cin >> k;
	if (e - a > k)PRI(":(");
	else PRI("Yay!");
	return 0;
}

Measured memory_bytes: 3552
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        var periodRes = Solve(new DateTime(400, 1, 1), new DateTime(799, 12, 31));

        var ymdymd = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var y1 = (int)(ymdymd[0] % 400);
        var m1 = (int)ymdymd[1];
        var d1 = (int)ymdymd[2];
        var y2 = (int)(ymdymd[3] % 400);
        var m2 = (int)ymdymd[4];
        var d2 = (int)ymdymd[5];
        if (y2 < y1) y2 += 400;
        var date1 = new DateTime(y1 + 400, m1, d1);
        var date2 = new DateTime(y2 + 400, m2, d2);

        var period = ((ymdymd[3] - y2) - (ymdymd[0] - y1)) / 400;
        var res = period * periodRes + Solve(date1, date2);
        Console.WriteLine(res);
    }
    public static long Solve(DateTime start, DateTime end)
    {
        long res = 0;
        while (start <= end)
        {
            if (start.Day == 13 && start.DayOfWeek == DayOfWeek.Friday)
            {
                res++;
            }
            start = start.AddDays(1);
        }
        return res;
    }
}


Measured memory_bytes: 20516
import sys
input = sys.stdin.readline


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


def main():
    N, P = map(int, input().split())
    p = prime_factorize(P)
    import collections
    ans = 1
    for k, v in collections.Counter(p).most_common():
        while v >= N:
            ans *= k
            v -= N
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
import java.util.*;
import java.util.function.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();
    sc.close();

    String s = S.replaceAll("ABC", "");
    long ans = (S.length() - s.length()) / 3;
    System.out.println(ans);
  }
}

Measured memory_bytes: 23764
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <set>
#include <bitset>
typedef long long ll;
typedef long double ld;

#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;

int main() {
    ll A;
    ld B;
    cin >> A >> B;
    ll C = B * 100 + 0.5;
    ll ans = (A * C)/ 100;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3728
#include<stdio.h>
int main(void){
  int hh,mm,m2deg,h2deg,dif,i,n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d:%d",&hh,&mm);
    m2deg=12*mm;
    h2deg=60*hh+mm;
    dif=m2deg-h2deg;
    if(dif<0) dif*=-1;
    dif=(720-dif<dif)?720-dif:dif;
    if(dif>=180){
      printf("safe\n");
    }else if(dif>=60){
      printf("warning\n");
    }else{
      printf("alert\n");
    }
  }
  return 0;
}

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

int main(){
    int n; cin >> n;
    vector<string> s(n);
    for(int i = 0; i < n; i++) cin >> s[i];
    sort(s.begin(), s.end());
    map<string, int> mp;
    for(int i = 0; i < n; i++) mp[s[i]]++;
    int mx = 0;
    for(int i = 0; i < n; i++) mx = max(mx, mp[s[i]]);
    for(int i = 0; i < n; i++){
        if(mp[s[i]] == mx){
            cout << s[i] << endl;
            mp[s[i]] = 0;
        }
    }
}

Measured memory_bytes: 26752
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define pb push_back
#define MAXN 21010
#define Scan(a) scanf("%I64d", &a)
#define CLR(a) memset(a,0,sizeof(a))
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORE(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)

using namespace std;

typedef pair<int, int> II;
typedef vector<II> vi;

int n, a[2010], f[2010];

int main()
{
    ios::sync_with_stdio(0);
    //freopen("inp.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a*b, c*d);
    return 0;
}


Measured memory_bytes: 256
/*==============================================*\
ID:          shahidul_brur
 
Name:     Md. Shahidul Islam
Study:      CSE, BRUR
Address:  Rangpur, Bangladesh
 
 mail: shahidul.cse.brur@gmail.com
 FB  : fb.com/shahidul.brur
 Blog: shahidul-brur.blogspot.com(in Bengali),
       shahidul-brur-en.blogspot.com(in English)
\*===============================================*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};

const double pi = acos(-1.0);
const double eps = 1e-6;
const int mod = (int)1e9+7;
const int maxn = (int)2e5+5;
const int logn = 20;
map<string,int> m;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n;
    ll r = 0;
    cin>>n;
    while(n--){
        string s; cin>>s;
        sort(all(s));
        r+=m[s];
        m[s]++;
    }
    cout << r;
    return 0;
}


Measured memory_bytes: 11264
#include <cstdio>
#include <cstring>
char a[4];int res=700;
int main()
{
    scanf("%s",a); // 注意这里不需要 &a
    for (register int i=0;i<strlen(a);++i)
        if (a[i]=='o')
            res += 100; // 判断 'o' 
    printf("%d\n",res); // 输出结果，记得要换行
    return 0;
}

Measured memory_bytes: 128
package main

import "fmt"

type Node struct {
  count int
  to [30]int
}

func (self *Node) addEdge(t int) {
  self.to[self.count] = t
  self.count += 1
}

var N, M int
var node [8]Node
var used [8]bool
var ans int = 0

func dfs(n int) {
  if used[n] {
    return
  }
  used[n] = true
  for i := 0; i < N; i++ {
    if used[i] == false {
      break;
    }
    if i == N - 1 {
      ans += 1
    }
  }


  for i := 0; i < node[n].count; i++ {
    dfs(node[n].to[i])
  }

  used[n] = false
}

func main() {
  fmt.Scan(&N)
  fmt.Scan(&M)

  for i := 0; i < M; i++ {
    var a, b int
    fmt.Scan(&a)
    fmt.Scan(&b)
    node[a - 1].addEdge(b - 1)
    node[b - 1].addEdge(a - 1)
  }

  dfs(0)
  fmt.Println(ans)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
ll n,a,li[100010];
bool f=true;

int main(){
	cin >> n;
	REP(i,0,n) cin >> a,li[a]++;
	
	ll c=0;
	if(li[0]>1){cout << 0 << endl; return 0;}
	else{
		REP(i,1,n){
			if(li[i]==0) continue;
			else if(li[i]==2) c++;
			else if(li[i]>3){cout << 0 << endl; return 0;}
		}
	}
	
	ll ans=1;
	REP(i,0,c) (ans*=2)%=MOD;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i=(a); i<(n); ++i)
#define rrep(i,a,n) for(ll i=(a); i>(n); --i)
#define erep(i,a,n) for(ll i=(a); i<=(n); ++i)
#define rerep(i,a,n) for(ll i=(a); i>=(n); --i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int) x.size())
#define print(X) cout << (X) << endl
#define _ << " " <<
static const int INF = 1e+9+7;

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

  if(d == 0){
    if(n == 100){
      print(101);
    }
    else{
      print(n);
    }
  }
  else if(d == 1){
    if(n == 100) print(10100);
    else print(100 * n);
  }
  else if(d == 2){
    if(n == 100) print(1010000);
    else print(10000 * n);
    
  }


  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <stack>
#include <vector>

using namespace std;

bool search_ele( int n,vector<int>& S, int ele)
{
    S[n] = ele;
    int i = 0;
    while (S[i] != ele)
    {
        ++i;
    }
    return i != n;
}

int main()
{
    int n, q, key;
    int count = 0;
    vector<int> S;
    cin >> n;
    S.resize(n + 1);
    for (int i = 0; i < n; ++i)
    {
        cin >> S[i];
    }
    cin >> q;
    for (int i = 0; i < q; ++i)
    {
        cin >> key;
        if (search_ele(n, S, key))
        {
            ++count;
        }
    }
    cout << count << endl;
}



Measured memory_bytes: 3120
A=input()
B=input()
C=input()
p="a"

while True:
  if p=="a":
    if len(A)>=1:
      p=A[0]
      A=A[1:]
    else:
      print("A")
      break
  elif p=="b":
    if len(B)>=1:
      p=B[0]
      B=B[1:]
    else:
      print("B")
      break
  else:
    if len(C)>=1:
      p=C[0]
      C=C[1:]
    else:
      print("C")
      break

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 2e5 + 5;
const int MAXL = 20 + 5;
const int LB = 50 + 5;

inline ll gcd(ll a,ll b){ return b? gcd(b,a%b): a;}

inline pii calc(ll x)
{
	int cnt2=0, cnt5=0;
	while(x % 2 == 0)
		++cnt2, x/=2;
	while(x % 5 == 0)
		++cnt5, x/=5;
	return make_pair(cnt2, cnt5);
}

ll calc(vector<pii> &p, vector<pii> &q)
{
	static int tot[LB];
	memset(tot,0,sizeof(tot));
	
	sort(p.begin(), p.end());
	sort(q.begin(), q.end());
	
	ll res = 0;
	for(int i=0,j=0; i<(int)p.size(); ++i)
	{
		while(j<(int)q.size() && q[j].first <= p[i].first)
			++tot[q[j].second],
			++j;
		
		int cnt5 = p[i].second;
		for(int k=0; k<=cnt5; ++k)
			res += tot[k];
	}
	return res;
}

int tot[LB];

int main(void)
{
	int n;
	scanf("%d",&n);
	
	vector<pii> f_1, f_25;
	vector<pii> f25, f52;
	
	const pii emp(0,0);
	for(int i=1; i<=n; ++i)
	{
		static char s[MAXL];
		memset(s,0,sizeof(s));
		
		scanf("%s",s+1);
		
		int dig = 0;
		for(int j=1; s[j]; ++j)
			if(s[j] == '.'){ dig=j; break;}
		if(!dig) dig = strlen(s+1) + 1; 
		
		s[dig] = '.';
		for(int j=1; j<=9; ++j)
			if(!s[dig + j])
				s[dig + j] = '0';
		
		ll a = 0;
		for(int j=1; s[j]; ++j)
			if(s[j] != '.')
				a = a * 10 + s[j] - '0';
		ll b = 1e9;
		
		ll t = gcd(a, b);
		a/=t; b/=t;
		
		pii aa = calc(a), bb = calc(b);
		
		if(bb == emp){ f_25.push_back(aa); continue;}
		if(aa == emp){ f_1.push_back(bb); continue;}
		
		if(aa.first) f25.push_back(make_pair(-bb.second, aa.first));
		else f52.push_back(make_pair(-aa.second, bb.first));
	}
	
	ll none = (int)f_25.size();
	
	ll ans = calc(f_25,f_1) + calc(f25,f52) + none * (none-1) / 2;
	
	for(int i=0; i<(int)f25.size(); ++i)
		f25[i] = make_pair(0, -f25[i].first);
	
	for(int i=0; i<(int)f52.size(); ++i)
		f52[i] = make_pair(f52[i].second, 0);;
	
	printf("%lld", ans + calc(f_25,f25) + calc(f_25,f52));
	return 0;
}

Measured memory_bytes: 5184
//Name: Alphametic
//Level: 2
//Category: 文字列,全探索,多倍長
//Note:

/**
 * Xに入る数字を全通り試し、実際に計算して等式が成立するかを確認する。
 * ただし数値がとても大きくなるため、計算は多倍長で行う必要がある。
 * 答えが0になることもあるので、preceding zeroの扱いで注意が必要。
 *
 * オーダーは O(|S|)。
 */
#include <iostream>
#include <string>
#include <cassert>
#include <cctype>
#include <algorithm>
#include <vector>

using namespace std;

typedef string::const_iterator Iterator;

vector<int> number(Iterator &it) {
    vector<int> res;
    while(isdigit(*it)) {
        res.push_back(*it++ - '0');
    }
    reverse(begin(res), end(res));
    return res;
}

bool check(string s, int x) {
    for(char &c : s) {
        if(c == 'X') c = '0' + x;
    }

    Iterator it = s.begin();
    vector<int> n1 = number(it);
    assert(*it++ == '+');
    vector<int> n2 = number(it);
    assert(*it++ == '=');
    vector<int> ans = number(it);
    if((n1.size() >= 2 && n1.back() == 0) || (n2.size() >= 2 && n2.back() == 0) || (ans.size() >= 2 && ans.back() == 0)) return false;

    const int L = max(n1.size(), n2.size());
    vector<int> sum(L+1, 0);
    for(int i = 0; i < L; ++i) {
        if(i < n1.size()) sum[i] += n1[i];
        if(i < n2.size()) sum[i] += n2[i];
        if(sum[i] >= 10) {
            sum[i] -= 10;
            sum[i+1]++;
        }
    }
    while(sum.size() >= 2 && sum.back() == 0) sum.pop_back();
    return sum == ans;
}

bool solve() {
    string line;
    if(!(cin >> line)) return false;
    int ans = -1;
    for(int x = 0; x <= 9; ++x) {
        if(check(line, x)) {
            ans = x;
            break;
        }
    }
    if(ans == -1) cout << "NA" << endl;
    else cout << ans << endl;
    return true;
}

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

    while(solve()) ;
    return 0;
}

Measured memory_bytes: 1212
import copy
N = int(input())
P = list(map(int, input().split()))

Q = sorted(P)

if Q == P:
    print('YES')
    exit()

for i in range(N):
    for j in range(i + 1, N):
        R = copy.deepcopy(P)
        R[i], R[j] = R[j], R[i]
        if R == Q:
            print('YES')
            exit()
print('NO')


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

long long s, m = 1;
int n, k;
void add(long long b) {
	s *= b;
	s += m;
	m *= b;
	long long tmp = __gcd(m, s);
	m /= tmp, s /= tmp;
}

int main() {
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		int tmp = i, r = 0;
		while (tmp < k)
			tmp *= 2, r++;
		add((1LL << r) * n);
	}
	cout.precision(10);
	cout << fixed << ((long double) s) / m;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<map>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<list>
#include<string>
#include<climits>
#define ll long long 
#define inf 0x7f7f7f7f
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
int main()
{
	int h,w,n;
	cin>>h>>w>>n;
	int x=max(h,w);
	if(n%x)
	cout<<n/x+1;
	else
	cout<<n/x;
} 

Measured memory_bytes: 256
def resolve():
    S = input()
    T = input()
    S_list = list(S)
    T_list = list(T)

    if len(S_list) + 1 == len(T_list):
        T_list.pop()
        if S_list == T_list:
            print("Yes")
        else:
            print("No")
    else:
        print("No")

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 9052
def fibonacci(n):
    if n <= 1:
        return 1
    fib_array = [1] * 45

    for i in range(2, n+1):
        fib_array[i] = fib_array[i-1] + fib_array[i-2]
    return fib_array[n]

def main():
    n = int(input())
    fib = fibonacci(n)
    print(fib)
    return


main()


Measured memory_bytes: 5596
#include<iostream>

using namespace std;

#define REP(i, n) for(int i=0; i<n; i++)
#define ll long long

ll n, k;
ll a[100000], b[100000];

int main(){
    cin >> n >> k;
    REP(i, n){
        cin >> a[i] >> b[i];
    }

    ll max_v = 0;
    ll num = 0;
    ll max_d = 1;

    ll next_d = 0;
    ll plus = 1;
    while(1){
        plus = 1;
        while(1){
            if((next_d|plus) <= k){
                next_d = (next_d | plus);
                plus *= 2;
            } else {
                break;
            }
        }

        ll tmp_v = 0;
        REP(i, n){
            if(a[i] <= next_d && (a[i]|next_d) == next_d){
                tmp_v += b[i];
            }
        }
        
        max_v = max(tmp_v, max_v);
        if(next_d == k) break;

        next_d += 1;
    }

    cout << max_v << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define MOD = 1e9+7
#define rep(i,n) for(int i=0;i<(n);++i)
const double PI=3.14159265358979323846; 
const int INF = 1001001001;
using namespace std;

int main(){
  int x,n;
  cin >> x >> n;
  map<int,int> mp;

  // if(n==0){
  //   cout << x << endl;
  //   return 0;
  // }

  rep(i,n){
    int p;
    cin >> p;
    mp[p] = 1;
  } 

  // int ans=x;
  rep(i,101){
    if(mp[x-i] == 0){
      cout << x-i << endl;
      break;
    }
    if(mp[x+i] == 0){
      cout << x+i << endl;
      break;
    }
  } 
}

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

using namespace std;

const int N = 3010;

double p[N];

long double dp[N][N];

int main() {

    int n;
    cin >> n;
    for(int i = 1 ; i <= n ; i++)
        cin >> p[i];

    for(int i = 0 ; i <= n ; i++) {
        for(int j = 0; j <= n ; j++) {
            if(i == 0)
                dp[i][j] = 0;
            else if(j == 0)
                dp[i][j] = 1;
            else if(i == 1) {
                if(j == 1)
                    dp[i][j] = p[i];
                else 
                    dp[i][j] = 0;
            }
            else if(i < j)
                dp[i][j] = 0;
            else 
                dp[i][j] = p[i] * dp[i - 1][j - 1] + (1 - p[i]) * dp[i - 1][j];
            
        }
    }

    cout << setprecision(10) << dp[n][(n + 1) / 2] << '\n';

    return 0;
}

Measured memory_bytes: 141568
(defun mincolor(n over3200)
  (if (zerop n)
    (if (zerop over3200)
      0
      1)
    n))
(defun compute(lst)
  (let ((rates (loop for i from 0 to 7 collect 0))
        (over3200 0))
    (mapcar (lambda(a)
              (cond ((and (>= a 1)    (<= a 399)) (incf (nth 0 rates)))
                    ((and (>= a 400)  (<= a 799)) (incf (nth 1 rates)))
                    ((and (>= a 800)  (<= a 1199)) (incf (nth 2 rates)))
                    ((and (>= a 1200) (<= a 1599)) (incf (nth 3 rates)))
                    ((and (>= a 1600) (<= a 1999)) (incf (nth 4 rates)))
                    ((and (>= a 2000) (<= a 2399)) (incf (nth 5 rates)))
                    ((and (>= a 2400) (<= a 2799)) (incf (nth 6 rates)))
                    ((and (>= a 2800) (<= a 3199)) (incf (nth 7 rates)))
                    (t (incf over3200)))) lst)
    (let ((n (reduce (lambda(acc x) (+ acc (if (zerop x) 0 1))) rates :initial-value 0)))
      (format t "~A ~A~%" (mincolor n over3200) (+ n over3200)))))

(defun test()
  (compute '(2100 2500 2700 2700))
  (compute '(1100 1900 2800 3200 3200))
  (compute '(800 810 820 830 840 850 860 870 880 890 900 910 920 930 940 950 960 970 980 990))
  (compute '(4000))
  (compute '(5 4000))
  (compute '(4))
  (compute '(4 401))
  (compute '(4 401 4000))
  )
;(test)

(defun splitat (c line)
  (labels ((rec (line acc)
				(let ((pos (position-if (lambda(cc) (char= c cc)) line)))
				  (if pos
					  (rec (subseq line (1+ pos)) (cons (subseq line 0 pos) acc))
					(nreverse (cons line acc))))))
	(rec line nil)))
	;(splitat #\a "john mccarthy")
(defun readline (callback)
  (labels ((rec (i)
				(let ((line (read-line nil nil)))
				  (when (not (zerop (length line)))
					(funcall callback line i)
					(rec (1+ i))))))
	(rec 0)))
	;(readline (lambda(line i)))
(defun start()
  (let ((n 0)
        (lst nil))
    (readline (lambda(line i)
                (cond ((zerop i) (setf n (parse-integer line)))
                      (t (compute (mapcar #'parse-integer (splitat #\space line)))))))))
(start)

Measured memory_bytes: 18020
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <cstdlib>
#define mem(a, b) memset(a, b, sizeof(a))
using namespace std;
set<string> st;
set<string> sst[110];
string ss;
string sc[110];
char s[11100];
int main()
{
    int n;
    while(scanf("%d",&n))
    {
        if(n==0)
            break;
        int i,j;
        st.clear();
        for(i=0; i<110; i++)
            sst[i].clear();
        for(i=0; i<110; i++)
            sc[i]="";

        ss="";
        cin>>s;
        int len=strlen(s);
        for(i=0; i<len; i++)
        {
            if(s[i]==':')
                break;
        }
        ss="";
        for(j=i+1; j<len; j++)
        {
            if(s[j]!=','&&s[j]!='.')
            {
                ss+=s[j];
            }
            else
            {
                //cout<<"ejje"<<endl;
                st.insert(ss);
                ss="";
            }
        }
        //cout<<st.size()<<" jjjd"<<endl;
        for(int k=1; k<n; k++)
        {
            cin>>s;
            len=strlen(s);
            ss="";
            for(i=0; i<len; i++)
            {
                if(s[i]==':')
                    break;
                else
                    sc[k]+=s[i];
            }
            for(j=i+1; j<len; j++)
            {
                if(s[j]!=','&&s[j]!='.')
                {
                    ss+=s[j];
                }
                else
                {
                    sst[k].insert(ss);
                    ss="";
                }
            }
        }
//        for(int i=1;i<n;i++)
//        {
//            cout<<sc[i]<<endl;
//        }
//        cout<<st.size()<<endl;
//        for(i=1;i<n;i++)
//            cout<<sst[i].size()<<endl;
        int flag=1;
        while(flag!=0)
        {
            flag=1;
            for(int k=1;k<n;k++)
            {
                if(st.count(sc[k]))
                {
                    //cout<<"542122222"<<endl;
                    st.erase(sc[k]);
                    set<string>::iterator it;
                    for(it=sst[k].begin();it!=sst[k].end();it++)
                    {
                        st.insert(*it);
                    }
                    flag=2;
                }
            }
            if(flag==1)
                flag=0;
        }
        cout<<st.size()<<endl;
    }
    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define loope(i,a,b) for(ll i=a;i<=b;i++)
#define test() ull t;cin>>t;while(t--)
#define pll pair<ll,ll>
#define puu pair<ull,ull>
#define f first
#define s second
#define pb push_back
#define mkp make_pair
#define ins insert
#define Vint vector<int>
#define Vll vector<ll>
#define Vull vector<ull>
#define nl cout<<endl
#define sp cout<<" "
#define MOD 1000000007
#define all(x) x.begin(),x.end()

int main() 
{
	 // #ifndef ONLINE_JUDGE
  //       freopen("input.txt", "r", stdin);
  //       freopen("output.txt", "w", stdout);
  //   #endif
  //   fastio();
    ll n,w;
    cin>>n>>w;
    vector<pll> v(n,{0,0});
    loop(i,0,n)
    {
    	cin>>v[i].f>>v[i].s;
    }

    ll dp[n+1][w+1];
    memset(dp,0,sizeof(dp));

    loop(i,1,n+1)
    {
    	loop(j,1,w+1)
    	{
    		if(j - v[i-1].f>=0)
    			dp[i][j] = max(dp[i][j],dp[i-1][j-v[i-1].f] + v[i-1].s);
    		dp[i][j] = max(dp[i][j],dp[i-1][j]);
    		dp[i][j] = max(dp[i][j],dp[i][j-1]);
    	}
    }
    cout<<dp[n][w];

}

Measured memory_bytes: 79104
from fractions import gcd
from math import sqrt

a,b = map(int,input().split())
n = gcd(a,b)
k = n
s = set()
s.add(1)
for i in range(2,int(sqrt(n))+1):
  while n%i == 0:
    n = n//i
    s.add(i)
  if n == 1:
    break
s.add(n)
print(len(s))

Measured memory_bytes: 5048
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Console;

namespace AtCoder_1
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = CinT();
            Cout(3 * Math.Pow(a, 2));
            Cin();
        }
        
        static readonly int MOD1E9 = (int)1e9 + 7;
        static string Cin() { return ReadLine(); }
        static string[] CinAr() { return ReadLine().Split(' '); }
        static int CinT() { return S2i(Cin()); }
        static int[] CinTAr() { return CinAr().Select((x, i) => { return S2i(x); }).ToArray(); }
        static long CinL() { return S2L(Cin()); }
        static long[] CinLAr() { return CinAr().Select((x, i) => { return S2L(x); }).ToArray(); }
        static double CinD() { return S2D(Cin()); }
        static double[] CinDAr() { return CinAr().Select((x, i) => { return S2D(x); }).ToArray(); }
        static int S2i(string s) { return int.Parse(s); }
        static long S2L(string s) { return long.Parse(s); }
        static double S2D(string s) { return double.Parse(s); }
        static void OYes() { Cout("Yes"); }
        static void ONo() { Cout("No"); }
        static void Cout(object s) { WriteLine(s); }
        /// <summary>
        /// Debug時のみの使用を推奨
        /// </summary>
        /// <typeparam name="Type"></typeparam>
        /// <param name="types"></param>
        static void CoutAr<Type>(IEnumerable<Type> types)
        {
            string text = "";
            foreach (var i in types)
            {
                text += " " + i;
            }
            WriteLine(text.Substring(1));
        }
    }
}


Measured memory_bytes: 11092
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <string>


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

  int n;
  std::string s;
  std::cin >> n >> s;

  int x = 0, mx = 0;
  for (const auto& c : s) {
    if (c == 'I') {
      x++;
      mx = std::max(mx, x);
    } else if (c == 'D') {
      x--;
    }
  }
  std::cout << mx << std::endl;

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
n,w_max = gets.split.map(&:to_i)
wv_arr = n.times.map{gets.chomp.split(" ").map(&:to_i)}

v_max = wv_arr.map(&:last).inject(:+)
dp = Array.new(v_max+1, Float::INFINITY)
dp[0] = 0
wv_arr.each do |wi, vi|
  v_max.downto(vi) do |v|
    w = wi + dp[v-vi]
    dp[v] = w if w <= w_max && w < dp[v]
  end
end
puts dp.rindex{|v|v != Float::INFINITY}


Measured memory_bytes: 2556
N, M = gets.split.map(&:to_i)
S = N.times.map { gets.split.map(&:to_i) }.sort_by{|v| -v[1] }
bitset = Array.new(M + 1, &:itself) # a variant of Union Find Tree.

class << bitset
  def next_clear_bit(base)
    return size if base >= size
    return base if self[base] == base
    self[base] = next_clear_bit(self[base])
  end
  
  def extend_trailling_set_bits(base)
    r = next_clear_bit(base)
    return nil if r >= size
    self[r] = next_clear_bit(r + 1)
    r
  end
end

puts S.inject(0){|s, (a, b)| bitset.extend_trailling_set_bits(a) ? s + b : s }



Measured memory_bytes: 13008
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


int main(){
    int n;
    cin >> n;
    map<string, int> m;
    rep(i, n){
        string s;
        cin >> s;
        m[s]++;
    }

    using P = pair<int, string>;
    vector<P> v;
    for(auto p: m) v.push_back({-p.second, p.first});
    sort(all(v));

    rep(i, v.size()){
        if(v[0].first == v[i].first) cout << v[i].second << endl;
        else return 0;
    }
}

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

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

  int c;
  c = 6-a-b;

  cout << c << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
const ll N = 1000030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;

int main()
{
		ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
string s;
cin>>s;
bool a=false,b=false;
rep(i,0,3)
{
	if(s[i]=='A')
	a=true;
	else
	b=true;
}
if(a&&b)
cout<<"Yes";
else
cout<<"No";

}

Measured memory_bytes: 256
h, w, k = map(int, input().split())
c = [list(input()) for _ in range(h)]
ans = 0

for i in range(2 ** h): # 行の塗り方パターン
   for j in range(2 ** w): # 列の塗り方のパターン

      d = [c[x][:] for x in range(h)]

      for p in range(h):
         bit = (1 << p)
         if i & bit > 0: 
            for x in range(w): d[p][x] = '*'

      for q in range(w):
         bit = (1 << q)
         if j & bit > 0: 
            for x in range(h): d[x][q] = '*'

      s = 0
      for p in range(h):
         for q in range(w): 
            if d[p][q] == '#': s += 1

      if s == k: ans += 1

print(ans)

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define ff { ios_base::sync_with_stdio(false);cin.tie(NULL);}
using namespace std;

typedef long long ll;
 ll  pp=1e9+7; 
double pi=3.141592653589793238;
  
 int main() {
        ff;
        ll n;
        cin>>n;
        string s;
        
        while(n>0){
            
            s.push_back('a'+(n%26+25)%26);
            n=(n+26-1)/26;
            n--;
        }
        
    
        reverse(s.begin(),s.end());
        cout<<s<<endl;
		
    return 0;
}

            
		
        
           
  

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
#define sz(a) ll(a.size())
ll r[300005],c[300005];
void solve(){
	ll n,m,k,res=0,hr=0,hc=0;
	cin>>n>>m>>k;
	set<p2> s;
	for(ll i=0;i<k;i++){
		ll x,y;
		cin>>x>>y;
		s.insert({x,y});
		r[x]++;
		c[y]++;
		hr=max(hr,r[x]);
		hc=max(hc,c[y]);
	}
	vector<ll> v1,v2;
	for(ll i=1;i<=n;i++)
		if(r[i]==hr)
			v1.push_back(i);
	for(ll i=1;i<=m;i++)
		if(c[i]==hc)
			v2.push_back(i);
	for(ll i=0;i<sz(v1);i++)
		for(ll j=0;j<sz(v2);j++){
			ll x=v1[i],y=v2[j];
			if(s.find({x,y})==s.end()){
				cout<<hr+hc;
				return;
			}
		}
	cout<<hr+hc-1;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
    #endif
    clock_t z=clock();
    ll qc=1;
    //cin>>qc;
    for(ll i=1;i<=qc;i++){
        solve();
    }
    debug("Total Time:%.4Lf\n",(ld)(clock()-z)/CLOCKS_PER_SEC);
}

Measured memory_bytes: 35052
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<cctype>
using namespace std;
int main(){
    string str;
    getline(cin,str);
    for(int i=0;i<str.length();i++)str[i]=toupper(str[i]);
    cout<<str<<endl;

    return 0;
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n;
     cin>>n;
   ll h[n];
    for(int i=0;i<n;i++)
       cin>>h[i];
  ll ans[n];
   ans[0]=0;
   ans[1]=abs(h[0]-h[1]);
   ans[2]=min(abs(h[2]-h[0]),ans[1]+abs(h[2]-h[1]));
   for(int i=3;i<n;i++)
       ans[i]=min(abs(h[i]-h[i-2])+ans[i-2],abs(h[i]-h[i-1])+ans[i-1]);
     cout<<ans[n-1];            
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);

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


//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
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;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}


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

int main() {
ll n;
ll a,b;
cin>>n>>a>>b;
cout<<min(a*n,b)<<endl;
return 0;


}




Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
int main()
{
  int n,m,k,a,c=0;
  map<int,int> f;
  cin >> n >> m;
  for(int i = 0 ; i < n ; i++)
  {
    cin >> k;
    while(k--)
    {
      cin >> a;
      f[a]++;
    }
  }
  for(int i = 1; i<=m;i++)
    c += f[i] == n ? 1 : 0;
  
  cout << c << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
  val N = readLine()!!.toInt()
  val P = readLine()!!.split(" ").map(String::toInt)
  var count = 1
  var max = P[0]
  var min = P[0]
  for (i in 1..N-1) {
    var flg = true
    if (max < P[i]) {
      max = P[i]
    } else if (min > P[i]) {
      min = P[i]
      count++
    }
  }
  println(count)
}
  


Measured memory_bytes: 83168
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();

        if (a.charAt(a.length()-1) == b.charAt(0) && b.charAt(b.length()-1) == c.charAt(0))
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}


Measured memory_bytes: 35640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			String c = sc.next();
			if (c.equals("-")) {
				break;
			}
			int m = sc.nextInt();
			for (int i = 0; i < m; i++) {
				int h = sc.nextInt();
				String head = c.substring(0, h);
				String tail = c.substring(h);
				c = tail + head;
			}
			System.out.println(c);
		}
	}
}




Measured memory_bytes: 26540
#include <iostream>

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

    const std::string target = "CODEFESTIVAL2016";
    int count = 0;
    for (int i = 0; i < (int)s.size(); i++) {
        if (s[i] != target[i]) {
            count += 1;
        }
    }

    std::cout << count << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

const int N = 2e5 + 5;
inline int Get() {
	char ch;
	while ((ch = getchar()) < '0' || ch > '9');
	int Num = ch - '0';
	while ((ch = getchar()) >= '0' && ch <= '9')
		Num = (Num << 3) + (Num << 1) + ch - '0';
	return Num;
}

int n, strA, strB, w[N][2], que[N], qn, vis[N], flag[N], ans;
struct Graph{
	int tot, first[N], next[N << 1], end[N << 1], dist[N], fa[N], sze[N], dfn[N];
	inline void AddEdge(int x, int y) {
		next[++tot] = first[x], first[x] = tot, end[tot] = y;
		next[++tot] = first[y], first[y] = tot, end[tot] = x;
	}
	void Dfs(int x) {
		que[qn = 1] = x, fa[x] = 0, dist[x] = 0;
		for (int ql = 1, u; u = que[ql], ql <= qn; sze[u] = 1, ++ql)
			for (int k = first[u], v; v = end[k], k; k = next[k])
				if (v != fa[u]) fa[v] = u, dist[v] = dist[u] + 1, que[++qn] = v;
		
		for (int qr = qn, u; u = que[qr], qr > 1; --qr) sze[fa[u]] += sze[u];
		
		dfn[x] = 1;
		for (int ql = 1, u, cur; u = que[ql], cur = dfn[u], ql <= qn; ++ql) 
			for (int k = first[u], v; v = end[k], k; k = next[k]) 
				if (v != fa[u]) dfn[v] = cur + 1, cur += sze[v];
	}
	inline bool check(int x, int y) {
		if (dist[x] < dist[y]) std :: swap(x, y);
		if (dist[x] - dist[y] > 2) return true;
		if (dfn[y] <= dfn[x] && dfn[x] < dfn[y] + sze[y]) return false;
		if (fa[x] == fa[y]) return false;
		return true;
	}
}A, B;

int main() {
	n = Get(), strA = Get(), strB = Get();
	for (int i = 1; i < n; ++i) w[i][0] = Get(), w[i][1] = Get();
	for (int i = 1; i < n; ++i) B.AddEdge(Get(), Get());
	
	B.Dfs(strB);
	for (int k = 1; k <= n; ++k)
		if (B.check(w[k][0], w[k][1])) flag[w[k][0]] = flag[w[k][1]] = true;
		else A.AddEdge(w[k][0], w[k][1]);
		
	que[qn = 1] = strA, vis[strA] = true, A.dist[strA] = 0;
	for (int ql = 1, u; u = que[ql], ql <= qn; ++ql) 
		for (int k = A.first[u], v; v = A.end[k], k; k = A.next[k]) 
			if ((A.dist[v] = A.dist[u] + 1) < B.dist[v] && !vis[v]) vis[v] = true, que[++qn] = v;
	
	for (int i = 1; i <= n; ++i) 
		if (vis[i]) {
			ans = std :: max(ans, B.dist[i] * 2);
			if (flag[i]) {
				puts("-1");
				return 0;
			}
		}
		
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 18176
#include <iostream>
#include <algorithm>

using namespace std;

#define MAX 1010

int H,W;
char a[MAX][MAX],b[2][2];
const char c[3] = {'J','O','I'};

bool inField(int y,int x){
  return 0 <= y && y < H && 0 <= x && x < W;
}

int Cnt(int y,int x,char ch){
  int res = 0;

  if(a[y][x] == b[0][0] && 
     (inField(y,x+1) && a[y][x+1] == b[0][1]) && 
     (inField(y+1,x) && a[y+1][x] == b[1][0]) &&
     (inField(y+1,x+1) && a[y+1][x+1] == b[1][1])) res++;
 
  if(b[0][0] == ch && 
     (inField(y,x+1) && a[y][x+1] == b[0][1]) && 
     (inField(y+1,x) && a[y+1][x] == b[1][0]) &&
     (inField(y+1,x+1) && a[y+1][x+1] == b[1][1])) res--;
 
  if(a[y][x] == b[0][1] && 
     (inField(y,x-1) && a[y][x-1] == b[0][0]) && 
     (inField(y+1,x-1) && a[y+1][x-1] == b[1][0]) &&
     (inField(y+1,x) && a[y+1][x] == b[1][1])) res++;
 
  if(b[0][1] == ch && 
     (inField(y,x-1) && a[y][x-1] == b[0][0]) && 
     (inField(y+1,x-1) && a[y+1][x-1] == b[1][0]) &&
     (inField(y+1,x) && a[y+1][x] == b[1][1])) res--;

  if(a[y][x] == b[1][0] && 
     (inField(y-1,x) && a[y-1][x] == b[0][0]) && 
     (inField(y-1,x+1) && a[y-1][x+1] == b[0][1]) &&
     (inField(y,x+1) && a[y][x+1] == b[1][1])){
    res++;
  }
  if(b[1][0] == ch && 
     (inField(y-1,x) && a[y-1][x] == b[0][0]) && 
     (inField(y-1,x+1) && a[y-1][x+1] == b[0][1]) &&
     (inField(y,x+1) && a[y][x+1] == b[1][1])) res--;
 
  if(a[y][x] == b[1][1] && 
     (inField(y-1,x) && a[y-1][x] == b[0][1]) && 
     (inField(y,x-1) && a[y][x-1] == b[1][0]) &&
     (inField(y-1,x-1) && a[y-1][x-1] == b[0][0])) res++;
 
  if(b[1][1] == ch && 
     (inField(y-1,x) && a[y-1][x] == b[0][1]) && 
     (inField(y,x-1) && a[y][x-1] == b[1][0]) &&
     (inField(y-1,x-1) && a[y-1][x-1] == b[0][0])) res--;
 
  return res;
}

int main(){
  cin >> H >> W;
  for(int i = 0 ; i < H ; i++){
    for(int j = 0 ; j < W ; j++){
      cin >> a[i][j];
    }
  }
  for(int i = 0 ; i < 2 ; i++){
    for(int j = 0 ; j < 2 ; j++){
      cin >> b[i][j];
    }
  }
  int ans = 0;
  for(int i = 0 ; i < H-1 ; i++){
    for(int j = 0 ; j < W-1 ; j++){
      for(int k = 0 ; k < 2 ; k++){
        for(int l = 0 ; l < 2 ; l++){
          if(a[i+k][j+l] != b[k][l]){
            goto next;
          }
        }
      }
      ans++;
    next:;
    }
  }
  int d = ans;
  for(int i = 0 ; i < H ; i++){
    for(int j = 0 ; j < W ; j++){
      char tmp = a[i][j];
      for(int k = 0 ; k < 3 ; k++){
        if(tmp == c[k]) continue;
        a[i][j] = c[k];
        ans = max(ans,d+Cnt(i,j,tmp));
      }
      a[i][j] = tmp;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 2160
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


def main():
    N, T = li_input()

    A = []
    for i in range(N):
        A.append(li_input())

    ans = 99999

    for a in A:
        cost, time = a

        if time <= T and cost < ans:
            ans = cost

    if ans == 99999:
        print("TLE")
    else:
        print(ans)


main()


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

using ll =long long;
const ll INFll = 0x7F7F7F7F7F7F7F7F;
const int INFint = 100100100;

int main()
{
    int n, k, dpk, mindp=INFint, maxk=0;
    cin >> n >> k;
    vector<int> h(n), dp(n);
    for (int i=0;i<n;i++) cin >> h[i];

    dp[0]=0;
    for (int i=1;i<n;i++)
    {
        mindp=dp[i-1]+abs(h[i]-h[i-1]);
        if (i>1){
            maxk = min(k, i);
            for (int j=2;j<=maxk;j++)
            {
                dpk = dp[i-j]+abs(h[i]-h[i-j]);
                if (mindp > dpk) mindp=dpk;
            }
        }
        dp[i]=mindp;

    }

    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
require "prime"
n = gets.chomp.to_i
 
def divisors(n)
  n.prime_division.inject([1]) do |ary, (p, e)|
    (0..e).map{ |e1| p ** e1 }.product(ary).map{ |a, b| a * b }
  end.sort
end
 
cnt = 0
 
(1..n).to_a.each do |i|
  if i % 2 == 1 && divisors(i).size == 8
    cnt += 1
  end
end
 
puts cnt

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

int main() {
  int X, ans = 0;

  cin >> X;

  if (X == 1) {
    cout << 1 << endl;
    return 0;
  }

  for (int i = 2; i <= sqrt(X); i++) {
    int tmp = pow(i, 2);
    while (tmp <= X) {
      ans = max(ans, tmp);
      tmp *= i;
    }
  }

  cout << ans << endl;
      

  return 0;

}

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


int main(){
  string X;
  cin>>X;
  int A,B,C,D;
  A=X.at(0)-'0';
  B=X.at(1)-'0';
  C=X.at(2)-'0';
  D=X.at(3)-'0';

  if(A+B+C+D==7){
    cout<<A<<'+'<<B<<'+'<<C<<'+'<<D<<"=7"<<endl;
  }else if(A-B+C+D==7){
    cout<<A<<'-'<<B<<'+'<<C<<'+'<<D<<"=7"<<endl;
  }else if(A+B-C+D==7){
    cout<<A<<'+'<<B<<'-'<<C<<'+'<<D<<"=7"<<endl;
  }else if(A-B-C+D==7){
    cout<<A<<'-'<<B<<'-'<<C<<'+'<<D<<"=7"<<endl;
  }else if(A+B-C-D==7){
    cout<<A<<'+'<<B<<'-'<<C<<'-'<<D<<"=7"<<endl;
  }else if(A-B-C-D==7){
    cout<<A<<'-'<<B<<'-'<<C<<'-'<<D<<"=7"<<endl;
  }else if(A+B+C-D==7){
    cout<<A<<'+'<<B<<'+'<<C<<'-'<<D<<"=7"<<endl;
  }else if(A-B+C-D==7){
    cout<<A<<'-'<<B<<'+'<<C<<'-'<<D<<"=7"<<endl;
  }

//  cout<<ans<<endl;
}


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

int main(){
  while(1){
    string g ;
    
    cin>>g;
    if(g=="#") break;
    int y,m,d;
    cin>>y>>m>>d;
   
    if(y==31 && m<=4 && d<=31){
      cout<<g<<" "<<y<<" "<<m<<" "<<d<<endl;
    }else if (0<y && y<31){
      cout<<g<<" "<<y<<" "<<m<<" "<<d<<endl;
    }else{
      cout<<"?"<<" "<<y-30<<" "<<m<<" "<<d<<endl;
    }
  }return 0;
}
     
  
    
    
  
  
    
    
  
    
    
  
    
      
    
  
    
    
    
    
    
    
    

   
 
   
    
    
	 
      
    
  
  

  
  

 




Measured memory_bytes: 3144
data = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]
  
n = int(input())
  
for _ in range(n):
    (b,f,r,v) = [int(i) for i in input().split()]
    data[b - 1][f - 1][r - 1] += v
  
for b in range(4):
    for f in range(3):
        for r in range(10):
            print('',data[b][f][r], end='')
        print()
    if b < 3:
        print('#' * 20)

Measured memory_bytes: 7716