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

#define REP(i,x) for(int i=0; i<(int)(x); i++)       // 0 <= i < x
#define REPS(i,x) for(int i=1; i<=(int)(x); i++)     // 0 < i <= x
#define RREP(i,x) for(int i=((int)(x)-1); i>=0; i--) // x > i >= 0
#define RREPS(i,x) for(int i=((int)(x)); i>0; i--)   // x >= i > 0
#define INF 999999999
#define ll long long

using namespace std;

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

int main(void){
	char a,b,c,d,e,f;
	scanf("%c%c%c\n%c%c%c",&a,&b,&c,&d,&e,&f);

	if(a==f && b==e && c==d){
		printf("YES\n");
	}
	else{
		printf("NO\n");
	}

	return 0;
}
	

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0)
    return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1; // 分母
  ll numerator = 1;   // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

class UnionFind {
private:
  vector<ll> parents;

public:
  UnionFind(ll n) : parents(n, -1) {}

  bool issame(ll x, ll y) {
    return root(x) == root(y);
  }

  bool merge(ll x, ll y) {
    if (issame(x, y))
      return false;

    ll rx = root(x);
    ll ry = root(y);
    if (parents[rx] > parents[ry])
      swap(rx, ry);
    // サイズ情報を更新
    parents[rx] += parents[ry];
    // yの親を更新
    parents[ry] = rx;

    return true;
  }

  ll size(ll x) {
    return -parents[root(x)];
  }

private:
  ll root(ll x) {
    if (parents[x] < 0)
      return x;
    // 根の親の値に木の(-)サイズの情報を入れる
    return parents[x] = root(parents[x]);
  }
};

bool cmp(pair<ll, ll> a, pair<ll, ll> b) {
  return a.second < b.second;
}

int main() {
  ll N;
  cin >> N;
  vector<pair<ll, ll>> Jobs(N);

  for (ll i = 0; i < N; i++) {
    cin >> Jobs[i].first;
    cin >> Jobs[i].second;
  }

  sort(Jobs.begin(), Jobs.end(), cmp);

  ll current = 0;
  ll ok = true;
  for (ll i = 0; i < N; i++) {
    current += Jobs[i].first;
    if (current > Jobs[i].second) {
      ok = false;
      break;
    }
  }

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

  return 0;
}


Measured memory_bytes: 3328
d = [[[-1, -1], [0, -1], [1, -1], [1, 0], [0, 1], [-1, 0]],
     [[-1,  0], [0, -1], [1,  0], [1, 1], [0, 1], [-1, 1]]]

w, h = gets.split.map(&:to_i)
fld = (h+2).times.map{ [false]*(w+2) }
(1..h).each do |i|
  gets.split(" ").each_with_index{ |e, j| fld[i][j+1] = true if e == "1" }
end

tmp = (h+2).times.map{ [false]*(w+2) }
arr = []
arr << [0, 0]
tmp[0][0] = true
until arr.empty?
  y, x = arr.pop
  d[y%2].each do |dy, dx|
    u = y + dy; v = x + dx
    next if u < 0 || u > h+1 || v < 0 || v > w+1
    if !fld[u][v] && !tmp[u][v]
      tmp[u][v] = true
      arr << [u, v]
    end
  end
end
fld = fld.flatten.zip(tmp.flatten).map{|f,p| !(!f&p) }
p fld.each_with_index.each_with_object([]){|(e, i), arr| arr << i if e}.compact.map{ |i| d[(i/(w+2))%2].count{ |y, x| !fld[i+y*(w+2)+x]}}.compact.reduce(:+)

Measured memory_bytes: 9424
#include<bits/stdc++.h>
#define cs const
#define pb push_back
using namespace std;
cs int N = 200;
int n, m, f[N][N][N], g[N][N][N];
char mp[N][N];
int main(){
	#ifdef FSYolanda
	freopen("1.in","r",stdin);
	#endif
	scanf("%d%d",&n,&m);
	for(int i=1; i<=n; i++)
	scanf("%s",mp[i]+1);
	for(int l=1; l<=n; l++)
	for(int r=l; r<=n; r++){
		f[l][r][m+1]=m;
		for(int i=m; i>=1; i--){
			bool ok = l==r || (mp[l][i]==mp[r][i]&&f[l][r-1][i]>=i);
			if(!ok) f[l][r][i]=i-1;
			else f[l][r][i]=mp[l][i]==mp[l][i+1]?f[l][r][i+1]:i;
		}
	}
	for(int l=1; l<=m; l++)
	for(int r=l; r<=m; r++){
		g[l][r][n+1]=n;
		for(int i=n; i>=1; i--){
			bool ok = l==r || (mp[i][l]==mp[i][r]&&g[l][r-1][i]>=i);
			if(!ok) g[l][r][i]=i-1;
			else g[l][r][i]=mp[i][l]==mp[i+1][l]?g[l][r][i+1]:i;
		}
	} int tim = 0;
	while(true){
		if(f[1][n][1]>=m) return cout<<tim,0; ++tim;
		for(int l=1; l<=n; l++)
		for(int r=l; r<=n; r++)
		for(int i=1; i<=m; i++)
		f[l][r][i]=f[l][r][f[l][r][i]+1];
		for(int l=1; l<=m; l++)
		for(int r=l; r<=m; r++)
		for(int i=1; i<=n; i++)
		g[l][r][i]=g[l][r][g[l][r][i]+1];
		for(int i=1; i<=n; i++)
		for(int j=1; j<=m; j++){
			static int a[N], b[N];
			for(int k=i; k<=n; k++) a[k]=f[i][k][j];
			for(int k=j; k<=m; k++) b[k]=g[j][k][i];
			a[n+1]=j-1; b[m+1]=i-1;
			for(int k=i; k<=n; k++)
			for(int l=a[k];l>a[k+1];l--) 
			g[j][l][i]=max(g[j][l][i],k);
			for(int k=j; k<=m; k++)
			for(int l=b[k];l>b[k+1];l--)
			f[i][l][j]=max(f[i][l][j],k);
		}
	} return 0;
}

Measured memory_bytes: 61440
import java.util.Scanner;

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

    private static void solve(Scanner in) {
        while (in.hasNext()) {
            int a = in.nextInt(), b = in.nextInt();
            int gcd = gcd(a, b);
            int lcm = a / gcd * b;
            System.out.println(gcd + " " + lcm);
        }
    }

    private static int gcd(int a, int b) {
        if (b == 0)
            return a;
        return gcd(b, a % b);
    }
}

Measured memory_bytes: 26124
N,K = map(int, input().strip().split(' '))
H = list(map(int, input().strip().split(' ')))

dp = [float('inf')]*N
dp[0] = 0
for i in range(N-1):
  for d in range(1, min(K+1, N-i)):
    dp[i+d] = min(dp[i+d], dp[i]+abs(H[i+d]-H[i]))

print(dp[N-1])


Measured memory_bytes: 55052
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            if (x == 0 && y==0)
                break;
            else if(x<y){
                System.out.println(x+" "+y);
            }else {
                System.out.println(y+" "+x);
            }
        }
    }
}


Measured memory_bytes: 35776
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<set>
#include<map>
#include<time.h>
#include<cstring>
#include<iomanip>
#include<numeric>
#include<list>
#define lli long long int
#define h 1000000007
#define pf push_front
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define pi 3.14159
using namespace std;
int main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL) ;
 string x;
 cin>>x;
 if(x[x.size()-1]!='s') x+="s";
 else x+="es";
 cout<<x<<endl;
  return 0;
} 


Measured memory_bytes: 3660
# Problem: https://atcoder.jp/contests/abc090/tasks/abc090_b
# Python 2nd Try

import sys
# from collections import defaultdict
# import heapq,copy
# from collections import deque


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solver(fromNum, toNum):
    result = 0
    # algorithm
    for number in range(fromNum, toNum+1):
        strNum = str(number)
        if strNum[0] == strNum[4]:
            if strNum[1] == strNum[3]:
                result = result + 1
    return result


if __name__ == "__main__":
    A, B = MI()
    print("{}".format(solver(A, B)))


Measured memory_bytes: 3064
import copy
n, m, q = map(int, input().split())
candi = []

def calc(ar, s):
    if len(ar) == n:
        if s <= m: candi.append(ar)
        return
    max_num = ar[len(ar) - 1]
    for i in range(0, m-s+1):
        tmp = copy.deepcopy(ar)
        tmp.append(max_num+i)
        calc(tmp, s+i)

calc([1], 1)
tes = [list(map(int, input().split())) for _ in range(q)]
ans = 0

for now in candi:
    tmp = 0
    for cons in tes:
        a, b, c, d = cons[0], cons[1], cons[2], cons[3]
        if now[b-1] - now[a-1] == c: tmp += d
    ans = max(ans, tmp)
print(ans)


Measured memory_bytes: 90772
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	ll x, y; cin >> x >> y;
    int ans = 1;
    while(x * 2 <= y) {
        x *= 2;
        ++ ans;
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

const int N=100010;

int n,l,t;
int a[N],b[N],c[N],nxt[N];

inline int dist(int x,int y){
	return (a[x]+l-a[y])%l;
}

void PutAns(int x){
	if(x>=10) PutAns(x/10); putchar(x%10+'0');
}

int main(){
	scanf("%d%d%d",&n,&l,&t);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&a[i],&b[i]);
	sort(c+1,c+1+n); int bg=0;
	for(int i=1;i<=n;i++){
		c[i]=a[i]+(b[i]==1?1:-1)*t;
		bg=(bg+c[i]/l)%n;
		c[i]%=l;
		if(c[i]<0) bg=(bg-1)%n,c[i]+=l;
	}
	bg=(bg+n)%n;
	sort(c+1,c+1+n);
	for(int i=1;i<=n;i++) printf("%d\n",c[(bg+i-1)%n+1]);
	return 0;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
int main(){
  string o,e;
  cin>>o>>e;
  for(int i=0;i<e.size();i++)
    cout<<o[i]<<e[i];
  if(o.size()>e.size())cout<<o[o.size()-1];
  cout<<endl;
  return 0;
}


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


int main(){
  int n;
  cin >> n;
  vector<int> c(n-1),s(n-1),f(n-1);
  for(int i=0;i<n-1;++i){
    cin >> c[i] >> s[i] >> f[i];
  }
  for(int i=0;i<n-1;++i){
    ll ti=c[i]+s[i];
    for(int j=i+1;j<n-1;++j){
      if(ti<s[j]){
        ti=s[j];
      }else if(ti%f[j]==0);
      else ti=ti+f[j]-ti%f[j];
      ti+=c[j];
    }
    cout << ti << endl;
  }
  cout << "0" << endl;
  return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).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; }
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; }
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
int main() {
	ll x, y;
	cin >> x >> y;
	int count = 0;
	while (x <= y) {
		x *= 2;
		count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

int main(void)
{
    int N, D;
    std::cin >> N >> D;

    int X[N][D];
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < D; j++)
        {
            std::cin >> X[i][j];
        }
    }

    int cnt = 0;
    for(int i = 0; i < N - 1; i++)
    {
        for(int j = i + 1; j < N; j++)
        {
            double d_distance = 0;
            
            for(int k = 0; k < D; k++)
            {
                d_distance += pow(X[i][k] - X[j][k], 2);
            }

            d_distance = sqrt(d_distance);
            
            int i_distance = (int)(d_distance);


            cnt += (i_distance / d_distance == 1);
        }
    }

    std::cout << cnt << std::endl;

    return 0;
}

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

using namespace std;

int main(){
int a,b;
while (	cin>>a>>b){
	int count=0;
	if(a!=0 || b!=0){
	for(int i=1; i<=a-2;i++){
		for (int j=2; j<=a-1;j++){
			for(int k=3;k<=a;k++){
				if(i<j && i<k && j<k){
					if(i+j+k==b){
						count++;
					}
				}
			}
		}	
	}
	cout<<count<<endl;
}
else {
	break;
}
}
}


Measured memory_bytes: 3100
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long
const double pi = acos(-1.0);

const LL mod = 998244353;

int n, m;

int main() {
#ifdef LOCAL
  auto start_clock = clock();
  freopen("in", "r", stdin);
#endif

  scanf("%d%d", &n, &m);
  if (m >= 2 * n && m <= 4 * n && m % 2 == 0) {
    printf("Yes\n");
  }
  else {
    printf("No\n");
  }

  
  

#ifdef LOCAL
 auto end_clock = clock();
 cout << "Time:" << (end_clock - start_clock) / CLOCKS_PER_SEC << endl;
#endif
  return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b

signed main(){
	ll n,k; cin>>n>>k;
    vl a(n),sum(n);
    rep(i,0,n){
        cin>>a[i];
        if(i!=0)sum[i]+=abs(a[i]-a[i-1])+sum[i-1];
    }
    ll ans=MOD;
	rep(i,k-1,n){
        ll j=sum[i]-sum[i-k+1];
        j+=min(abs(a[i]),abs(a[i-k+1]));
        chmin(ans,j);
    }
    cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 4844
// #include <bits/stdc++.h>
// #define ll long long int
// #define vi vector<ll>
// #define vvi vector<vector<ll>>
// #define pii pair<ll, ll>
// #define pb push_back
// #define rep0(i, n) for(ll i = 0;i<n;i++)
// #define rep1(i, n) for(ll i = 1;i<n;i++)
// #define all(v) v.begin(),v.end()
// #define fast                          \
//     ios_base::sync_with_stdio(false); \
//     cin.tie(NULL);                    \
//     cout.tie(NULL);
// using namespace std;
// const int N = 1e5 + 5;
// void solve(){
//     string s, t;
//     cin >> s >> t;
//     int l1 = s.size();
//     int l2 = t.size();
//     for(int i=0; i<l1-l2+1;i++){
//         int c = 0;
//         int mx = 0;
//         for(int j=0; j<l2; j++){
//             if(s[i+j] != t[j]){mx = max()}
//             else{c++;}
//         }
//     }
// }
 
// int main()
// {
//     fast;
//     solve();
//     // int t;
//     // cin >> t;
//     // while(t--){
//     //     solve();
//     // }
//     return 0;
// }
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<ll, ll>
#define pb push_back
#define rep0(i, n) for(ll i = 0;i<n;i++)
#define rep1(i, n) for(ll i = 1;i<n;i++)
#define all(v) v.begin(),v.end()
#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
using namespace std;
const int N = 1e5 + 5;
void solve(){
    string s, t;
    cin >> s >> t;
    int l1 = s.size();
    int l2 = t.size();
    int total = 1e9;
    bool flag = false;
    for(int i=0; i<l1; i++){
        int c = 0;
        for(int j=0; j<l2; j++){
            if(i+j>=l1){flag=true;break;}
            if(s[i+j]!=t[j]){c++;}
        }
        if(flag){break;}
        total = min(total, c);
    }
    cout << total;
}
 
int main()
{
    fast;
    solve();
    // int t;
    // cin >> t;
    // while(t--){
    //     solve();
    // }
    return 0;
}

Measured memory_bytes: 3616
using System;
using System.Collections.Generic;

namespace ConsoleApp1
{
    class ABC179D
    {
        // https://atcoder.jp/contests/abc179/tasks/abc179_d

        const int m = 998244353;
        static int[] a = new int[200001];
        static int[] sum = new int[200001];
        static int[] L = new int[10];
        static int[] R = new int[10];
        static int N = 0;

        static void Main(string[] args)
        {
            var NK = Console.ReadLine().Split();
            N = Int32.Parse(NK[0]);
            int K = Int32.Parse(NK[1]);

            for (int i = 0; i < K; i++)
            {
                var LR = Console.ReadLine().Split();
                L[i] = Int32.Parse(LR[0]);
                R[i] = Int32.Parse(LR[1]);
            }

            a[1] = 1;
            sum[1] = 1;
            for (int i = 2; i <= N; i++)
            {
                for (int j = 0; j < K; j++)
                {
                    int li = Math.Max(i - R[j] - 1, 0);
                    int ri = i - L[j];
                    if (ri < 0) continue;
                    a[i] = (a[i] + sum[ri] - sum[li]) % m;
                    a[i] = (a[i] + m) % m;
                }
                sum[i] = (sum[i - 1] + a[i]) % m;
            }

            Console.WriteLine(a[N]);
        }

    }
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    ll n, m;
    cin >> n >> m;
    ll a[n];
    rep(i, n) { cin >> a[i]; }
    ll sum = 0;
    rep(i, n) { sum += a[i]; }

    double temp = (double)sum / (4 * (double)m);

    ll num = 0;
    rep(i, n) {
        if (a[i] >= temp) {
            num++;
        }
    }

    if (num >= m) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}



Measured memory_bytes: 256
n = int(input())
def prime(n):
    p = []
    flag = [True] * (n - 1)
    for i in range(n - 1):
        if flag[i] == True:
            p.append(i + 2)
            num = i
            while num <= n - 2:
                flag[num] = False
                num += i + 2
    return p
p =prime(int(n ** 0.5 + 1))
p2 = {}
for i in p:
    while True:
        if n % i == 0:
            p2.setdefault(i, 0)
            p2[i] += 1
            n //= i
        else:
            break
if n != 1:
    p2[n] = 1
if not p2:
    print(0)
else:
    ans = 0
    for i in p2.values():
        num = 1
        while i >= num:
            ans += 1
            i -= num
            num += 1
    print(ans)

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


ll n;
ll chomo[100004]={-1};
ll pogo[100004]={-1};

ll dp(ll arr[100004],ll k)
{
	if(k==0)return 0;
	ll ans=0;
	if(pogo[k]!=-1)return pogo[k];
	for (int i = 0; i < n; ++i)
	{
		if(arr[i]>k)continue;
		if(dp(arr,k-arr[i])==0)ans=1;
	}
	return pogo[k]=ans;
}

int main()
{
    ////////////////////////////////////////////////////NOTHING SPECIAL DO NOT EDIT OR TOUCH //////////////////////////////////////////////////////////////////////  
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.in", "r", stdin);
    // for writing output to output.txt
    freopen("output.in", "w", stdout);
    #endif
     ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    ////////////////////////////////////////////////////LET'S START//////////////////////////////////////////////////////////////////////  
ll k;
cin>>n>>k;
memset(pogo,-1,100004*sizeof(pogo[0]));
ll arr[n];
for (int i = 0; i < n; ++i)
{
	cin>>arr[i];
	
}
if(dp(arr,k)==1)cout<<"First";
else cout<<"Second";


}

Measured memory_bytes: 8984
#include<iostream>
#include<cstdio>
using namespace std;
long long a[55],tot=0;
int n;
int main()
{
	cin>>n;
	for(int i=1;i<=n;++i) cin>>a[i],tot+=a[i];
	for(long long s=max(tot-10000,0LL);s<=tot+10000;++s)
	{
		long long tot=0;
		for(int i=1;i<=n;++i) tot+=(a[i]+s+1)/(n+1);
		if(tot<=s) return 0*printf("%lld\n",s);	
	}
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9


int main(){

	int a,b;
	cin>>a>>b;
	if((a*b)%2==0){
		cout<<"Even"<<endl;
	}else{
		cout<<"Odd"<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
def check(s):
    if len(s)%2 !=0:
        return False
    i=int(len(s)/2)
    s1=s[:i]
    s2=s[i:]
    return s1==s2

s = input()
while True:
    s = s[:len(s)-1]
    if check(s):
        print(len(s))
        break


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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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


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

    ll x; cin>>x;

    ll ans = lcm(360ll, x)/x;
    // if(360%x == 0){
    //     ans = 360/x;
    // }else{
    //     ll g = lcm(360, x)/x;
    // }
    cout<<ans<<endl;

    return 0;

}

Measured memory_bytes: 3628
use proconio::input;

fn main() {
    input! {
        x: u32,
        n: usize,
    }
    let mut p = Vec::<u32>::new();
    for _i in 1..n + 1 {
        input! {
          n: u32,
        }
        p.push(n)
    }
    let mut cnt = 0;
    loop {
        if cnt == 0 && !p.contains(&x) {
            println!("{}", x);
            break
        } else if !p.contains(&(x - cnt)) {
            println!("{}", x - cnt);
            break
        } else if !p.contains(&(x + cnt)) {
            println!("{}", x + cnt);
            break
        } else {}
        cnt+=1;
    }
}


Measured memory_bytes: 2160
n = int(input())
if n == 3:
    print(61)
    exit()
MOD = 10 ** 9 + 7
# dp[i][i-1][i-2][i-3][i-4]
dp = [[[[[0] * (4) for _ in range(4)] for i in range(4)] for i in range(4)] for i in range(n + 1)]

to = {0:"A", 1:"C", 2:"G", 3:"T"}
for i1 in range(4):
    for i2 in range(4):
        for i3 in range(4):
            for i4 in range(4):
                if "AGC" in to[i1] + to[i2] + to[i3] + to[i4]:
                    continue
                if "ACG" in to[i1] + to[i2] + to[i3] + to[i4]:
                    continue 
                if "GAC" in to[i1] + to[i2] + to[i3] + to[i4]:
                    continue 
                if "AAGC" in to[i1] + to[i2] + to[i3] + to[i4]:
                    continue 
                if "ACGC" in to[i1] + to[i2] + to[i3] + to[i4]:
                    continue 
                if "AGGC" in to[i1] + to[i2] + to[i3] + to[i4]:
                    continue 
                if "ATGC" in to[i1] + to[i2] + to[i3] + to[i4]:
                    continue 
                if "AGAC" in to[i1] + to[i2] + to[i3] + to[i4]:
                    continue 
                if "AGCC" in to[i1] + to[i2] + to[i3] + to[i4]:
                    continue 
                if "AGGC" in to[i1] + to[i2] + to[i3] + to[i4]:
                    continue 
                if "AGTC" in to[i1] + to[i2] + to[i3] + to[i4]:
                    continue 
                dp[4][i1][i2][i3][i4] = 1

for i in range(4, n):
    for i1 in range(4):
        for i2 in range(4):
            for i3 in range(4):
                for i4 in range(4):
                    if "AGC" in to[i1] + to[i2] + to[i3] + to[i4]:
                        continue
                    if "ACG" in to[i1] + to[i2] + to[i3] + to[i4]:
                        continue 
                    if "GAC" in to[i1] + to[i2] + to[i3] + to[i4]:
                        continue 
                    if "AAGC" in to[i1] + to[i2] + to[i3] + to[i4]:
                        continue 
                    if "ACGC" in to[i1] + to[i2] + to[i3] + to[i4]:
                        continue 
                    if "AGGC" in to[i1] + to[i2] + to[i3] + to[i4]:
                        continue 
                    if "ATGC" in to[i1] + to[i2] + to[i3] + to[i4]:
                        continue 
                    if "AGAC" in to[i1] + to[i2] + to[i3] + to[i4]:
                        continue 
                    if "AGCC" in to[i1] + to[i2] + to[i3] + to[i4]:
                        continue 
                    if "AGGC" in to[i1] + to[i2] + to[i3] + to[i4]:
                        continue 
                    if "AGTC" in to[i1] + to[i2] + to[i3] + to[i4]:
                        continue 
                    for j in range(4):
                        dp[i + 1][i1][i2][i3][i4] += dp[i][i2][i3][i4][j]
                        dp[i + 1][i1][i2][i3][i4] %= MOD

ans = 0
for i1 in range(4):
    for i2 in range(4):
        for i3 in range(4):
            for i4 in range(4):
                ans += dp[-1][i1][i2][i3][i4]
                ans %= MOD
print(ans % MOD)

Measured memory_bytes: 44524
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    if (isupper(s[0]))
    {
        cout<<"A";
    }
    if(islower(s[0]))
    {
        cout<<"a";
    }
    
    
    return 0;
}

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

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

string mp[25];
int h,w;
int dist[25][25];
int ans=0;

void chk(int sy, int sx) {
  if(mp[sy][sx]=='#')return;

  for(int i=0;i<25;i++)
    for(int j=0;j<25;j++)
      dist[i][j]=-1;
  dist[sy][sx]=0;

  queue<pair<int, int> > q;
  q.push({sy, sx});
  while(!q.empty()){
    auto v = q.front();q.pop();
    int y = v.first;
    int x = v.second;
    for(int i=0;i<4;i++){
      int ny = y + dy[i];
      int nx = x + dx[i];
      if(0<=ny&&ny<h&&0<=nx&&nx<w && mp[ny][nx]=='.' && dist[ny][nx]==-1){
        dist[ny][nx] = dist[y][x]+1;
        ans = max(ans, dist[ny][nx]);
        q.push({ny, nx});
      }
    }
  }
}

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  cin>>h>>w;
  for(int y=0;y<h;y++)cin>>mp[y];

  for(int y=0;y<h;y++){
    for(int x=0;x<w;x++){
      chk(y, x);
    }
  }

  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
#define vaibhavv06               \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(0);
#define endl '\n'
#define int long long
#define MM(a,b) memset(a,b,sizeof(a))
const ll MOD = 1000000007;
using namespace std;
 
int32_t main(){
    vaibhavv06;
	int n,k; cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++) cin>>arr[i];
    int dp[n]={0};
    dp[1]=abs(arr[1]-arr[0]);
    for(int i=1;i<n;i++){
        dp[i]=dp[i-1]+abs(arr[i-1]-arr[i]);
        for(int j=1;j<=k;j++){
            if(i-j>=0){
                dp[i]=min(dp[i],dp[i-j]+abs(arr[i-j]-arr[i]));
            }
        }
    }
    cout<<dp[n-1]<<endl;
}

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

//#define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいいです。
  return is;
}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : " " );
  }
  return os;
}
/* }}} */

signed main() 
{
  int a,b;
  cin >> a >> b;
  string s;
  cin >> s;
  if(s[a]!='-')
  {
    print("No");
    return 0;
  }
  rep(i,a)
    if(s[i]=='-')
    {
      print("No");
      return 0;
    }
  REPS(i,a+1,a+b+1)
    if(s[i]=='-')
    {
      print("No");
      return 0;
    }
  print("Yes");
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	int count = 1;
	vector<int> a(n);
	for (auto&& ai : a) cin >> ai;
	
	vector<bool> check(n, false);
	for (int i = 0; a[i] != 2; i = a[i]-1)
	{
		if (check[i])
		{
			count = -1;
			break;
		}
		count++;
		check[i] = true;
	}

	cout << count << endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

const long long M = 1000000007;

long long fact(long long n){
    long long ret = 1;
    range(i,1, n + 1){
        ret *= i;
        ret %= M;
    }
    return ret;
}

int main(){
    long long n, m;
    cin >> n >> m;
    if(abs(n - m) > 1){
        cout << 0 << endl;
        return 0;
    }

    if(n == m){
        cout << fact(n) * fact(m) % M * 2 % M << endl;
    }else{
        cout << fact(n) * fact(m) % M << endl;
    }
}


Measured memory_bytes: 256
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back
#define N 1000000007
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.x<<','<< P.y<<')';}
template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}


signed main()
{
	speed
	int h;cin>>h;
	int tot=1;
	int fin=0;
	while(h>0)
	{
		h/=2;
		fin+=tot;
		tot*=2;
	}
	cout<<fin<<"\n";
}

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

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

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;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

int main()
{
	i64 R;
	cin >> R;

	cout << (R<1200 ? "ABC" : R<2800 ? "ARC" : "AGC") << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=10000+10;
int a[maxn],b[maxn],c[maxn];
int main(){
	int i,j,k,m,n;
	cin>>n;
	int sum=0;
	for(register int i=1;i<=n;i++)cin>>a[i];
	for(register int i=1;i<=n;i++){cin>>b[i];sum+=b[i];}
	for(register int i=1;i<=n-1;i++)cin>>c[i];
	for(register int i=1;i<=n+1;i++)
		if(a[i]==a[i+1]-1)sum+=c[a[i]];
	cout<<sum<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  int K;
  cin >> S >> K;
  for(int i=0;i<K;i++){
    if(S.at(i)!='1'){
      cout << S.at(i) << endl;
      return 0;}
  }
  cout << 1 << endl;
}

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

int main(void){
    // Your code here!
    int n;
    cin>>n;
    
    int pr[n][2];
    
    
    for(int i=0;i<n;i++){
        cin>>pr[i][0]>>pr[i][1];
        //cout<<pr[i][0]<<endl;
    }
    
    
    double sum=0;
    
    for(int i=0; i<n-1;i++){
        for(int j=i+1;j<n;j++){
            double x = pow(pr[i][0] - pr[j][0] ,2);
            double y = pow(pr[i][1] - pr[j][1] ,2);
            double len = sqrt(x+y)*2/n;

            sum+=len;
        }
    }
    
    printf("%0.10f", sum);
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>    
#include <cstring>
#include <array>
#include <cctype>
#include <string.h>
#include <vector>
#include <limits.h>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cassert>
#include <algorithm>
#include <functional>
#include <sstream>
#include <iomanip>
#include <cstdlib>
#include <stdio.h>
#include <bitset>
using namespace std;
#define PI 3.14159265359
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n) FOR(i,0,n)
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const int INF = 1<<29;
typedef long long ll;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int n;
int dp[100001];

int main(){
	ios_base::sync_with_stdio(false); //Fast I/O
	cin.tie(NULL);
	//freopen("in.txt","r",stdin);
	//freopen("output.txt","w",stdout);	

	cin >> n;

	for(int i=1;i<=n;i++){
		dp[i]=dp[i-1]+1;
		for(int j=6;j<=i;j*=6)
			dp[i]=min(dp[i],dp[i-j]+1);
		for(int j=9;j<=i;j*=9)
			dp[i]=min(dp[i],dp[i-j]+1);
	}
	cout << dp[n] << endl;

	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>

using   namespace std;

int main(){
    int R,G,B,N,count=0;
    scanf("%d %d %d %d",&R,&G,&B,&N);

    for(int i=N/R;i>=0;i--){
        for(int j=(N-i*R)/G;j>=0;j--){
            if((N-i*R-j*G)%B==0)
                count++;
        }
    }
    cout <<count << endl;
}

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

// Created by White Knife on 15/04/20.
// doot diddly donger cuckerino Hahahahahah

#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#pragma GCC target("popcnt")


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;

// @formatter:off
#define F               first
#define S               second
#define all(x)          (x).begin(), (x).end()
#define sz(x)           int((x).size())
#define sim             template<typename T
#define ris             return *this
#define dor             > debug & operator <<
#define eni(x)          sim > typename enable_if<sizeof dud<T>(0) x 1, debug&>::type operator<<(T i)
sim> struct rge { T b, e; };
sim> rge<T> rang(T i, T j) { return rge<T>{i, j}; }
sim> auto dud(T *x) -> decltype(cerr << *x, 0);
sim> char dud(...);
struct debug {
#ifdef LOCAL
  ~debug() { cerr << endl; }
  eni(!=) { cerr << boolalpha << i; ris; }
  eni(==) { ris << rang(all(i)); }
  sim, typename U dor(pair<U, T> d) { ris << "(" << d.first << ", " << d.second << ")"; }
  sim dor(rge<T> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
  sim dor(const T&) { ris; }
#endif
};
#define pr(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ull = unsigned long long;
using ld = long double;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vb = vector<bool>;

using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
template <typename T> using ordered_set = tree<T, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;

const ld PI = acos(-1);

template<typename T> inline T mini(T& x, T y) { return x = min(x, y); }
template<typename T> inline T maxi(T& x, T y) { return x = max(x, y); }
template<typename T> int sgn(T val) { return (T(0) < val) - (val < T(0));}
template<typename T> T rand(T x, T y) { return rand() % (y - x + 1) + x; }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
template <typename T> T gcd(T x, T y) { return (y == T(0)) ? x : gcd(y, x % y); }
// @formatter:on


class ATakahashikunTheStrider {
public:
  
  void solve(std::istream& cin, std::ostream& cout) {
    int x;
    cin >> x;
    cout << (360 / gcd(360, x)) << '\n';
  }
};

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
	ATakahashikunTheStrider solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
using namespace std;
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<60; // 十分大きな値

int main() {
    // 入力
    int N;
    cin >> N;
    vector<long long> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];

    // 累積和を求める
    vector<long long> s(N+1, 0);
    for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i];

    // DP 初期化
    vector<vector<long long> > dp(N+1, vector<long long>(N+1, INF));

    // DP 初期条件
    for (int i = 0; i < N; ++i) dp[i][i+1] = 0;

    // DP
    // between: j - i
    for (int between = 1; between <= N; ++between) {
        for (int i = 0; i < N && i + between <= N; ++i) {
            int j = i + between;
            long long addcost = s[j] - s[i];
            for (int k = i+1; k <= j-1; ++k) {
                chmin(dp[i][j], dp[i][k] + dp[k][j] + addcost);
            }
        }
    }

    // 結果出力
    cout << dp[0][N] << endl;
}


Measured memory_bytes: 1536
//#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cstring>
#include <cassert>

using namespace std;

#ifdef LOCAL_DEBUG
#include <local_debug.h>
#define DEBUG(x...) cerr << __LINE__ << ": " << #x << " = "; DBG::_print(x)
#else
#define DEBUG(x...)
#endif

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;



int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   int N;
   llong K;
   cin >> N >> K;

   VI A(N+1);
   FOR(i, 1, N)
      cin >> A[i];

   vector<int> seen(N+1, -1);
   int cycle_start = -1, period = 0;
   for (int t = 0, x = 1; ; ++t) {
      if (seen[x] >= 0) {
         cycle_start = x;
         period = t - seen[x];
         break;
      }
      seen[x] = t;
      x = A[x];
   }
   DEBUG(cycle_start, period);

   if (seen[cycle_start] > K) {
      int x = 1;
      for (int t = 0; t < K; ++t)
         x = A[x];
      cout << x << '\n';
   }
   else {
      K -= seen[cycle_start];
      K %= period;
      int x = cycle_start;
      for (int t = 0; t < K; ++t)
         x = A[x];
      cout << x << '\n';
   }

   return 0;
}


Measured memory_bytes: 4792
////////////////いろいろあるよ//////////////////////////////////
//include,namespace
 #include<bits/stdc++.h>
 #include<iostream>
 #include<bitset>
 using namespace std;
//REPmacro
 #define all(x) (x).begin(),(x).end()             //ソート
 #define FOR(i,x,n)for(int i=(x);i<(n);i++)
 #define FOR_R(i,x,n) for(int i=(n-1);i>=(x);i--)
 #define REP(i, n) FOR(i, 0, n)
 #define REP_R(i, n) FOR_R(i, 0, n)
//long long(define)
 using ll = long long;
 typedef long long ll;
 typedef long long int64;
 typedef long long lint;
 typedef long long lli;
////////////////いろいろあるよ//////////////////////////////////

int main(){
	int a,b;
	cin >>a >>b;
	vector<long long> data(a);
	REP(i,a){
		cin >> data[i];
      
	}
	sort(data.begin(),data.end());
	ll sum=0;
	for(int i=(a-b-1);i>=0;i--){sum+=data[i];
                        }
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1792
L, R = [int(i) for i in(input().split(' '))]
minn=2019
if R-L+1>2019:
  print(0)
  exit()
for i in range(L,R):
    for j in range(i+1,R+1):
        mo = i*j
        amari = mo%2019
        minn = min(amari,minn)
        if minn==0:
          break
print(minn)

Measured memory_bytes: 3064
#include <stdio.h>

int main()
{
        int n, i, cnt = 0;

        for ( ; ; )
        {
                scanf( "%d", &n );
                if ( n == 0 )
                        break;
                for ( i = 5 ; i <= n ; i *= 5 )
                {
                        cnt += n/i;
                }
                fprintf( stdout, "%d\n", cnt );
                cnt = 0;
        }
        return 0;
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;++i)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;

int main(){
    int n,b;cin>>n;
    int MX = 0;
    vector<int>arr(n,0);
    fol(i,n){
        cin>>arr[i];
        MX = max(MX,arr[i]);
    }
    sort(arr.begin(),arr.end());
    int NX = MX/2;
    int ans = 0;
    fol(i,n){
        if(arr[i]!=MX){
            if(arr[i]>NX){b=MX-arr[i];}
            else b = arr[i];
            if(b>ans) ans = arr[i];
        }
    }
    printf("%d %d\n",MX,ans);
    return 0;
}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)


class UnionFind():
    def __init__(self, n):
        self.par = [-1] * n

    def root(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.root(self.par[x])  # contraction
            return self.par[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x != y:
            if self.par[x] > self.par[y]:  # merge technique
                x, y = y, x
            self.par[x] += self.par[y]
            self.par[y] = x

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

    def size(self, x):
        return -self.par[self.root(x)]


n, q = map(int, input().split())
uf = UnionFind(n)
for _ in range(q):
    t, u, v = map(int, input().split())
    if t == 0:
        # add
        uf.unite(u, v)
    else:
        print(1 if uf.same(u, v) else 0)


Measured memory_bytes: 11880
def main():
    N, M = list(map(int, input().split()))
    A = list(map(int, input().split()))

    A.sort()

    if N >= M:
        print(0)   
        return

    D = M - N

    B = []
    for i in range(1, len(A)):
        B.append(A[i] - A[i-1])

    B.sort()

    print(sum(B[:D]))

main()

Measured memory_bytes: 13960
import java.util.Scanner;


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

			int i;
			int j;
			int k;

			int n = sc.nextInt();
			int m = sc.nextInt();
			int l = sc.nextInt();

			long A[][] = new long[n][m];
			long B[][] = new long[m][l];
			long C[][] = new long[n][l];

			for(i = 0; i < n; i++) {
				for(j = 0; j < m; j++) {
					int a_ij = sc.nextInt();
					A[i][j] = a_ij;
				}
			}

			for(i = 0; i < m; i++) {
				for(j = 0; j < l; j++) {
					int b_ij = sc.nextInt();
					B[i][j] = b_ij;
				}
			}

			for(i = 0; i < n; i++) {
				for(j = 0; j < l; j++) {
					for(k = 0; k < m; k++) {
						C[i][j] = C[i][j] + A[i][k] * B[k][j];
					}
					if(j == l - 1) {
						System.out.println(C[i][j]);
					} else {
						System.out.print(C[i][j] + " ");
					}
				}
			}

	}
}

Measured memory_bytes: 53340