akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

class Dice {
    int dice[6];

public:
    Dice() {
        dice[0] = 1, dice[1] = 2, dice[2] = 3;
        dice[3] = 4, dice[4] = 5, dice[5] = 6;
    }
    int North();
    int East();
    int West();
    int South();
    int Right();
    int Left();
};

int main()
{
    int n;

    while (cin >> n, n) {
        Dice dice;

        int sum = 1;
        string op;
        for (int i = 0; i < n; ++i) {
            cin >> op;

            if (op == "North")
                sum += dice.North();
            else if (op == "East")
                sum += dice.East();
            else if (op == "West")
                sum += dice.West();
            else if (op == "South")
                sum += dice.South();
            else if (op == "Right")
                sum += dice.Right();
            else if (op == "Left")
                sum += dice.Left();
        }

        cout << sum << endl;
    }

    return 0;
}

int Dice::North()
{
    swap(dice[0], dice[4]);
    swap(dice[0], dice[1]);
    swap(dice[1], dice[5]);

    return dice[0];
}

int Dice::East()
{
    swap(dice[0], dice[2]);
    swap(dice[0], dice[5]);
    swap(dice[0], dice[3]);

    return dice[0];
}

int Dice::West()
{
    swap(dice[0], dice[3]);
    swap(dice[0], dice[2]);
    swap(dice[2], dice[5]);

    return dice[0];
}

int Dice::South()
{
    swap(dice[0], dice[1]);
    swap(dice[0], dice[5]);
    swap(dice[0], dice[4]);

    return dice[0];
}

int Dice::Right()
{
    swap(dice[1], dice[3]);
    swap(dice[1], dice[2]);
    swap(dice[2], dice[4]);

    return dice[0];
}

int Dice::Left()
{
    swap(dice[1], dice[2]);
    swap(dice[1], dice[4]);
    swap(dice[1], dice[3]);

    return dice[0];
}

Measured memory_bytes: 1216
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int n;

int cou[300];

int main()
{
    cin >> n;
    string s;
    rep(i,1,n)
    {
        cin >>s;
        cou[s[0]] = 1;
    }

    int res = 0;
    for(int c : cou)
    {
        res += c;
    }

    if(res == 3)
    {
        cout << "Three" << endl;
    }
    else{
        cout << "Four" << endl;
    }
}

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

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

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

int main(){
    ll A, B;
    cin >> A >> B;
    cout << lcm(A, B) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;
#define INF 1e9

static const int seed=6;
static const int D=365;
static const int ntype=26;
static const int t=1e5;
static int ans[t+1][D+1];
static int max_score=-INF;

class Contest{
public:
    Contest(){
        last=0;
    }
    int s[D+1];
    int c;
    int last;
};

static Contest contest[ntype+1];

void Input(){
    int d;
    cin>>d;
    for(int i=1;i<=ntype;++i){
        int t;
        cin>>t;
        contest[i].c=t;
    }
    for(int day=1;day<=D;++day){
        for(int type=1;type<=ntype;++type){
            int t;
            cin>>t;
            contest[type].s[day]=t;
        }
    }
}

int evaluate(int i){
    int sum=0;
    vector<int> l(ntype+1,0);
    for(int day=1;day<=D;++day){
        int type=ans[i][day];
        sum+=contest[type].s[day];
        l[type]=day;
        for(int t=1;t<=ntype;++t){
            sum-=contest[t].c*(day-l[t]);
        }
    }
    return sum;   
}

void Output(int i){
    for(int d=1;d<=D;++d) cout<<ans[i][d]<<endl;
}

void Init(int k){
    for(int i=0;i<k;++i){
        for(int d=1;d<=D;++d) ans[i][d]=rand()%ntype+1;
    }
}

int solve(){
    Init(t);
    int max_p=-1;
    for(int i=0;i<t;++i){
        int temp=evaluate(i);
        if(max_score<temp){
            max_score=temp;
            max_p=i;
        }
    }
    return max_p;
}

int main(){
    srand(seed);
    Input();
    Output(solve());
}


Measured memory_bytes: 146624
#include <bits/stdc++.h>
using namespace std;
long long int X;
long long int A,B;
int flg=0;

int main(){
    cin>>X;
    for(int i=-120;i<=120;i++){
        A=i;
        long long int A5=pow(A,5);
        for(int j=-120;j<=120;j++){
            B=j;
            long long int B5=pow(B,5);
            if(A5-B5==X){flg=1;break;}
        }
        if(flg==1)break;
    }
    cout<<A<<" "<<B;
    return 0;
}

Measured memory_bytes: 4028
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <queue>
#include <cmath>
#include <iomanip>
#include <cstdlib>
// #include <fstream>

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

std::string s, t;
const int MAX_LEN = 3010;
int dp[MAX_LEN][MAX_LEN] = { 0 };

int main()
{
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0);
    
    std::cin >> s >> t;
    
    const int N = s.length();
    const int M = t.length();
    
    for(int i=0; i<N; i++)
    {
        for(int j=0; j<M; j++)
        {
            if(s[i]==t[j])
            {
                dp[i+1][j+1] = dp[i][j] + 1;
            }
            else
            {
                dp[i+1][j+1] = std::max(dp[i][j+1], dp[i+1][j]);
            }
        }
    }

    std::string ans = "";
    int x = N;
    int y = M;
    while(x > 0 && y > 0)
    {
        if(dp[x][y]==dp[x-1][y]) x--;
        else if(dp[x][y]==dp[x][y-1]) y--;
        else
        {
            x--;
            y--;
            ans.push_back(s[x]);
        }
        
    }
    std::reverse(ans.begin(), ans.end());
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 35584
#include <iostream>

using namespace std;

int main()
{
    int H,N,res=0;
    cin >> H >> N;
    int A[N];
    for (int i=0; i<N; i++){
        cin >> A[i];
        res+=A[i];
    }
    if (res>=H){
        cout << "Yes";
    }
    else cout << "No";


    return 0;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    int ac=0;
    int wa=0;
    int tle=0;
    int re=0;
    string S;
    for(int i=0;i < N; i++){
        cin >>S;
        if(S =="AC"){
            ac++;
        } else if(S =="WA"){
            wa++;
        } else if(S =="TLE"){
            tle++;
        } else if(S =="RE"){
            re++;
        }
    }    
    
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;    
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
    
    return 0;
}


Measured memory_bytes: 3232
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

            Console.WriteLine(input[0] * input[1] % 2 != 0 ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 13268
from collections import deque

def bfs(sx, sy):
    dist = [[-1]*W for _ in range(H)]
    dist[sx][sy] = 0
    q = deque([(sx, sy)])
    res = 0
    
    while q:
        cx, cy = q.popleft()
        
        for nx, ny in [(cx-1, cy), (cx+1, cy), (cx, cy-1), (cx, cy+1)]:
            if not (0<=nx<H and 0<=ny<W):
                continue
            
            if S[nx][ny]=='.' and dist[nx][ny]==-1:
                dist[nx][ny] = dist[cx][cy]+1
                q.append((nx, ny))
                res = max(res, dist[nx][ny])
    
    return res

H, W = map(int, input().split())
S = [input() for _ in range(H)]
ans = 0

for i in range(H):
    for j in range(W):
        if S[i][j]=='.':
            ans = max(ans, bfs(i, j))

print(ans)

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

using namespace std;

#define deb(x) cout << #x << " " << x << endl;

typedef long long ll;
const ll mod = 1000000007;

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


int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t,i,n,j;
    cin>>t>>n;
    if(t%n==0)
        cout<<t/n;
    else
    {
            cout<<t/n+1;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
int n;
int main(){
	cin>>n;
	repn(i,n){

		string s; int a; cin>>s>>a;
		vec.pb(mp(s,mp(-a,i)));
	}
	SORT(vec);
	rep(i,n)cout<<vec[i].sc.sc<<endl;
}

Measured memory_bytes: 256
n, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(n)]


def recur(i, a, b, c):
    if i == n:
        if a < 1 or b < 1 or c < 1:
            return 10 ** 18
        return abs(a - A) + abs(b - B) + abs(c - C)
    return min([
        recur(i + 1, a, b, c),
        recur(i + 1, a + l[i], b, c) + (10 if a > 0 else 0),
        recur(i + 1, a, b + l[i], c) + (10 if b > 0 else 0),
        recur(i + 1, a, b, c + l[i]) + (10 if c > 0 else 0)
    ])

print(recur(0, 0, 0, 0))

Measured memory_bytes: 3064
n,m = map(int,input().split())
l = []
max = 0
min = n

for i in range(m):
    l += [input().split()]
    if int(l[i][0]) > max:  
        max = int(l[i][0])
    if int(l[i][1]) < min:
        min = int(l[i][1])

if min - max >= 0:
    print(min - max + 1)
else:
    print(0)

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


int main(){
	int a,b;
	bool ok=false;
	string s;
	cin >> a >> b >> s;
	
	int i;
	for(i=0;i<a;i++){
		if(s[i]>='0'&&s[i]<='9') continue;
		ok=true;
	}
	
	if(s[i]!='-'){
		ok=true;
	}
	i++;
	a+=1+b;
	for(;i<a;i++){
		if(s[i]>='0'&&s[i]<='9') continue;
		ok=true;
	}
	
	
	cout << (ok?"No":"Yes") << endl;
	return 0;
}

Measured memory_bytes: 256
class combinationmod():
  def __init__(self,MAX, mod):
    self.mod =mod
    self.fac=[0]*(MAX+1)
    self.finv=[0]*(MAX+1)
    self.inv=[0]*(MAX+1)
    self.fac[0]=self.fac[1]=1
    self.finv[0]=self.finv[1]=1
    self.inv[1]=1
    for i in range(2,MAX+1):
      self.fac[i] = self.fac[i-1]*i%mod
      self.inv[i] = (-self.inv[mod%i]*(mod//i))%mod
      self.finv[i] = self.finv[i-1]* self.inv[i] %mod

  def nCk(self,n,k):
    if n<k or n<0 or k<0:
      #print(n,k,0)
      return 0
    ans = self.fac[n]*(self.finv[k]*self.finv[n-k]%self.mod)%self.mod
    #print(n,k,ans)
    return ans
#assert(combinationmod(100,int(1e9+7)).nCk(10,2)==45)

MOD = 10**9+7
C = combinationmod(4000,MOD)

N, K = list(map(int, input().split()))

if N==K:
  print(1)
  for _ in range(N-1):
    print(0)
  exit()

for i in range(1,K+1):
  print(C.nCk(K-1,i-1)*(C.nCk(N-K-1,i-2) + 2*C.nCk(N-K-1,i-1) + C.nCk(N-K-1,i))%MOD)
  


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

typedef pair<int,int> P;
vector<int> dijkstra(int s,vector<vector<P> > & G){
  int n=G.size();
  int INF=1LL<<55LL;
  vector<int> d(n,INF);
  priority_queue<P,vector<P>,greater<P> > q;
  d[s]=0;
  q.push(P(d[s],s));
  while(!q.empty()){
    P p=q.top();q.pop();
    int v=p.second;
    if(d[v]<p.first) continue;
    for(P e:G[v]){
      int u=e.first,c=e.second;
      if(d[u]>d[v]+c){
	d[u]=d[v]+c;
	q.push(P(d[u],u));
      }
    }
  }
  return d;
}


signed main(){
  int n,k;
  while(cin>>n>>k,n){
    vector<vector<P> > G(n);
    int INF=1LL<<55LL;
    for(int i=0;i<k;i++){
      int t;
      cin>>t;
      if(t==0){
	int a,b;
	cin>>a>>b;
	a--;b--;
	int k=dijkstra(a,G)[b];
	if(k>=INF) k=-1;
	cout<<k<<endl;
      }
      if(t==1){
	int c,d,e;
	cin>>c>>d>>e;
	c--;d--;
	G[c].push_back(P(d,e));
	G[d].push_back(P(c,e));
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    
    double a,b;
    int c=0,d=0,e=0,f=0;
    int g=0,h=0,i=0,j=0;
    
    while(cin >>a>>b){
        if(a>=1.1) c+=1;
        else if(a>=0.6 && a<1.1) d+=1;
        else if(a>=0.2 && a<0.6) e+=1;
        else f+=1;
        
        if(b>=1.1) g+=1;
        else if(b>=0.6 && b<1.1) h+=1;
        else if(b>=0.2 && b<0.6) i+=1;
        else j+=1;
    }
    
    cout <<c<<" "<<g<<endl;
    cout <<d<<" "<<h<<endl;
    cout <<e<<" "<<i<<endl;
    cout <<f<<" "<<j<<endl;
}



Measured memory_bytes: 3228
import math
def prime(n):
    for i in range(2, int(math.sqrt(n))):
        if n % i == 0: return False
    return True

X = int(input())

for i in range(X, 10**8):
    if prime(i):
        print(i)
        exit(0)

print('No prime number in this range')

Measured memory_bytes: 3060
import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        LinkedList<Integer> list = new LinkedList<Integer>();
        for(int i=0;i<n;i++){
            if(i%2==0) list.addLast(Integer.parseInt(sc.next()));
            else list.addFirst(Integer.parseInt(sc.next()));
        }
        boolean flg = false;
        if(n%2==0) while(!list.isEmpty()){
            if(flg)System.out.print(" ");
            System.out.print(list.poll());
            flg = true;
        }
        else while(!list.isEmpty()){
            if(flg)System.out.print(" ");
            System.out.print(list.pollLast());
            flg = true;
        }
    }
}


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

int main() {
int X,A,B;
  cin>>X>>A>>B;
  int s;
  int r;
  if(X>=A){
    r =X-A;
  }
  else{
    r =A-X;
  }
  if(B>=X){
    s =B-X;
  }
  else {
    s = X-B;
  }
  
  if(r<s){
    cout <<"A";
  }
  else {
    cout <<"B";
  }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define mp make_pair
signed main(){
    int n;cin>>n;
    int ans=INF;
    int a,b,c,d; cin>>a>>b>>c>>d;
    for(int w=1;w<=n;w++){
        map<int,pii>Mp;
        pii now=pii(0,0);
        for(int i=1;i<=n;i++){
            Mp[i]=now;
            now.first++;
            if(now.first==w){
                now.first=0;
                now.second++;
            }
        }
        int temp=abs(Mp[a].first-Mp[b].first)+abs(Mp[a].second-Mp[b].second);
        temp+=abs(Mp[c].first-Mp[d].first)+abs(Mp[c].second-Mp[d].second);
        cmin(ans, temp);
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  ll s; cin >> s;
  if(s == 1000000000000000000ll) {
    cout << "0 0 0 1000000000 1000000000 0" << endl;
  } else {
    ll a = s / 1000000000;
    ll b = s % 1000000000;
    cout << "1 0 0 1000000000 " << 1 + a << " " << b << endl;
  }
}


Measured memory_bytes: 256
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**6)
INF = float('inf')
MOD = 10 ** 9 + 7
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rf(): return float(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]
def rf_(): return [float(_) for _ in rs().split()]
def divisors(n, sortedresult=True):
    div = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            div.append(i)
            if i != n // i:
                div.append(n//i)
    if sortedresult:
        div.sort()
    return div
# endregion
N, M = ri_()
d = [[] for i in range(N + 1)]
ans = [0] * (N + 1)
for i in range(M):
    A, B = ri_()
    d[A].append(B)
    d[B].append(A)
L = deque([1])
while L:
    n = L.popleft()
    for i in d[n]:
        if not ans[i]:
            ans[i] = n
            L.append(i)
if 0 in ans[2:]:
    print('No')
    exit()
print('Yes')
for i in range(2, N + 1):
    print(ans[i])

Measured memory_bytes: 98428
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
#define irep(i,a,b) for(int i=int(a);i>=int(b);i--)
using ll = long long;
using namespace std;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
//sort(a, a + N, greater<ll>())   // descend
//sort(a, a+N)                    //  ascend

/**
void comb(vector<vector <ll> > &v) {
	rep (i,0,v.size()) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	rep (k,1,v.size()) {
		rep (j,1,k) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
/*main内でnCn~nC0 生成 **
vector<vector<ll> > v(n + 1, vector<ll>(n + 1, 0));
comb(v);
*/

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

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

using namespace std;

int main()
{
    int T;
    
    scanf("%d", &T);
    
    while (T--){
        int x, y, w, h;
        
        scanf("%d %d %d %d", &x, &y, &w, &h);
        
        int n;
        
        scanf("%d", &n);
        
        int ans = 0;
        
        for (int i = 0; i < n; i++){
            int a, b;
            scanf("%d %d", &a, &b);
            
            ans += (x <= a && a <= x + w && y <= b && b <= y + h);
        }
        
        printf("%d\n", ans);
    }
    
    return (0);
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n , k ; 
  cin >> n >> k ;
  vector<intll> d(n) ; 
  rep(i,n) cin >> d.at(i) ;

  for(int i=k; i<n ; i++){
    if(d.at(i-k) < d.at(i) ){
      cout << "Yes" << endl ; 
    }
    else {
      cout << "No" << endl ;
    }
    
  }
 
}


Measured memory_bytes: 4788
#include <bits/stdc++.h>
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>

#define fr(i,b,e) for(int i=(b); i<(e); ++i)
#define rp(i,e) for(int i=0; i<(e); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long int li;
typedef long long ll;
const int INF=1000000;


int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    vector<ll> cnt(n);
    rp(i,n){
        cin >> a[i];
        ++cnt[a[i]-1];
    }

    ll sum=0;
    
    rp(i,n){
        sum+=cnt[i]*(cnt[i]-1);
    }

    sum=sum>>1;

    rp(i,n){
        cout << sum-cnt[a[i]-1]+1 << '\n';
    }
}

Measured memory_bytes: 4992
#include "bits/stdc++.h"
using namespace std;
typedef pair<int, int> P;

const int INF = 1e9;
char maze[1010][1010];
int dist[1010][1010];
int H, W;

int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};

int main() {
    cin >> H >> W;
    queue<P> que;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            dist[i][j] = INF;
            cin >> maze[i][j];
            if (maze[i][j] == '#') {
                que.push(P(i, j));
                dist[i][j] = 0;
            }
        }
    }
    
    while (que.size()) {
        P p = que.front();
        que.pop();
        for (int i = 0; i < 4; i++) {
            int nh = p.first + dh[i]; 
            int nw = p.second + dw[i];
            if (0 <= nh && nh < H && 0 <= nw && nw < W && maze[nh][nw] == '.' && dist[nh][nw] == INF) {
                que.push(P(nh, nw));
                dist[nh][nw] = dist[p.first][p.second] + 1;
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) ans = max(ans, dist[i][j]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 13456
x, y = map(int, input().split())

foot = 0
for i in range(x):
  foot += 4
  
ok = False
if foot == y:
  ok = True
for i in range(x):
  foot -= 2
  if foot == y:
    ok = True

if ok == True:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9180
<?php


fscanf(STDIN, "%d%d", $N, $M);
$key = [[0,0]];
for($i=0;$i<$M; $i++){
    fscanf(STDIN, "%d%d", $tmpV, $tmpN);
    $Ns = explode(" ",trim(fgets(STDIN)));
    $tmpNs=0;
    foreach($Ns as $value){
        $tmpNs += 2**($value-1);
    }
    $key[]=[$tmpV,$tmpNs];
}

$N = 2**$N-1;
$table = array_fill(0,$M+1, [0] +  array_fill(1,$N,1000000000));
for($i=1;$i<=$M;$i++){
    for($j=1;$j<=$N;$j++) {
        $rest = $j & (~$key[$i][1]);
        $table[$i][$j] = min($table[$i - 1][$j], $key[$i][0] + $table[$i][$rest]);

    }
}

if($table[$M][$N] == 1000000000){
    echo -1;
}else{
    echo $table[$M][$N];
}

Measured memory_bytes: 141816
#include <bits/stdc++.h>
using namespace std;
int main()
{   ios_base::sync_with_stdio(0);
    cin.tie(0);
    const double pi = 3.14159265358979323846;
    long long R;
    cin >> R;
    cout << 2*pi*R <<endl;
    return 0;
}

Measured memory_bytes: 3800
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int l = Integer.parseInt(sc.next());
        String[] s = new String[n];
        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
        }

        // 主処理
        Arrays.sort(s);
        String result = String.join("", s);

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define all(v)   v.begin(), v.end()
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define THINK_TWICE_CODE_ONCE cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define isOdd(n)    (n&1)
#define LLMAX LLONG_MAX
#define LLMIN LLONG_MIN
#define IMN INT_MIN
#define IMX INT_MAX
#define pow(n, m) power((ll)n, (ll)m)
#define numOfDigits(n)  ((n)? (ll)(log10(n)+1) : 1)
#define mem(x, val)    memset(x, val, sizeof(x))
#define MOD 1000000007

typedef long long ll;
typedef long double ld;
typedef double dd;
typedef string str;
typedef pair<int, int> pii;



int main()
{
    THINK_TWICE_CODE_ONCE
    //freopen("test cases\\.txt", "r", stdin) ;
    int n; cin>>n;
    cout<<n*(n+1)/2;
	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto x:v)cerr<<x<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define EPS 1e-9
typedef long long ll;

vector<long long> primelist(long long n){
  vector<bool> prime(n+1,1);
  for(long long i = 2;i <= n;i++){
    if(prime[i]){
      for(long long j = 2*i;j <= n;j += i){
        prime[j] = 0;
      }
    }
  }
  prime[0] = 0;
  prime[1] = 0;
  vector<long long> primelist;
  for(long long i = 0;i <= n;i++)if(prime[i])primelist.pb(i);
  return primelist;
}

signed main(){
  int n;
  while(cin >> n){
    cout << primelist(n).size() << endl;
  }
}


Measured memory_bytes: 4636
n = int(raw_input())
dp = [+float('inf')] * (n+1)
dp[0] = 0
for i in range(1, n+1):
	q = 1
	if i - q >= 0:
		dp[i] = min(dp[i], 1 + dp[i - q])
	for u in [6,9]:
		p = 1
		q = u ** p
		while((i  - q) >= 0):
			dp[i] = min(dp[i], 1 + dp[i - q])
			p += 1
			q = u ** p
print dp[n]


Measured memory_bytes: 98740
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


ll n, W, V = 0;
ll w[110], v[110];

int main() {
    cin >> n >> W;
    rep(i, n) {
        cin >> w[i] >> v[i];
        V += v[i];
    }
    // dp[i+1][j] = { i+1までのアイテムで価値jにしたときの最小の重み }
    vector<ll> dp(V+1, 1000100000);
    dp[0] = 0;
    rep(i, n) {
        for (int j = V; j >= v[i]; --j) {
            dp[j] = min(dp[j], dp[j-v[i]] + w[i]);
        }
    }
    ll ans = -1;
    rep(i, V+1) if (dp[i] <= W) {
        ans = i;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define vv vector< vector< int > >
#define ll long long
#define ALL(a) (a).begin(), (a).end()
const long long mod = 1000000000 + 7;
const long long INF = 9e18;
const double PI = 3.14159265358979323846;

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

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


int main(){
    int N, M;
    cin >> N;
    int P[110], X[110];
    vector<int> T(N, 0);
    for(int i = 0; i < N; i++){
        cin >> T[i];
    }
    cin >> M;
    for(int i = 0; i < M; i++){
        cin >> P[i] >> X[i];
    }
    for(int i = 0; i < M; i++){
        int idx = P[i] - 1;
        int tmp = T[idx];
        T[idx] = X[i];
        int sum = accumulate(ALL(T), 0);
        cout << sum << endl;
        T[idx] = tmp;
    }
    return 0;
}




Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
#define rep for(int i = 0;i<n;i++)
#define ll long long
 
//const int INF = 1e8;
typedef pair<int,int>P;
int dx[4] = {1,0,-1,0};int dy[4] = {0,1,0,-1};
queue<P> que;
bool compare(pair<pair<int,int>,int> a,pair<pair<int,int>,int> b){
    return a.second < b.second;
}
int main(){
    int n;cin >> n;
    int a[n];rep{cin >> a[i];}
    int ans = 1e9;
    for(int j = -100;j<=100;j++){
        int s = 0;
        rep{
            s += (j-a[i])*(j-a[i]);
        }
        ans = min(ans,s);
    }
    cout << ans << endl;
}

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

using namespace std ;

#define sz(v) (int)v.size()
#define ll long long
#define all(v)  v.begin() , v.end()
#define rall(v)  v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define PI acos( -1.0 )
#define forn( t , v , be , n ) for( t v = be ; v < n ; v++ )
#define fore( x , j ) for( auto x : j )
#define se second
#define fr first
//#define c_b fflush(stdin);

const ll Long_max = numeric_limits < ll > :: max() ;
const int Int_max = numeric_limits < int > :: max() ;

void File_input( string pathIn ) {
    freopen( pathIn.c_str(), "r", stdin ) ;
}

void File_output( string pathOut ) {
    freopen( pathOut.c_str(), "w", stdout ) ;
}

int msg() {
    srand( time( 0 ) ) ;
    vector < string > st = {
        "Wish everyone high ratings!",
        "Good luck!",
        "Have fun!",
        "Please, read all the problems!",
        "Go Go fight!"
    } ;
    cerr << st[ rand() % sz( st ) ] ;
    return 0 ;
}

void FastInputOutput() {
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}


ll n , t , v ;
ll sum  ;

int main() {
   cin >> n >> t ;
   ll c = t ;
   n--;
   sum += t ;
   ll ls = 0 ;
   cin >> ls ;
   while( n-- ){
     cin >> v ;
     sum += min( t , v - ls ) ;
     ls = v ;
   }
   cout << sum ;
   cerr << "\n\n" << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
   return 0 ;
}


Measured memory_bytes: 384
// C - March

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

ll cnt[5];

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

	for (int i=0; i<N; i++) {
		string S;
		cin >> S;
		switch(S[0]) {
			case 'M':
				cnt[0]++;
				break;
			case 'A':
				cnt[1]++;
				break;
			case 'R':
				cnt[2]++;
				break;
			case 'C':
				cnt[3]++;
				break;
			case 'H':
				cnt[4]++;
				break;
		}
	}

	ll ans = 0;

	for (int i=0; i<5; i++) {
		for (int j=i+1; j<5; j++) {
			for (int k=j+1; k<5; k++) {
				ans += cnt[i] * cnt[j] * cnt[k];
			}
		}
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> P;
#define INF 10000000000000
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i < (ll)(n); i++)
#define repN_1(i, n) for(ll i = 0; i < (ll)(n - 1); i++)
#define repM(i, n) for(ll i = (ll)(n - 1); i >= 0; i--)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

int main()
{
	cout << fixed << setprecision(18);

	ll n, m;
	ll ans = 0;
	cin >> n >> m;

	vector<ll> h(n+1);
	rep(i, n)
		cin >> h[i+1];

	vector<ll> a(m), b(m);
	rep(i, m)
		cin >> a[i] >> b[i];

	vector<vector<ll>> c(n+1);

	rep(i, m)
	{
		if (c[a[i]].empty())
			c[a[i]].push_back(h[a[i]]);
		if (c[b[i]].empty())
			c[b[i]].push_back(h[b[i]]);

		c[a[i]].push_back(h[b[i]]);
		c[b[i]].push_back(h[a[i]]);
	}

	rep(i, n + 1)
		sort(c[i].begin(), c[i].end());

	rep1(i, n + 1)
	{
		if (c[i].empty())
			ans++;
		else if (c[i].back() == h[i] && c[i][c[i].size() - 2] != h[i])
			ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 12232
N, M, Q = list(map(int, input().split()))

C = [[0] * (N+1) for i in range(N+1)]
for i in range(M):
  L, R = list(map(int, input().split()))
  C[L][R] += 1

A = [[0] * (N+1) for i in range(N)]
for i in range(1,N+1):
  A[0][i] = C[i][i]
for i in range(1,N):
  A[1][i] = A[0][i] + A[0][i+1] + C[i][i+1]
for i in range(2,N):
  for j in range(1,N+1-i):
    A[i][j] = A[i-1][j] + A[i-1][j+1] - A[i-2][j+1] + C[j][i+j]
    
for i in range(Q):
  p, q = list(map(int, input().split()))
  print(A[q-p][p])

Measured memory_bytes: 11524
use std::f64;
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T, T, T) {
    let v: Vec<T> = read_vec();
    assert_eq!(v.len(), 4);
    (v[0], v[1], v[2], v[3])
}

fn main() {
    let (a, b, H, M) = read_touple::<f64>();
    let mut rad: f64 = (30. * H + 0.5 * M - 6. * M).abs();
    rad = rad.to_radians();
    let ans = (a * a + b * b - 2. * a * b * rad.cos()).sqrt();
    println!("{}", ans);
}


Measured memory_bytes: 3028
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
int MOD = 1000000007;

int main() {
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	if (x - r >= 0 && y - r >= 0 && x + r <= W && y + r <= H)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define y1 y3278
#define sz(v) int(v.size())
#define y2 y4368
#define y y4368232
#define x x43682322
#define ff first
#define ss second
#define pb push_back
#define all(a) a.begin(),a.end()
#define tm tm3278
#define left left3278
#define right right3278
typedef long long ll;
typedef long double ld;
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
template <class T> using Pair_indexed_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
const long long INF = 2000000000000000000;
const long long Maxll = 9223372036854775807;
const long long MOD = 1000000000000037;
const int MOD2 = 1100000009;
const int inf = 1000000000;
const long long q0 = 31;
const int differ = 'a' - 'A';

/// Actual code starts here
ll t, n, m, k, x , y, sz;
string str, str2;
void VOLK() {
    cin >> str >> str2;
    int ans = 0;
    for (int i = 0; i < sz(str);i++)
        ans += str[i] != str2[i];
    cout << ans;
}
int main() {
    ios::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    t = 1;
    //cin >> t;
    while (t--)
        VOLK();
}


Measured memory_bytes: 3748
n, a, b = gets.chomp.split(" ").map(&:to_i)


result = 0

(1..n).each do |i|
  sum = 0
  j = i
  loop do
    break if i == 0
    sum += i % 10
    i /= 10
  end
  if sum >= a && sum <= b
    result += j
  end
end

puts result


Measured memory_bytes: 1788
loop do
	n = STDIN.gets.to_i
	break if n.zero?

	a_score = 0
	b_score = 0
	n.times do
		a, b = STDIN.gets.split.map(&:to_i)
		case a <=> b
		when 1
			a_score += a + b
		when 0
			a_score += a
			b_score += a
		else
			b_score += a + b
		end
	end

	puts "#{a_score} #{b_score}"
end

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

int parent(int i) {
  return i / 2;
};

int left (int i) {
  return 2 * i;
};

int right (int i) {
  return 2 * i + 1;
};

int main() {
  int H;
  cin >> H;
  vector<int> heap(H + 1);
  for (int i = 1; i <= H; i++) {
    cin >> heap[i];
  };
  for (int i = 1; i <= H; i++) {
    cout << "node " << i << ": key = " << heap[i] << ", ";
    if (parent(i) >= 1) cout << "parent key = " << heap[parent(i)] << ", ";
    if (left(i) <= H) cout << "left key = " << heap[left(i)] << ", ";
    if (right(i) <= H) cout << "right key = " << heap[right(i)] << ", ";
    cout << endl;
  }
};



Measured memory_bytes: 3084
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */

void c004()
{
    size_t n, m;
    cin >> n >> m;
    vector<string> grid(n);
    cin >> grid;

    cout << string(m, '#') << '\n';

    for(size_t i = 1; i + 1 < n; ++i)
        if(i & 1)
            cout << '#' << grid[i].substr(1) << '\n';
        else
            cout << string(m - 1, '#') << '.' << '\n';
    cout << string(m, '.') << '\n' << '\n';

    cout << string(m, '.') << '\n';
    for(size_t i = 1; i + 1 < n; ++ i)
        if(i & 1)
            cout << '.' << string(m - 1, '#') << '\n';
        else
            cout << grid[i].substr(0, m - 1) << '#' << '\n';

    cout << string(m, '#') << '\n';
}


int main(const int argc, char * argv [])
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    c004();

    return EXIT_SUCCESS;
}


Measured memory_bytes: 1024
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int N = scan.nextInt();
			int K = scan.nextInt();
			double [] s = new double[N+1]; 
			int[]p = new int[N];
			for(int i = 0;i<N;i++) p[i] = scan.nextInt();
			
			for(int i = 0;i<N;i++) {
				s[i+1] = s[i]+(p[i]+1)/2.0; 
			}
			
			double max = 0;
			
			for(int i = 0;i<=N-K;i++) {
				double a = s[i+K]-s[i];
				
				if(max<a)max = a;
			}
			
			
			BigDecimal d = new BigDecimal(max);
			String str = String.format("%1$.7f", d);
			
			System.out.println(max);
			
			
 			
		}
		
		
	}
		

}

Measured memory_bytes: 83192
nums = []
nums = [int(x) for x in input().split()]

if (nums[0] == nums[1]) or (nums[1] == nums[2]) or (nums[2] == nums[0]):
    if nums[0] == nums[1] == nums[2]:
        print("No")
    else:
        print("Yes")
else:
    print("No")



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

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

    for(int i = 0; i <n ;i++) cin >> a[i];
    for(int i = 0, j = k; k < n; i++,k++){
        if(a[i] < a[k]) cout << "Yes\n";
        else cout << "No\n";
    }

    return 0;
}


Measured memory_bytes: 4412
#include<iostream>
#include<climits>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int arr[n],dp[n+1];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    dp[0]=0;
    dp[1]=abs(arr[0]-arr[1]);
    for(int i=2;i<n;i++)
    {
        dp[i]=INT_MAX;
        for(int j=i-1;j>=0 && (i-j)<=k;j--)
        {
            dp[i]=min(dp[i],abs(arr[j]-arr[i])+dp[j]);
        }
    }
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 4300
//52行目から編集
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvl;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

template<class T> bool chmin(T& a,T b){if(a > b){a = b;return true;}else return false;}
template<class T> bool chmax(T& a,T b){if(a < b){a = b;return true;}else return false;}
///////////////////////////////////////////////////////////
int ans[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(20);
    int k;cin >> k;
    cout << ans[k-1] << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int pattern[8][8];
	int outpattern[8][8];
	char line[9];
	int i,j;
	for(i = 0; i < 8; i++){
		scanf("%s",line);
		for(j = 0; j < 8; j++){
			pattern[i][j] = line[j];
		}
	}
	puts("90");
	for(i = 0; i < 8; i++){
		for(j = 0; j < 8; j++){
			putchar(pattern[7-j][i]);
		}
		putchar('\n');
	}
	puts("180");
	for(i = 0; i < 8; i++){
		for(j = 0; j < 8; j++){
			putchar(pattern[7-i][7-j]);
		}
		putchar('\n');
	}
	puts("270");
	for(i = 0; i < 8; i++){
		for(j = 0; j < 8; j++){
			putchar(pattern[j][7-i]);
		}
		putchar('\n');
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<queue>
using namespace std;

const int MAX = 200000;

struct Node {
	int n;
	bool isExist;
	vector<int> edge;
	pair<int, int> node; // 繋がっている'A'と'B'の個数
};

int main() {
	int N, M, a, b;
	string s;
	cin >> N >> M >> s;
	static Node node[MAX];
	for (int i = 0;i < N;++ i) {
		node[i].node = make_pair(0, 0);
		node[i].n = i;
		node[i].isExist = true;
	}
	for (int i = 0;i < M;++ i) {
		cin >> a >> b;
		-- a; -- b;
		node[a].edge.push_back(b);
		node[b].edge.push_back(a);
		s[a] == 'A' ? ++ node[b].node.first : ++ node[b].node.second;
		s[b] == 'A' ? ++ node[a].node.first : ++ node[a].node.second;
	}
	queue<int> que; // 削除する頂点
	for (int i = 0;i < N;++ i) {
		if (node[i].node.first == 0 || node[i].node.second == 0) que.push(i);
	}
	int tmp;
	int del = 0; // 削除した頂点の数
	while (!que.empty()) {
		tmp = que.front();
		que.pop();
		if (!node[tmp].isExist) continue;
		node[tmp].isExist = false;
		++ del;
		for (int i = 0, l = node[tmp].edge.size();i < l;++ i) {
			if (!node[node[tmp].edge[i]].isExist) continue;
			s[node[tmp].n] == 'A' ? -- node[node[tmp].edge[i]].node.first : -- node[node[tmp].edge[i]].node.second;
			if (node[node[tmp].edge[i]].node.first == 0 || node[node[tmp].edge[i]].node.second == 0) que.push(node[tmp].edge[i]);
		}
	}
	if (del == N) cout << "No";
	else cout << "Yes";
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

解説AC
'A'と'B'の両方に同時に繋がっていない辺を消していくことを繰り返すと解ける

*/

Measured memory_bytes: 13956
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;
const long long MOD = (ll)1e9+7;
const long long MAX = (ll)1e5+100;


int main(void) {
   ll R,G,B,N;
   cin>>R>>G>>B>>N;
   ll ans = 0;
   rep(i,0,N/R+1) rep(j,0,N/G+1) {
      if ((N - i*R - j*G)<0) continue;
      if ((N - i*R - j*G)%B!=0) continue;
      ans++;
      // cout<<i<<" "<<j<<" "<<(N - i*R - j*G)/B<<endl;
   }
   cout<<ans<<endl;


   return 0;
}

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

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

int N;
string S[200010];
map<string, int> m;

signed main()
{
    cin >> N;

    int ma = 0;

    rep(i, N) {
        cin >> S[i];
        m[S[i]]++;
        chmax(ma, m[S[i]]);
    }

    vector<string> ans;

    rep(i, N) {
        if (m[S[i]] == ma) {
            ans.push_back(S[i]);
        }
    }

    sort(all(ans));
    ans.erase(unique(all(ans)), ans.end());

    rep(i, ans.size()) cout << ans[i] << endl;
}


Measured memory_bytes: 29172
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <math.h>
#include <unordered_map>
#include <algorithm>

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
inline int gcd(int a,int b){return b?gcd(b,a%b):a;}
inline int lcm(int a,int b){return a*b/gcd(a,b);}
typedef long long ll;
typedef std::vector<int> VI;
typedef std::pair<int, int> PII;

using namespace std;

int main()
{
  int N;
  cin >> N;
  cout << 3*N*N << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  double hight[50]={};
  int i=0;
  double max,min;
  while(scanf("%lf",&hight[i])!=EOF){
      if(i==0){
          max=hight[0];
          min=hight[0];
      }else{
        if(max<hight[i]) max=hight[i];
        if(min>hight[i]) min=hight[i];
      }
      i++;
  }
  printf("%.1f\n",max-min);
  return 0;
}



Measured memory_bytes: 1924
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	int n,m,high,low;
	cin>>n;
	for(int i=0;i<n;i++){
		vector <int> data;
		high=0;low=0;
		cin>>m;
		int k=10000000;
		for(int j=0;j<8;j++){
			int num=m/k%10;
			data.push_back(num);
			k/=10;
		}
		sort(data.begin(),data.end());
		k=1;
		for(int j=0;j<8;j++){
			high+=k*data[j];
			low+=k*data[7-j];
			k*=10;
		}
		cout<<high-low<<endl;
	}
}

Measured memory_bytes: 1216
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int N;
	cin >> N;
	set<string> s;
	for (auto i = 0; i < N; ++i)
	{
		string S;
		cin >> S;
		s.insert(S);
	}

	cout << (int)s.size() << endl;

	return 0;
}

Measured memory_bytes: 19256
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> fib(N + 1, 1);
    for (int i = 2; i <= N; ++i) {
        fib[i] = fib[i - 1] + fib[i - 2];
    }
    cout << fib[N] << endl;
    return 0;
}



Measured memory_bytes: 3108
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())))

A_diff = np.diff(A)

wollet = 1000
stock = 0
for i, rate in enumerate(A_diff):
    if rate > 0:
        stock_num = wollet // A[i]
        wollet -= stock_num*A[i]
        stock += stock_num
    elif rate < 0:
        wollet += stock*A[i]
        stock = 0
        
wollet += A[N-1]*stock

print(wollet)

Measured memory_bytes: 27228