akhauriyash/Code-Regression huggingface dataset:
class queue():
    def __init__(self,size,q):
        self.time={}
        self.finishlist=[]
        self.S=[None]*size
        self.q=q
        self.under=0#最後の要素
    def print(self):
        print(self.under)

    def enqueue(self,x):#FI
        self.under+=1
        self.S[self.under]=x
    def unqueue(self):#FO
        self.under-=1
        vari=self.S[1]
        del self.S[1]
        self.S.append(None)
        return vari
    def isEmpty(self):
        return self.under!=0
    def calc(self):
        alltime=0
        while(self.isEmpty()):
            process=self.unqueue()
            da=int(process[1])
            if int(process[1])>self.q:
                # if process[0] not in self.time:
                #     self.time[process[0]]=self.q
                # else:
                #     self.time[process[0]] += self.q
                alltime+=self.q
                da-=self.q
                (process[1])=str(da)
                self.enqueue(process)
            else:#処理終了
                alltime+=int(process[1])
                self.time[process[0]] = alltime


                self.finishlist.append(process[0])
        return self.time,self.finishlist

size,q=[int(x) for x in input().split()]
que=queue(size+1,q)
# [que.enqueue(x) for x in input().split()]
[que.enqueue(input().split()) for x in range(size)]
time,finishhantei=que.calc()
for name in finishhantei:
    print(name,time[name])


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>bool chmin(T&a,const T&b){return a>b?(a=b,1):0;}
template<class T>bool chmax(T&a,const T&b){return a<b?(a=b,1):0;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  deque<int> b;
  int N = nextInt();
  REP(i, N) {
    int x = nextInt();
    if (i % 2 == 0) 
      b.push_back(x);
    else
      b.push_front(x);
  }
  if (N % 2 == 1) reverse(ALL(b));
  REP(i, N) {
    if (i > 0) printf(" ");
    printf("%d", b[i]);
  }
  printf("\n");
  
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}



Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=1e9;
const long long LINF=1e18;
#define int long long
//template
template <typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
/*
*/
//main
signed main(){
  int N,Q;string s;cin>>N>>s>>Q;
  std::vector<int> v(Q);
  for(int i=0;i<Q;i++)cin>>v[i];
  int M;//待機してるMの数
  int nexD;//次のMに対してかかるDの数
  int pDM;//待機してるDMのペアの数
  int ans;
  for(int i=0;i<Q;i++){
    ans=M=nexD=pDM=0;
    for(int j=0;j<N;j++){
      if(s[j]=='D')nexD++;
      if(s[j]=='M'){
        M++;
        pDM+=nexD;
      }
      if(s[j]=='C')ans+=pDM;
      int A=j-v[i]+1;
      if(A<0)continue;
      if(s[A]=='D'){
        nexD--;
        pDM-=M;
      }
      if(s[A]=='M')M--;
    }
    cout<<ans<<endl;
  }
}


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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

vector<int> dp(1 << 26, INF);

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

    string s;
    cin >> s;
    int n = s.length();
    ll mask = 0;
    dp[0] = 0;
    for (int i = 0; i < n; i++)
    {
        int b = s[i] - 'a';
        mask ^= (1LL << b);
        for (int j = 0; j < 26; j++)
        {
            dp[mask] = min(dp[mask], dp[mask ^ (1LL << j)] + 1);
        }
    }
    cout << max(1, dp[mask]) << endl;
}


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

int main() {
	
	vector<int> v{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 k;
	cin >> k;
	cout << v.at(k-1) << endl;
	
}


Measured memory_bytes: 256
'use strict'
function otoshidama(stdin) {
  const inputs = stdin.split(' ')
  const n = inputs[0]
  const y = inputs[1]
  for (let i = 0;i <= n;i++) {
    const remain = y - 10000 * i
    if (remain === 0 && n === i) {
      return console.log(n, 0, 0)
    } else if (remain <= 0 && i < n) {
      break
    }
    for (let j = 0;j <= n - i;j++) {
      const sen = n - i - j
      const result = remain - 5000 * j - 1000 * sen
      if (result === 0) {
        return console.log(i, j, sen)
      } else if (result < 1000) {
        break
      }
    }
  }
  return console.log(-1, -1, -1)
}
otoshidama(require('fs').readFileSync(0, 'utf8'))

Measured memory_bytes: 7500
from collections import *

H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
xd = defaultdict(int)
yd = defaultdict(int)

for i in range(H):
    for j in range(W):
        xd[A[i][j]] = i
        yd[A[i][j]] = j

acc = [[0] for _ in range(D)]

for i in range(D+1, H*W+1):
    cost = abs(xd[i]-xd[i-D])+abs(yd[i]-yd[i-D])
    acc[i%D].append(acc[i%D][-1]+cost)
    
Q = int(input())

for _ in range(Q):
    L, R = map(int, input().split())
    
    if L%D==0:
        print(acc[0][R//D-1]-acc[0][L//D-1])
    else:
        print(acc[L%D][R//D]-acc[L%D][L//D])

Measured memory_bytes: 78684
// In the name of God

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define Size(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
typedef pair<int , int>pii;
const int INF = 1e9 + 10 , MN = 2e5 + 10;

int n , a[MN] , b[MN];

int main(){
	ios_base :: sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
	cin >> n;
	ll sm = 0;
	for(int i=0;i<n;++i) cin >> a[i] >> b[i] , sm += a[i];
	bool fl = false;
	for(int i=0;i<n;++i)
		if(a[i] ^ b[i]) fl = true;

	if(!fl) return cout << "0\n" , 0;

	int mn = INF;
	for(int i=0;i<n;++i) if(a[i] > b[i]) mn = min(mn , b[i]);
	cout << sm - mn << '\n';
	return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	vector<int> perm(n), p(n), q(n);
	for (int i = 0; i < n; ++i) {
		cin >> p[i];
		perm[i] = i + 1;
	}

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

	int a, b;
	int order = 1;
	do {
		if (perm == p) {
			a = order;
		} 
		if (perm == q) {
			b = order;
		}

		++order;
	} while (next_permutation(perm.begin(), perm.end()));	

	cout << abs(a - b) << "\n";

	return 0;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
    int N,K,cnt=0;
    cin >> N >> K;
    for (int i=1; i<=N; i+=2,cnt++)
        ;
    if (cnt >= K)
        cout << "YES" << endl;
    else
        cout << "NO"  << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
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; }
typedef pair<int,int> P;

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

vector<pair<ll,int>> prime_factor(ll n) {
  vector<pair<ll,int>>res;
  for(ll i = 2; i * i <= n; i++) {
    if(n % i == 0) {
      int t = 1;
      n /= i;
      while(n%i==0){
        t++;
        n/=i;
      }
      res.push_back(pair<ll,int>(i,t));
    }
  }
  if(n != 1) res.push_back(pair<ll,int>(n,1));
  return res;
}

int main(){
  ll a,b;
  cin >> a >> b;
  ll t = gcd(a,b);
  auto fac = prime_factor(t);
  ll ans = 0;
  for(auto p:fac){
    ans++;
  }
  cout << ans+1 << endl;
  // int n;
  // cin >> n;
  // auto ans = prime_factor(n);
  // for(auto p:ans){
  //   cout << p.first << " " << p.second << endl;
  // }
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;

#define rep(i, a, b) for(auto i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back

struct edge{int to;};
using graph = vector<vector<edge>>;

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

  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int t1 = h1 * 60 + m1;
  int t2 = h2 * 60 + m2;
  int diff = t2 - t1;
  cout << (diff - k) << '\n';
}


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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a+b==c+d){
        cout << "Balanced" << endl;
    }
    else{
        if(a+b>c+d){
            cout << "Left" << endl;
        }
        else{
            cout << "Right" << endl;
        }
    }
}

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

int main (void)
{
    string S; cin >> S;
    int cnt = 0;
    long int len = S.length();

    for(int i = 0; i < (len / 2); i++)
    {
        if(S[i] != S[len - i - 1] )
        {
            cnt++;
        }
    }
    cout << cnt;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define EPS 1e-8
#define DEB 1


int main(){
	int n,q;
	int data[128];
	while(scanf("%d%d",&n,&q),n|q){
		memset(data,0,sizeof(data));
		rep(i,n){
			int m;
			scanf("%d",&m);
			rep(j,m){
				int d; scanf("%d",&d);
				data[d]++;
			}
		}
		int ans = 0;
		int member = 0;
		rep(i,128){
			if( data[i]>=q ){
				if( data[i]>member ){
					member = data[i];
					ans = i;
				}
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	long N, A;
	cin >>N >>A;
	vector<long> x(N, 0);
	for (long i=0; i<N; i++)
		cin >>x.at(i);
	vector<long> P(2500, 0);
	vector<long> M(2500, 0);
	long Z=0;
	long PPP=0;
	long MMM=0;
	for (long i=0; i<N; i++) {
		long D=x.at(i)-A;
		if (0==D)
			Z++;
		else if (D>0) {
			P.at(D)++;
			PPP +=D;
		} else {
			M.at(-D)++;
			MMM -=D;
		}
	}
	long DD=min(PPP, MMM);
	vector<long> PP(DD+1, 0);
	vector<long> MM(DD+1, 0);
	PP.at(0)=1;
	MM.at(0)=1;

	for (long i=0; i<N; i++) {
		long D=x.at(i)-A;
		if (0==D)
			continue;
		else if (D>0)
			for(long j=DD-D; j>=0; j--)
				PP.at(j+D) +=PP.at(j);
		else {
			D=-D;
			for(long j=DD-D; j>=0; j--)
				MM.at(j+D) +=MM.at(j);
		}
	}
	long S=0;
	for (long i=1; i<=DD; i++)
		S +=PP.at(i)*MM.at(i);
	long ZZ=pow(2, Z);
	S *=ZZ;
	S +=ZZ-1;
	cout <<S <<endl;
	return 0;
}



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

int main(){
  string w;
  cin>>w;
  vector<int> a(26,0);

  for(int i=0; i<w.size(); i++)a.at(w[i]-97)++;

  bool ans=true;
  for(int i=0; i<26; i++){
    if(a.at(i)%2!=0){
      ans=false;
      break;
    }
  }

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

Measured memory_bytes: 256
using System;

namespace AtCoderDiverta2019B
{
    class Program
    {
        static void Main(string[] args)
        {
            int ans = 0;

            string[] s = Console.ReadLine().Split(' ');

            int N = int.Parse(s[3]);

            int[] X = new int[3];

            for (int i = 0; i < 3; i++)
            {
                X[i] = int.Parse(s[i]);
            }

            for(int i=0;i*X[0]<=N;i++)
            {
                int rest = N - i * X[0];

                for(int j=0;j*X[1]<=rest;j++)
                {
                    int rest2 = rest - j * X[1];
                    if (rest2 % X[2] == 0)
                        ans++;
                }

            }

            Console.WriteLine(ans.ToString());
        }
    }

}


Measured memory_bytes: 11092
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int a = sc.nextInt();
        int p = sc.nextInt();
        System.out.println((a * 3 + p ) / 2);
    }

    private static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte())
                return buffer[ptr++];
            else
                return -1;
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr]))
                ptr++;
            return hasNextByte();
        }

        public String next() {
            if (!hasNext())
                throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong() {
            if (!hasNext())
                throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
                throw new NumberFormatException();
            return (int) nl;
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}



Measured memory_bytes: 22484
import numpy as np


def mul(A, B):
    v = 0
    for a, b in zip(A, B):
        v += a * b
    return v


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

    B = [int(v) for v in input().split()]

    cnt = 0
    for _ in range(N):
        A = [int(v) for v in input().split()]
        if mul(A, B) + C > 0:
            cnt += 1

    print(cnt)


if __name__ == "__main__":
    main()


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

int N, C;
int x[100100], v[100100];
int rsum1[100100], rsum2[100100], lsum1[100100], lsum2[100100];
int r1[100100], r2[100100], l1[100100], l2[100100];

signed main()
{
    cin >> N >> C;
    for(int i = 0; i < N; i++){
        cin >> x[i] >> v[i];
    }
    for(int i = 0; i < N; i++){
        rsum1[i + 1] += v[i] - x[i] + rsum1[i];
        rsum2[i + 1] += v[i] - 2 * x[i] + rsum2[i];
        if(i > 0){
            rsum1[i + 1] += x[i - 1];
            rsum2[i + 1] += 2 * x[i - 1];
        }
    }
    lsum1[N - 1] = v[N - 1] - (C - x[N - 1]);
    lsum2[N - 1] = v[N - 1] - 2 * (C - x[N - 1]);
    for(int i = N - 2; i >= 0; i--){
        lsum1[i] += lsum1[i + 1] + v[i] - (C - x[i]) + (C - x[i + 1]);
        lsum2[i] += lsum2[i + 1] + v[i] - 2 * (C - x[i]) + 2 * (C - x[i + 1]);
    }
    for(int i = 1; i <= N; i++){
        r1[i] = max(r1[i - 1], rsum1[i]);
        r2[i] = max(r2[i - 1], rsum2[i]);
    }
    for(int i = N - 1; i >= 0; i--){
        l1[i] = max(l1[i + 1], lsum1[i]);
        l2[i] = max(l2[i + 1], lsum2[i]);

    }
    int ans = 0ll;
    for(int i = 0; i < N; i++){
        ans = max(ans, r1[i]);
        ans = max(ans, l1[i]);
        ans = max(ans, r2[i] + l1[i]);
        ans = max(ans, l2[i] + r1[i]);
    }
    ans = max(ans, r1[N]);
    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 8064
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextLong()
  val m = sc.nextLong()
  val s = sc.next()
  val t = sc.next()

  if (s[0] != t[0]) {
    println(-1)
    return
  }

  val nn = n / gcd(n, m).toInt()
  val mm = m / gcd(n, m).toInt()
  var ok = true
  for (i in 0 until gcd(n, m).toInt()) {
    val ni = (i * nn).toInt()
    val mi = (i * mm).toInt()
    val si = s[ni]
    val ti = t[mi]
    if (si != ti) {
      ok = false
      break
    }
  }

  if (ok) {
    val lcm = lcm(n, m)
    println(lcm)
    return
  }
  println(-1)

}

// 最大公約数
private fun gcd(a: Long, b: Long): Long {
  if (b > 0) {
    return gcd(b, a % b)
  }
  return a
}

// 最小公倍数
private fun lcm(a: Long, b: Long): Long {
    return a / gcd(a, b) * b
}

Measured memory_bytes: 40780
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = ll(1e9) + 7LL;

template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < v.size(); ++i) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    if (v.size() == 0) return os;
    for (int i = 0; i < v.size() - 1; ++i) {
        os << v[i] << " ";
    }
    os << v[v.size() - 1];
    return os;
}

struct edge {int to, cap, rev;};

int dfs(int v, int t, int f, vector<bool>& used, vector<vector<edge>>& G) {
    if (v == t) return f;
    used[v] = true;
    REP(i, G[v].size()) {
        edge& e = G[v][i];
        if (!used[e.to] && e.cap > 0) {
            int d = dfs(e.to, t, min(f, e.cap), used, G);
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

void solve() {
    int x;
    cin >> x;
    if (360 % x == 0) {
        cout << 360 / x << endl;
        return;
    }
    ll ans = x;
    while (ans % 360 != 0) {
        ans += x;
    }
    cout << ans / x << endl;
}

int main() {
    char tmp;
    while (cin >> tmp) {
        cin.putback(tmp);
        solve();
    }
}


Measured memory_bytes: 3592
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N,K = MI()
A = [-10**10] + LI()
A.sort()

mod = 10**9+7

B = [0]*(K-1) + [1]  # B[i] = i_C_(K-1)
for i in range(K,N):
    B.append((B[-1]*i*pow(i-(K-1),mod-2,mod)) % mod)

ans = 0
for i in range(1,N+1):
    ans += (B[i-1]-B[N-i])*A[i]
    ans %= mod
print(ans)


Measured memory_bytes: 91388
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  string s; cin >> s;
  bitset<200'000> bs;
  for (int i = 0; i < n; ++i) bs[i] = s[i] == 'B';
  int i = 0;
  bool rev = false;
  for (int _ = 0; _ < k; ++_) {
    if (rev ^ !bs[i]) bs.flip(i);
    else {
      if (++i == n) i = 0;
      rev = !rev;
    }
  }
  for (int i = 0; i < n; ++i) s[i] = 'A' + bs[i];
  rotate(begin(s), next(begin(s), i), end(s));
  if (rev) {
    for (int i = 0; i < n; ++i) s[i] = 'A' + 'B' - s[i];
  }
  cout << s << '\n';
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N;
  cin >> N;
  if (N <= 2) {
    cout << 1 << endl;
    return 0;
  }

  vector<ll> A(N);
  REP(i, N) { cin >> A.at(i); }

  ll ans = 1;
  ll prev_a = A.at(0);
  ll a;
  bool dec = false;
  bool inc = false;
  REPI(i, 1, N) {
    a = A.at(i);

    if (!dec && !inc) {
      if (prev_a != a) {
        if (prev_a < a) {
          inc = true;
        } else {
          dec = true;
        }
      }
      prev_a = a;
      continue;
    }

    if (dec) {
      if (prev_a < a) {
        dec = false;
        ++ans;
      }
      prev_a = a;
      continue;
    }

    if (inc) {
      if (prev_a > a) {
        inc = false;
        ++ans;
      }
      prev_a = a;
      continue;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;
 
 
/*bool compare_function(const pair<int, int> a, const pair<int, int> b)
{
    return a.first < b.first;
}*/
// use case
//sort(V.begin(), V.end(), compare_function);
 
/*struct compare
{
    bool operator ()(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.second-a.first==b.second-b.first)
    {
        return a.first>b.first;
    }
    return a.second-a.first < b.second-b.first;}
};
priority_queue <pair<int,int>, vector <pair<int,int>>, compare> Q;*/
 
/*void print1(vector <int> X)
{
    for (int i=0; i<X.size(); i++)
    {
        cout<<X[i]<<" ";
    }
    cout<<endl;
    return;
}
 
void print2(vector <vector <int>> X)
{
    for (int i=0; i<X.size(); i++)
    {
    for (int j=0;j<X[i].size();j++) {
        cout<<X[i][j]<<" ";}
    cout<<endl;}
    return;
}*/

 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector <ll> X(n);
    vector <ll> Y(n);
    int ind1=0;
    int ind2=0;
    int ind3=0;
    int ind4=0;
    ll m=0;
    for (int i=0;i<n;i++) {
		cin>>X[i]>>Y[i];
		if (X[ind1]+Y[ind1]>X[i]+Y[i]) {ind1=i;}
		if (X[ind2]+Y[ind2]<X[i]+Y[i]) {ind2=i;}
		if (X[ind3]-Y[ind3]>X[i]-Y[i]) {ind3=i;}
		if (X[ind4]-Y[ind4]<X[i]-Y[i]) {ind4=i;}
		}
    for (int i=0;i<n;i++) {
		m=max(m,abs(X[i]-X[ind1])+abs(Y[i]-Y[ind1]));
		m=max(m,abs(X[i]-X[ind2])+abs(Y[i]-Y[ind2]));
		m=max(m,abs(X[i]-X[ind3])+abs(Y[i]-Y[ind3]));
		m=max(m,abs(X[i]-X[ind4])+abs(Y[i]-Y[ind4]));
		}
    cout<<m<<endl;
    
    return 0;
}


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

using namespace std;

#define ll 			long long
#define db			double
#define up(i,j,n)		for (int i = j; i <= n; i++)
#define down(i,j,n)	for (int i = j; i >= n; i--)
#define cadd(a,b)		a = add (a, b)
#define cpop(a,b)		a = pop (a, b)
#define cmul(a,b)		a = mul (a, b)
#define pr			pair<int, int>
#define fi			first
#define se			second
#define SZ(x)		(int)x.size()
#define bin(i)		(1 << (i))
#define Auto(i,node)	for (int i = LINK[node]; i; i = e[i].next)

template<typename T> inline bool cmax(T & x, T y){return y > x ? x = y, true : false;}
template<typename T> inline bool cmin(T & x, T y){return y < x ? x = y, true : false;}

map<int, int> m;

int N, ans = 0;

int main(){
	scanf("%d", &N);
	up (i, 1, N) {
		int v;
		scanf("%d", &v);
		m[v]++;
	}
	for (map<int, int>::iterator it = m.begin(); it != m.end(); it++) {
		int v = (*it).fi, c = (*it).se;
		ans += c < v ? c : (c - v);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 4736
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
using namespace std;

int ns,nl;
int use[30];
int a[30],b[30],d[30];
vector<int> v,tmpv;
int ans,tmp;


void dfs(int x){
  bool f = false;

  for(int i=0;i<nl;i++){
    if(!use[i] && a[i] == x){
      use[i] = true;
      tmp += d[i];
      tmpv.push_back(b[i]);

      dfs(b[i]);

      use[i] = false;
      tmp -= d[i];
      tmpv.pop_back();
      f = true;
    }      
    if(!use[i] && b[i] == x){
      use[i] = true;
      tmp += d[i];
      tmpv.push_back(a[i]);

      dfs(a[i]);

      use[i] = false;
      tmp -= d[i];
      tmpv.pop_back();
      f = true;
    }
  }

  if(!f){
    if(ans<tmp){
      ans = tmp;
      v = tmpv;
    }
    if(ans==tmp && tmpv<v){
      v = tmpv;
    }
  }
}

int main(){
  while(cin >> ns >> nl, ns||nl){
    for(int i=0;i<nl;i++){
      cin >> a[i] >> b[i] >> d[i]; 
      use[i] = false;
    }

    ans = 0;v.clear();

    for(int i=1;i<=ns;i++){
      tmp = 0;
      tmpv.clear(); tmpv.push_back(i);
      dfs(i);
    }

    cout << ans << endl;
    for(int i=0;i<(int)v.size()-1;i++)cout << v[i] << " ";
    cout << v.back() << endl;
  }
}

Measured memory_bytes: 0
#include <stdio.h>
 
 
int main()
{
	int n, count, i, min = 100;
	int a[200];
	
	//nを入力(1~200)
	scanf("%d", &n);
 
	//データを入力(1~10^9)
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);
	//整数を2で割れる回数が一番少ないものを結果として出力
	//すべてを同時に割るので、それが基準になるということ。
	for (i = 0; i < n; i++)
	{
		for (count = 0; a[i] % 2 == 0; a[i] /= 2)
			count++;
		//printf("a[%d]=%d,count=%d\n", i, a[i], count);
		if (min > count)
			min = count;
	}
	printf("%d", min);
	
    return 0;
 
}

Measured memory_bytes: 128
import sys
import math

a, b = map(int, input().split())

kaibun_cnt = 0
length = len(str(a))
length_half = math.floor(len(str(a))/2)

for i in range(a, b+1):
    num_list = []
    num = i
    
    for j in range(len(str(i))):
        num_list.append(num%10)
        num = math.floor(num/10)
    
    cnt = 0
    for j in range(length_half):
        if num_list[j] == num_list[length-j-1]:
            cnt += 1
    
    if cnt == length_half:
        kaibun_cnt += 1

print("{}".format(kaibun_cnt))

Measured memory_bytes: 3064
def is_doubled_string(N, S):
    if N % 2 == 1:
        return False
    
    half = N // 2
    for i in range(half):
        if S[i] != S[i + half]:
            return False
    else:
        return True


N = int(input())
S = input()
res = is_doubled_string(N, S)
if res:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int k1,k2,k3,k4;

int main()
{
          string x;
          cin>>x;
          for(int i=0;i<x.size();i++)
          {
                    k1+=(x[i]=='W');
                    k2+=(x[i]=='N');
                    k3+=(x[i]=='E');
                    k4+=(x[i]=='S');
          }
          if(k1*k3==0 && k1+k3!=0)
          {
                    cout<<"No";
                    return 0;
          }
          if(k2*k4==0 && k2+k4!=0)
          {
                    cout<<"No";
                    return 0;
          }
          cout<<"Yes";
}


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

LL N,K,S,T;
LL A[50];
LL pc[1<<18]={};
LL D[1<<18];
LL C[51][51];
LL X[51]={};

int main(){
 cin>>N>>K>>S>>T;
 rep(i,N) cin>>A[i];
 if(S&~T){ cout<<0<<endl; return 0; }
 rep(i,N) if((~T&A[i])|(S&~A[i])){ swap(A[i],A[N-1]); i--; N--; }
 rep(i,1<<18) if(i) pc[i]=pc[i&(i-1)]+1;
 T^=S;
 rep(n,51){ C[n][0]=C[n][n]=1; rep(r,n-1) C[n][r+1]=C[n-1][r]+C[n-1][r+1]; }
 X[0]=1; rep(n,50){ X[n+1]=X[n]*2; if(n>=K) X[n+1]-=C[n][K]; }
 for(LL n=50; n>=0; n--) X[n+1]-=X[n];
 LL ans=0;
 rep(t,T+1){
  if(t&~T) continue;
  LL tmp=0;
  rep(i,N) D[A[i]&t]=0;
  rep(i,N){ D[A[i]&t]++; tmp+=X[D[A[i]&t]]; }
  if(pc[t]&1) ans-=tmp; else ans+=tmp;
 }
 cout<<ans<<endl;
 return 0;
}

Measured memory_bytes: 7800
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
const int MOD = 998244353;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N);
	int res = 0;
	int a;
	bool ok = true;
	for (int i = 0; i < N; i++) {
		cin >> a;
		A[a]++;
		if (i == 0 && a != 0) {
			ok = false;
		}
	}
	if (!ok || A[0] >= 2) {
		cout << 0 << endl;
		return 0;
	}
	res = 1;
	for (int i = 1; i < N; i++) {
		int ad = 1;
		for (int j = 0; j < A[i]; j++) {
			ad = (ad * A[i - 1]) % MOD;
		}

		res = (res * ad) % MOD;
	}


	cout << res << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<(n);i++)
typedef long long ll;

ll gcd(ll a, ll b){
    if(a<b) swap(a,b);
    if(a%b == 0) return b;
    else return gcd(b,a%b);
}

struct UnionFind{
    vector<int> r;

    UnionFind(int N){
        r = vector<int> (N,-1);
    }

    int root(int x){
        if(r[x]<0) return x;
        return r[x] = root(r[x]);
    }

    bool unite(int x,int y){
        x = root(x);
        y = root(y);
        if(x==y) return false;
        if(r[x]>r[y]) swap(x,y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }

    int size(int x) {
        return -r[root(x)];
    }
};

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

    UnionFind UF(n);
    for(int i=0; i<m;i++){
        int a,b;
        cin >> a >> b;
        a--; b--;
        UF.unite(a,b);
    }

    int ans = 0;
    rep(i,n) ans = max(ans,UF.size(i));

    cout << ans << endl;
}

Measured memory_bytes: 4060
#include <stdio.h>

int color[5];

int main()
{
	int n,i,sum=0;
	char a;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%c ",&a);
		if(a=='Y')color[0]++;
		if(a=='W')color[1]++;
		if(a=='G')color[2]++;
		if(a=='P')color[3]++;
	}
	for(i=0;i<4;i++)if(color[i])sum++;
	if(sum<4)printf("Three");
	else printf("Four");
	return 0;	
}

Measured memory_bytes: 128
program prob4
    implicit none
    integer :: n, i, m, tmp
    integer, allocatable :: a(:), aa(:)
    read(*,*) n
    allocate(a(n))
    allocate(aa(n))
    read(*,*) a
    read(*,*) aa

    tmp = a(1)
    do i = 1, n
        tmp = tmp + aa(i)
    end do
    m = tmp

    do i = 2, n
        tmp = tmp + a(i)
        tmp = tmp - aa(i-1)
        m = max(m, tmp)
    end do

    write(*,*) m
    deallocate(a)
    deallocate(aa)

    stop
contains
end program prob4

Measured memory_bytes: 384
#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: 2096
#include <stdio.h>

int main(void)
{
    int a, b;
    scanf("%d%d", &a, &b);
    if (a == b) {
        printf("Draw\n");
    } else if (a == 1) {
        printf("Alice\n");
    } else if (b == 1) {
        printf("Bob\n");
    } else if (a > b) {
        printf("Alice\n");
    } else if (a < b) {
        printf("Bob\n");
    }
    return 0;
}


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

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

// -------------------------------------------

const long long MOD = 1000000007;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};

mint choose(ll n, ll k) {
  mint x = 1, y = 1;
  for(ll i=0; i<k; i++) {
    x *= n-i;
    y *= i+1;
  }
  return x / y;
}

istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
void solve(long long n, long long a, long long b){
  mint x = 2;
  std::cout << x.pow(n)-(choose(n,a)+choose(n,b)+1) << std::endl;
}

int main(){
    long long n;
  scanf("%lld",&n);
  long long a;
  scanf("%lld",&a);
  long long b;
  scanf("%lld",&b);
    solve(n, a, b);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int D = sc.nextInt();
    int X = sc.nextInt();
    int totalSum = 0;
    for (int i = 1; i <= N; i++) {
      int A = sc.nextInt();
      int sum = 1;
      for (int j = 1; j*A + 1 <= D; j++) {
        sum++;
      }
      totalSum += sum;
    }
    
    System.out.println(totalSum + X);
  }
}

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

typedef long long ll;

const int lim = 3500;

int n;

struct frac {
	ll u, v;
	
	frac() {}
	frac(ll u, ll v): u(u), v(v) {}
	
	frac operator - (const frac &rhs) const {
		static ll uu, vv, gcd;
		
		uu = u * rhs.v - v * rhs.u;
		vv = v * rhs.v;
		gcd = std::__gcd(uu, vv);
		return frac(uu / gcd, vv / gcd);
	}
	
	bool operator < (const frac &rhs) const {
		return u * rhs.v < v * rhs.u;
	}
	
	bool operator <= (const frac &rhs) const {
		return !(rhs < *this);
	}
} N, A, B, C;

int main() {
	std::cin >> n;
	
	N = frac(4, n);
	
	for (int a = 1; a <= lim; ++a) {
		A = frac(1, a);
		if (N <= A) continue;
		frac tmp = N - A;
		for (int b = a; b <= lim; ++b) {
			B = frac(1, b);
			if (tmp <= B) continue;
			tmp = tmp - B;
			if (tmp.u == 1) {
				std::cout << a << " " << b << " " << tmp.v << std::endl;
				return 0;
			}
		}
	}
	
	assert(0);
	
	return 0;
}

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

using namespace std;

typedef pair<int,int> P;
typedef pair<int,P> PP;

const int B=1500;

struct Segtree{
	struct Node{
		int lch,rch;
		int val;
		long long all;
		Node(){
			lch=-1,rch=-1,val=0,all=0;
		}
	};
	Node nodes[B*80];
	int c;
	void init(){
		c=1;
		for(int i=0;i<B*80;i++) nodes[i]=Node();
	}
	void add(int l,int r,int k,int a,int b){
		if(l<=a&&b<=r){
			nodes[k].val++;
			nodes[k].all+=(b-a);
			return;
		}else if(r<=a||b<=l) return;
		if(nodes[k].lch==-1){
			nodes[k].lch=c++;
			nodes[k].rch=c++;
			assert(c<=B*80);
		}
		add(l,r,nodes[k].lch,a,(a+b)/2);
		add(l,r,nodes[k].rch,(a+b)/2,b);
		int le=max(l,a);
		int ri=min(r,b);
		nodes[k].all+=(ri-le);
	}
	void add(int l,int r){
		add(l,r,0,0,1073741824);
	}
	long long sum(int l,int r,int k,int a,int b){
		if(l<=a&&b<=r){
			return nodes[k].all;
		}else if(r<=a||b<=l) return 0;
		long long res=0;
		if(nodes[k].lch!=-1){
			res+=sum(l,r,nodes[k].lch,a,(a+b)/2);
			res+=sum(l,r,nodes[k].rch,(a+b)/2,b);
		}
		int le=max(a,l),ri=min(b,r);
		res+=(long long)nodes[k].val*(ri-le);
		return res;
	}
	long long sum(int l,int r){
		return sum(l,r,0,0,1073741824);
	}
};

Segtree segs[100100/B+1];

PP pps[100100];

int N,M,Q;

int main(){
	scanf("%d%d%d",&N,&M,&Q);
	for(int i=0;i<M;i++){
		int a,b,v;
		scanf("%d%d%d",&a,&b,&v);
		pps[i]=PP(v,P(a,b));
	}
	sort(pps,pps+M);
	for(int i=0;i<M/B;i++) segs[i].init();
	for(int i=0;i<M;i++){
		int a=pps[i].second.first;
		int b=pps[i].second.second;
		segs[i/B].add(a,b+1);
	}
	for(int q=0;q<Q;q++){
		int a,b;
		long long x;
		scanf("%d%d%lld",&a,&b,&x);
		long long sum=0;
		int id=0;
		for(id=0;id<M/B;id++){
		//	long long cur=val[id][b]-val[id][a-1];
			long long cur=segs[id].sum(a,b+1);
			if(sum+cur>=x) break;
			sum+=cur;
		}
		for(int i=id*B;;i++){
			int ca=pps[i].second.first,cb=pps[i].second.second;
			int le=max(ca,a),ri=min(cb,b);
			int ad=max(0,ri-le+1);
			sum+=ad;
			if(sum>=x){
				printf("%d\n",pps[i].first);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 190640
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
import bisect
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def Yes(): print("Yes"); return
def No(): print("No"); return

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#############
# Main Code #
#############


#####約数列挙#####

N = inputI()

dic = {}
for i in range(2,N+1):
  for p,n in factorization(i):
    if p in dic:
      dic[p] += n
    else:
      dic[p] = n

key = [k for k in dic]


ans = 0
for p in key:
  if dic[p] >= 74:
    ans += 1
    
for p in key:
  if dic[p] >= 24:
    for q in key:
      if dic[q] >= 2 and p!=q:
        ans += 1

for p in key:
  if dic[p] >= 14:
    for q in key:
      if dic[q] >= 4 and p!=q:
        ans += 1
        
for p in key:
  for q in key:
    if p > q and dic[p] >= 4 and dic[q] >= 4:
      for r in key:
        if dic[r] >= 2 and p!=r and q!=r:
            ans += 1
    
print(ans)

Measured memory_bytes: 65260
#include<iostream>
#include<cmath>
#include<bitset>

using namespace std;

double eps = 1.0e-8;
bool eq(double a, double b){
  return abs(a-b) < eps;
}
int main()
{
  
  while(true){
    double p;
    bool b[4] = {false,};
    cin >> p;
    if( p < 0 ) break;
    int d = (int)floor(p+eps);
    
    p = p - d;
    double c = 0.5;
    bool na=false;
    int n = 0;

    bitset<32> bi(d);

    while( true ){
      if( eq(p,0) ) break;
      if( p >= c ){
	p -= c;
	b[n] = true;
	if( eq(p,0) ) break;
      }
      ++n;
      c *= 0.5;
      if( n == 5 ){
	na = true;
	break;
      }
    }
    
    if( d > 255 ) na = true;

    if( na ){
      cout <<"NA"<<endl;
    }else{
      for(int i = 0; i < 8; ++i){
	cout << (int)bi[7-i];
      }
      cout << '.';
      for(int i = 0; i < 4; ++i){
	if( b[i] ){
	  cout << '1';
	}else{
	  cout << '0';
	}
      }
      cout << endl;
    }
    
  }
  return 0;
}

Measured memory_bytes: 0
/// mAAria


#include<bits/stdc++.h>
#include<stdio.h>
#include<string>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define MAX 500000
#define K 30

int a[111111],pre[111111],suf[111111],ans;
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

   int n;
   cin >> n;

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

   for(int i = 1;i<=n;i++)pre[i]=__gcd(pre[i-1],a[i]);
   for(int i = n;i>=1;i--)suf[i] = __gcd(suf[i+1],a[i]);


   for(int i = 1;i<=n;i++)
      ans = max(ans,__gcd(pre[i-1],suf[i+1]));
    cout << ans << endl;

    return 0;
}

///....


Measured memory_bytes: 2560
import java.util.*;
import java.io.*;
class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int N = Integer.parseInt(st.nextToken());
        int A = Integer.parseInt(st.nextToken());
        st = new StringTokenizer(br.readLine());
        int[] cards = new int[N];
        for(int i=0;i<N;i++){
            cards[i]=Integer.parseInt(st.nextToken());
        }

        long[][][] dp = new long[52][52][2502];
        dp[0][0][0]=1;
        for(int i=1; i<=N; i++){
            for(int j=0; j<=i; j++){
                for(int k=0; k<=2501; k++){
                    dp[i][j][k] += dp[i-1][j][k];
                    if(j-1>=0 && k-cards[i-1]>=0)
                        dp[i][j][k] += dp[i-1][j-1][k-cards[i-1]];
                }
            }
        }
        long ans = 0;
        for(int j=1; j<=N; j++){
            ans+=dp[N][j][A*j];
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 89940
import sys

s = sys.stdin.readline().strip()
l = len(s)

half = l // 2

left = s[:half]

if half * 2 == l:
    right = s[half:]
else:
    right = s[half+1:]


def is_pal(string):
    return string == string[::-1]


if is_pal(s) and is_pal(left) and is_pal(right):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38576
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func min(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v < ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	a, b, k := nextInt(), nextInt(), nextInt()
	i := 0
	div := min(a, b)
	for ; i < k; div-- {
		if a%div == 0 && b%div == 0 {
			i++
			// fmt.Println(i, div)
		}
	}
	fmt.Println(div + 1)
}


Measured memory_bytes: 640
def find(P):
    count=0
    for i in range(1,len(P)-1):
        x,y,z=P[i-1],P[i],P[i+1]
        if P[i]==sorted([x,y,z])[1]:
            count+=1
    return count
input()
A=list(map(int,input().strip().split(' ')))
print(find(A))

Measured memory_bytes: 3060