akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main()
{

	string S, T;

	cin >> S >> T;

	string ans = "Yes";

	if (S.length() != T.length() - 1)
		ans = "No";

	else
	{
		for (int i = 0; i < S.length(); i++)
		{
			if (S[i] != T[i])
			{
				ans = "No";
				break;
			}
		}
	}

	cout << ans << endl;

}


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

int main() {
    string s,t;
    string tmp = "";
    cin >> s >> t;
    string ans = "No";
    for(int i = 0; i < (int)s.size(); i++)
    {
        for(int j = 0; j < (int)s.size(); j++)
        {
            if (s.at((j + i) % (int)s.size()) != t.at(j)) {
                break;
            }
            if (j == (int)t.size() - 1) {
                ans = "Yes";
                break;
            }
        }
        if (ans == "Yes") break;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt();
		int d = sc.nextInt();
		int sum = 0;
		for(int i = 1; i <= m; i++){
			for(int j = 1; j <= d; j++){
				if(j%10>=2&&j/10>=2&&(j%10)*(j/10)==i){
					sum++;
				}
			}
		}
		System.out.print(sum);
	}
}


Measured memory_bytes: 22996
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	defer writer.Flush()
	N := ReadInt()
	A := ReadInts(N)
	B := ReadInts(N)

	cnt := make(map[int]int)
	for i := 0; i < N; i++ {
		cnt[A[i]]++
		cnt[B[i]]++
	}
	for _, c := range cnt {
		if c > N {
			fmt.Println("No")
			return
		}
	}

	type Val struct {
		Num, Type int
	}
	c := make([]*Val, 0)
	for i := 0; i < N; i++ {
		c = append(c, &Val{Num: A[i], Type: 0})
		c = append(c, &Val{Num: B[i], Type: 1})
	}
	sort.Slice(c, func(i, j int) bool {
		return c[i].Num < c[j].Num
	})

	type Pair struct {
		X, Y *Val
	}
	pairs := make([]*Pair, N)
	for i := 0; i < N; i++ {
		pairs[i] = &Pair{
			X: c[i],
			Y: c[i+N],
		}
	}

	type0Indices := make([]int, 0)
	type1Indices := make([]int, 0)
	for i := 0; i < N; i++ {
		if pairs[i].X.Type != pairs[i].Y.Type {
			continue
		}
		if pairs[i].X.Type == 0 {
			type0Indices = append(type0Indices, i)
		} else {
			type1Indices = append(type1Indices, i)
		}
	}
	for i := 0; i < len(type0Indices); i++ {
		j := type0Indices[i]
		k := type1Indices[i]
		if pairs[j].X.Num == pairs[k].Y.Num {
			pairs[j].Y, pairs[k].X = pairs[k].X, pairs[j].Y
		} else {
			pairs[j].Y, pairs[k].Y = pairs[k].Y, pairs[j].Y
		}
	}

	for i := 0; i < N; i++ {
		if pairs[i].X.Type == 1 {
			pairs[i].X, pairs[i].Y = pairs[i].Y, pairs[i].X
		}
	}
	sort.Slice(pairs, func(i, j int) bool {
		return pairs[i].X.Num < pairs[j].X.Num
	})
	Println("Yes")
	for i := 0; i < N; i++ {
		if i > 0 {
			Printf(" ")
		}
		Printf("%d", pairs[i].Y.Num)
	}
	Println()
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}

var writer = bufio.NewWriter(os.Stdout)

func Printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }
func Println(a ...interface{})               { fmt.Fprintln(writer, a...) }


Measured memory_bytes: 30340
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
  string S;
   cin >> S;
   if(S[0] != '9' && S[1] != '9') cout << "No" << endl;
   else cout << "Yes" << endl;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
S = [input() for _ in range(H)]

import heapq
def dijkstra(adj, n, st=1):
    dj = [2**64] * (n)
    dj[st] = 0
    q = []
    heapq.heappush(q, (0, st))
    while q:
        fc, fn = heapq.heappop(q)
        if dj[fn] < fc: continue
        for tn, lc in adj[fn]:
            if dj[fn] + lc < dj[tn]:
                dj[tn] = dj[fn] + lc
                heapq.heappush(q, (dj[tn], tn))
    return dj

def cid(x):
    return x[0] * W + x[1]

def cl(adj, x, y):
    xid = cid(x)
    yid = cid(y)
    adj[xid].append((yid, 1))
    adj[yid].append((xid, 1))

adj = dict([(x, []) for x in range(H*W)])
for i in range(H):
    for j in range(W):
        if S[i][j] == "#": continue
        ni = i + 1
        if ni < H and S[ni][j] == ".":
            cl(adj, (i, j), (ni, j))
        nj = j + 1
        if nj < W and S[i][nj] == ".":
            cl(adj, (i, j), (i, nj))

c = dijkstra(adj, H*W, cid((0,0)))
hwc = c[cid((H-1,W-1))]
print(-1 if hwc == 2**64 else H * W - sum(s.count("#") for s in S) - hwc - 1)

Measured memory_bytes: 4468
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int x = 7;
    int result = -1;
    for (int i = 1; i <= k; i++) {
      if (x % k == 0) {
        result = i;
        break;
      }
      x = (x * 10 + 7) % k;
    }
    System.out.println(result);
  }
}


Measured memory_bytes: 35620
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
 
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
 
#define REP(i, l, n) for(ll i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
 
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;}
 
char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
 
int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(){
    ld a, b; cin >> a >> b;
    ld ans = a * b;
    cout << (ll)ans << endl;
}

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

int main() {
    string s;
    cin >> s;
    int counter = 0;
    if(s[0] == '1') ++counter;
    if(s[1] == '1') ++counter;
    if(s[2] == '1') ++counter;
    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
     
    int main()
    {
      int x;
      cin >> x;
      for (int i=1; i < 361; ++i)
      {
        if ((x * i) % 360 == 0)
        {
          cout << i << endl;
          return 0;
        }
      }
    }

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

using namespace std;

#ifdef NeverBeRed
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ld> point;
#define F first
#define S second



int main()
{
	#ifdef TurnRed
		//freopen("a.in", "r", stdin);
		//freopen("a.out", "w", stdout);
	#endif

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

	int h1, m1, h2, m2, k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;

	int a = h1 * 60 + m1;
	int b = h2 * 60 + m2;
	cout << b-a-k << "\n";

	return 0;
}


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

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)

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

void Main() {
  int a, b;
  cin >> a >> b;
  rep(i, b*20) {
    if (i*8/100 == a && i*10/100==b) {
      cout << i << endl;
      return;
    }
  }
  cout << -1 << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


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

int main() {
  int n;
  while(cin >> n && n) {
    int a[n],b[n];
    for(int i=0; i<n; i++) cin >> a[i];
    for(int i=0; i<n; i++) cin >> b[i];
    sort(a,a+n,greater<int>());
    sort(b,b+n,greater<int>());
    for(int i=0,j=0; i<n-1; i+=2,j++) {
      if(a[i]>b[j]) {
        cout << i+1 << endl;
        goto end;
      }
    }
    cout << "NA" << endl;
  end:;
  }
  return 0;
}


Measured memory_bytes: 3404
import functools

def sign(x):
    if x>0:
        return 1
    elif x==0:
        return 0
    else:
        return -1
    
def multiply(x,y):
    ans = x*y
    if ans>=10**9+7 or ans<0:
        ans %= (10**9+7)
    return ans

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

if (A[-1]<0 and K%2==1):
    combi = A[-K:]
    if K >1:
        answer =  functools.reduce(multiply,combi)

elif K == N:
    answer = functools.reduce(multiply,A)
    
else:
    signs = 1
    i,j = 0,0
    for _ in range(K):
        if abs(A[i]) > abs(A[N-j-1]):
            signs *= sign(A[i])
            i += 1
            
        else:
            signs *= sign(A[N-j-1])
            j += 1
    combi = A[N-j:] + A[:i]
    del A[N-j:]
    del A[:i]
    combi = combi[::-1]     
       
    if signs == -1:
        if A:
            if combi[-1]<0:
                del combi[0]
                combi.append(A[-1])
            elif A[0]>=0:
                del combi[0]
                combi.append(A[-1])
            elif A[0]<0 and A[-1] >0:
                if combi[0]*A[0] > combi[-1]*A[-1]:
                    del combi[-1]
                    combi.insert(0,A[0])
                else:
                    del combi[0]
                    combi.append(A[-1])
            elif A[-1] <= 0:
                del combi[-1]
                combi.insert(0,A[0]) 
                
    answer =  functools.reduce(multiply,combi)
print(answer)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
typedef long long ll;

int c[3][3];

void solve(){
  int x, y, z;
  x = c[0][0] + c[1][1] + c[2][2];
  y = c[0][1] + c[1][2] + c[2][0];
  z = c[0][2] + c[1][0] + c[2][1];
  if (x == y && y == z){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

int main(){
  rep(i, 3){
    rep(j, 3){
      cin >> c[i][j];
    }
  }
  solve();
}

Measured memory_bytes: 256
N=int(input())
A=[0] + list(map(int, input().split())) + [0]
dist = 0
for i in range(1,N+2):
  dist += abs(A[i]-A[i-1])

for i in range(1,N+1):
  if (A[i-1] <= A[i] <= A[i+1]) or (A[i-1] >= A[i] >= A[i+1]):
    print(dist)
  else:
    print(dist - 2 * min( abs(A[i]-A[i-1]), abs(A[i]-A[i+1]) ) )



Measured memory_bytes: 14048
#include<bits/stdc++.h>
#define f first
#define se second
#define pb push_back
#define pf push_front
#define eb emplace_back
#define emp emplace
#define ins insert
#define sz(s) (int)s.size()
#define rep(i,a,b) for( int i=a;i<b;i++)
#define repr(i,a,b) for( int i=a;i>=b;i--)
#define bitcount __builtin_popcount
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(n,m) memset(n,m,sizeof(n))
#define ii pair<int,int>
#define iii tuple<int, int, int>
#define si set<int>
#define vi vector<int>
#define vii vector<ii>
#define mi map<int,int>
#define lb lower_bound
#define ub upper_bound
#define present(s,x) (s.find(x) != s.end())
#define ford(container, it) for(auto it:container)
#define fors(container, it, a, b) for(auto it = a; it != b; it++)
#define Anurag_Gupta ios_base::sync_with_stdio(0);
#define IIIT_ALLD cin.tie(0);cout.tie(0);
#define mod 998244353
#define EPSILON 1e-9
#define PI acos(-1)
#define inf 1e17
#define int long long
#define debug(a) cerr<<#a<<": ";for(auto i:a)cerr<<i<<" ";cerr<<'\n';
#define trace(a) cerr<<#a<<": "<<a<<"\n"
#define gcd(a,b) __gcd(a,b)
using namespace std;
int add(int a, int b, int c){int res=a+b;return(res>=c?res-c:res);}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
int mul(int a, int b, int c){int res=(int)a*b;return(res>=c?res%c:res);}
template<typename T>T power(T e, T n){T x=1,p=e;while(n){if(n&1)x=x*p;p=p*p;n>>=1;}return x;}
template<typename T>T mdpower(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}
/*------------------------------------------------------------------------------------------------------------------*/
const int N = 200005;
int fact[N];
int inverseFact[N];
void preprocess()
{
    fact[0] = 1;
    for(int i=1;i<N;i++){
        fact[i] = (fact[i-1]%mod*i%mod)%mod;
    }
}

int ncr(int n,int r)
{
    int ans = fact[n];
    int temp = (fact[r]%mod*fact[n-r]%mod)%mod;
    return (ans%mod*mdpower(temp,(int)mod-2LL,(int)mod)%mod)%mod;
}
int32_t main()
{
    Anurag_Gupta
    IIIT_ALLD
 
  
    preprocess();

   int n,m,k;
   cin>>n>>m>>k;

   int ans=0;

   for(int i=0;i<=k;i++)
   {
       int temp = n-1-i;

       int temp1 = mdpower(m-1,temp,(int)mod);
       temp1 = (m%mod*temp1%mod)%mod;

       int dd = ncr(n-1,i);
       temp1 = (temp1%mod*dd%mod)%mod;

       ans = (ans%mod+temp1%mod)%mod;
   }

   cout<<ans<<"\n";



 
 






 
#ifndef LOCAL_DEFINE
        cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}


Measured memory_bytes: 5348
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

string s1,s2,s3;

int main()
{
	cin>>s1>>s2>>s3;
	cout<<s1[0]<<s2[0]<<s3[0]<<endl;
}


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

#define MaxN 100005
#define INF 2140000000
#define MOD 998244353

using namespace std;

int N,S,found[MaxN];
long long Ans;
int n=0,p=0;
pair<int,int>d[MaxN],s[MaxN],l[MaxN];
int delta(pair<int,int>a)
{
    if(a.second<0)
        return a.second;
    else if(a.first>0)
        return a.first;
    else return 0;
}
bool cond(pair<int,int> a,pair<int,int> b)
{
    return abs(delta(a))>abs(delta(b));
}

int main()
{
    cin>>N;
    for(int i=1;i<=N;i++)
    {
        int X,Y;
        cin>>X>>Y;
        d[++S]={X,Y};
        if(delta(d[S])>0)
            p++;
        else if(delta(d[S])<0) n++;
    }

    if(p>n)
        p=n+1;
    else if(n>p)
        n=p+1;
    sort(d+1,d+1+S,cond);
    N=0;
    for(int i=1;i<=S;i++)
    {
        if(delta(d[i])>0&&p)
            p--,Ans+=2*delta(d[i]);
        else if(delta(d[i])<0&&n)
            n--,Ans-=2*delta(d[i]);
        else
            d[++N]=d[i];
    }

    for(int i=1;i<=N;i++)
    {
        s[i]={d[i].second,i};
        l[i]={d[i].first,i};
    }

    sort(s+1,s+1+N);
    sort(l+1,l+1+N);

    int P=N;

    for(int i=1;i<=N;i++)
    {
        if(found[s[i].second])
            continue;
        while(P&&found[l[P].second])
            P--;
        if(P==0||l[P].first<=s[i].first)
        {
            cout<<Ans;
            return 0;
        }
        Ans+=2*(l[P].first-s[i].first);
        found[l[P].second]=1;
        found[s[i].second]=1;
        P--;
    }

    cout<<Ans;

    return 0;
}


Measured memory_bytes: 2944
#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 sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;

  const int w = 2100;
  const int h = 2100;

  //訪問済みの座標を記録するvector
  vector<vector<int>> visited(h,vector<int>(w,0));

  //どの方向から移動してきたかを記録するvector
  vector<vector<char>> direction(h,vector<char>(w));

  //座標値を配列の添え字に変換する関数
  auto to_idx = [&](int c){
    return c + 1005;
  };

  //与えられた2点の座標を配列の添え字に変換
  const int sx_ = to_idx(sx);
  const int sy_ = to_idx(sy);
  const int tx_ = to_idx(tx);
  const int ty_ = to_idx(ty);
  
  string ans;

  //4回の移動を行う
  rep(I,4){
    //出発地点の座標と対応する配列の添え字
    int nx,ny;

    //出発地点の座標と対応する配列の添え字
    int gx,gy;

    //出発地点と目標地点をセット
    if(I%2==0){
      nx = sx_;
      ny = sy_;
      gx = tx_;
      gy = ty_;
    }
    else{
      nx = tx_;
      ny = ty_;
      gx = sx_;
      gy = sy_;
    }

    //目標地点を未訪問にしておく
    visited[gy][gx] = 0;

    /*BFS（多分）する*/
    queue<P> q;
    const int dx[4] = { 0, 1,-1, 0};
    const int dy[4] = { 1, 0, 0,-1};
    const char di[4] = {'U','R','L','D'};

    //訪問済みの座標を記録するvector（最短経路上ではない座標も記録）
    vector<vector<int>> tmp_visited(h,vector<int>(w,0));

    //出発地点をキューに追加
    q.push(make_pair(nx,ny));

    while(!q.empty()){
      //目標地点に到達したかのフラグ
      bool reached = false;

      P p = q.front();
      q.pop();

      int X = p.first;
      int Y = p.second;

      rep(i,4){
        int to_x = X + dx[i];
        int to_y = Y + dy[i];

        //行先の座標が範囲外ならば
        if(0>to_x||to_x>=w) continue;
        if(0>to_y||to_y>=h) continue;

        //行先の座標が訪問済みならば
        if(visited[to_y][to_x]==1||tmp_visited[to_y][to_x]==1) continue;

        //訪問済みにしておく
        tmp_visited[to_y][to_x] = 1;

        //移動してきた方向を記す
        direction[to_y][to_x] = di[i];

        //目標地点に到達したら
        if(to_x==gx&&to_y==gy) reached = true;

        //キューに追加
        q.push(make_pair(to_x,to_y));
      }

      //目標地点に到着したときそれまでの経路を記録する
      if(reached){
        string tmp_ans;

        //出発地点に到達したかのフラグにする
        reached = false;

        int to_x = gx;
        int to_y = gy;

        while(!reached){
          //経路を記録
          tmp_ans = direction[to_y][to_x] + tmp_ans;

          //訪問済みにしておく
          visited[to_y][to_x] = 1;

          //経路を戻る
          if(direction[to_y][to_x]=='U') to_y--;
          else if(direction[to_y][to_x]=='D') to_y++;
          else if(direction[to_y][to_x]=='L') to_x++;
          else if(direction[to_y][to_x]=='R') to_x--;

          //出発地点に到着したら
          if(to_x==nx&&to_y==ny) reached = true;
        }

        ans += tmp_ans;

        break;
      }

    }

  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 42724
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		int[] prices = {a, b, c};
		Arrays.sort(prices);

		System.out.println(prices[0] + prices[1]);
	}
}

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

const long long MOD=1000000007;
int k;
std::vector<bool> visited;

using namespace std;

long long dfs(int pos,vector<vector<int>> &g){
    long long ret=1;
    int res=k-2;
    visited[pos]=true;
    for(auto i:g[pos]){
        if(visited[i])continue;
        ret=ret*dfs(i,g)%MOD;
        ret=ret*res%MOD;
        --res;
    }
    return ret;
}

int main(){
    int n;
    cin>>n>>k;
    visited.assign(n,false);
    vector<vector<int>> g(n);
    for (int i = 0; i < n-1; ++i) {
        int a,b;
        cin>>a>>b;
        --a;--b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    long long ans=1;
    for (long long i = k-g[0].size(); i<=k ; ++i) {
        ans=ans*i%MOD;
    }
    visited[0]=true;
    for(auto i:g[0]){
        visited[i]=true;
        ans=ans*dfs(i,g)%MOD;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)
template<typename T> void scan(T &x){x = 0;bool _=0;T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}

using namespace std;
typedef long long ll;
typedef __int128 lll;

int t;
ll n;
lll a, b, c, d;
#include <ext/pb_ds/assoc_container.hpp>
__gnu_pbds::gp_hash_table<ll, lll> dp;

ll go(ll x){
    if(dp.find(x) != dp.end())
        return dp[x];
    dp[x] = d*x;
    ll y;
    if(x >= 5){
        y = x/5;
        dp[x] = min(dp[x], d*abs(x-y*5)+c+go(y));
        y++;
        if(y < x) dp[x] = min(dp[x], d*abs(x-y*5)+c+go(y));
    }
    
    if(x >= 3){
        y = x/3;
        dp[x] = min(dp[x], d*abs(x-y*3)+b+go(y));
        y++;
        if(y < x) dp[x] = min(dp[x], d*abs(x-y*3)+b+go(y));
    }
    
    if(x >= 2){
        y = x/2;
        dp[x] = min(dp[x], d*abs(x-y*2)+a+go(y));
        y++;
        if(y < x) dp[x] = min(dp[x], d*abs(x-y*2)+a+go(y));
    }
    return dp[x];
}

int main(){
    
    scan(t);
    while(t--){
        scan(n, a, b, c, d);
        dp.clear();
        dp[0] = 0;
        print(go(n));
    }
    
    
    return 0;
}
/*
 * for f(x) --> y, if -d is better than divide, for smaller x, better too
 * f(x) whether +-d and jump or just --> 0
 * for each q = {2, 3, 5}, check for ++d/q or --d/q

3
11 1 2 4 8
11 1 2 2 8
32 10 8 5 4
 
 
 */

Measured memory_bytes: 8760
#include <bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i, r, n) for (ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i, r, n) for (ll i = (ll)(n - 1); i >= r; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
template <class T>
T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T>
T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/

int main()
{
    cin >> s;
    ans = (s[0] - '0') + 9 * (s.size() - 1);
    REP(i,s.size()-1){
        if(s[i+1]!='9'){
            cout << --ans << endl;
            return 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String s1 = s.substring(0, 2);
    String s2 = s.substring(2);
    int t1 = Integer.parseInt(s1);
    int t2 = Integer.parseInt(s2);
    String ans = "NA";
    int p = 0;
    if((t2 > 0) && (t2 <= 12)) {
      ans = "YYMM";
      p++;
    }
    if((t1 > 0) && (t1 <= 12)) {
      ans = "MMYY";
      p++;
    }
    if(p == 2) ans = "AMBIGUOUS";
    System.out.println(ans);
  }
}

Measured memory_bytes: 22356
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define rev(a,b,c) for(int a=b;a>=c;a--)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define F first
#define S second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define get(a) cin>>a
#define nextl cout<<"\n"
#define deb(x) cout<<#x<<"="<<x<<"\n";
const ll mod = 1000000007;
const ll maxn = 10005;
const ll mm = 1e+18;
ll power(ll x, ll y)
{
    ll res = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res;
}
ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2); 
} 
ll nCrModPFermat(ll n, ll r, ll p) 
{ 
   if (r==0) 
      return 1; 
    ll fac[n+1]; 
    fac[0] = 1; 
    for (int i=1 ; i<=n; i++) 
        fac[i] = fac[i-1]*i%p; 
  
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
} 
void solve()
{
    ll x,y;
    cin>>x>>y;
    x++;
    y++;
    ll z=x+y;
    bool p=true;
    if((z-2)%3) p=false;
    if(p){
        if(abs(x-y)>(z-2)/3) p=false;
    } 
    if(!p) cout<<"0";
    else{
        ll q=(z-2)/3;
        q++;
        x-=q;
        y-=q;
        ll ans=nCrModPFermat(x+y,x,mod);
        cout<<ans;
    }
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    cout<<fixed<<setprecision(10);
   // cin>>t;
    while(t--){
        solve();
       // nextl;
    }
    return 0;
}


Measured memory_bytes: 5504
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;

int N;
vint G[100];
int AM[100][100];

int main() {

	cin >> N;
	rep(i, N){
		int id, D; 
		cin >> id >> D; id--;
		rep(j, D){
			int n; cin >> n; n--;
			G[id].push_back(n);
		}
	}

	rep(i, N) rep(j, N){
		AM[i][j] = 0;
	}
	rep(i, N){
		vint v = G[i]; 
		rep (j, v.size()){
			AM[i][v[j]] = 1;
		}
	}

	rep(i, N){
		rep(j, N){
			cout << AM[i][j];
			if (j == N - 1){ cout << "\n"; }
			else{ cout << " "; }
		}
	}
}

Measured memory_bytes: 3196
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstring>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<vector>
using namespace std;
int E[300000], W[300000];
int main() {

	int n;
	string s;
	cin >> n;
	cin >> s;
	int i;
	int e = 0, w = 0;
	for (i = 0; i < n; i++) {
		if (s[i] == 'E') {
			e++;
		}
		else {
			w++;
		}
		E[i] = e; W[i] = w;
	}
	int MIN = E[n - 1] - E[0];
	for (i = 1; i < n; i++) {
		
		if (MIN > W[i - 1] + E[n - 1] - E[i]) {
			MIN = W[i - 1] + E[n - 1] - E[i];
		}
	}
	cout << MIN << endl;
	return 0;
}

Measured memory_bytes: 6048
#include<stdio.h>

int main(void){
	int n,x,i,m,d[262144]={0},r[262144]={0};
	scanf("%d%d",&n,&x);
	if(x == 1 || x == 2*n-1){
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	for(i = 1;i <= 2*n-1;i++){
		d[i]=1;
	}
	if(x == 2*n - 2){
		r[n-1]=x-1;d[x-1]=0;
		r[n]=x+1;d[x+1]=0;
		r[n+1]=x;d[x]=0;
		r[n+2]=x-2;d[x-2]=0;
	}
	else{
		r[n-1]=x+1;d[x+1]=0;
		r[n]=x-1;d[x-1]=0;
		r[n+1]=x;d[x]=0;
		r[n+2]=x+2;d[x+2]=0;
	}
	m = 1;
	for(i=1;i<=2*n-1;i++){
		if(r[i]){continue;}
		while(1){
			if(d[m]){r[i] = m;m++;break;}
			m++;
		}
	}
	for(i = 1;i <= 2*n-1;i++){
		printf("%d\n",r[i]);
	}
	return 0;
}

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

int main (void) {

    int a, b;

    cin >> a >> b;

    if (a % 3 == 0 || b % 3 == 0||(a + b) % 3 == 0){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }

    return 0;

}


Measured memory_bytes: 3624
// I'm a f*cking looser
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fasino ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
#define input(A) for(auto &i:A) cin>>i;
struct point {
    int left, right, block, id;
};

bool cmp(const point &lhs, const point &rhs) {
    if (lhs.block < rhs.block)
        return true;
    else if (lhs.block > rhs.block)
        return false;
    else
        return lhs.right < rhs.right;
}

signed main(){
  	fasino
    int n, q;
    cin>>n>>q;
    vector<int> A(n);
    input(A);
    int block_size = sqrt(n);
    vector<point> query(q);
    for (int i = 0; i < q; i++) {
        cin>>query[i].left>>query[i].right;
        query[i].left--, query[i].right--;
        query[i].block = query[i].left / block_size;
        query[i].id = i;
    }
    sort(query.begin(), query.end(), cmp);
    vector<int> solution(q);
    vector<int> hash(1000100);
    int left = 0, right = 0, answer = 1;
    hash[A[0]] = 1;
    for (const point &task : query) {
        while (left < task.left) {
            hash[A[left]]--;
            answer -= (hash[A[left]] == 0);
            left++;
        }
        while (left > task.left) {
            left--;
            hash[A[left]]++;
            answer += (hash[A[left]] == 1);
        }
        while (right < task.right) {
            right++;
            hash[A[right]]++;
            answer += (hash[A[right]] == 1);
        }
        while (right > task.right) {
            hash[A[right]]--;
            answer -= (hash[A[right]] == 0);
            right--;
        }
        solution[task.id] = answer;
    }
    for (int answer : solution)
        printf("%d\n", answer);

    return 0;
}

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

int main() {
  vector<int> a(3);
  cin>>a[0]>>a[1]>>a[2];
  sort(a.begin(),a.end());
  if (a[0]==5&&a[1]==5&&a[2]==7) {
    cout<<"YES";
  }else{
    cout<<"NO";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin >> a >> b >> c;
    cout << (a+b+c>=22? "bust":"win") << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n1 = sc.nextInt();
        int n2 = sc.nextInt();
        int n3 = sc.nextInt();
        if((n1 == n2 && n1 != n3) || (n2 == n3 && n1 != n2) || (n1 == n3 && n1 != n2)){
        	System.out.println("Yes");
        }else{
        	System.out.println("No");
        }
    }
}

Measured memory_bytes: 35668
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout<<#x<<" = "<<(x)<<" (L"<<LINE<<")"<<endl;
#define vdeb(x) {cout<<#x<<" = { "; rep(i, x.size()) cout<<x[i]<<' '; cout <<'}'<<" (L"<<LINE<<")"<<endl;}
using namespace std;
using ll = long long;
using vi = vector<int>;
using vivi = vector<vi>;
using vll = vector<long long>;
using vllvll = vector<vll>;
using vs = vector<string>;

int main()
{
    int N;
    cin >> N;
    string nstr = to_string(N);
    if (nstr[0] == '7' or nstr[1] == '7' or nstr[2] == '7') {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3688
/**
Make it happen now, not tomorrow.
Tomorrow is a loser's excuse.
**/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef map<int, int> mi;
typedef map<ll, ll> ml;
typedef unordered_map<int, int> umi;
typedef unordered_map<ll, ll> uml;

const int mod = 1e9 + 7; // 998244353;

ll power(ll x, ll y) {ll xx = x, ans = 1; while (y > 0) {if (y & 1)ans = (ans * xx); xx = (xx * xx); y = y >> 1;} return ans;}
ll nCr(ll n, ll r) {ll p = 1, k = 1; if (n - r < r) r = n - r;  if (r != 0) {while (r) {p *= n; k *= r; ll m = __gcd(p, k); p /= m; k /= m; n--; r--;}} else p = 1; return p;}
void printv(vl v) {cout << "Vector is \n"; for (auto x : v)cout << x << " "; cout << "\nVector End\n";}
void printa(int a[], int n) {cout << "Array is\n"; for (int i = 0; i < n; i++) {cout << a[i] << " ";} cout << "\nVector End\n";}
int day(int date, int month, int year) {if (month == 1) {month = 13; year--;} if (month == 2) {month = 14; year--;} int q = date, m = month, k = year % 100, j = year / 100; int day = q + (13 * (m + 1)) / 5 + k + (k / 4) + (j / 4) + 5 * j; day = day % 7; return day;}
ll ston(string s) {ll val = 0, bs = 1; ll sl = s.length(); sl--; while (sl >= 0) {val += ((s[sl] - 48) * bs); bs *= 10; sl--;} return val;}
ll lcm(ll a, ll b) {return (a * b) / __gcd(a, b);}

#define F first
#define S second
#define mp make_pair
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(v) v.begin(),v.end()
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


int main() {
	int n;
	cin>>n;
	int a[n];
	map<int,int>m;
	for (int i=0;i<n;i++)cin>>a[i];
	int ans=0;
	sort(a,a+n);
	set<vi>s;
	for (int i=0;i<n;i++){
        for (int j=i+1;j<n;j++){
            for (int k=j+1;k<n;k++){
                if((a[i]+a[j]>a[k]&&a[k]+a[j]>a[i]&&a[i]+a[k]>a[j])&&a[k]!=a[j]&&a[k]!=a[i]&&a[j]!=a[i]){
                    ans++;
                }
            }
        }
	}
	cout<<ans<<endl;

}

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


Measured memory_bytes: 3576
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

void main()
{
	foreach (line; stdin.byLine) {
		auto st = line.chomp.split(",").map!(to!double);
		if (st[1] / (st[2]^^2) >= 25) st[0].to!int.writeln;
	}
}

Measured memory_bytes: 1084
# Author: S Mahesh Raju
# Username: maheshraju2020
# Date: 05/07/2020

from sys import stdin,stdout
from math import gcd, ceil, sqrt
from collections import Counter
ii1 = lambda: int(stdin.readline().strip())
is1 = lambda: stdin.readline().strip()
iia = lambda: list(map(int, stdin.readline().strip().split()))
isa = lambda: stdin.readline().strip().split()
mod = 1000000007

n = ii1()
arr = []
for i in range(n):
    arr.append(is1())
d = Counter(arr)
for i in ['AC', 'WA', 'TLE', 'RE']:
    print(i + ' x ' + str(d[i]))



Measured memory_bytes: 16548
#include <bits/stdc++.h>
using namespace std;
const int N = 200010;

#define PI acos(-1)
typedef long long ll;
#define INF 0x3f3f3f3f
int mod = 1000000007;
int rec[N];
int main()
{
	//freopen("in.txt", "r", stdin);
	int a, b;
	while (cin >> a >> b)
	{
		cout<<(2*b - a)<<endl;
	}
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007

using namespace std;

int main(void){
	int n;
	cin>>n;
	int h[n];
	rep(i,n)cin>>h[i];
	ll ans=0;
	rep(i,n){
		while(h[i]!=0){
			for(int j=i+1;j<n;j++){
				if(h[j]==0)break;
				h[j]--;
			}
			h[i]--;
			//cout<<i<<":"<<h[i]<<endl;
			ans++;
		}
	}

	cout<<ans<<endl;

	return 0;

}


Measured memory_bytes: 256
def examC():
    N = I()
    A = LI()
    Ad = [0]*N
    for i in range(N):
        Ad[i] = A[i]-(i+1)
    Ad.sort()
#    print(Ad)
    b = Ad[N//2]
    ans = 0
    for a in Ad:
        ans +=abs(a-b)
    print(ans)
    return

def examD():
    N = I()
    A = LI()
    cumA = [0]*N
    cumA[0] = A[0]
    for i in range(N-1):
        cumA[i+1] = cumA[i]+A[i+1]
    ans = inf
#    print(cumA)
    for i in range(1,N-1):
        curcd = (cumA[i]+1)//2
        cd = bisect.bisect_right(cumA,curcd)
#        print(curcd,cd)
        C = cumA[cd]; D = cumA[i]-C
        if cd>0 and abs(C-D)>abs(cumA[cd-1]-(cumA[i]-cumA[cd-1])):
            C = cumA[cd-1]; D = cumA[i] - C
        curef = (cumA[-1]-cumA[i]+1)//2
        ef = bisect.bisect_right(cumA,curef+cumA[i])
#        print(curef,ef)
        E = cumA[ef]-cumA[i]; F = cumA[-1]-E-cumA[i]
        if abs(E-F)>abs(cumA[ef-1]-cumA[i]-(cumA[-1]-cumA[ef-1])):
            E = cumA[ef-1]-cumA[i]; F = cumA[-1]-E-cumA[i]
 #           print(E,F)
        ansC = max(C,D,E,F)-min(C,D,E,F)
        ans = min(ans,ansC)
 #       print(C,D,E,F)
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,inf
mod = 10**9 + 7
inf = 10**18

if __name__ == '__main__':
    examD()


Measured memory_bytes: 26308
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int gcd(int a, int b)
{
    if(b == 0) return a;
    return gcd(b, a%b);
}
int main()
{
    int k;
    cin >> k;
    ll ans = 0;
    for(int a = 1; a <= k; a++)
    {
        for(int b = 1; b <= k; b++)
        {
            for(int c = 1; c <= k; c++)
            {
                int g = gcd(a, b);
                g = gcd(g, c);
                ans += g;
            }
        }
    }
    cout << ans << endl;
}



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

int main(){
  int a,b,c,d;cin>>a>>b;
  
  rep(i,b){
    cin>>d;
    c+=d;
  }
  
  if(c>=a){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

//*
#define bsf __builtin_ctzll
ll gcd(ll a, ll b) {
  // a = abs(a); b = abs(b);
  if (!a || !b) return a|b;
  int t = bsf(a|b); a >>= bsf(a);
  do { b >>= bsf(b); if (a > b) swap(a, b); b -= a;} while (b);
  return a << t;
}
ll lcm(ll x, ll y) { return x/gcd(x,y)*y;}
/*/
l3 _gcd(l3 x, l3 y) { return y ? _gcd(y,x%y) : x;}
l3 gcd(l3 x, l3 y) { return _gcd(x<0?-x:x,y<0?-y:y);}
//*/


int main() {
  int x;
  scanf("%d",&x);
  int g = gcd(x,360);
  int ans = 360 / g;
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 3756
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main(string[] args)
        {
            var xy = Scanner.scanlong;
            var res = 1;
            var sum = xy[0];
            while(true)
            {
                sum = sum * 2;
                if (sum > xy[1]) break;
                res++;
            }
            Console.WriteLine(res);
        }
    }

    public class Scanner
    {
        public static string[] scan => Console.ReadLine().Split(' ');
        public static string[][] rescan(int n) => Enumerable.Repeat(0, n).Select(_ => Console.ReadLine().Split(' ')).ToArray();
        public static int[] scanint => Array.ConvertAll(scan, int.Parse);
        public static long[] scanlong => Array.ConvertAll(scan, long.Parse);
    }

    public class Ex
    {
        public static int[] subarr(int[] arr, int begin, int n) { int[] a = new int[arr.Length]; Array.Copy(arr, begin, a, 0, n); return a; }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string T[4] = {
	"dream","dreamer","erase","eraser"
};



int main() {
	string S;

	cin >> S;

	reverse(S.begin(), S.end());

	for (int i = 0; i < 4; i++)
	{
		reverse(T[i].begin(), T[i].end());
	}

	bool can = true;
	for (int i = 0; i <(int) S.size();)
	{
		bool can2 = false;
		for (int j = 0; j < 4; j++)
		{
			string s = T[j];
			if (S.substr(i, s.size()) == s) {
				can2 = true;
				i += s.size();
			}
			
		}
		if (!can2) {
				can = false;
				break;
		}
	}

	if (can)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}

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

int main(){
  string a, b;
  cin >> a >> b;
  if (a.size()>b.size()) {
    printf("GREATER\n");
  } else if (a.size()<b.size()) {
    printf("LESS\n");
  } else {
    int a0=a[0]-'0', b0=b[0]-'0';
    if (a0>b0) {
      printf("GREATER\n");
    } else if (a0<b0) {
      printf("LESS\n");
    } else {
      printf("EQUAL\n");
    }
  }
  return 0;
}

Measured memory_bytes: 256
Module Module1

    Sub Main()
        Dim H, W, K As Integer
        Dim tbl(35, 35) As String
        Dim arr() As Integer = Array.ConvertAll(Of String, Integer)(Console.ReadLine.Split(" "), AddressOf Integer.Parse)
        H = arr(0) : W = arr(1) : K = arr(2)
        Dim result As Integer = 0
        For i As Integer = 0 To H - 1
            Dim s As String = Console.ReadLine
            For j As Integer = 0 To W - 1
                tbl(j, i) = s.Substring(j, 1)
            Next
        Next

        For bit = 0 To (1 << W) - 1
            Dim width(W - 1) As Integer
            For i As Integer = 0 To W - 1
                If (bit >> i) And 1 Then
                    width(i) = 1
                End If
            Next
            For bit2 = 0 To (1 << H) - 1
                Dim hight(H - 1) As Integer
                For j As Integer = 0 To H - 1
                    If (bit2 >> j) And 1 Then
                        hight(j) = 1
                    End If
                Next
                Dim count As Integer = 0
                Dim g(,) As String = CType(tbl.Clone(), String(,))
                For y As Integer = 0 To H - 1
                    For x As Integer = 0 To W - 1
                        If hight(y) = 1 Then
                            g(x, y) = "R"
                        ElseIf width(x) = 1 Then
                            g(x, y) = "R"
                        ElseIf tbl(x, y) = "#" Then
                            count = count + 1
                        End If
                    Next
                Next

                If count = K Then
                    result = result + 1
                End If
            Next
        Next
        Console.WriteLine(result)
        'Debug.WriteLine(result)
    End Sub

End Module


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

int main() {
    int k, s;
    cin >> k >> s;

    int ans = 0;
    for (int x = 0; x <= k; ++x) {
        for (int y = 0; y <= k; ++y) {
            int t = s - x - y;
            if (t >= 0 && t <= k) ++ans;
        }
    }

    cout << ans << endl;
}


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

long long dist_modoru(long long x, long long s, long long t) {
  return min(abs(s - x), abs(t - x)) * 2 + max(abs(s - x), abs(t - x));
}

long long min(long long a, long long b) {
  if (a - b > 0)
    return b;
  else
    return a;
}

int main() {
  int A, B, Q;
  cin >> A >> B >> Q;
  long long s[A + 1], t[B + 1], x;
  long long *si, *ti;
  long long ans;
  for (int i = 0; i < A; i++) cin >> s[i];
  s[A] = LLONG_MAX;
  for (int i = 0; i < B; i++) cin >> t[i];
  t[B] = LLONG_MAX;
  for (int i = 0; i < Q; i++) {
    cin >> x;
    si = lower_bound(s, s + (sizeof(s) / sizeof(long long)), x);
    si--;
    ti = lower_bound(t, t + (sizeof(t) / sizeof(long long)), x);
    ti--;
    ans = LLONG_MAX;
    if (si >= s && ti >= t) {
      ans = min(ans, max(x - *si, x - *ti));
    }
    if (si >= s && *(ti + 1) >= x) {
      ans = min(ans, dist_modoru(x, *si, *(ti + 1)));
    }
    if (*(si + 1) >= x && ti >= t) {
      ans = min(ans, dist_modoru(x, *(si + 1), *ti));
    }
    if (*(si + 1) >= x && *(ti + 1) >= x) {
      ans = min(ans, max(*(si + 1) - x, *(ti + 1) - x));
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 2816
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader bf = new BufferedReader(is);
		String[] strAry = bf.readLine().split(" ");
		int a = Integer.parseInt(strAry[0]);
		int b = Integer.parseInt(strAry[1]);
		int c = Integer.parseInt(strAry[2]);
		if (a < b && b < c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 24348
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

// #define DEBUG

template <typename T>
T my_pow_with_mod(T x, T a, T mod = 1e9 + 7);
template <typename T>
void prime_factorization(T n);
template <typename T>
T my_gcd(T a, T b);
template <typename T>
T my_lcm(T a, T b);

template <typename T>
T my_pow_with_mod(T x, T a, T mod)
{
    ll ans = 1;
    ll b = x;
    while (a)
    {
        if (a & 1)
            ans *= b;
        ans %= mod;
        a = a >> 1;
        b = b * b;
        b %= mod;
    }
    return ans;
}

template <typename T>
void prime_factorization(T n)
{
    vector<pair<T, T>> a;
    T counter, p;
    T m = sqrt(n) + 1;
    p = n;
    for (T i = 2; i <= m; i++)
    {
        counter = 0;
        while (n % i == 0)
        {
            counter++;
            n /= i;
        }
        if (counter)
            a.push_back(make_pair(i, counter));

        if (n == 1)
            break;
    }
    if (n != 1)
        a.push_back(make_pair(n, 1));

    cout << p << ":";
    for (int i = 0; i < a.size(); i++)
    {
        for (int j = 0; j < a[i].second; j++)
        {
            cout << " " << a[i].first;
        }
    }
    cout << endl;
}

template <typename T>
T my_gcd(T a, T b)
{
    T tmp;
    if (a > b)
        swap(a, b);
    while (a > 0)
    {
        tmp = a;
        a = b % a;
        b = tmp;
    }
    return b;
}

template <typename T>
T my_lcm(T a, T b)
{
    T c = my_gcd(a, b);
    return a * b / c;
}

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif
    int n, x;
    cin >> n;
    int ans = 1;
    for (int i = 0; i < n; i++)
    {
        cin >> x;
        ans = my_lcm(ans, x);
    }
    cout << ans << endl;
    return 0;
}

// getline(cin,s);
// a = strtok(s, ",");  ","で分解
// for (int i = 0; i < n; i++)


Measured memory_bytes: 3120