akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();    
        int N = r.i();
        int copy = N;
        int fX = 0;
        while(copy > 0){
            fX += copy%10;
            copy /= 10;
        }
        println(N%fX == 0 ? "Yes" : "No");
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;

const ll mod=(1e+9)+7;
const ll inf=1e+16; 

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

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

 ll n;
  cin >> n;
  vvll G(n);
  vpll e(n-1);
  rep(i,0,n-1){
  ll a,b;
    cin >> a >> b;
    a--;
    b--;
   G[a].push_back(b); 
   G[b].push_back(a);
   e[i]=make_pair(a,b);
  }
  
  ll k=0;
  queue<ll> que;
  map<pll,ll> mp;
  vb flag(n,false);
  vll p(n,-1);
  
  flag[0]=true;
  que.push(0);
  
  while(!que.empty()){
    ll v=que.front();
    que.pop();
    if(k<G[v].size()) k=G[v].size();
    ll cnt=1;
   for(auto u:G[v]){
    if(flag[u]) continue;
    if(cnt==p[v]) cnt++;
    p[u]=mp[make_pair(u,v)]=mp[make_pair(v,u)]=cnt++;
    flag[u]=true;
    que.push(u);
   }
  }
  
  cout << k << endl;
  rep(i,0,n-1) cout << mp[e[i]] << endl;
  
  
}


Measured memory_bytes: 21376
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=998244353 ;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
//17:00~

int main(void){
	cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);
	int n,a=0,b=99999;cin>>n;
	while(n--){int x;cin>>x;maxeq(a,x);mineq(b,x);}
	cout<<(a+1-b)/2<<endl;
	return 0;
}



Measured memory_bytes: 3212
#include "bits/stdc++.h"
using namespace std;

#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()

typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int n,k;
string s;

int main(){
    cin >> n >> k >> s;
    s.push_back('2');
    int con = 0;
    //priority_queue<int> pq;
    vector<int> cc;
    REP(i,n){
        if(s[i+1]==s[i]){
            con++;
        }else{
            cc.push_back(con+1);
            con=0;
        }
    }
    
    int nc = cc.size();
    vector<int> sc(nc+1);
    REP(i,nc){
        sc[i+1] = sc[i]+cc[i];
    }
    int res = 0;
    if(s[0]=='0'){
        //if(s[n-1]=='0'){
            //s[4]-s[0];
            Rep(i,nc){
                int r = min((k+i)*2-1,nc-1);
                int l = max(0,2*i-1);
                if(r>=l){
                    chmax(res,sc[r+1]-sc[l]);
                }else{
                    break;
                }
            }
        //}else{
            
        //}
    }else{
        //if(s[n-1]=='0'){
            Rep(i,nc){
                int r = min((k+i)*2,nc-1);
                int l = max(0,2*i);
                if(r>=l){
                    chmax(res,sc[r+1]-sc[l]);
                }else{
                    break;
                }
            }
        //}else{
            
        //}
    }
    put(res);
    return 0;
}


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

using namespace std;

#define LIMIT 100
typedef pair<int64_t, int64_t> ii;
typedef int64_t ll;
int gcd(ll a, ll b) { return (b==0)?a:gcd(b, a%b); }
int lcm(ll a, ll b) { ll i=(a/gcd(a,b))*b; assert(i>0); return i; }

int lesser(string a, string b){

  for(int i = 0; i <min(a.size(), b.size()); ++i){
    if(a[i] < b[i]){
      return true;
    }
    if (a[i] > b[i]){
      return false;
    }
  }

  return a.size()<b.size();
}

//  ***** MAIN *****
int main(){
  //ios::sync_with_stdio(false);
  cin.tie(NULL);
  string s, t;
  cin >> s >> t;
  sort(s.begin(),  s.end());
  sort(t.begin(), t.end(), greater<char>());

  if(lesser(s, t)){
    std::cout << "Yes" << std::endl;
  }
  else{
    std::cout << "No" << std::endl;
  }

  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
struct Dice{
  int s[6];
  void roll(char c){
    int b;
    if(c=='E'){
      b=s[0];
      s[0]=s[3];
      s[3]=s[5];
      s[5]=s[2];
      s[2]=b;
    }
    if(c=='W'){
      b=s[0];
      s[0]=s[2];
      s[2]=s[5];
      s[5]=s[3];
      s[3]=b;
    }
    if(c=='N'){
      b=s[0];
      s[0]=s[1];
      s[1]=s[5];
      s[5]=s[4];
      s[4]=b;
    }
    if(c=='S'){
      b=s[0];
      s[0]=s[4];
      s[4]=s[5];
      s[5]=s[1];
      s[1]=b;
    }
    if(c=='R'){
      b=s[1];
      s[1]=s[2];
      s[2]=s[4];
      s[4]=s[3];
      s[3]=b;
    }    
  }
  int top() {
    return s[0];
  }
  int right(){
    return s[2];
  }
  int left(){
    return s[3];
  }
  int front(){
    return s[1];
  }
};
bool same(Dice a,Dice b){
  for(int i=0;i<6;i++) if(a.s[i]!=b.s[i]) return false;
  return true;
}
int main(){
  Dice d[2];
  for(int j=0;j<2;j++) 
    for(int i=0;i<6;i++)
      cin >> d[j].s[i];
  bool f=false;
    
    
  for(int i=0;i<4;i++){
    d[1].roll('R');
    for(int j=0;j<4;j++){
      d[1].roll('N');
      if(same(d[0],d[1])) f=true;
    }
  }
  d[1].roll('E');
  for(int j=0;j<4;j++){
    d[1].roll('N');
    if(same(d[0],d[1])) f=true;
  }
  
  d[1].roll('W');
  d[1].roll('W');
  for(int j=0;j<4;j++){
    d[1].roll('N');
    if(same(d[0],d[1])) f=true;
  }
    
  cout << (f?"Yes":"No") << endl;
  return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int n,m;
	cin>>n;
	vector<int> a(n);
	rep(i,n)cin>>a[i];
	vector<bool> ans(100000,false);
	for(int bit = 0; bit<(1<<n); ++bit){
		int e = 0;
		rep(i,n){
			if(bit & (1<<i)){
				e += a[i];
			}
		}
		ans[e] = true;
	}
	cin>>m;
	rep(i,m){
		int q;
		cin>>q;
		if(ans[q])cout<<"yes"<<endl;
		else cout<<"no"<<endl;
	}	
	return 0;
}



Measured memory_bytes: 3120
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
#include <bitset>
using namespace std;

const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;
typedef long long ll;


int main() {
    int n, m;
    cin >> n >> m;
    vec abc(3);
    cin >> abc[0] >> abc[1] >> abc[2];

    vector<vec> G(n);
    for(int i=0;i<m;i++){
        int u, v;
        cin >> u >> v;
        G[u-1].push_back(v-1);
    }

    bitset<50> cango[50][1001];
    for(int j=0;j<n;j++){
        cango[j][0].set(j);
        for(int k=0;k<G[j].size();k++){
            int to = G[j][k];
            cango[j][1].set(to);
        }
    }
    for(int i=2;i<=1000;i++){
        for(int j=0;j<n;j++){
            for(int k=0;k<G[j].size();k++){
                int to = G[j][k];
                cango[j][i] |= cango[to][i-1];
            }
        }
    }

    vector<bool> goal(n, false);
    goal[n-1] = true;
    for(int t=1;t<=n;t++){
        vector<bool> goal_new = goal;
        for(int i=0;i<n;i++){
            if(goal[i]) continue;
            bool ableall = true;
            for(int j=0;j<3;j++){
                bool ableany = false;
                for(int k=0;k<n;k++){
                    if(!goal[k]) continue;
                    if(goal[k] && cango[i][abc[j]][k]){
                        ableany = true;
                        break;
                    }
                }
                if(!ableany){
                    ableall = false;
                    break;
                }
            }
            if(ableall){
                if(i == 0){
                    cout << t << endl;
                    return 0;
                }
                goal_new[i] = true;
            }
        }
        goal = goal_new;
    }

    cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 1624
#include<stdio.h>
#define N 101
int total,time,A[N][N],B[N],C[N],D[N];
void depth(int a){
  int i; C [a]=1,D[a]=++time;
  for(i=0;i<total;++i){
    if(A[a][i]==1){
      if(C[i]==0)depth(i);
    }
  }
  C[a]=2;
  B[a]=++time;
}
int main(){
  int i,j,a,b,c;
  scanf("%d",&total);
  for(i=0;i<total;++i){
    C[i]=0;
    for(j=0;j<total;j++){
      A[i][j]=0;
    }
  }
  time=0;
  for(i=0;i<total;++i){
    scanf("%d%d",&a,&b);
    for(j=0;j<b;j++){
      scanf("%d",&c);
      A[a-1][c-1]=1;
    }
  }
  for(i=0;i<total;++i){
    if(C[i]==0)depth(i);
  }
  for(i=0;i<total;++i){
    printf("%d %d %d\n",i+1,D[i],B[i]);
  }
  return 0;
}


Measured memory_bytes: 2084
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


n, m, k = map(int, input().split())
uf = UnionFind(n)
fs = [[] for _ in range(n)]
bs = [[] for _ in range(n)]

for _ in range(m):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    uf.union(a, b)
    fs[a].append(b)
    fs[b].append(a)
for _ in range(k):
    c, d = map(int, input().split())
    c, d = c - 1, d - 1
    bs[c].append(d)
    bs[d].append(c)

for i in range(n):
    ans = uf.size(i)
    ans -= 1 + len(fs[i])
    for b in bs[i]:
        if uf.same(i, b):
            ans -= 1
    print(ans, end=' ')


Measured memory_bytes: 107456
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

D, N = map(int, input().split())
if N <= 99:
    print(N * (100 ** D))
else:
    print(101 * (100 ** D))


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

int main(){
	int h, w, si, sj, gi, gj;
  	cin >> h >> w >> si >> sj >> gi >> gj;
  	si--; sj--; gi--; gj--;
  	vector<string> s(h);
  	rep(i, h) cin >> s[i];
  	const int INF = 1e9;
  
  	vector<vector<int>> dist(h, vector<int>(w, INF));
  	deque<P> q;
  	dist[si][sj] = 0;
  	q.emplace_back(si, sj);
  	while(!q.empty()){
    	int i = q.front().first;
        int j = q.front().second;
      	q.pop_front();
        int d = dist[i][j];
      
      	//歩きの処理
      	for(int ei = -1; ei <= 1; ei++){
        	for(int ej = -1; ej <= 1; ej++){
              	if(ei == 1 && ej == 1) continue;
                if(ei == 1 && ej == -1) continue;
              	if(ei == -1 && ej == 1) continue;
              	if(ei == -1 && ej == -1) continue;

        		int ni = i+ei, nj = j+ej;
          		if(ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
          		if(s[ni][nj] == '#') continue;
          		if(dist[ni][nj] <= d) continue;
          		dist[ni][nj] = d;
            	q.emplace_front(ni, nj);
        	}
        }
         
        //ワープの処理
      	for(int ei = -2; ei <= 2; ei++){
        	for(int ej = -2; ej <= 2; ej++){
            	int ni = i+ei, nj = j+ej;
              	if(ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
          		if(s[ni][nj] == '#') continue;
          		if(dist[ni][nj] <= d+1) continue;
              	dist[ni][nj] = d+1;
              	q.emplace_back(ni, nj);
            }
        }
    }
                     
    int ans = dist[gi][gj];
  	if(ans == INF) ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 9444
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    int H, W;
    cin >> H >> W;
    vector<string> a(H);
    rep(i, 0, H){
        cin >> a.at(i);
    }
    rep(i, 0, H + 2){
        if (i == 0 || i == H + 1){
            rep(j, 0, W+2){
                cout << "#";
            }
        }
        else{
            cout << "#" << a.at(i - 1) << "#";
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(ll i=0;i<N;++i)
typedef long long int ll;
ll INF = 1LL<<60;

// フィボナッチ数列の第n項の出力
ll dp[1010];

int main(){
    ll N;
    cin >> N;
    dp[0] = 1; dp[1] = 1;
    for(int i=2;i<=N;i++){
        dp[i] = dp[i-1]+dp[i-2];
    }
    cout << dp[N] << endl;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
int mod =1000000007;
const double PI = acos(-1);

int main(){
    int n,d;cin>>n>>d;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    sort(been(a));
    auto f =[&](int x){
        int cnt =0;
        rep(i,n){
            cnt+=a[i]/x;
            cnt--;
            if(a[i]%x)cnt++;
        }
        return cnt<=d;
    };
    ll l=0,r=a[n-1];
    while(l+1<r){
        ll mid =(l+r)/2;
        if(f(mid)){
            r=mid;
        }
        else l=mid;
    }
    cout<<r<<endl;
}

Measured memory_bytes: 3984
package main

import (
	"fmt"
	"strconv"
)

func avalibleMonth(num int) bool {
	if num >= 1 && num <= 12 {
		return true
	}
	return false
}

func main() {
	var s string
	fmt.Scan(&s)

	prefix, _ := strconv.Atoi(s[0:2])
	suffix, _ := strconv.Atoi(s[2:4])

	if avalibleMonth(prefix) && avalibleMonth(suffix) {
		fmt.Println("AMBIGUOUS")
	} else if avalibleMonth(prefix) {
		fmt.Println("MMYY")
	} else if avalibleMonth(suffix) {
		fmt.Println("YYMM")
	} else {
		fmt.Println("NA")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int function1(long a,long b){
   long long r = a%b ;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  } 
  return b;
}
 
 
  

int main(){
  long long A,B,C,D;
  cin >>A>>B>>C>>D ;
  long long s;
  long long r=B/C-(A-1)/C;
  long long t=B/D-(A-1)/D;
  long long p=function1(min(C,D),max(C,D));
  p=C*D/p;
  long long q=B/p-(A-1)/p; 
  cout <<B+1-A-r-t+q<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int a, b;
int d[] = {31,29,31,30,31,30,31,31,30,31,30,31};
string s[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};

signed main() {
	while (1) {
		cin >> a >> b;
		if (a==0) break;
		cout << s[accumulate(d,d+a-1,b+2)%7] << endl;
	}
}


Measured memory_bytes: 3236
n = int(input())
A = [int(input()) for i in range(n)]
cnt = 0
G = []
g = 0
while 3*g+1 <= n:
    G.append(3*g+1)
    g = 3*g+1
G.reverse()
m = len(G)

def InsertionSort(A, n, g=1):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i -g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            cnt += 1
        A[j+g] = v

def ShellSort(A, n):    
    for i in range(m):
        InsertionSort(A, n, G[i])

ShellSort(A, n)

print(m)
print(*G)
print(cnt)  
print(*A, sep = "\n")


Measured memory_bytes: 53280
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
const ll INF = 1e18;
template <typename T>
T pow(T a, long long n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}

class RollingHash{
    const ll mod = 1e9+7;
    const ll base = 1007;
    V<> hash, power;
public:
    RollingHash(const string &s){
        ll n = SZ(s);
        hash.assign(n+1, 0);
        power.assign(n+1, 1);
        REP(i,n){
            hash[i+1] = (hash[i] * base + s[i]) % mod;
            power[i+1] = (power[i] * base) % mod;
        }
    }
    inline ll get(ll l, ll r) const {
        ll res = hash[r] - hash[l] * power[r-l] % mod;
        if(res < 0) res += mod;
        return res;
    }
    inline ll s_hash(){return get(0, SZ(hash) - 1);}
    inline ll getLCP (int a, int b) const {
        ll len = min(SZ(hash)-a, SZ(hash)-b);
        ll ok = 0, ng = len;
        while(abs(ok-ng) > 1){
            ll mid = (ok+ng) / 2;
            if(get(a, a+mid) != get(b, b+mid)) ng = mid;
            else ok = mid;
        }
        return ok;
    }
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s, t; cin >> s >> t;
    string _ = s;
    while(SZ(s) < SZ(t)) s += _;
    s += s + s;
    RollingHash RH(s);
  
    auto check = [&](ll mid){
        string u = "";
        REP(i, mid) u += t;
        RollingHash mew(u);
        ll c = mew.s_hash();
        REP(i, SZ(s) - SZ(u)){
            if(RH.get(i, i + SZ(u)) == c) return true;
        }
        return false;
    };
    ll k = Roundup_div(SZ(s), SZ(t));
    ll ok = 0, ng = k;
    while(abs(ok - ng) > 1){
        ll m = (ok + ng) / 2;
        if(check(m)) ok = m;
        else ng = m;
    }
    cout << (ok == k - 1 ? -1 : ok) << endl;
}

Measured memory_bytes: 98952
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;
    const int N = 300;
    static double e[N+1][N+1][N+1];
    for(int n3 = 0; n3 <= n; n3++) {
        for(int n2 = 0; n2 <= n; n2++) {
            for(int n1 = 0; n1 <= n; n1++) {
                if(n1 == 0 and n2 == 0 and n3 == 0) {
                    e[n1][n2][n3] = 0;
                } else if(n1 + n2 + n3 <= n) {
                    e[n1][n2][n3] = (n1 ? (double) n1 / n * (e[n1 - 1][n2][n3] + 1) : 0)
                                  + (n2 ? (double) n2 / n * (e[n1 + 1][n2 - 1][n3] + 1) : 0)
                                  + (n3 ? (double) n3 / n * (e[n1][n2 + 1][n3 - 1] + 1) : 0);
                    if(n1 + n2 + n3 < n) {
                        double p0 = double(n - n1 - n2 - n3) / n;
                        e[n1][n2][n3] = (e[n1][n2][n3] + p0) / (1 - p0);
                    }
                }
            }
        }
    }
    int N1 = count(a.begin(), a.end(), 1), N2 = count(a.begin(), a.end(), 2), N3 = count(a.begin(), a.end(), 3);
    cout << fixed << setprecision(9) << e[N1][N2][N3] << endl;
    return 0;
}


Measured memory_bytes: 213248
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;

int main(){
    map<pair<int,int>, int> mp;
    ll H,W,N;
    ll ANS[10];
    cin>>H>>W>>N;
    ANS[0]=(H-2)*(W-2);
    for(int i = 1;i <= 9;i++){
        ANS[i]=0;
    }
    ll a_,b_;
    for(int i = 0;i < N;i++){
        cin>>a_>>b_;
        a_--;b_--;
        for(ll a = min(a_,H-3);a_-a < 3&&a>=0;a--){
            for(ll b = min(b_,W-3);b_-b < 3&&b>=0;b--){
                //cout<<a<<b<<endl;
                if(mp.count(make_pair(a,b))==0){
                    mp[make_pair(a,b)]=1;
                }else{
                    mp[make_pair(a,b)]++;
                }
            }
        }
    }
    map<pair<int,int>,int>::iterator it = mp.begin();
    while(it!=mp.end()){
        ANS[it->second]++;
        ANS[0]--;
        it++;
    }
    for(int i = 0;i <= 9;i++){
        cout<<ANS[i]<<endl;
    }
}


Measured memory_bytes: 56448
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto ds = readln.split.to!(long[]);
    long s;
    foreach (i; 0..N) {
        foreach (j; i+1..N) {
            s += ds[i] * ds[j];
        }
    }
    writeln(s);
}

Measured memory_bytes: 256
N, K, Q = map(int, input().split())

ptsList = [K-Q]*N

if K - Q > 0:
    for i in range(N):
        print("Yes")
else:
    for i in range(Q):
        ptsList[int(input())-1] += 1

    for i, e in enumerate(ptsList):
        if e > 0:
            print("Yes")
        else:
            print("No")


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

int main() {
  int H, W;
  cin >> H >> W;
  
  for (int i=0; i<W+2; i++) {
    cout << "#";
  }
  
  cout << endl;
  
  vector<string> vec(H);
  
  for (int i=0; i<H; i++) {
    cin >> vec.at(i);
    cout << "#";
    cout << vec.at(i);
    cout << "#" << endl;
  }
  
  for (int i=0; i<W+2; i++) {
    cout << "#";
  }
}

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

int main() {
	int a,sum=0;
	cin>>a;
	for(int i=0;i<a;i++){
	    for(int j=0;j<a;j++){
	        for(int k=0;k<a;k++){
	            sum++;
	        }
	    }
	}
	cout<<sum<<'\n';
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
		
		System.out.println(Math.max(Math.max(a*c, a*d),Math.max(b*c, b*d)));
	}
}


Measured memory_bytes: 35608
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
typedef long long ll;

int n,a[202020]={0};
int s[202020]={0},t[202020]={0};

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

    for(int i=0;i<n;++i){
        s[i+1]=s[i]^a[i];
        t[i+1]=t[i]+a[i];
    }


    ll ans=0,k=0;
    for(int i=0;i<=n;++i){
        for(int j=k;j<=n;++j){
            if((s[j]^s[i])!=(t[j]-t[i])){
                ans+=(ll)j-(ll)i-1LL;
                //cout<<i<<" "<<j<<endl;
                k=max(j-1LL,k);
                break;
            }
            else if(j==n){
                ans+=(ll)n-(ll)i;
                k=max(n-1LL,(ll)j);
            }
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


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

    string s;
    cin>>s;

    Yes(s[2]==s[3]&&s[4]==s[5]);


}

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

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
    string s; cin >> s;
    Ans(s[0]!=s[1] && s[1]!=s[2] && s[2]!=s[0]);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;
 
int main(){
    int n,s=0;
    cin>>n;
    int l = n;
    while(n>=10){
        s += n%10;
        n /= 10;
    }
    s += n;
    cout<<(l % s == 0 ? "Yes":"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;
using ll = long long;
using P = pair<int,int>;


int main(){
  int N, K;
  cin >> N >> K;
  
  double ans = 0;
  
  for(int i = 1; i <= N; i++){
    int score = i;
    double tmp = 1.0 / N; //まずさいころを振ってiが出る確率は1/N
    int count = 0;

    while(score < K){
      score *=2;
      tmp /= 2; //コインで表を出さなければいけない回数ぶんだけ確率が落ちる
    }
    
    ans += tmp;
    

  }
  
  cout << setprecision(12) << ans << endl;
}

Measured memory_bytes: 3744
import sys
input = sys.stdin.buffer.readline

N = int(input())
prev = [0, 0, 0]
for _ in range(N):
    t, x, y = map(int, input().split())
    if abs(x - prev[1]) + abs(y - prev[2]) > t - prev[0]:
        print('No')
        exit()
    elif (x-prev[1] + y - prev[2]) % 2 != (t-prev[0])%2:
        print('No')
        exit()
    else:
        prev = [t, x, y]
print('Yes')


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

LL memo[50];


void solve(long long A, long long B){
    if(A == B) {
        cout << A << endl;
        return;
    }
    A--;
    LL now = 1;
    REP(i, 50){
        memo[i] = now;
        now *= 2LL;
    }

    LL a[50], b[50];
    REP(i, 50) {
        a[i] = 0;
        b[i] = 0;
    }
    LL ans = 0;
    REP(i, 50) {
        if(A - memo[i] + 1 > 0) {
            a[i] = (A - memo[i] + 1) / (memo[i] * 2) * memo[i];
            a[i] += min(memo[i], (A - memo[i] + 1) % (memo[i] * 2));
        }
        if(B - memo[i] + 1 > 0) {
            b[i] = (B - memo[i] + 1) / (memo[i] * 2) * memo[i];
            b[i] += min(memo[i], (B - memo[i] + 1) % (memo[i] * 2));
        }

        //cout << "i: " << i << " a[i]: " << a[i] << " b[i]: " << b[i] << endl;

        if((b[i] - a[i]) % 2 == 1){
            ans += (1LL << i);
        }
    }

    cout << ans << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
using namespace std;
int main() {
	string h;
	long long int n, mon, oneco = 0, mm;
	cin >> h >> n;
	bool one = false;
	if (h.length() == 1) cout << h[0] << endl;
	else {
		if (h[0] != '1') cout << h[0] << endl;
		else {
			for (int i = 0; i < h.length(); ++i) {
				if (h[i] != '1') {
					mm = i;
					one = true;
					break;
				}
				else oneco++;
			}
			if (oneco == h.length()) cout << "1" << endl;
			else if (oneco >= n) cout << "1" << endl;
			else cout << h[mm] << endl;
		}
	}
}

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

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

int main(void){
    int k, x, s, e;
    cin >> k >> x;

    s = x - (k - 1);
    e = x + (k - 1);

    for(int i = s; i <= e; i++)
        cout << i << endl;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class BTwoContests {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      vector<P> vec(n);
      rep(i, n) {
        cin >> vec[i].first >> vec[i].second;
      }
      sort(all(vec));

      vector<ll> v1(n);
      ll mi = 1;
      ll ma = 1e+9;
      rep(i, n) {
        chmax(mi, vec[i].first);
        chmin(ma, vec[i].second);
        v1[i] = max(ma-mi+1, 0LL);
      }
      vector<ll> v2(n);
      mi = 1;
      ma = 1e+9;
      for(int i=n-1; i>=0; i--) {
        chmax(mi, vec[i].first);
        chmin(ma, vec[i].second);
        v2[i] = max(ma-mi+1, 0LL);
      }
      ll ans = 0;
      rep(i, n-1) {
        chmax(ans, v1[i]+v2[i+1]);
      }

      multiset<int, greater<>> left;
      multiset<int> right;
      rep(i, n) {
        left.insert(vec[i].first);
        right.insert(vec[i].second);
      }

      rep(i, n) {
        auto it = left.find(vec[i].first);
        left.erase(it);
        it = right.find(vec[i].second);
        right.erase(it);

        debug(*right.begin(), *left.begin());

        ll tmp = max(0, (*right.begin())-(*left.begin())+1);
        ll tmp2 = max(0LL, vec[i].second-vec[i].first+1);
        chmax(ans, tmp + tmp2);

        left.insert(vec[i].first);
        right.insert(vec[i].second);
      }

      cout << ans << endl;

    }
};

signed main() {
  BTwoContests solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 12800
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N + 2];
        A[0] = 0;
        A[N+ 1] = 0;
        for (int i = 1; i <= N; i++) {
            A[i] = sc.nextInt();
        }
        int length = 0;
        for (int i = 1; i <=  N  ; i++) {
            length += Math.abs(A[i] - A[i + 1]);
        }

        length  = length + Math.abs(A[1]);


        for (int i = 0 ; i < N  ; i ++) {
            int ans = length;
            ans = ans + Math.abs(A[i] - A[i + 2]) - Math.abs(A[i] - A[i + 1]) - Math.abs(A[i + 1] - A[i + 2]) ;
            System.out.println(ans);
        }
    }

}


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

int main(){
	int n, f, d;
	for( ; cin >> n , n; ){
		bitset<50> b[31];
		bitset<50> has[50];
		for( int i = 0; i < n; ++i ){
			has[i].set( i );
			for( cin >> f; f--; ){
				cin >> d;
				b[d].set( i );
			}
		}

		for( d = 1; d <= 30; ++d ){
			bitset<50> gather;
			for( int i = 0; i < n; ++i ){
				if( b[d][i] ){
					gather |= has[i];
				}
			}
			for( int i = 0; i < n; ++i ){
				if( b[d][i] ){
					has[i] = gather;
				}
			}
			
			if( gather.count() == n ){
				break;
			}
		}
		
		if( d > 30 ){
			d = -1;
		}
		cout << d << endl;
	}
}

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

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto&& e : a) {
    cin >> e;
  }
  int ans = 0;
  for (int i = 0; i < n; i += 2) {
    if (a[i] % 2 != 0) ans++;
  }
  cout << ans << endl;
}


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

#define int           long long 
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (int)(1e9)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii>

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){ cerr << name << " = " << arg1 << endl;}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args)
{ const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);}

template< typename T1, typename T2 > istream& operator>>(istream& in, pair<T1, T2> &q){ in >> q.F >> q.S; return in;}
template< typename T1, typename T2 > ostream& operator<<(ostream& out, pair<T1, T2> &q){ out << q.F << " " << q.S; return out;}
template< typename T1, typename T2 > pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F+p2.F, p1.S+p2.S};}
template< typename T1, typename T2 > pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F-p2.F, p1.S-p2.S};}
template< typename T1, typename T2 > bool operator<(pair<T1, T2> p1, pair<T1, T2> p2){ return p1 < p2 ;}

template<typename T> void Unique(vector<T> &v){
    sort(all(v)), v.resize(distance(v.begin(), unique(all(v))));
}


void solve(int &test) {
    double x, eps = 1e-9;
    cin >> x;
    x = x*acos(-1)/180;
    int k = 1;
    while(k++){
        double c = sin(k*x/2)*cos((k+1)*x/2);
        double s = sin(k*x/2)*sin((k+1)*x/2);
        // cout << c << " " << s << endl;
        if(abs(c) <= eps && abs(s) <= eps){
            cout << k << endl;
            return;
        }
    }
}

signed main(){

    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);   

    int t = 1;

    start = clock(); 

    cout << fixed << setprecision(20);
    
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout);
    // freopen("error.txt", "w", stderr);
    // #endif
   
    // cin >> t;
     
    for(int i = 1; i <= t; ++i){
        solve(i);
    }
    //cerr << time(start);
    return 0;
}

Measured memory_bytes: 4304
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int main()
{
int sx,sy,tx,ty,i,x,y;
scanf("%d %d %d %d",&sx,&sy,&tx,&ty);
x=tx-sx;
y=ty-sy;
for(i=0;i<x;++i){
    printf("R");
}
for(i=0;i<y;++i){
    printf("U");
}
for(i=0;i<x;++i){
    printf("L");
}
for(i=0;i<y;++i){
    printf("D");
}
printf("D");
for(i=0;i<x+1;++i){
    printf("R");
}
for(i=0;i<y+1;++i){
    printf("U");
}
printf("L");
printf("U");
for(i=0;i<x+1;++i){
    printf("L");
}
for(i=0;i<y+1;++i){
    printf("D");
}
printf("R");





    return 0;
}


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

using namespace std;

typedef complex<double> P;

#define EPS (1e-7)

double dot(P const& a, P const& b) {
  return real(conj(a)*b);
}

double cross(P const& a, P const& b) {
  return imag(conj(a)*b);
}

bool is_parallel(P const& a1, P const& a2, P const& b1, P const& b2) {
  return abs(cross(a2-a1, b2-b1)) < EPS;
}

bool is_orthogonal(P const& a1, P const& a2, P const& b1, P const& b2) {
  return abs(dot(a2-a1, b2-b1)) < EPS;
}

int main () {
  
  int q; cin >> q;
  for(;q--;) {
    P a1, a2, b1, b2;
    cin >> a1.real() >> a1.imag() >> a2.real() >> a2.imag();
    cin >> b1.real() >> b1.imag() >> b2.real() >> b2.imag();
    if(is_parallel(a1, a2, b1, b2)) {
      cout << 2 << endl;
    }
    else if(is_orthogonal(a1, a2, b1, b2)) {
      cout << 1 << endl;
    }
    else {
      cout << 0 << endl;
    }

  }
  return 0;
}

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

using namespace std;

int main()
{
	ll n;
	cin >> n;
	ll ans = 0;
	for(ll i = 1; i<= n; i++)
	{
		ll dig = i;
		ll k = 0;
		while(dig)
		{
			k++;
			dig /= 10;
		}
		if(k & 1)
			ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

int main(){
    ll n,X;
    cin >> n >> X;
    vector<ll> vec;
    vec.push_back(X);
    rep(i,n) {
        ll x;
        cin >> x;
        vec.push_back(x);
    }
    sort(all(vec));
    vector<ll> diff;
    rep(i,n){
        diff.push_back(vec[i+1]-vec[i]);
    }
    ll ans = gcd(diff[0],diff[1]);
    rep(i,n-1){
        ans = gcd(ans,diff[i+1]);
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 2548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,a,b) for(int i=(a);i<(b);i++)
#define frr(i,a,b) for(ll i=(a-1);i>=(b);i--)
#define vi vector<int>
#define de deque<int>
#define del deque<ll>
#define vl vector<ll>
#define pb push_back
#define ppb pop_back()
#define pf push_front
#define ppf pop_front()
#define mpp map<ll,ll>
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define ln(a) a.length()
#define sz(a) a.size()
#define endl "\n"
int M=1000000007;
ll n;ll dp[105][100005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

cin>>n;
ll mw;cin>>mw;
ll w[n],v[n];
f(i,0,n)
{
    cin>>w[i]>>v[i];
}
f(i,0,n){dp[i][0]=0;}
f(j,0,mw+1)
{
    if(j>=w[0]){dp[0][j]=v[0];}
    else{dp[0][j]=0;}
}
f(i,1,n)
{
    f(j,1,mw+1)
    {
        if(j>=w[i]){dp[i][j]=max(dp[i-1][j],v[i]+dp[i-1][j-w[i]]);}
        else{dp[i][j]=dp[i-1][j];}
    }

}
cout<<dp[n-1][mw]<<endl;
}


Measured memory_bytes: 80128
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
#include <iostream>
using namespace std;

int main() 
{
    int N,K;
    cin >> N >> K;
    vector<int>H(N);
    for (int i = 0; i < N; i++){
        cin >> H.at(i);
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (K <= H.at(i)) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
    while(1){
        int x, y;
        cin >>x >>y;
        if(x==0 && y==0) break;
        else if(x <= y) cout <<x<<" "<<y<<endl;
        else cout <<y<<" "<<x<<endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#include<iostream>
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int a, b, c;
	std::cin >> a >> b >> c;
	if (a == b && b == c)
		return std::cout << "No", 0;
	if (a == b || a == c || b == c)
		return std::cout << "Yes", 0;
	else
		return std::cout << "No", 0;
}

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

using namespace std;

int main()
{
    string s;
    cin >> s;
    int zc = 0, oc = 0;
    for (int i = 0; i < s.size(); i++){
        if (s[i] == '0'){
            zc++;
        }
        else {
            oc++;
        }
    }
    cout << min(zc, oc)*2;
    return 0;
}


Measured memory_bytes: 512
//it's what you do that defines you
//fr u gotta do it
//get up and solve
//CMON
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rep2(r, aa, bb) for (int r = (aa)-1; r >= (bb); r--)
#define be(x) (x.begin(), x.end())
#define pb(t) push_back(t)
#define ll long long
#define mp(a, b) make_pair(a, b)
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	vector<int>A={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 a;
	cin>>a;
	cout<<A[a-1]<<"\n";
}


Measured memory_bytes: 256