akhauriyash/Code-Regression huggingface dataset:
fn main() {
    let n: u32 = read();
    let mut v: Vec<u32> = Vec::new();
    for _ in 0..n {
        let n: u32 = read();
        v.push(n);
    }
    v.sort();
    v.dedup();
    println!("{}", v.len());
}

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

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  vector<int> rate(9, 0);
  int a;
  rep(i, N) {
    cin >> a;
    a = std::min(a, 3200);
    rate[a / 400]++;
  }

  int colors = 0;
  rep(i, 8) {
    if (rate[i] > 0) {
      colors++;
    }
  }

  int mn = std::max(colors, 1);
  int mx = colors + rate[8];

  cout << mn << " " << mx << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
int a[10],b,i,j,c=0,d=0,e=0;
scanf("%d\n",&b);
for(j=0;j<b;j++){
for(i=0;i<10;i++){
scanf("%d ",&a[i]);
}
scanf("\n");
for(i=0;i<10;i++){
if(a[i]>c){
c=a[i];
e++;
}
else if(a[i]>d){
d=a[i];
e++;
}
}
if(e==10){
printf("YES\n");
}
else{
printf("NO\n");
}
c=0,d=0,e=0;
}
return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define vl          vector<ll>
#define vi          vector<int>
#define pi          pair<int,int>
#define pl          pair<ll,ll>
#define all(a)      a.begin(),a.end()
#define mem(a,x)    memset(a,x,sizeof(a))
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define endl 		"\n"
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define fast_io     std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define trace(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1) {std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " : " << arg1;
	ZZ(comma, args...);
}
ll xoruptoK(ll k) {
	if (k % 2 == 0) {
		ll d = k / 2;
		if (d % 2 == 0)return k;
		else return k ^ 1ll;
	}
	else {
		ll d = (k + 1) / 2;
		if (d % 2 == 0)return 0;
		else return 1;
	}
}
void solve() {
	ll a, b;
	cin >> a >> b;
	// trace(xoruptoK(a - 1), xoruptoK(b))
	a = max(a - 1, 0ll);
	cout << (xoruptoK(b)^xoruptoK(a));

}
int main() {
	fast_io;
	int t = 1;
	// cin>>t;
	while (t--) {
		solve();
	}
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 3644
import java.io.PrintWriter
import kotlin.math.pow

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun Int.pow(n: Int) = pow(n.toLong())
fun Int.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()
fun Long.pow(n: Int) = pow(n.toLong())
fun Long.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (A, B, C) = nextIntList()
    for (i in 1..100) {
        if (A * i % B == C) {
            println("YES")
            return
        }
    }
    println("NO")
}

Measured memory_bytes: 36592
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
//typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){int i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N,M;
  cin>>N>>M;
  vector<vector<int>> edge(N);
  for(int i=0;i<M;i++){
    int u,v;
    cin>>u>>v;
    u--; v--;
    edge[u].push_back(v);
    edge[v].push_back(u);
  }
  vector<int> col(N,0);
  function<bool(int)> dfs=
    [&](int u){
      bool ret=true;
      for(auto &v:edge[u]){
        if(col[v]==0){col[v]-=col[u]; ret&=dfs(v);}
        else{ret&=col[u]+col[v]==0;}
      }
      return ret;
    };
  ll P=0,B=0,O=0;
  for(int i=0;i<N;i++){
    if(col[i]!=0){continue;}
    col[i]=1;
    if(edge[i].empty()){P++;}
    else if(dfs(i)){B++;}
    else{O++;}
  }
  ll ans=P*N+P*(N-P)+O*(B+O)+B*O+B*B*2;
  cout<<ans<<endl;


  return 0;
}


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

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

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

bool choose(int a , int b , int c , int d){
    if(a * d >= b * c)   return true;
    return false;
}

int n , m , s;
int a[MAXX];

int main()
{
    _FastIO;
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        s += a[i];
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(choose(a[i] , s , 1 , 4 * m)){
            ans++;
        }
    }
    if(ans >= m){
        cout << "Yes" << endl;
    }
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
table = []
for _ in range(n):
    x, l = map(int, input().split())
    table.append([x-l, x+l])

sorted_table = sorted(table, key=lambda x: x[1])
# print(sorted_table)
left = sorted_table[0][1]
ans = n
for i in range(1, n):
    if left <= sorted_table[i][0]:
        left = sorted_table[i][1]
    else:
        ans -= 1

print(ans)

Measured memory_bytes: 26244
#include <stdio.h>


int main(void){
	int n;
	int max;
	
	scanf("%d",&n);
	
	int r[n];
	for(int i =0 ;i < n;i++){
		scanf("%d",&r[i]);
	}
	int min = r[0];
	max = r[1]-r[0];
	for(int i = 1;i<n;i++){
		max = (max > r[i]-min) ? max : r[i]-min;
		min = (min < r[i]) ? min : r[i];
	}
	printf("%d\n",max);
	return 0;
}



Measured memory_bytes: 2548
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

int main()
{
    string s;
    cin >> s;

    int ans = 0;
    for(int i = 0; i < s.size(); ++i){
        if(s[i] == 'a') ans |= 0x01;
        if(s[i] == 'b') ans |= 0x02;
        if(s[i] == 'c') ans |= 0x04;
    }
    if(ans == 0x07) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
    ll x, n;    cin >> x >> n;
 
    map<ll, ll> key;
    REP(i, n){
        ll p;   cin >> p;
        key[p] += 1;
    }
    ll res=0;
    FOR(i, -1000, 1001){
        if(key.count(i)) continue;
        if(abs(i-x)<abs(res-x)) res = i;
    }
    cout << res << endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);

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

constexpr int MOD = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double pi=3.141592653589793;

template< typename S, typename T >
inline void chmax(S &a, const T &b) { if(a < b) a = b; }
 
template< typename S, typename T >
inline void chmin(S &a, const T &b) { if(a > b) a = b; }
 

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

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
ll modinv(ll a, ll m) {
	if(m==0)return (ll)1;
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


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

int main() {
ll n;
cin>>n;
string ss;
cin>>ss;
string s="";

rrep(i,n){
	s+=ss[i];
}
for(int i=n;i<=2*n-1;i++){
	s+=ss[3*n-1-i];
}
ll ans=0;

for(ll bit=0;bit<(1<<n);bit++){
int nowr=2*n-1;
string sr="";
string sb="";
for(int j=0;j<=n-1;j++){
if(bit & (ll)1<<j) sr+=s[j];
else sb+=s[j];
}
ll dp[n+1][n+1];
rrep(i,n+1){
	rrep(j,n+1){
dp[i][j]=0;
if(i==0 && j==0){dp[i][j]=1; continue;}
if(i>sr.size()||j>sb.size())continue;
if(i){
if(sr[i-1]==s[n-1+i+j])dp[i][j]+=dp[i-1][j];}
if(j){
if(sb[j-1]==s[n-1+i+j])dp[i][j]+=dp[i][j-1];}
if(i+j==n)ans+=dp[i][j];
}
	}
}

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




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

int main() {
    int n;
    cin >> n;
    int64_t sum = 0;
    for (int i = 1; i <= n; i++) {
        if(i % 3 != 0 && i % 5 != 0)
            sum += i;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3596
# ライブラリ改変テスト
class Combi():
    def __init__(self, N, mod):
        self.power = [1 for _ in range(N+1)]
        self.rev = [1 for _ in range(N+1)]
        self.mod = mod
        for i in range(2, N+1):
            self.power[i] = (self.power[i-1]*i) % self.mod
        self.rev[N] = pow(self.power[N], self.mod-2, self.mod)
        for j in range(N, 0, -1):
            self.rev[j-1] = (self.rev[j]*j) % self.mod

    def com(self, K, R):
        if K < R:
            return 0
        else:
            return ((self.power[K])*(self.rev[K-R])*(self.rev[R])) % self.mod

    def pom(self, K, R):
        if K < R:
            return 0
        else:
            return (self.power[K])*(self.rev[K-R]) % self.mod


N, M = map(int, input().split())
mod = 10**9+7
c = Combi(10**6, mod)
ans = c.pom(M, N)**2 % mod
for k in range(1, N+1):
    s = (-1)**((k-1) % 2)
    t = c.com(N, k)
    u = (c.pom(M-k, N-k)**2) % mod
    v = c.pom(M, k) % mod
    ans -= s*t*u*v
print(ans % mod)

Measured memory_bytes: 208372
def f(x1, x2):
  W=[[i,1000] for i in range(n)]
  W[x1]=[x1,0]
  W[x2]=[x2,2000]
  G = range(n)
  while 1:
    A = sorted([W[e] for e in G], key=lambda x: x[1])
    p1, w1 = A[0]
    G.remove(p1)
    if p1==x2: break
    for p2, w2 in A[1:]:
      way=(p1, p2)
      if way in cost:
        W[p2] = [p2, min([w2, w1 + cost[way]])]
  return w1

def g(): return map(int, raw_input().split(","))

n=int(raw_input())
m=int(raw_input())
cost={}
for _ in [0]*m:
  a,b,c,d=g()
  a-=1
  b-=1
  cost[(a,b)]=c
  cost[(b,a)]=d
x1,x2,y1,y2=g()
x1-=1
x2-=1
print y1-y2-f(x1,x2)-f(x2,x1)

Measured memory_bytes: 4288
/*
  A - Addition and Subtraction Easy
  <http://abc050.contest.atcoder.jp/tasks/abc050_a>
*/

#include <stdio.h>

int main(int argc, char const *argv[]) {

  int A, B;
  char op;

  scanf("%d %c %d", &A, &op, &B);
  if( op == '+' ){
    printf("%d", A + B);
  }else{
    printf("%d", A - B);
  }

  return 0;
}


Measured memory_bytes: 128
// Ashish Agarwal @ashuag007
// references: geeksforgeeks

#include<bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
typedef long long ll;

int main() 
{ 
	ll n,p,ans=1,i,count=0,z;
	cin>>n>>p; 
	vector<pair<ll,ll>>v;
  
    while (!(p % 2))
    { 
        p >>= 1;
        count++; 
    } 
  
    if (count) 
    v.push_back(make_pair(2,count)); 
  
    for ( i = 3; i <= sqrt(p); i += 2) 
    { 
        count = 0; 
        while (p % i == 0)
        { 
            count++; 
            p = p / i; 
        } 
        if (count) 
            v.push_back(make_pair(i,count)); 
    } 
  
    
    if (p > 2) 
        v.push_back(make_pair(p,1)); 
	for( i=0;i<v.size();i++)
	{
	    z=v[i].second/n;
	    ans=ans*pow(v[i].first,z);
	}
	cout<<ans<<endl;
	return 0; 
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
int main(){
    string s,t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    vector<vector<ll>> dp(n + 1, vector<ll>(m + 1, 0));
    dp[0][0] = 1;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < m; ++j){
            if(!dp[i][j])continue;

            dp[i+1][j] += dp[i][j];
            dp[i+1][j] %= MOD;
            if(s[i] == t[j]){
                dp[i+1][j+1] += dp[i][j];
                dp[i+1][j+1] %= MOD;
            }
        }
        dp[i+1][m] += dp[i][m];
        dp[i+1][m] %= MOD;
    }
    cout << dp[n][m] % MOD << endl;
}



Measured memory_bytes: 10776
import sys
readline = sys.stdin.readline

N = int(readline())
A = list(map(int,readline().split()))

# (1).左からN + 1～2N個のデータについて、iがいくつあるかのdictionary
# (2).左から2N個のデータのうち、大きい順にN個のデータの和
# (3).左から2N個のデータのうち、小さい順にN個のデータを、大きい順にheapqに入れたもの
# (4).右からN個のデータの和
# (5).右からN個のデータを、大きい順にheapqに入れたもの

# 上記を用いて、iを2N～N+1までずらし、そのたびに
# A[i]の数を(1)から減らす
# 次の数を(3)から取り出す。その数が(1)に存在していなければ何もしない
# 取り出した数を(2)に足す
# (4)にA[i]を足す
# (5)から一つ取り出し、(4)から引く
# (2) - (4)の最大値を更新

from collections import defaultdict

sortA = sorted(A[:2 * N])
smallA = sortA[:N]
small_dic = defaultdict(int)
for i in range(len(smallA)):
  small_dic[smallA[i]] += 1
largeA = sortA[N:]
large_dic = defaultdict(int)
for i in range(len(largeA)):
  large_dic[largeA[i]] += 1

leftsum = sum(sortA[N:])

import heapq as hq
leftq = list(map(lambda x:-x,smallA))
hq.heapify(leftq)

rightq = A[2 * N:]
rightsum = sum(rightq)
rightq = list(map(lambda x:-x,rightq))
hq.heapify(rightq)

ans = leftsum - rightsum

#print("leftsum",leftsum,"rightsum",rightsum,"ans",ans)
for i in range(2 * N - 1, N - 1, -1):
  #print("i",i,"A[i]",A[i])
  if large_dic[A[i]] > 0: # 除外対象である場合
    large_dic[A[i]] -= 1
    leftsum -= A[i]
    while True:
      move = -hq.heappop(leftq)
      if small_dic[move] > 0:
        small_dic[move] -= 1
        break
    leftsum += move
    large_dic[move] += 1
    #print("leftsumから",A[i],"を除外",leftsum)
  else:
    small_dic[A[i]] -= 1
    
  hq.heappush(rightq, -A[i])
  rem = -hq.heappop(rightq)
  rightsum += A[i]
  rightsum -= rem
  
  if ans < leftsum - rightsum:
    ans = leftsum - rightsum
  #print("leftsum",leftsum,"rightsum",rightsum,"ans",ans)
    
print(ans)


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

A=list(map(int,input().split()))

d=10**9+7

c=0

for i in range(N-1):
    for j in range(i+1,N):
        if A[i]>A[j]:
            c+=1
c=c%d

cc=0

for i in range(N):
    for j in range(N):
        if A[i]>A[j]:
            cc+=1

cc=cc%d

e=(K*(K-1)//2)%d

print(int(((c*K)%d+(cc*e)%d)%d))

Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 2000005;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[SIZE], finv[SIZE], inv[SIZE];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;
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 mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}

double len(int a, int b, int c, int d) {
	return (double)sqrt((a - c) * (a - c) + (b - d) * (b - d));
}

ll a, b, dp[105][100005], ans;
vector<pair<ll, ll>>v;

int main() {
	cin >> a >> b;
	v.resize(a);

	for (int i = 0; i < a; ++i) {
		cin >> v[i].first >> v[i].second;
	}

	memset(dp, 9999, sizeof(dp));
	dp[0][0] = 0;

	for (int i = 0; i < a; ++i) {
		for (int j = 0; j <= 100000; ++j) {
			if (j < v[i].second) { dp[i + 1][j] = dp[i][j]; }
			else { dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i].second] + v[i].first); }
		}
	}

	for (int i = 0; i <= 100000; ++i) {
		if (dp[a][i] <= b) { ans = i; }
	}

	cout << ans << endl;
}

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

int main(void){
    int N, M;
    ll K;
    cin >> N >> M >> K;
    vector<ll> A(N + 1, 0), B(M + 1, 0);
    for(int i = 1; i <= N; i++){
        cin >> A[i];
        A[i] += A[i - 1];
    }
    for(int i = 1; i <= M; i++){
        cin >> B[i];
        B[i] += B[i - 1];
    }
    ll ans = 0;
    int j = M;
    for(int i = 0; i <= N; i++){
        while(j >= 0 && A[i] + B[j] > K) j--;
        if(j >= 0) ans = max(ans, (ll)(i + j));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6424
#include <stdio.h>
 
int main(){
	
	int N,i,siro=0;
	char S[200010];
	
	scanf("%d",&N);
	scanf("%s",S);
	
	
	for(i=0;i<N;i++){
		if(S[i]=='.'){
			siro++;
		}
	}
	int ans=siro;
	
	for(i=0;i<N;i++){
		if(S[i]=='.'){
			siro--;
		}else {
			siro++;
		}
	
	
	if(siro<ans){
		ans=siro;
	}
	}
	
	
	printf("\n%d\n\n",ans);
	
	
	
	return 0;
}

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

vector<int> to[200005];
int check[200005];
queue<int> q;
int S,T;

void kkp(int v){
    for(int u : to[v]){
        for(int w : to[u]){
            for(int x : to[w]){
                if(check[x]==0){
                    q.push(x);
                    check[x]++;
                }
                if(check[T-1]>0)break;
            }
            if(check[T-1]>0)break;
            }
        if(check[T-1]>0)break;
    }
}

int main(){
    int N,M;
    cin >> N >> M;
    int i,j,u,v;
    for(i=0;i<M;i++){
        cin >> u >> v;
        to[u-1].push_back(v-1);
    }
    cin >> S >> T;
    kkp(S-1);
    if(check[T-1]>0)cout << 1 << endl;
    else{
        int flag=2;
        int tmp=q.size();
        int count=0;
        while(!q.empty()){
            kkp(q.front());
            q.pop();
            count++;
            if(check[T-1]>0)break;
            if(tmp==count){
                flag++;
                count=0;
                tmp=q.size();
            }
        }
        if(check[T-1]>0)cout << flag << endl;
        else cout << -1 << endl;
}}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll unsigned long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
 
ll power(ll a, ll b){//a^b
    ll res=1;
    while(b>0){
        if(b&1){res=(res*a);b--;}
        a=(a*a);
        b>>=1;
    }
    return res;
}
 
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n;
	cin>>n;
	string s="";
	while(n>0){
		ll t=n%26;
		if(t==0)
			s='z'+s;
		else
			s=(char)('a'+t-1)+s;
		n=n/26;
		if(t==0)
			n--;
	}
	cout<<s<<"\n";
}

Measured memory_bytes: 3652
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"

int memo[22][22][22][22];


int getnum(const vector<vector<int>>&field,const int l,const int r,const int u,const int d) {
	if (memo[l][r][u][d] != -1)return memo[l][r][u][d];
	if (l == r)return 0;
	else if (u == d)return 0;
	else {
		assert(l < r);
		assert(u < d);
		set<int>nums;
		for (int x = l; x < r; ++x) {
			for (int y = u; y < d; ++y) {
				if (field[y][x])continue;
				else {
					int anum = 0;
					anum ^= getnum(field, l, x, u, y);
					anum ^= getnum(field, x + 1, r, u, y);
					anum ^= getnum(field, l, x, y + 1, d);
					anum ^= getnum(field, x + 1, r, y + 1, d);
					nums.emplace(anum);
				}
			}
		}
		int ans = 0;
		auto it = nums.begin();
		while (it != nums.end()) {
			if (ans == *it) {
				ans++;
				it++;
			}
			else {
				break;
			}
		}
		return memo[l][r][u][d]=ans;
	}
}

int main() {
	int H, W; cin >> H >> W;
	for (int i = 0; i < 22; ++i) {
		for (size_t j = 0; j < 22; j++)
		{
			for (size_t k = 0; k < 22; k++)
			{
				for (size_t l = 0; l < 22; l++)
				{
					memo[i][j][k][l] = -1;
				}
			}
		}
	}
	vector<vector<int>>field(H, vector<int>(W));
	for (int i = 0; i < H; ++i) {
		string st; cin >> st;
		for (int j = 0; j < W; ++j) {
			if (st[j] == '.') {
				field[i][j] = false;
			}
			else {
				field[i][j] = true;
			}
		}
	}
	int ans = getnum(field,0, W, 0, H);
	if (ans) {
		cout << "First" << endl;
	}
	else {
		cout << "Second" << endl;
	}
	return 0;

}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<ll, ll> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

ll bpow(ll x,ll n,ll m=MD){ll r=1LL;for(;n>0;n>>=1,x=x*x%m) if(n&1) r=r*x%m; return r;}
ll nCk_mod(ll n, ll k, int mod=MD) {
	if(k > n || n <0 || k <0) return 0;
	ll ret = 1, rt2 = 1;
	for(ll i=n-k+1; i<n+1; i++) ret = ( ret * i) % mod;
	for(ll i=1; i<k+1; i++) rt2 = ( rt2 * i) % mod;
	return ( ret * bpow( rt2, mod-2, mod)) % mod;
}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll n, a, b;
	cin >>n >>a >>b;
	ll ans = bpow(2, n) +MD -1;
	ans += MD - nCk_mod(n, a);
	ans += MD - nCk_mod(n, b);
	cout << ans %MD <<"\n";
	return 0;
}


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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    ll N;
    cin >> N;
    vector<vector<ll>> A(N,vector<ll>(2));

    rep(i,N) {
        ll x,y;
        cin >> x >> y;
        A[i][0] = x;
        A[i][1] = y;
    }

    set<P> S;
    rep(i,N-1) {
        for (int j=i+1;j<N; j++) {
            int p = A[j][0]-A[i][0];
            int q = A[j][1]-A[i][1];
            P tmp = make_pair(p,q);
            S.insert(tmp);
            tmp = make_pair(-p,-q);
            S.insert(tmp);
        }
    }
    int ans = 0;
    for (auto s:S){
        int p = s.first;
        int q = s.second;
        int tmp = 0;
        rep(i,N) {
            rep(j,N) {
                if (i==j) continue;
                if (A[i][0]-A[j][0]==p && A[i][1]-A[j][1]==q) {
                    tmp++;
                }

            }
        }
        ans = max(ans,tmp);
    }
    ans = N-ans;
    cout << ans << endl;

}

Measured memory_bytes: 3716
#include <iostream>
#include <algorithm>
#include <cstring>
#include <utility>
using namespace std;

int main(){
  int n, m; cin >> n >> m;
  pair<int, int> p[m];

  for(int i=0; i<m; i++){
    int a, b; cin >> a >> b;
    p[i] = {b, a};
  }

  sort(p, p+m);

  int cnt = 0, be = -1;
  for(int i=0; i<m; i++){
    if(p[i].second> be){
      be = p[i].first-1;
      cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>

int main()
{
  int n,l;
  char s[101][101];
  int i,j;
  char t[101];
  scanf("%d%d",&n,&l);
  for(i=0;i<n;i++){
    scanf("%s",s[i]); 
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      strcpy(t,s[i]);
      if(strcmp(s[i],s[j])<0){
        strcpy(s[i],s[j]);
        strcpy(s[j],t);
      }
    }
  }
  for(i=0;i<n;i++){
    printf("%s",s[i]);
  }
  return 0;
}


Measured memory_bytes: 1692
#include <stdio.h>

int main(void) {
	
	int a, b, c, d;

	int area1, area2;

	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	scanf("%d", &d);

	area1 = a * b;
	area2 = c * d;

	if (area1 >= area2) {
		printf("%d", area1);
	}
	else {
		printf("%d", area2);
	}


	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100111;
const int mod=1000000007;
const int inf=1000000007;
const long long INF=1000000000000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};

#define x first
#define y second
int k, x, y, t;
P a[200020];
P cal(int x, int y) {
	if (x > y) {
		P t = cal(y, x);
		return {t.y, t.x};
	}
	if (x < 0) {
		P t = cal(-x, y);
		return { -t.x, t.y};
	}
	if (x + y >= 2 * k) return {x, y - k};

	if (x + y == k) return {0, 0};
	return  { -k + (x + y) / 2, x + y - (x + y) / 2};
}
int main() {
	cin>>k>>x>>y;
	if (!(k & 1) && (x + y) & 1) return puts("-1"), 0;
	a[0] = {x, y};
	for (; a[t].x || a[t].y; t++) a[t + 1] = cal(a[t].x, a[t].y);
	print(t);
	for (; t--;) print(a[t].x<<" "<<a[t].y);
}

Measured memory_bytes: 5632
import math
def isp(x):
    if x==2:
        return True
    if x<2 or x%2==0:
        return False
    i=3
    while i <= math.sqrt(x):
        if x %i==0:
            return False
        i = i+2
    
    return True

n=int(input())
cnt =0
for i in range(n):
    if isp(int(input())):
        cnt = cnt+1
print(cnt)
    



Measured memory_bytes: 5672
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};


long long x[65],y[65],z[65];

int main(){
  int A,B;
  cin >> A >> B;
  cout << 6 - A - B << endl;
  
  return 0;
}



// int gcd(int a, int b){
//   if (b==0) return a;
//   else return gcd(b,a%b);
// }


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 1000; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j])%mod;
//       }
//     }
//   }
//   return 0;
// }


// int factorial(int n){
//   if(n == 0) return 1;
//   return n*factorial(n-1);
// }

// int divisor(int a){
//   int cnt = 0;
//   for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
//   return cnt;
// }

// int comb(int n, int k){
//   pascal_triangle();
//   return memo[n][k];
// }

// int cans(bool f){
//   if(f) cout << "Yes" << endl;
//   else cout << "No" << endl;
//   return 0;
// }







//二項係数(mod剰余)----------------------------

// const int MAX = 3000010;
// const int M = 1000000007;

// vector<ll> fac(MAX); //n!(mod M)
// //a,bの範囲的にこれだけ配列を用意していけば十分
// vector<ll> ifac(MAX); //k!^{M-2} (mod M)

// ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
//     ll ans = 1;
//     while(n != 0){
//         if(n&1) ans = ans*x % M;
//         x = x*x % M;
//         n = n >> 1;
//     }
//     return ans;
// }

// ll COMinit(){
//   //大した量ではないので，先にfax[i]とifax[i]を全て計算しておく
//   fac[0] = 1;
//   ifac[0] = 1;
//   for(ll i = 0; i<MAX; i++){
//     fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
//     ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
//   }
//   return 0;
// }

// ll COM(ll a, ll b){ //aCbをmod計算
//   if(a == 0 && b == 0)return 1;
//   if(a < b || a < 0)return 0;
//   ll tmp = ifac[a-b]* ifac[b] % M;
//   return tmp * fac[a] % M;
// }

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


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
#define INF 1<<28
using namespace std;

struct edge{
	int to,cap,rev;
	edge(){}
	edge(int tt,int cc,int rr){
		to=tt;
		cap=cc;
		rev=rr;
	}
};

vector<edge> G[2005];
bool used[2005];

void add_edge(int from,int to,int cap){
	G[from].push_back(edge(to,cap,G[to].size()));
	G[to].push_back(edge(from,0,G[from].size()-1));
}

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

int max_flow(int s,int t){
	int flow=0;
	while(1){
		memset(used,false,sizeof(used));
		int f=dfs(s,t,1);
		if(f==0)return flow;
		flow+=f;
	}
}

int n,m,l;
int dist[101][101];
int p[1001],t[1001];

void solve(){
	for(int k=0;k<n;k++){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
			}
		}
	}
	int S=l*2,T=S+1;
	for(int i=0;i<=T;i++){
		G[i].clear();
	}
	for(int i=0;i<l;i++){
		add_edge(S,i,1);
		add_edge(l+i,T,1);
		for(int j=0;j<l;j++){
			if(i==j)continue;
			if(dist[p[i]][p[j]]<=t[j]-t[i]){
				add_edge(i,l+j,1);
			}
		}
	}
	printf("%d\n",l-max_flow(S,T));
}

int main(void){
	while(1){
		scanf("%d%d%d",&n,&m,&l);
		if(n+m+l==0)break;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				dist[i][j]=INF;
			}
			dist[i][i]=0;
		}
		for(int i=0;i<m;i++){
			int a,b,c;
			scanf("%d%d%d",&a,&b,&c);
			dist[a][b]=c;
			dist[b][a]=c;
		}
		for(int i=0;i<l;i++){
			scanf("%d%d",&p[i],&t[i]);
		}
		solve();
	}
	return 0;
}

Measured memory_bytes: 27528
N,K = (int(T) for T in input().split())
Next = [int(T)-1 for T in input().split()]
GetP = [int(T) for T in input().split()]
Disp = -10**9
for TN in range(0,N):
    Now = Next[TN]
    Point = GetP[Now]
    MAXP = Point
    RoopC = 1
    RoopFlag = False
    for TK in range(1,K):
        Now = Next[Now]
        Point += GetP[Now]
        RoopC += 1
        MAXP = max(MAXP,Point)
        if Now==TN:
            RoopFlag = True
            break
    if RoopFlag and Point>0:
        Omit = K-RoopC*(K//RoopC)
        PointO = 0
        MAXO = 0
        for TO in range(0,Omit):
            Now = Next[Now]
            PointO += GetP[Now]
            MAXO = max(MAXO,PointO)          
        Disp = max(Disp,max(Point*(K//RoopC)+MAXO,Point*((K//RoopC)-1)+MAXP))
    else:
        Disp = max(Disp,MAXP)
print(Disp)

Measured memory_bytes: 74588
#include <bits/stdc++.h>
     
using namespace std;
     
int main() {
    int n;
    cin >> n;
    int max = 0;
    int scnd_max = 0;
    vector<int> vals(n);
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (x > max) {
            scnd_max = max;
            max = x;
        } else if (x > scnd_max) {
            scnd_max = x;
        }
        vals[i] = x;
    }
    for (int i = 0; i < n; i++) {
        if (vals[i] == max) {
            cout << scnd_max << '\n';
        } else {
            cout << max << '\n';
        }
    }
}

Measured memory_bytes: 4060
import java.util.HashMap;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.regex.Pattern;
import java.util.Collections;
import java.math.BigDecimal;
import java.util.LinkedList;

public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        String s = sc.next();
        int n = sc.nextInt();
        
        for (int i = 0; i < n; i++) {
            String cmd = sc.next();
            switch (cmd) {
            case "print":
                print(s, sc.nextInt(), sc.nextInt());
                break;
            case "reverse":
                s = reverse(s, sc.nextInt(), sc.nextInt());
                break;
            case "replace":
                s = replace(s, sc.nextInt(), sc.nextInt(), sc.next());
                break;
            }
        }
    }
    
    static void print(String s, int a, int b) {
        System.out.println(s.substring(a, b+1));
    }
    
    static String reverse(String s, int a, int b) {
        StringBuilder sb = new StringBuilder();
        for (int i = b; i >= a; i--) {
            sb.append(s.substring(i, i+1));
        }
        return s.substring(0, a) + sb.toString() + s.substring(b+1, s.length());
    }
    
    static String replace(String s, int a, int b, String p) {
        return s.substring(0, a) + p + s.substring(b+1, s.length());
    }
}

Measured memory_bytes: 30560
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;


void solve(long long N, std::vector<long long> d){
    sort(all(d));
    if(d[N/2]==d[N/2-1])op(0)
    else {
        op(d[N/2]-d[N/2-1])
    }
    return;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> d(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&d[i]);
    }
    solve(N, std::move(d));
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, N) for(ll i = 0; i < (ll)N; i++)
using ll = long long;
using namespace std;
#define MOD 1000000007
typedef pair<int,int> P;
typedef vector<int> vi;

int main() {
    int d, t, s,ans = 0, flag = 0;
    cin >> d >> t >> s;
    

    cout << ( (t*s >= d) ? "Yes" : "No" );
    //printf("%.8lf", ans);
    //cout << ans;
    printf("\n");
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589

using namespace std;

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

void solve_A(){
    string s;
    cin >> s;

    if(s[0] == '7' || s[1] == '7' || s[2] == '7') cout << "Yes" << endl;
    else cout << "No";
}

void solve_B(){
    ll n;
    cin >> n;

    ll ans = 0;
    for(int i = 0; i <= n; i++){
        if(i%3==0 || i % 5 == 0) continue;
        ans += i;
    }
    cout << ans << endl;
}

int main(void){
    solve_B();
    
    return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define repi(i,a,b) for(int i = (a); i<= (b); i++)
#define repA(i,n) for(int i=n; i>=0; i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (int)(a.size())

typedef long long ll;
typedef long double ld;
const ll mod = 998244353;//1e9+7

vector<int> cnt[201],sp;

void pre() {

}

void solve() {
  int n;  cin>>n;
  int z = (n*360)/__gcd(n,360);
  cout<<z/n;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  #endif
  int t = 1;
  pre();
  //cin>>t;
  rep(i,t)  {
    solve();
    cout<<'\n';
  }
  return 0;
}


Measured memory_bytes: 3612
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

    int n = nextInt();
    int m = nextInt();

    int[][] AB = new int[n][2];
    for(int i=0;i<n;i++){
      AB[i][0] = nextInt();
      AB[i][1] = nextInt();
    }

    Arrays.sort(AB, (a, b)->a[0]-b[0]);

    int anscnt = 0;
    long ans = 0;

    int cnt = 0;
    while(anscnt!=m){

      //buy 1
      ans += AB[cnt][0];
      anscnt ++;
      AB[cnt][1]--;

      if(AB[cnt][1]==0){
        cnt++;
      }

    }

    System.out.println(ans);


    //System.out.println();

  }

  static int lcm(int a,int b){
    return a*b*gcd(a,b);
  }

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

  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

  static int nextInt(){
    return Integer.parseInt(sc.next());
  }

  static long nextLong(){
    return Long.parseLong(sc.next());
  }

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

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


Measured memory_bytes: 64396
a, b, c = list(map(int,input().split()))
aa = list(map(int,input().split()))
bb = list(map(int,input().split()))
cc = [list(map(int,input().split())) for i in range(c)]
ans = 0

for i in range(c):
  ans1 = aa[cc[i][0] - 1] + bb[cc[i][1] - 1] - cc[i][2]
  if i == 0 :
    ans = ans1
  ans = min(ans,ans1)

aa.sort()
bb.sort()
ans2 = aa[0] + bb[0]
ans = min(ans, ans2)
  
print(ans)




Measured memory_bytes: 38948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,ans=0; cin >> N;
    for (ll i=10;i<=N;i*=5) ans+=N/i;
    if (N%2==1) ans=0;
    cout << ans << endl;
}

Measured memory_bytes: 256
def mapint_inp():
    return map(int, input().split())

def intinp():
    return int(input())

A, B, N = mapint_inp()

from math import floor

S_1 = (A*N)//B
S_2 = A*(N//B)
if N < B:
    print(S_1-S_2)
else:
    print(((A*(B-1))//B))

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

    if temp!=1:
        arr.append([temp, 1])

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

    return arr

n = int(input())
count = 0
primelist = factorization(n)
#print(primelist)

if primelist[0][0]==1:
  print(0)
else:
  for i in range(len(primelist)):
    for j in range(40):
      if j*(j+1)/2 > primelist[i][1]:
        count += (j-1)
        break
  print(count)

Measured memory_bytes: 9500
#include<bits/stdc++.h>
using namespace std;
int a,b,n,need,honest;
int s[4008],ta;
bool ans[4008];
inline bool ask(int x,int y)
{
	cout<<'?'<<' '<<x<<' '<<y<<'\n';
	char c;
	cin>>c;
	return c=='Y';
}
inline void solve()
{
	n=a+b;
	need=b;
	for(int i=0;i<n;++i){
		//cout<<"!!!!!!!!!"<<i<<' '<<ta<<' '<<s[ta]<<'\n';
		if(ta==0){
			s[++ta]=i;
			if(ta>need)	break;
			continue;
		}
		bool t=ask(s[ta],i);
		if(t){
			s[++ta]=i;
			if(ta>need)	break;
		}
		else{
			--ta;
			--need;
		}
	}
	honest=s[ta];
	ans[honest]=1;
	for(int i=0;i<n;++i){
		if(i!=honest)	ans[i]=ask(honest,i);
	}
	cout<<'!'<<' ';
	for(int i=0;i<n;++i){
		cout<<ans[i];
	}
}
int main()
{
	cin>>a>>b;
	if(a<=b){
		puts("Impossible");
	}
	else{
		solve();
	}
	return 0;
}

Measured memory_bytes: 724
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,x=1;
  cin>>n;
  vector<int>a (n);
  for (int i=0;i<n;i++){
    cin>>a.at(i);}
  sort (a.begin(),a.end());
  for(int i=0;i<n-1;i++){
  if (a.at(i)<a.at(i+1)){
    x++;}
  else {continue;}
  }
  cout<<x<<endl;}
    

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

template <class T> using V = vector<T>;

using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;


#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;


ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}


ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}


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


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/


signed main() {
  ll n;
  	ci(n);
  vll A(n);
  FOR(i,0,n){
    ci(A[i])
  }
  SORT(A);
  REV(A);
  ll ans=1;
  ll count=0;
  FOR(i,1,n){
    if(A[i-1]==A[i]){
      ans*=A[i];
      count++;
      i++;
    }
  	if(count==2){
      co(ans);
      break;
    }
  }
  if(count!=2) co(0)
}


Measured memory_bytes: 1024
m, d = map(int, input().split())
ans = 0
for i in range(1, m + 1):
    for j in range(2, 10):
        if (i % j == 0) & (2 <= i // j <= 9) & (((i // j) * 10 + j) <= d):
            ans += 1
print(ans)            

Measured memory_bytes: 9152
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
inline void add(int &x, int v) { x += v; if (x >= MOD) x -= MOD; }

int N;
int A[200000], B[200000];
int nCr[8001][4001];
int T[4002][4002];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  nCr[0][0] = 1;
  for (int i=1; i<=8000; i++) {
    nCr[i][0] = 1;
    for (int j=1; j<=min(i, 4000); j++) {
      nCr[i][j] = nCr[i-1][j-1] + nCr[i-1][j];
      if (nCr[i][j] >= MOD) nCr[i][j] -= MOD;
    }
  }
  cin >> N;
  rep(i, N) {
    cin >> A[i] >> B[i];
    T[2000-A[i]][2000-B[i]]++;
  }
  for (int i=0; i<=4000; i++) {
    for (int j=0; j<=4000; j++) {
      add(T[i+1][j], T[i][j]);
      add(T[i][j+1], T[i][j]);
    }
  }
  int s = 0;
  rep(i, N) {
    int X = A[i], Y = B[i];
    add(s, T[2000+A[i]][2000+B[i]]);
  }
  rep(i, N) {
    add(s, MOD-nCr[2*A[i]+2*B[i]][2*A[i]]);
  }
  s = (500000004LL*s)%MOD;
  cout << s << "\n";
  return 0;
}


Measured memory_bytes: 189440
#include <stdio.h>

int main(void)
{
  int a,b,k,i,j;

  scanf("%d%d%d",&a,&b,&k);
  j=0;
  for(i=100;i>=1;i--){
        if((a%i==0)&&(b%i==0)) j++;
        if(j==k){
                printf("%d\n",i);
                break;
                }
  }
  return 0;
}


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

using namespace std;

int main(void){
  int input;
  vector<int> num;
  vector<int> ans{1,4,7,9};
  
  for(int i = 0 ; i < 4 ; i++){
    cin >> input;
    num.push_back(input);
  }
  
  sort(num.begin(), num.end());
  
  if(num == ans) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}

Measured memory_bytes: 256