akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
ll intpow(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = intpow(N, P/2);
        return t*t;
    }
    return N * intpow(N, P-1);
}
ll modpow(ll N, ll P,ll k){
    if(P==0) return 1;
    if(P%2==0){
        ll t = modpow(N, P/2,k)%k;
        return t*t%k;
    }
    return N * modpow(N, P-1,k)%k;
}
ll modkai(ll n,ll m,ll k){//n*(n-1)*(n-2)*...(m+1)%k
    if(n == m)return 1;
    return modkai(n-1,m,k)*n%k;
}
ll mod_cnb(ll n,ll m,ll k){//nCm%k,kは十分大きい素数
  int m_=modkai(m,0,k);
  return modkai(n,n-m,k)*modpow(m_,k-2,k)%k;
}
ll gcd(ll n,ll m){
    n = max(n,m);
    m = min(n,m);
    if(n%m == 0)return m;
    return gcd(m,n%m);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}
const double pi=3.14159265358979323846;
int main(){
    double a,b,x;cin>>a>>b>>x;
    if(x<=a*a*b/2){
        cout << setprecision(10) << atan(a*b*b/(x*2))*180/pi <<endl;
    }   
    else{
        cout<< setprecision(10)<<atan(2*(a*a*b-x)/(a*a*a))*180/pi<<endl;
    }
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include <string>
#define ll long long
using namespace std;
int main(){
	string buf;
	getline(cin, buf);
	for (int i=0;i<buf.size();i++) {
			if(buf[i]>='a' &&buf[i]<='z') buf[i]-=32;
			else if(buf[i]>='A'&&buf[i]<='Z') buf[i]+=32;
			else ;
	}
	cout << buf << endl;
}



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

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

    ll a = ceil(N/(A+B));
    ll b = N%(A+B);
    ll ans = a*A + ((b > A)? A : b);
    cout << ans << endl;
}


Measured memory_bytes: 256
lst = [0,0,0,0]
for i in range(3):
  a,b = list(map(int,input().split(" ")))
  lst[a-1] += 1
  lst[b-1] += 1
  
if (lst.count(2)==2 and lst.count(1)==2) or (lst.count(3)==1 and lst.count(2)==2 and lst.count(1)==1):
  print("YES")
else :
  print("NO")

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

#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;

TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM T> inline istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }
TPL<TNM V, TNM H> void resize(vector<V>& _v, const H _h) { _v.resize(_h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& _v, const H& _h, const T& ... _t) { _v.resize(_h); for (auto& __v : _v) resize(__v, _t ...); }
TPL<TNM V, TNM T> TNM enable_if<!is_class<V>::value>::type fill(vector<V>& _v, const T& _t) { std::fill(ALL(_v), _t); }
TPL<TNM V, TNM T> TNM enable_if<is_class<V>::value>::type fill(vector<V>& _v, const T& _t) { for (auto& _e : _v) fill(_e, _t); }
TPL<TNM T> inline void UNIQUE(vector<T>& _v) { sort(ALL(_v)); _v.erase(unique(ALL(_v)), _v.end()); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

int main(void) {
	int a, b;
	cin >> a >> b;
	int c = a + b;
	cout << (c + 2 - 1) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
using namespace std;
int main(void) {
  string s;
  int ans = -1;
  cin >> s;
  for (auto i = s.begin(); i != s.end(); i++) {
    auto j = i;
    int c = 0;
    while (*j == 'A' or *j == 'C' or *j == 'G' or *j == 'T') {
      if (j == s.end())
        break;
      c++;
      j++;
    }
    ans = max(ans, c);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 888
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.ABC098.B
{
    class Program
    {
        static void Main ()
        {
            var sc = new Scanner ();
            int n = sc.Nextint ();
            var s = sc.Next ();
            int max = 0;
            for (int i = 1; i <= n - 1; i++)
            {
                var s1 = s.Substring (0, i).Distinct ();
                var s2 = s.Substring (i, n - i).Distinct ();
                var cnt = s1.Intersect<char> (s2);
                max = Math.Max (max, Enumerable.Count (cnt));
            }
            Console.WriteLine (max);
        }
    }

    class Scanner
    {
        string[] s;
        long i;

        char[] cs = new char[] { ' ' };

        public Scanner ()
        {
            s = new string[0];
            i = 0;
        }

        public string Next ()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine ();
            while (st == "") st = Console.ReadLine ();
            s = st.Split (cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next ();
            i = 0;
            return s[i++];
        }

        public int Nextint ()
        {
            return int.Parse (Next ());
        }
        public int[] Arrayint (int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Nextint () + add;
            }
            return Array;
        }

        public long NextLong ()
        {
            return long.Parse (Next ());
        }

        public long[] ArrayLong (int N, long add = 0)
        {
            long[] Array = new long[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextLong () + add;
            }
            return Array;
        }

        public double NextDouble ()
        {
            return double.Parse (Next ());
        }

        public double[] ArrayDouble (long N, double add = 0)
        {
            double[] Array = new double[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDouble () + add;
            }
            return Array;
        }

        public decimal NextDecimal ()
        {
            return decimal.Parse (Next ());
        }

        public decimal[] ArrayDecimal (long N, decimal add = 0)
        {
            decimal[] Array = new decimal[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDecimal ();
            }
            return Array;
        }
    }
}

Measured memory_bytes: 11348
# for #!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion
class union_find:
    def __init__(self, n):
        self.n = n
        self.rank = [0]*n
        self.parent = [int(j) for j in range(n)]
    
    def union(self,i,j):
        i = self.find(i)
        j = self.find(j)
        if self.rank[i] == self.rank[j]:
            self.parent[i] = j
            self.rank[j] += 1

        elif self.rank[i] > self.rank[j]:
            self.parent[j] = i
        else:
            self.parent[i] = j

    def find(self, i):
        temp = i
        if self.parent[temp] != temp:
            self.parent[temp] = self.find(self.parent[temp])
        return self.parent[temp]
from math import log2, ceil
def main():
# Enter your code here. Read input from STDIN. Print output to STDOUT
    n,k = [int(j) for j in input().split()]
    a = max(n-k+1, 0)
    for x in range(1, min(k, n+1)):
        tmp = (1/2)**ceil(log2(k/x))
        # print(tmp,x,ceil(log2(k/x)))
        a+=tmp
    print(a/n)
    # if
    

    # s[k-1] = s[k-1].lower()
    # print("".join(s))
        





        
                # ls[i+1]=
            # base = f
        # print()


        
        




        # l = [int(j) for j in input().split()]




if __name__ == "__main__":
    main()

Measured memory_bytes: 65628
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


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


def main():
    N, Q = map(int, input().split())

    edges = [[] for _ in range(N + 1)]
    nums = [0 for _ in range(N + 1)]
    for _ in range(N - 1):
        a, b = map(int, input().split())
        edges[a].append(b)
        edges[b].append(a)

    for _ in range(Q):
        p, x = map(int, input().split())
        nums[p] += x

    def dfs(now, parent):
        for i in edges[now]:
            if i != parent:
                nums[i] += nums[now]
                dfs(i, now)

    dfs(1, 0)
    for n in nums[1:]:
        print(n)


if __name__ == "__main__":
    main()


Measured memory_bytes: 266800
/*
 * ITP1_1_D.c
 *
 *  Created on: 2017/05/11
 *      Author: sl2-user
 */
#include<stdio.h>

int main(void){

	int a , b,c;
	scanf("%d %d %d" , &a , &b , &c);
	if((a<b)&&(b<c)){printf("Yes\n");}else{printf("No\n");}

return 0;
}

Measured memory_bytes: 580
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
        
        int n=sc.nextInt();
        int x;
        
        for(int i=1;i<=n;i++){
            x=i;
        	if(x%3==0){
                System.out.print(" "+i);
                continue;
            }
            for(;;){
                if(x%10==3){
                	System.out.print(" "+i);
                    break;
                }
                x/=10;
                if(x<2)
                	break;
        	}
        }
            	
        System.out.println();
	}
}



Measured memory_bytes: 28760
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>

using namespace std;

const int MAX = 200000;
vector<int> prime;
set<int> prime_s;

void make(){
  bool f[MAX];
  fill(f,f+MAX,true);
  for(int i=2;i<MAX;++i){
    if(f[i]){
      for(int j=2*i;j<MAX;j+=i){
        f[j]=false;
      }
      prime.push_back(i);
      prime_s.insert(i);
    }
  }
}

int solve(int n){
  int ret = 0;
  for(int i = 0; i < (int)prime.size(); ++i){
    if( prime[i] > n/2 ) break;
    if( prime_s.find(n-prime[i]) != prime_s.end() ){
      ++ret;
    }
  }
  return ret;
}

int main(){
  make();
  int n;
  while(cin >> n && n){
    cout << solve(n) << endl;
  }
}

Measured memory_bytes: 2252
// -*- mode:c++; coding:utf-8; indent-tabs-mode:nil; -*-

#include <algorithm>
#include <iostream>

int max_profit(int const rs[], const unsigned int n) {
  int r0 = rs[0];
  int r1 = rs[1];
  int cur_p = r1 - r0;
  int max_p = cur_p;
  int min_r =  std::min(r0, r1);

  for (unsigned int i = 2; i < n; ++i) {
    const int r = rs[i];
    cur_p = r - min_r;
    max_p = std::max(max_p, cur_p);
    min_r = std::min(min_r, r);
  }

  return max_p;
}

int main(void) {
  unsigned int n;
  std::cin >> n;
  int* rp = new int[n];
  for (unsigned int i = 0; i < n; ++i) {
    std::cin >> rp[i];
  }

  const int max_p = max_profit(rp, n);
  std::cout << max_p << std::endl;

  delete rp;
  return 0;
}
// end

Measured memory_bytes: 1796
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>


int n;
vector<int> a;

void f(int k){

  vector<int> b(n,0);
  rep(i,n){
    b[i]=k;
    k=2*(a[i]-k/2);
  }

  k=(b[0]+k)/2;
 

  rep(i,n){
    b[i]=k;
    k=2*(a[i]-k/2);
  }

  rep(i,n){
    cout<<b[i]<<' ';
  }
  cout<<endl;


}

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


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

  f(0);

}


Measured memory_bytes: 2944
using System;
using System.Collections.Generic;
class Program {

    static Graph G;
    static int N;
    static int X;
    static int Y;

    public struct Graph {
        public HashSet<int>[] points;

        public Graph (int n) {
            points = new HashSet<int>[n];
            for (int i = 0; i < n; i++) {
                points[i] = new HashSet<int> ();
            }
        }

        public void AddLine (int a, int b) {
            points[a].Add (b);
            points[b].Add (a);
        }

        public void AddDirectionalLine (int a, int b) {
            points[a].Add (b);
        }
    }

    static void Main (string[] args) {
        string[] input = Console.ReadLine ().Split (' ');
        N = int.Parse (input[0]);
        X = int.Parse (input[1]);
        Y = int.Parse (input[2]);
        G = new Graph (N);

        for (int i = 0; i < N - 1; i++) {
            G.AddLine(i, i+1);
        }

        G.AddLine(X - 1, Y - 1);

        int[] allRet = new int[N];

        for (int h = 0; h < N; h++) {
            int[] ret = BFS(G, h);
            for (int n = 0; n < N; n++) {
                allRet[n] += ret[n];
            }
        }

        for (int i = 1; i < N; i++) {
            Console.WriteLine (allRet[i] / 2);
        }

    }

    static int[] BFS (Graph graph, int startNode) {
        int[] dist = new int[N];
        Queue<int> que = new Queue<int> ();
        for (int i = 0; i < N; i++) {
            dist[i] = -1;
        }
        dist[startNode] = 0;
        que.Enqueue (startNode);

        while (que.Count > 0) {
            int nowPoint = que.Dequeue ();
            foreach (int nextPoint in graph.points[nowPoint]) {
                if (dist[nextPoint] != -1) continue;

                dist[nextPoint] = dist[nowPoint] + 1;
                que.Enqueue (nextPoint);
            }
        }

        int[] ret = new int[N];

        for (int i = 0; i < N; i++) {
            ret[dist[i]]++;
        }

        return ret;
    }
}


Measured memory_bytes: 30304
/*By Ravenclaw_OIer*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int (i) = 0; (i) < n; (i)++)
#define ll long long
#define ull unsigned long long
#define lsh(X) (1 << (X))
#define lshll(x) (1LL << (x))
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
const int MAXN = 100010;
vector <int> g[MAXN];
int dp[MAXN];
int n, m;
int DP(int u) {
	if (dp[u] != -1)return dp[u];
	dp[u] = 0;
	for (auto v:g[u])dp[u] = max(DP(v) + 1, dp[u]);
	return dp[u];
}
int main()
{
	cin >> n >> m;
	rep(i, m) {
		int u, v;
		cin >> u >> v;
      	u--;v--;
		g[u].push_back(v);
	}
	memset(dp, -1, sizeof(dp));
	int ans = 0;
	rep(i, n)ans = max(ans, DP(i));
	cout << ans << endl;
	return 0;
} 


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

int main() {
  int a, b;
  cin >> a >> b;
  for (int i = 0; i < 100 * 100; i++)
    if (i * 8 / 100 == a && i * 10 / 100 == b) return cout << i << endl, 0;
  cout << -1 << endl;
  return 0;
}


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

using namespace std;

int main(){
  
  int N;
  cin >> N;
  
  vector<long long> v(N);
  
  for(int i = 0; i < N; i++){
    long long x;
    cin >> x;
    v[i] = x;
  }
  sort (v.begin(),v.end());
  
  auto i = v.begin();
  auto j = v.end() - 1;
  
  cout <<abs(*j - *i);
}

Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<algorithm>
#include<set> 
#define LL long long 
using namespace std;

struct node
{
	int a,b,t;
}a[100005];
bool cmp(node a,node b)
{
	return a.b>b.b;
}
int main()
{
	int n,h;
	cin>>n>>h;
	int maxa=-1;
	int maxb=-1;
	int in=1;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i].a>>a[i].b;
		a[i].t=i;
		if(a[i].a>maxa)
		{
			in=i;
			maxa=a[i].a;
			maxb=a[i].b;
		}	
	}
	int ans=0;
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=n;i++)
	{	
	
//		if(a[i].a<a[i+1].b&&a[i].a!=maxa){
//			ans++;
//			h-=a[i].b;
//		}
		
		if(a[i].t!=in&&a[i].b>=maxa)
		{
			h-=a[i].b;
			ans++;
			if(h<=0)
				break;
			else
			{
				if(maxb>a[i].b&&h-(maxb-a[i].b)<=0)
				{
					h=-1;break;
				}
					
			}
		}
		if(a[i].b<maxa)
			break;
	}
	if(h<=0)
		cout<<ans;
	else
	{
		if(h<=maxb)
			cout<<ans+1;
		else
			cout<<(ans+1+(h-maxb+maxa-1)/maxa);
	}
} 

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

using namespace std;

bool pal(string s)
{
    bool ok=1;
    int n=s.size();
    for(int i=0;i<n;i++) if(s[i]!=s[n-i-1]) ok=0;
    return ok;
}

int main()
{
    string s;
    cin >> s;
    int n=s.size();
    bool b=1;
    if(!pal(s)) b=0;
    if(!pal(s.substr(0,(n-1)/2))) b=0;
    if(!pal(s.substr((n+3)/2-1,n))) b=0;
    if(b) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


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

int main(){
	int n,a,b;
	bool flag;
	int number;
	map<int,int> info;
	vector<int> seq;
	
	while(cin >> n && n){
		info.clear();
		seq.clear();
		while(n--){
			cin >> number >> a >> b;
			if(!info[number])seq.push_back(number);
			while(b-- && info[number]<1000000){
				info[number] += a;
			}
		}
		flag = true;
		for(int i=0;i<seq.size();i++){
			if(info[seq[i]]>=1000000){
				flag = false;
				cout << seq[i] << endl;
			}
		}
		if(flag)cout << "NA" << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef  pair<int,int> P;
typedef long long LL;
typedef vector<LL> VEC;

const LL INF=1<<30;
const LL MOD=1000000007;


int main(){
    	int a,b,c;
        cin>>a>>b>>c;
        int ans=a^b^c;
        cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <iostream>

int main(){
  int N;
  std::string S,T;
  std::cin>>N>>S>>T;
  for(int i=N;i>=0;i--){
    if(S.substr(N-i,N)==T.substr(0,i)){
      std::cout<<N*2-i<<std::endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#define ll long long
using namespace std;

ll check(ll a){
  ll cnt = 0;
  while(a){
    a /= 10;
    cnt++;
  }
  return cnt;
}

int main(){
  ll n, ans = 1000000000;
  cin >> n;
  for(ll i = 1; i <= sqrt(n); i++){
    if(n % i == 0){
      ll a = i;
      ll b = n / i;
      ans = min(ans, max(check(a), check(b)));
    }
  }
  cout << ans << endl;
  return 0;
}


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

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

int solve(int start,int a[],int n,int ans,int dp[])
{
    if(dp[start]==-1)
    {
        if(start==n-1)
            return 0;
        if(start==n-2)
        {
            int ans1=abs(a[start]-a[start+1]);
            //return ans1/*+solve(start+1,a,n,ans1)*/;

            dp[start]=ans1+solve(start+1,a,n,ans1,dp);
            return(dp[start]);
        }
        int ans1=abs(a[start]-a[start+1]);
        int ans2=abs(a[start]-a[start+2]);

        dp[start]=min(ans1+solve(start+1,a,n,ans1,dp),ans2+solve(start+2,a,n,ans2,dp));
        return(dp[start]);
    }
    else
    {
        return(dp[start]);
    }
}
int main()
{
    //cout<<"Enter number of stones: ";
    int n;
    cin>>n;
    //cout<<"\nEnter the height of the stones:";
    int a[n],x[n];
    for(int i=0;i<n;i++)
    {
      	x[i]=-1;
        cin>>a[i];
    }

    int start=0,ans=0;
    ans=solve(start,a,n,ans,x);
    cout/*<<"\n Minimum dist:"*/<<ans;

    return 0;
}


Measured memory_bytes: 4992
import scala.io.{StdIn => in}

object Main extends App {

  val n = in.readInt
  val tar ="MARCH".toCharArray
  val table = Array.ofDim[Long](tar.size)

  Iterator.continually(in.readLine)
    .take(n)
    .foreach(s => {
      val idx = tar.indexWhere(_ == s.head)
      if(idx != -1) table(idx) += 1
    })

    // debug(table.mkString(" "))

  val ans = {
    var res = 0L
    for {
      i <- tar.indices
      j <- i+1 until tar.size
      k <- j+1 until tar.size
    } res += table(i) * table(j) * table(k)
    res
  }
  println(ans)

  def debug(any:Any*):Unit = {
    if(this.getClass.toString == "class Main$") return
    println(any.mkString(" "))
  }
}

Measured memory_bytes: 35844
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s[10001],d,f,g,h,i,j;
	for(i=2;i<=10000;i++)	s[i]=1;
		s[1]=0;
	for(i=2;i<=10000;i++){
		if(s[i]==1){
			for(j=2;j<=5000;j++){
				if(i*j<=10000)
					s[i*j]=0;
			}
		}
	}
	while(1){
		d=0;
		f=0;
		scanf("%d",&a);
		if(a==0)	break;
		for(i=a;i>0;i--){
			if(s[i]==1){
				if(d==0) d=i;
				else f=i;
			}
			if(d!=0&&f!=0){
				if(d-f==2)
					break;
				d=f;
			}
		}
		printf("%d %d\n",f,d);
	}
	return 0;
}

Measured memory_bytes: 2708
#include <algorithm>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n, k; cin >> n >> k;
  vector<bool> d(10, false);
  while (k--) {
    int dd; cin >> dd;
    d[dd] = true;
  }
  while (true) {
    int now = n;
    bool ok = true;
    while (now > 0) {
      if (d[now % 10]) {
        ok = false;
        break;
      }
      if (!ok) break;
      now /= 10;
    }
    if (ok) {
      cout << n << '\n';
      return 0;
    }
    ++n;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second

void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
}
const int N = 2e5 + 50;
ll mod = 998244353;
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937_64 mt(seed);
int fac[N],invf[N];
inline int add(int x, int y) { return x + y >= mod ? x + y - mod : x + y; }
inline int sub(int x, int y) { return x - y >= 0 ? x - y : x - y + mod; }
inline int power(int x, int y, int res = 1) {
    for (; y; y >>= 1, x = 1ll * x * x % mod) {
        if (y & 1) { res = 1ll * res * x % mod; }
    } return res;
}
void initcombi(int n) {
    for (int i = fac[0] = 1; i <= n; i++) { fac[i] = 1ll * fac[i - 1] * i % mod; }
    invf[n] = power(fac[n], mod - 2);
    for (int i = n; i; i--) { invf[i - 1] = 1ll * invf[i] * i % mod; }
}
 
inline int NCR(int n, int m) {
    if (n < m) { return 0; }
    return 1ll * fac[n] * invf[m] % mod * invf[n - m] % mod;
}

int main() {
    io();
    string s;
    cin >> s;
    if(s[2] == s[3] and s[4] == s[5]) {
        cout << "Yes\n";
    }
        else    cout << "No";


}
    

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    try{
      Scanner scanner = new Scanner(System.in);
      int N = scanner.nextInt();
      int M = scanner.nextInt();
      int[][] cities =new int[N][N];
      int i = 0;
      int j = 0;
      int sum = 0;

      for(i=0;i<N;i++){
        for(j=0;j<N;j++){
          cities[i][j]=0;
        }
      }

      for(i=0;i<M;i++){
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        cities[a-1][b-1]++;
        cities[b-1][a-1]++;
      }
      for(i=0;i<N;i++){
        sum = 0;
        for(j=0;j<N;j++){
          sum+=cities[i][j];
        }
        System.out.println(sum);
      }
      scanner.close();
    }catch(Exception e){
      System.out.println("何か入力してください");
    }
  }
}


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

int main()
{
    ll N, Y;
    cin >> N >> Y;
    rep(i,N+1) {
        rep(j,N+1) {
            ll a = i;
            ll b = j;
            ll c = N - a - b;
            if (c < 0) c = 0;
            if (a+b+c > N) continue;
            if (a*10000 + b * 5000 + c*1000 == Y) {
                cout << a << " " << b << " " << c << endl;
                exit(0);
            }
        }
    }
    cout << "-1 -1 -1" << endl;

}

Measured memory_bytes: 3600
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

//macro
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define EPS (1e-8)
#define equals(a,b)(fabs((a)-(b))<EPS)

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

int main() {
	string S;
	cin >> S;
	YesNo(S[0] == S[2]);
}

Measured memory_bytes: 256
function main(io = stdin)
    readto(target = '\n') = readuntil(io, target)
    readnum(T::Type{<:Number} = Int; dlm = isspace, kwargs...) =
        parse.(T, split(readto(), dlm; kwargs...))

    N, = readnum()
    for cnt in solve(N)
        println(cnt)
    end
end

function solve(N)
    cnts = zeros(Int, N)
    n = floor(Int, √N)
    for x in 1:n
        for y in 1:n
            for z in 1:n
                v = x^2 + y^2 + z^2 + x*y + y*z + z*x
                v ≤ N && (cnts[v] += 1)
            end
        end
    end
    return cnts
end

@static if @isdefined(Juno)
    main(open(replace(@__FILE__, r"(.+)\.jl" => s"\1.in")))
else
    main()
end


Measured memory_bytes: 199492
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>       // for next_permutation
#include <vector>
#include <cstdlib>
#define INF 998244353

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

const ll MOD = 1e9+7;

static long gcd(long a, long b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}
/*
long long int facctorialMethod(int k){//階乗
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}*/

long long int tousasum(long long int n){//等差数列
    return n*(n+1)/2;
}

unsigned GetDigit(unsigned num){//桁数
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された

    if(n%2 == 0) return false;
    if(n%3 == 0) return false;
    // 2と3の倍数でないので6の倍数ではないことが保証された

    if(n%6 != 1 && n%6 != 5) return false;
    // 6の倍数前後の数(素数かもしれない数)であることが保証された

    // 6の倍数前後の数を使って試し割りをする
    for(unsigned i=5;i*i<=n;i+=6){
        if(n%i     == 0) return false; // 6n-1
        if(n%(i+2) == 0) return false; // 6n+1
    }

    return true;
}

map< ll, ll > prime_factor(ll n) {//素因数分解
    map< ll, ll > ret;
    for(ll i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

ll calcNumOfCombination(ll n, ll r){
    ll num = 1;
    for(ll i = 1; i <= r; i++){
        num = num * (n - i + 1) / i;
    }
    return num;
}

int bubblesort(vector<int> array,int size){//バブルソート　転倒数
    int kaisu = 0;
    for(int i = 0; i < size; i++){
        for(int j = i + 1; j < size; j++){
            if(array[i] > array[j]){
                int number = array[i];
                array[i] = array[j];
                array[j] = number;
                kaisu++;
            }
        }
    }
    return kaisu;
}

ll facctorialMethod(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum = (sum * i)%MOD;
    }
    return sum;
}

// nPnの順列に対して処理を実行する
void foreach_permutation(int n, std::function<void(int *)> f) {
    int indexes[n];
    for (int i = 0; i < n; i++) indexes[i] = i;
    do {
        f(indexes);
    } while (std::next_permutation(indexes, indexes + n));
}





int main() {
 int H,W,N;
 cin >> H >> W >> N;
 int result = max(H,W);
 int ans = 0;
 for(int i=0;i<100000;i++){
     if(ans * result >= N){
         break;
     }
     ans++;
 }
 cout << ans << endl;
}








Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

ans = B[A[0]-1]
for i in range(1, N):
    ans += B[A[i]-1]
    if A[i-1] + 1 == A[i]:
        ans += C[A[i]-2]
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
typedef vector<int> vi;
const int MAX=1e5+5;
const int MOD=1e9+7;

int extgcd(int a,int b,int& x, int& y){
	int d=a;
	if(b!=0){
		d = extgcd(b, a%b, y, x);
		y -= (a/b) * x;
	}
	else{
		x = 1; y = 0;
	}
	return d;
}
int mod_inv(int a,int m){
	int x,y;
	extgcd(a,m,x,y);
	return (m+x%m)%m;
}


int a[MAX];
int ct[MAX];
vi v;

int main(){
	int n;
	cin>>n;
	rep1(i,n+1){
		cin>>a[i];
		ct[a[i]]++;
	}
	int x;
	rep1(i,n){
	if(ct[i]==2)x=i;
	}
	rep1(i,n+1){
		if(a[i]==x)v.push_back(i);
	}
	int m=n+v[0]-v[1];
	
	//kについて、答えは(n+1)_C_k-m_C_(k-1)
	//逆元を使ってCの計算
	
	lli cn1[MAX],cm[MAX];
	cn1[0]=1;
	rep1(i,n+1){
		cn1[i]=(((cn1[i-1]*(n+1-i+1))%MOD)*mod_inv(i,MOD))%MOD;
	}
	cm[0]=1;
	rep1(i,m){
		cm[i]=(((cm[i-1]*(m-i+1))%MOD)*mod_inv(i,MOD))%MOD;
	}
	rep1(k,n+1){
		if(k<=m+1)cout<<(cn1[k]+MOD-cm[k-1])%MOD<<endl;
		else cout<<cn1[k]<<endl;
	}
	
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = ll(1)<<60;
const int N = 100;

int n, x, d, m[N], p[N], indegree[N];

ll f[N*N*N];
// f[i] : min cost when val = i.

inline void ck_min( ll &a, ll b ) { if( a > b ) a = b; }
inline void ck_max( ll &a, ll b ) { if( a < b ) a = b; }

struct tDoughnut {
	ll val, cost, lim;
	
	bool operator < ( const tDoughnut &rhs ) const {
		return double(val) / cost > double(rhs.val) / rhs.cost;
	}
} a[N];

int main()
{
	scanf( "%d%d%d", &n, &x, &d );
	
	scanf( "%d", &a[1].cost );
	for( int i = 2; i <= n; i ++ ) 
		scanf( "%d%d", &a[i].cost, &p[i] ), indegree[p[i]] ++;
		
	for( int i = 1; i <= n; i ++ )
		a[i].val = 1, a[i].lim = ( i == 1 ? INF : d );
		
	queue <int> q;
	for( int i = 1; i <= n; i ++ )
		if( !indegree[i] ) q.push( i );
		
	while( !q.empty() ) 
	{
		int u = q.front(); q.pop();
		
		a[p[u]].val += a[u].val;
		a[p[u]].cost += a[u].cost;
		indegree[p[u]] --;
		if( !indegree[p[u]] )
			q.push( p[u] );
	}
	
	for( int i = 1; i <= n*n*n; i ++ )
		f[i] = INF;
	
	for( int i = 1; i <= n; i ++ ) 
	{
		int t = min( ll(n), a[i].lim );
		a[i].lim -= t;
		
		for( int j = 1; j <= t; j <<= 1 ) 
		{
			for( int k = n*n*n; k >= j*a[i].val; k -- )
				ck_min( f[k], f[k-j*a[i].val] + j*a[i].cost );
			t -= j;
		}
		
		if( !t ) continue;
		for( int k = n*n*n; k >= t*a[i].val; k -- ) 
			ck_min( f[k], f[k-t*a[i].val] + t * a[i].cost ); 
	}
	
	sort( a+1, a+1+n );
//	for( int i = 1; i <= n; i ++ )
//		printf( "%lld ", a[i].cost ); printf( "f\n" );
	
	ll ans = 0;
	for( int i = 0; i <= n*n*n; i ++ )
	{
		if( f[i] > x ) continue;
		ll left = x - f[i], tmp_ans = i;
		
		for( int j = 1; j <= n; j ++ )
		{
			ll num = min( a[j].lim, left / a[j].cost );
//			printf( "left:%lld, cost:%lld\n", left, a[j].cost );
//			printf( "j:%d, num:%d\n", j, num );
			
			tmp_ans += num * a[j].val;
			left -= num * a[j].cost;
		}
		
//		printf( "tmp_ans:%lld\n", tmp_ans );
		ck_max( ans, tmp_ans );
	}
	
	printf( "%lld\n", ans );
	
	return 0;
}



Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>

using namespace std;

#define N_MAX 53

int main(){
	int N;
	char S1[N_MAX];
	char S2[N_MAX];
	long long res;
	int state,len;

	scanf("%d",&N);

	scanf("%s",S1);
	scanf("%s",S2);

	res = 3;

	int i=1;

	if(S1[0] == S2[0])
		state = 1;
	else{
		res = res*2;
		state = 2;
		i++;
	}


	while(i<N){
		if(S1[i] == S2[i]){
			if(state==1){
				res = res*2%1000000007;
			}
			state = 1;
		}else{
			if(state==1){
				res = res*2%1000000007;
			}else{
				res = res*3%1000000007;
			}
			state = 2;
			i++;
		}

		i++;
	}

	printf("%lld\n",res);

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
#include <cstdio>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
 
int dy[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
int dx[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
int x[100010], y[100010];
 
int main(void){
    int h, w, n; cin >> h >> w >> n;
    set<pair<int, int> > s;
    set<pair<int, int> > used;
    rep(i, n){
        int a, b; cin >> a >> b;
        a--; b--;
        y[i] = a; x[i] = b;
        s.insert(make_pair(a, b));//y,x
    }
 
    ll ans[10];
    rep(i, 10) ans[i] = 0;
 
    rep(i, n){
        rep(j, 9){
            //黒の周りから3x3の真ん中となりうるものをcy,cx
            int cy = y[i] + dy[j], cx = x[i] + dx[j];
            if(!(0 <= cy && cy < h && 0 <= cx && cx < w)) continue;
            if(used.count(make_pair(cy, cx)) == 1)continue;//すでに調べた
            int tmp = 0;
            rep(k, 9){//cy,cxを中心とした3x3を調べる
                int ny = cy + dy[k], nx = cx + dx[k];
                if(!(0 <= ny && ny < h && 0 <= nx && nx < w)) break;
                if(s.count(make_pair(ny, nx)) == 1)tmp++;
                if(k == 8){
                    used.insert(make_pair(cy, cx));
                    ans[tmp]++;
                }
            }
        }       
    }
    ll sum = 0;
    rep(i, 10){//1~9の合計
        sum += ans[i];
    }
    //0は全ての3x3から1~9の合計を引けばいい
    printf("%lld\n", ((ll)h - 2) * ((ll)w - 2) - sum);
    for (int i = 1; i <= 9; ++i){
        printf("%lld\n", ans[i]);
    }
    return 0;
}

Measured memory_bytes: 47872
#include <stdio.h>

int main(){
  int X,Y,Z;
  scanf("%d %d %d",&X,&Y,&Z);
  int T;
  T=X;
  X=Y;
  Y=T;
  T=X;
  X=Z;
  Z=T;
  printf("%d %d %d\n",X,Y,Z);
  return 0;
}

Measured memory_bytes: 1696
#include<iostream>
#include<vector>
#include<map>

using namespace std;

int main(void){

    int n;
    vector<int> num;
    vector<bool> numFlag;
    bool flag = true;

    cin >> n;

    for(int i = 0;i < n;i++){
        int x;
        cin >> x;
        num.push_back(x);
        numFlag.push_back(true);
    }

    int i = 0;
    while(i < n-1){
        if(num[i] <= num[i+1]){
            i++;
        }else if(flag == true && numFlag[i] == true && num[i] > num[i+1]){
            flag = true;
            num[i]--;
            numFlag[i] = false;
            i--;
        }else{
            flag = false;
            i++;
        }
    }

    cout << (flag==true ? "Yes" : "No") << endl;

    return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];

    ll sum = 0, cnt1 = 0, cnt2 = 0;

    for (int i = 0, s = 1; i < n; i++, s *= -1)
    {
        sum += a[i];
        if (sum * s <= 0)
            cnt1 += abs(sum) + 1, sum = s;
    }
    sum = 0;
    for (int i = 0, s = -1; i < n; i++, s *= -1)
    {
        sum += a[i];
        if (sum * s <= 0)
            cnt2 += abs(sum) + 1, sum = s;
    }

    OP(min(cnt1, cnt2));
}

/*int main()
{
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];

    ll cnt1 = 0, cnt2 = 0;
    ll sumv = 0;

    rep(i, n)
    {
        sumv += a[i];
        if (i % 2 == 0 && sumv <= 0)
        {
            cnt1 += abs(sumv) + 1;
            sumv = 1; //符号がプラスになるべきところ。
        }
        else if (i % 2 == 1 && sumv >= 0)
        {
            cnt1 += abs(sumv) + 1;
            sumv = -1; //符号がマイナスになるべきところ。
        }
    }

    sumv = 0;

    rep(i, n)
    {
        sumv += a[i];
        if (i % 2 == 0 && sumv >= 0)
        {
            cnt2 += abs(sumv) + 1;
            sumv = -1; //符号マイナスになるべきところ。
        }
        else if (i % 2 == 1 && sumv <= 0)
        {
            cnt2 += abs(sumv) + 1;
            sumv = 1; //符号がプラスになるべきところ。
        }
    }

    OP(min(cnt1, cnt2));

    return 0;
}*/

Measured memory_bytes: 640
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<cmath>
#include<complex>
#include<iomanip>

using namespace std;

#define REP(i,s,e) for(int i=int(s);i<=int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)
#define pi 3.14159265358979

int a[17][17],r[17][17],u[17][17];

int main(void){

	int n,gx,gy,p,x1,y1,x2,y2;
	cin >> n;
	rep(i,n){
	cin >> gx >> gy >> p;

	REP(x,0,gx){
	REP(y,0,gy){
	a[x][y]=0; r[x][y]=0; u[x][y]=0;
	}
	}

	rep(j,p){
	cin >> x1 >> y1 >> x2 >> y2;
	if(x1==x2) u[x1][min(y1,y2)]=1;
	if(y1==y2) r[min(x1,x2)][y1]=1;
	}

    a[0][0]=1;
	REP(y,0,gy){
	REP(x,0,gx){
	if(u[x][y]==0) a[x][y+1]+=a[x][y];
	if(r[x][y]==0) a[x+1][y]+=a[x][y];

	}
	}

    if(a[gx][gy]==0) cout << "Miserable Hokusai!" << endl;
    else cout << a[gx][gy] << endl;

	}

	return 0;
}

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

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    int K, A, B;
    cin >> K >> A >> B;
    for (int i=A; i<=B; ++i) {
        if (i % K == 0) {
            cout << "OK\n";
            return 0;
        }
    }
    cout << "NG\n";
    return 0;
}

Measured memory_bytes: 3640
n = gets.chomp.to_i
#as = gets.chomp.split.map(&:to_i)

cnt = Array.new(n+1,0)
ans = 0
max = Math.sqrt(n)
for x in 1..max do
    for y in 1..x do
        for z in y..x do
            ans = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if ans <= n
                #puts "#{x} #{y} #{z}"
                if x == y && y == z 
                    cnt[ans] += 1
                elsif x != y && y != z && x != z
                    cnt[ans] += 6
                else
                    cnt[ans] += 3
                end
            end
        end
    end
end

for i in 1..n do
    #puts "N=#{i}のとき"
    puts cnt[i]
end

Measured memory_bytes: 14320
from functools import lru_cache


def check(s):
    bads = ["AGC", "ACG", "GAC"] + [b.format(_s) for b in ["AG{}C", "A{}GC"] for _s in "ACGT"]
    return not any(map(lambda x: x in s, bads))


def solve(string):
    n = int(string)

    @lru_cache(n * 4**3)
    def dfs(pos, last3):
        if pos == n:
            return 1
        ans = 0
        for _s in "ACGT":
            ans += dfs(pos + 1, last3[1:] + _s) if check(last3 + _s) else 0
        return ans % (10**9 + 7)

    return str(dfs(0, "TTT"))


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


Measured memory_bytes: 6288
#include <stdio.h>
 
int main(void)
{    int a,b;
    long int sum=0;
     int min=1000000;
    int max=-1000000;
    
    scanf("%d",&a);
    
   for(int i=1;i<=a;i++){
       scanf("%d",&b);
       sum=sum+b;
       if(b>max){
           max=b;
       }
       if(b<min){
           min=b;
       }
   }
    
    printf("%d %d %ld\n",min,max,sum);
    
    /*int a,n,i,min=1000000,max=-1000000;
    long int sum=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a);
        sum+=a;
        if(min>a)
            min=a;
        if(max<a)
            max=a;
    }
    printf("%d %d %ld\n",min,max,sum);*/
    
    return 0;
}


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

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

  bool ans = false;
  for(int i=1; i<=9; i++) {
    if(n%i==0 && n/i<10) ans=true;
  }

  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
	
}



signed main(){
	ll h,n,sum = 0;
	cin >> h >> n;
	
	ll a[n];
	rep(i,0,n){
		cin >> a[i];
		sum += a[i];
	}
	
	if(sum < h) cout << "No" << endl;
	else cout << "Yes" << endl;
	
	
    return 0;
}

Measured memory_bytes: 1024
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-30 19:19:26
**/

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

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

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

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

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

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

class UnionFind {
 public:
  UnionFind(int n) : n_(n) { Initialize(); }

  int GetRoot(int x) {
    if (parent_[x] == -1)
      return x;
    else
      return parent_[x] = GetRoot(parent_[x]);
  }

  bool IsSame(int x, int y) { return GetRoot(x) == GetRoot(y); }

  void Unite(int x, int y) {
    x = GetRoot(x);
    y = GetRoot(y);
    if (x == y) return;
    if (rank_[x] < rank_[y]) std::swap(x, y);
    if (rank_[x] == rank_[y]) ++rank_[x];
    parent_[y] = x;
    return;
  }

 private:
  const int n_;
  std::vector<int> parent_;
  std::vector<int> rank_;

  void Initialize() {
    parent_.assign(n_, -1);
    rank_.assign(n_, 0);
  }
};


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

  int n, m; cin >> n >> m;
  vector<int> p(n); cin >> p;

  for_each(all(p), [](int& x){ --x; });

  UnionFind uf(n);

  for (int i = 0; i < m; ++i) {
    int x, y; cin >> x >> y; --x; --y;
    uf.Unite(x, y);
  }

  int ans = 0;

  for (int i = 0; i < n; ++i) ans += uf.IsSame(p[i], i);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1408
#!/usr/bin/python
import sys,heapq
try:
	import rpython.rlib.streamio
	stream=rpython.rlib.streamio.fdopen_as_stream(sys.stdin.fileno(),'r')
	raw_input=stream.readline
	def cmp_lt(x,y): return x < y
	heapq.cmp_lt=cmp_lt
	COMPILE=123456789012
	def compile(a,b,c):
		return ((a+COMPILE)<<18) | (b<<9) | c
	def decompile(a):
		return ((a>>18)-COMPILE,(a>>9)&511,a&511)
except ImportError:
	def compile(a,b,c):
		return (a,b,c)
	def decompile(a):
		return a
	if sys.version_info[0]>=3: raw_input=input

INF=1234567890123456789
def shortestPath(g,dist,prev):
	n = len(g)-1
	h = [INF]*n+[0]
	for k in range(n+1):
		for i in range(n+1):
			for e in g[i]:
				if h[e[1]]<INF and e[0]<INF and h[e[2]] > h[e[1]] + e[0]:
					h[e[2]] = h[e[1]] + e[0]
					if k==n: return False # negative cycle
	for i in range(n):
		for e in g[i]:
			e[0]+=h[i]-h[e[2]]
	for s in range(n):
		Q=[]
		heapq.heappush(Q,compile(0,s,s))
		while Q:
			e = decompile(heapq.heappop(Q))
			if prev[s][e[2]]!=-2: continue
			prev[s][e[2]] = e[1]
			for f in g[e[2]]:
				if e[0]<INF and f[0]<INF and dist[s][f[2]] > e[0] + f[0]:
					dist[s][f[2]] = e[0] + f[0]
					heapq.heappush(Q,compile(e[0]+f[0],f[1],f[2]))
		for u in range(n):
			if dist[s][u]<INF: dist[s][u] += h[u] - h[s]
	return True

def entry_point(argv):
	V,E=[int(e) for e in raw_input().rstrip().split(' ')]
	g=[[] for i in range(V+1)]
	dist=[[INF]*V for i in range(V)]
	prev=[[-2]*V for i in range(V)]
	for i in range(V): g[i].append([0,i,i])
	for i in range(V): g[V].append([0,V,i])
	for i in range(E):
		s,t,e=[int(e) for e in raw_input().rstrip().split(' ')]
		g[s].append([e,s,t])
	if not shortestPath(g,dist,prev):
		print("NEGATIVE CYCLE")
	else:
		for i in range(V):
			print(' '.join(["INF" if dist[i][j]>=INF else str(dist[i][j]) for j in range(V)]))
	return 0

def target(*args):
	return entry_point, None

if __name__ == '__main__': entry_point([])

Measured memory_bytes: 6364