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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define Mod 1000000007
#define REP(i,a,b) for (int i = a; i <= b; i++)

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    double x=0,t;
    for(int i=0;i<n;i++){
        cin>>t;
        x+=(1.0/t);
    }
    cout<<fixed<<setprecision(6)<<(1.0/x);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
struct UnionFind {
  int sz;
  vector<int> par;
  vector<pair<ll, ll>> cnt;
  UnionFind(int sz) {
    this->sz = sz;
    par.clear();
    par.resize(2 * sz);
    cnt.clear();
    cnt.resize(2 * sz);
    for(int i=0;i<sz;++i) {
      par[i] = i;
      par[sz+i] = sz+i;
      cnt[i] = {1, 0};
      cnt[sz+i] = {0, 1};
    }
  }
  int root(int x) {
    return par[x] == x ? x : par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    int rootx = root(x), rooty = root(y);
    if(rootx == rooty) return;
    ll cntxf = cnt[rootx].first, cntxs = cnt[rootx].second, cntyf = cnt[rooty].first, cntys = cnt[rooty].second;
    cnt[rootx] = {cntxf + cntyf, cntxs + cntys};
    par[rooty] = rootx;
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int sizex(int x) {
    return cnt[root(x)].first;
  }
  int sizey(int x) {
    return cnt[root(x)].second;
  }
};
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  int sz = 100000;
  UnionFind uf(sz);
  for(int i=0;i<n;++i) {
    int x, y; cin >> x >> y;
    x--; y--;
    uf.unite(x, y + sz);
  }
  vector<bool> sel(2 * sz);
  ll ans = -n;
  for(int i=0;i<sz;++i) {
    int root = uf.root(i);
    if(!sel[root]) {
      sel[root] = true;
      ll szx = uf.sizex(root), szy = uf.sizey(root);
      ans += szx * szy;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;

int main() {
    int n; cin >> n;
    int r,l = 0; int a[n];
    for(int i = 0;i < n;i++){
        cin >> a[i];
        l+= a[i];
    }
    int ans = 200;
    for(int i = 0;i < n;i++){
        ans = min(ans,abs(r-l));
        r+=a[i];
        l-=a[i];
    }
    cout << ans;
}


Measured memory_bytes: 3500
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace ABC120A_FavoriteSound
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var input = Console.ReadLine().Split(' ').Select(elem => int.Parse(elem)).ToArray();
            var tanka = input[0];
            var have = input[1];
            var heartFullCount = input[2];
            var hearableCount = have / tanka;

            int answer;
            if (heartFullCount <= hearableCount)
            {
                answer = heartFullCount;
            }
            else
            {
                answer = hearableCount;
            }

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 13268
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        if(S.length()==2){
            System.out.println(S);
        } else {
            System.out.print(S.charAt(2));
             System.out.print(S.charAt(1));
              System.out.print(S.charAt(0));
        }
    }
}


Measured memory_bytes: 22868
N,A,B = map(int,input().split())

memo = [0]*37

def S(n):
  if n<10:
    return n
  return n%10+S(n//10)

for n in range(1,N+1):
  memo[S(n)] += n

answer = sum(memo[A:B+1])
print(answer)

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

int main() {

	ll n, a, b;
	cin >> n >> a >> b;

	if (a == 0) {
		cout << 0 << endl;
		return 0;
	}

	if (b == 0) {
		cout << n << endl;
		return 0;
	}


	ll ans = 0;
	ll count = 0;
	ll c = a + b;

	ll re = n / c;

	ans = a*re;
	count = c*re;
	n -= c*re;

	if (n < a) {
		cout << ans + n << endl;
		return 0;
	}
	else {
		cout << ans + a << endl;
		return 0;
	}


	return 0;
}

Measured memory_bytes: 3612
#include <cstdio>
#include <cmath>

#include <algorithm>
#include <iostream>
#include <vector>
#include <list>
#include <tuple>
#include <string>
#include <unordered_map>
#include <queue>

using namespace std;

#define MAX(A, B)	((A) > (B) ? (A) : (B))
#define MIN(A, B)	((A) < (B) ? (A) : (B))

pair<bool, unordered_map<int, bool>> v[55];

bool isBridge(int a, int b) {
	queue<int> q;

	q.push(a);

	while (!q.empty()) {
		int n = q.front();
		q.pop();

		// printf("%d -> ", n);

		for (auto &p : v[n].second) {
			if (!p.second || !v[p.first].first) continue;

			if (p.first == b) return false;

			v[p.first].first = false;
			q.push(p.first);
		}
	}

	return true;
}

int main(int argc, char const *argv[]) {
	int n, m;
	cin >> n >> m;

	vector<pair<int, int>> e;

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

		a -= 1; b -= 1;
		v[a].second.insert(make_pair(b, true));
		v[b].second.insert(make_pair(a, true));
		e.push_back(make_pair(a, b));
	}

	int sum = 0;
	for (auto &p : e) {
		for (int i = 0; i < n; ++i) {
			v[i].first = true;
		}

		v[p.first].second[p.second] = false;
		v[p.second].second[p.first] = false;

		// bool ans;
		// printf("isBridge %d - %d : %d\n", p.first, p.second, ans = isBridge(p.first, p.second));
		// sum += ans;

		sum += isBridge(p.first, p.second);

		v[p.first].second[p.second] = true;
		v[p.second].second[p.first] = true;
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000009)
	sc.Split(bufio.ScanWords)

	n := oneInt()

	weigts := scanNums(n)

	acc := cumSum(weigts)

	ans := 105000000
	for i := 0; i < n; i++ {
		ans = min(ans, abs(acc[i]-acc[0]-(acc[n]-acc[i])))
	}
	fmt.Println(ans)

}

func oneInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

func scanNums(len int) (nums []int) {
	for i := 0; i < len; i++ {
		nums = append(nums, oneInt())
	}
	return nums
}

func scanStrings(len int) (strs []string) {
	for i := 0; i < len; i++ {
		strs = append(strs, oneStr())
	}
	return strs
}

func abs(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}

func cumSum(nums []int) []int {
	sums := []int{0}

	for i := 0; i < len(nums); i++ {
		sums = append(sums, sums[i]+nums[i])
	}
	return sums
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
using namespace std;
using ll = long long;
typedef vector<int> vi;

int main(){
	string s;
	cin >> s;
	int n = 0, ss = 0, w = 0, e = 0;
	rep(i, s.size()){
		if(s[i] == 'N') n++;
		if(s[i] == 'S') ss++;
		if(s[i] == 'W') w++;
		if(s[i] == 'E') e++;
	}
	if(n && ss && w && e) cout << "Yes" << endl;
	else if(n && ss && !w && !e) cout << "Yes" << endl;
	else if(!n && !ss && w && e) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3576
#include <stdio.h>
#define max(x, y) ((x)<(y) ? (y) : (x))
#define upfloor(x, y) ((x)/(y) + ((x)%(y) ? 1 : 0))

int main(){
  int n;  scanf("%d", &n);
  long nowt, nowa;  scanf("%ld %ld", &nowt, &nowa);
  while(n-- > 1){
    long t, a;  scanf("%ld %ld", &t, &a);    
    long x = max(upfloor(nowt, t), upfloor(nowa, a));
    nowt = t * x;
    nowa = a * x;
  }

  printf("%ld\n", nowt+nowa);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
vector<int> l[100005];
int ans;
int par[100005],Rank[100005];
void init(int n){
	for(int i=0;i<n;i++){
		par[i]=i; Rank[i]=0;
	}
}
int find(int x){
	if(par[x]==x){
		return x;
	}else{
		return par[x]=find(par[x]);
	}
}
void unite(int x,int y){
	x=find(x); y=find(y);
	if(x==y) return;
	if(Rank[x]<Rank[y]){
		par[x]=y;
	}else{
		par[y]=x;
		if(Rank[x]==Rank[y]) Rank[x]++;
	}
}
bool same(int x,int y){
	return find(x)==find(y);
}
int main(void){
	int n,m; cin>>n>>m;
	int k,L;
	for(int i=0;i<n;i++){
		cin>>k;
		for(int j=0;j<k;j++){
			cin>>L;
			l[L-1].push_back(i);
		}
	}
	init(100005);
	for(int i=0;i<m;i++){
		int t=l[i].size();
		for(int j=0;j<t-1;j++){
			//cout<<l[i][j]<<" "<<l[i][j+1]<<endl;
			unite(l[i][j],l[i][j+1]);
		}
		//cout<<l[i].size()<<endl;
	}
	for(int i=0;i<n;i++){
		if(same(0,i)){
			ans++;
		}
	}
	if(ans==n){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	
}


Measured memory_bytes: 5376
from __future__ import division, print_function
from sys import stdin
n = int(stdin.readline())
result = [0, 0]
for _ in range(n):
    taro, hanako = stdin.readline().split()
    if taro > hanako:
        result[0] += 3
    elif taro < hanako:
        result[1] += 3
    else:
        result[0] += 1
        result[1] += 1
print(*result)

Measured memory_bytes: 4252
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint 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;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 

    int main(){
        lint n;
        cin>>n;
        lint x[n];
        lint y[n];
        lint pp[n];
        lint pm[n];
        lint mp[n];
        lint mm[n];
        rep(i,n){
            lint a,b;
            cin>>a>>b;
            x[i]=a;
            y[i]=b;
            pp[i]=a+b;
            pm[i]=a-b;
            mp[i]=-a+b;
            mm[i]=-a-b;
        }
        sort(pp,pp+n,greater<lint>());
        sort(pm,pm+n,greater<lint>());
        sort(mp,mp+n,greater<lint>());
        sort(mm,mm+n,greater<lint>());
        lint ans=0;
        rep(i,n){
            ans=max(ans,-x[i]-y[i]+pp[0]);
            ans=max(ans,x[i]+y[i]+mm[0]);
            ans=max(ans,-x[i]+y[i]+pm[0]);
            ans=max(ans,x[i]-y[i]+mp[0]);
        }
        cout<<ans<<endl;


    }
      

Measured memory_bytes: 13020
//ほとんどbetrue12さんの提出(https://atcoder.jp/contests/abc168/submissions/13352386)の写経です

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) {
	if (a > b) a = b;
}
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) {
	if (a < b) a = b;
}
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 998244353;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e18 + 1;

using P = pair<int, int>;

struct edge { int to, cost; };
int V;//頂点数
vector<edge>G[MAX];
int d[MAX];//始点からの距離
void dijkstra(int s) {
	priority_queue<P, vector<P>, greater<P>>que;
	fill(d, d + V, INF);
	d[s] = 0;
	que.push(P(0, s));
	while (!que.empty()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if (d[v] < p.first)continue;
		for (int i = 0; i < G[v].size(); i++) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

void solve() {
	int N, M, S; cin >> N >> M >> S;
	V = N;
	REP(i, M) {
		int u, v; cin >> u >> v;
		int d; cin >> d;
		G[u].push_back({ v,d });

	}
	dijkstra(S);
	REP(i, N) {
		if (d[i] == INF)print("INF");
		else print(d[i]);
	}
}



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//mt.seed((int)(time(0)));
	//REP(_, 10000)test();
	//int q;
	//cin >> q;
	//while (q--)
	solve();
}




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

const int N = 1e5 + 10, M = 32;
int n, ans, x, mark[M];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		int y, cnt = 0;
		cin >> y;
		x ^= y;
		
		while (y % 2 == 0) {
			cnt++;
			y /= 2;
		}
		mark[++cnt]++;
	}
	
	for (int i = M - 2; i >= 0; i--)
		if (x & (1LL << i)) {
			if (!mark[i + 1])
				return cout << -1, 0;
			x = ~x;
			ans++;
		}
	cout << ans;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: usize,
        m: usize,
        k: usize,
        a: [usize; n], // v_1 v_2 ... v_n
        b: [usize; m], // v_1 v_2 ... v_n
    }

    let sum_a = {
        let mut sum_a: Vec<usize> = Vec::new();
        if a[0] > k {
            sum_a
        } else {
            sum_a.push(a[0]);
            for i in 1..n {
                let xx = sum_a[i-1]+a[i];
                if xx > k {
                    break;
                }
                sum_a.push(xx);
            }
            sum_a.reverse();
            sum_a
        }
    };

    let sum_b = {
        let mut sum_b: Vec<usize> = Vec::new();
        if b[0] > k {
            sum_b
        } else {
            sum_b.push(b[0]);
            for i in 1..m {
                let xx = sum_b[i-1]+b[i];
                if xx > k {
                    break;
                }
                sum_b.push(xx);
            }
            sum_b
        }
    };

    let len_a = sum_a.len();
    let len_b = sum_b.len();
    let mut ans = {
        if a[0] > k {
            0
        } else {
            len_a
        }
    };
    if len_b > 0 {
        let mut j = 0;
        for i in 0..len_a {
            if j == len_b {
                break;
            }
            let mut yy = sum_a[i]+sum_b[j];
            while yy <= k {
                j += 1;
                if j == m {
                    break;
                }
                yy += b[j];
            }
            if ans < (len_a-i)+j {
                ans = (len_a-i)+j
            }
        }
    }

    if a[0] > k {
        ans = len_b;
    }
    if ans < len_b {
        ans = len_b
    }
    println!("{}",ans)

}


Measured memory_bytes: 10356
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
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;}
template<class T>
ll sum(const T& a){return accumulate(all(a),0LL);}

ll selectionSort(vl &a,ll n){
    ll cnt=0;
    rep(i,n){
        ll minj=i;
        fore(j,i,n-1){
            if(a[j]<a[minj])minj=j;
        }
        if(minj!=i){
            cnt++;
            swap(a[minj],a[i]);
        }
    }
    return cnt;
}

void solve(){
    ll n;cin>>n;
    vl a(n);rep(i,n)cin>>a[i];

    ll cnt=selectionSort(a,n);
    rep(i,n){
        if(i>0)cout<<" ";
        cout<<a[i];
    }
    cout<<endl;
    cout<<cnt<<endl;
}

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



Measured memory_bytes: 3172
<?php
fscanf(STDIN, "%d %d", $n, $m);
for ($i = 0; $i < $m; $i++) {
	fscanf(STDIN, "%d %d", $a, $b);
	$e[$a][] = $b;
	$e[$b][] = $a;
}
$x = 0;
path(1, []);
echo $x;

function path($p, $f) {
	global $n, $e, $x;
	$f[$p] = 1;
	if (count($f) == $n) {
		$x++;
	} elseif (isset($e[$p])) {
		foreach ($e[$p] as $q) {
			if (!isset($f[$q])) path($q, $f);
		}
	}
}

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

int main() {
    int x,y;
    cin >> x >> y;
    if ( y % 2 != 0) {
        cout << "No";
        return 0;
    }
    for (int c = x; c >=0; c--) {
        int t = x - c;
        if ((4*c+2*t) == y) {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";

}

Measured memory_bytes: 3632
/*
    Author: Shivam Shukla
    Title : DP_L_Modified.cpp
    Date : 01/09/2020   >> 17:22:59
*/

#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pair<ll,ll> > vpll;
 
const int MOD=1e9+7;
const int MAX=1e5+5;
const double PI= acos(-1.0);
const long double EPS=1e-10;
const int64_t INF=1e18+10;
 
#define fastio() ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0)
#define trace(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vi vector<int>
#define vl vector<ll>
#define vs vector<str>
#define vc(x) vector<x>
#define mapll map<ll,ll>
#define mapib map<int,bool>
#define mapiv map<int,vector>
#define mapsi map<string,int>
#define rep(i,j,k) for(ll i=j;i<k;i++)
#define down(i,j,k) for(ll i=j;i>=k;i--)
#define repa(i,n) for(ll i=0;i<n;i++)
#define dowa(i,n) for(ll i=n;i>=0;i--)
#define reps(i,j,k,s) for(ll i=j;i<k;i+=s)
#define downs(i,j,k,s) for(ll i=j;i>=k;i-=s)
#define trv(i,x) for(auto i:x)
#define pb push_back
#define eb emplace_back
#define sz(x) (int)x.size()
#define ff first
#define ss second
#define str string 
#define dub double
#define pqmax priority_queue<ll>
#define pqmin priority_queue<ll,vl,greater<ll> >
#define INF(x) numeric_limits<x>::max()
 
template<typename t> t lcm(t a, t b) {return (a*b)/__gcd(a,b);}
template<typename t> t gcd(t a, t b) {return __gcd(a,b);}
template<typename t> t mul_mod(t a, t b, t m){t res=((a%m)*(b%m)%m); return res;}
template<typename t> t add_mod(t a, t b, t m){t res=((a%m)+(b%m))%m; return res;}
template<typename t> t pow_mod(t a,t b,t m) {t res=1;while(b){if(b&1) res=mul_mod(res,a,m);a=mul_mod(a,a,m), b>>=1;} return res%m;}
template<typename t> vc(t) num_vec(t num) {t res; while (num) res.pb(num%10), num/=10; return res;}
template<typename t> t vec_num(t vec) {t res=0; ll mul=1; repa(i,sz(vec)) res=vec[i]*mul, mul*=10; return res;}

ll solve(vl& a) {
    int n = sz(a);
    vc(vl) dp(n, vl(n));

    dowa(i, n) {
        rep(j, i, n)
            if (i == j)
                dp[i][j] = a[i];
            else if (i < j)
                dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1]);   
    }
    return dp[0][n - 1];        
}  

int32_t main(int argc,char** argv){
    fastio();
    auto tstart= clock();
 
    #ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
      freopen("error.txt","w",stderr);
    #endif   

    int n; cin >> n;
    vl a(n); repa(i, n) cin >> a[i];

    cout << solve(a) << endl; 

    cerr << setprecision(2) << fixed<<"Time elapsed: " << (double)(clock() - tstart)/CLOCKS_PER_SEC << endl; 
    return 0; 
}

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

int main(){
    long N, M;
    cin >> N >> M;

    vector<long> A(N), B(N);
    for (int i=0; i<N; i++){
        cin >> A.at(i) >> B.at(i);
    }

    long ans=0;

    vector<int> index(A.size());
    iota(index.begin(), index.end(), 0);

    sort(index.begin(), index.end(),
        [&](int x, int y){return A[x] < A[y];});
    
    for (auto& i:index){
        //cout << i << " " << A[i] << " " << B[i] << endl;
        ans += A[i] * min(M, B[i]);
        M -= min(M, B[i]);     
    }

    cout << ans << endl;

}

Measured memory_bytes: 2176
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		ArrayList<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < n; i++) {
			int q = sc.nextInt();
			if (q == 0) {
				int x = sc.nextInt();
				pushBack(list, x);
			} else if (q == 1) {
				int x = sc.nextInt();
				randomAccess(list, x);
			} else {
				popBack(list);
			}
		}
	}

	public static void pushBack(List<Integer> list, int x) {
		list.add(x);
	}

	public static void randomAccess(List<Integer> list, int x) {
		System.out.println(list.get(x));
	}

	public static void popBack(List<Integer> list) {
		int last = list.size() - 1;
		list.remove(last);
	}

}



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

using namespace std;

using ll = long long;

constexpr int MAX_LEN = 10010, MAX_D = 100;
constexpr int MOD = 1e9 + 7;
int dp[MAX_LEN][2][MAX_D];

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

    string K;
    int D;

    cin >> K >> D;

    const int len = K.size();
    dp[0][1][0] = 1;
    for (int i = 0; i < len; ++i) {
        for (int j = 0; j < 2; ++j) {
            for (int l = 0; l < D; ++l) {
                if (dp[i][j][l] == 0) continue;

                if (j == 0) { //制限なし
                    for (int m = 0; m < 10; ++m)
                        (dp[i + 1][0][(l + m) % D] += dp[i][j][l]) %= MOD;
                }
                else { // 制限あり
                    const int ub = (int)(K[i] - '0');
                    for (int m = 0; m < ub; ++m)
                        (dp[i + 1][0][(l + m) % D] += dp[i][j][l]) %= MOD;
                    (dp[i + 1][1][(l + ub) % D] += dp[i][j][l]) %= MOD;
                }
            }
        }
    }

    ll res = (dp[len][0][0] + dp[len][1][0]) % MOD;
    cout << (res - 1 + MOD) % MOD << endl;

    return 0;
}


Measured memory_bytes: 8064
#include<iostream>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define rrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int n;
    cin >> n;
    cout << n * n << endl;
    return 0;
} /*atcoder*/



Measured memory_bytes: 3508
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define DEBUG(x) cerr << (#x) << ": " << (x) << endl
#define DEBUG_VEC(v)          \
  cerr << #v << ": ";         \
  REP(__i, (v).size())        \
  cerr << ((v)[__i]) << ", "; \
  cerr << endl

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

const ll BIGINT = 1e9 + 7;

// A?GC  AG?C  ACG   GAC  AGC
// index is ACGT order
ll dp[105][4][4][4];

int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  dp[N][3][3][3] = 1;   // "TTT"

  for (int idx = N - 1; idx >= 0; --idx) {
    REP(i, 4) REP(j, 4) REP(k, 4) REP(l, 4) {
      if (k == 0 and i == 2 and l == 1)  // A?GC
        dp[idx][l][i][j] = 0;
      else if (k == 0 and j == 2 and l == 1)  // AG?C
        dp[idx][l][i][j] = 0;
      else if (j == 0 and i == 1 and l == 2)  // ACG
        dp[idx][l][i][j] = 0;
      else if (j == 2 and i == 0 and l == 1)  // GAC
        dp[idx][l][i][j] = 0;
      else if (j == 0 and i == 2 and l == 1)  // AGC
        dp[idx][l][i][j] = 0;
      else
        dp[idx][l][i][j] += dp[idx + 1][i][j][k];
      
      dp[idx][l][i][j] %= BIGINT;
    }
  }
  ll ans = 0LL;
  REP(i, 4) REP(j, 4) REP(k, 4) {
    ans += dp[0][i][j][k];
    ans %= BIGINT;
  } 
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var io = new StandardIO();
        //var io = new TestIO();
        new Process(io).Run();
    }

}

class Process
{
    public Process(IIO io)
    {
        this.io = io;
    }

    IIO io;

    public void Run()
    {
        var texts = io.GetStrings('/');
        io.Write(string.Format("2018/{0:00}/{1:00}", texts[1], texts[2]));
    }
}

public interface IIO
{
    string Get();
    void Write(string s);
    void Flush();
}

public class StandardIO : IIO
{
    string IIO.Get()
    {
        return Console.ReadLine();
    }

    void IIO.Write(string s)
    {
        Console.WriteLine(s);
    }

    void IIO.Flush()
    {
        Console.Out.Flush();
    }
}

public static class InputExtension
{
    public static int GetInteger(this IIO input)
    {
        return int.Parse(input.Get());
    }

    public static string[] GetStrings(this IIO input, char separator = ' ')
    {
        return input.Get().Split(separator);
    }

    public static int[] GetIntegerArray(this IIO input, char separator = ' ')
    {
        return input.GetStrings().Select(s => int.Parse(s)).ToArray();
    }
}



Measured memory_bytes: 11092
#include <stdio.h>
int main(void)
{
	int a[1000],k,n,m;
	int i,j;
	int temp;
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	k=1;
	do{
		for(i=1,j=2;i<n,j<=n;i++,j++){
			if(a[i]%k>a[j]%k){
				temp=a[i];
				a[i]=a[j];
				a[j]=temp;
			}
		}
		k++;
	}while(k<=m);
	for(i=1;i<=n;i++)printf("%d\n",a[i]);
	return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    cout << (1000 - (N%1000))%1000 << endl;
    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 rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

typedef long long ll;

int main(){
  vector<int> ans(0);
  int n;
  cin >> n;
  if(n == 0){
    cout << 0 << endl;
    return 0;
  }
  while(n != 0){
    ans.push_back(abs(n%2));
    n = (n-abs(n%2))/(-2);
  }
  reverse(ans);
  for(auto p : ans) cout << p;
  cout << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{

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

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int sum = a + b + c;
		int m = Math.max(a, b);
		int max = Math.max(m, c);
		if (sum % 2 == 0 && (sum - max) == (sum / 2)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21716
#include<iostream>
using namespace std;
int a[210];
int main()
{
	int n=0,sum=0,j=0;
	cin>>n;
	for(int i=1;i<=n;i=i+2)
	{
		j=1;
		while(j*i<=n)
		{
			++a[j*i];
			j=j+2;
		}
		if(a[i]==8)++sum;
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7;
const ll LINF=1e18;
using namespace std;
#define int long long
//template
//main
signed main(){
  int N,M;cin>>N>>M;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  std::vector<int> ma(N),mi(N);
  for(int i=0;i<N;i++){
    ma[i]=max(i,v[i]);
    mi[i]=min(i,v[i]);
  }
  sort(ma.begin(),ma.end());
  sort(mi.rbegin(),mi.rend());
  int ans=0;
  for(int i=0;i<N;i++)ans+=abs(i-v[i]);
  for(int i=0;i<M;i++)ans+=2*max(mi[i]-ma[i],0LL);
  cout<<ans<<endl;
}



Measured memory_bytes: 5184
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<unistd.h>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<set>
#include<unordered_map>
#include<cstdio>
#include<map>
#include<numeric>
using namespace std;
#define F first
#define S second
typedef long long ll;
const int MAXN = 1e5 + 10;
const int MAX = 1e7;
double pi = 3.1415926535897932384626433832795;
const ll inf=1e10 ;
struct node{
    int a,b;
    int index ;
} ;

string convert(int n){
    string str="";
    while(n > 0){
        str+=(char)(n%10 + '0');
        n/=10;
    }
    reverse(str.begin(),str.end());
    return str ;
}

ll powr(ll a,ll b,int m){
    if(b==0)
        return 1 ;
    ll x = powr(a,b/2,m)%m;
    x = (x*x)%m ;
    if(b%2)
        return ((x%m)*(a%m))%m ;
    return x ;
}
int main(){
    /* if(compare("99","9988"))
     cout<<"Yes\n"; */
   
        int a,b,c;
        cin>>a>>b>>c;
        int d ;
        cin >>d ;
        if(abs(a-c)<=d)
            cout<<"Yes"<<endl;
        else if(abs(a-b)<=d && abs(c-b)<=d)
            cout<<"Yes\n";
        else
            cout<<"No\n";
    
    return 0;
}


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

using namespace std;

int main(){
  string a,b;
  cin >> a >> b;
  if(a.size()>b.size()){
    cout << "GREATER" << endl;
  }else if (a.size()<b.size()){
    cout << "LESS" << endl;
  }else{
    if(a[0]>b[0]){
      cout << "GREATER" << endl;
    }else if (a[0]<b[0]){
      cout << "LESS" << endl;
    }else{
      cout << "EQUAL" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
using namespace std;

bool check(string &s, int l, int r) {
	int cnt[26] = {0};
	
	for (int i = l; i <= r; i++) {
		cnt[s[i] - 'a']++;
	}
	
	for (int i = 0; i < 26; i++) {
		if (cnt[i] * 2 > r - l + 1) {
			return true;
		}
	}
	return false;
}

signed main() {
	int i, j;
	string s;
	
	cin >> s;
	
	for (i = 0; i < s.length(); i++) {
		for (j = i + 1; j < min((int)s.length(), i + 5); j++) {
			if (check(s, i, j)) {
				cout << i + 1 << " " << j + 1 << endl;
				return 0;
			}
		}
	}
	cout << -1 << " " << -1 << endl;
	return 0;
}

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

int main(){
    ll x,y;cin >> x >> y;
    ll now = x;
    ll ans = 1;
    while(now < y){
        if(now*2 <= y){
            now = now*2;
            ans++;
        }else{
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin>>N;
    
    if(N==3||N==5||N==7){
        cout1("YES")
    }else{
        cout1("NO")
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var S = ReadLine();
        var K = long.Parse(ReadLine());
        var a = 0L;

        var kk = 0;
        var dd = S[0];
        for (int i = 0; i < S.Length; i++)
        {
            if (S[i] == dd) kk++;
        }
        if (kk == S.Length)
        {
            WriteLine(S.Length * K/2);
            return;
        }
        var c = 1;
        for (int i = 0; i < S.Length - 1; i++)
        {
            if (S[i] == S[i + 1])
            {
                c++;
            }
            else
            {
                a += c / 2 * K;
                c = 1;
            }
        }
        if(c!=1)
        {
            a += c / 2 * K;
        }

        if (S[0] == S[S.Length - 1])
        {
            var p = 0;
            var n = 0;
            for (int i = 0; S[i] == dd; i++)
            {
                p++;
            }

            for (int i = S.Length - 1; S[i] == dd; i--)
            {
                n++;
            }
            if (p % 2 == 1 && n % 2 == 1)
            {
                a +=K-1;
            }
        }


        WriteLine(a);
    }
}

Measured memory_bytes: 11220
#include <stdio.h>
#define R register
#define ll long long
namespace IO{
	char buf[1<<15],*S,*T;
	inline char gc(){
		if (S==T){
			T=(S=buf)+fread(buf,1,1<<15,stdin);
			if (S==T) return EOF;
		}return *S++;
	}
	inline int read(){
		R int x; R bool f; R char c;
		for (f=0; (c=gc())<'0'||c>'9'; f=c=='-');
		for (x=c^'0'; (c=gc())>='0'&&c<='9'; x=(x<<3)+(x<<1)+(c^'0'));
		return f?-x:x;
	}
}
#define MN 1000005
#define M (1<<20)
#define P 1000000007
int n,T[M<<1],ans,tt;
inline void rw(int &x,int y){x+=y; if (x>=P) x-=P;}
inline int mul(int x,int y){return (ll)x*y%P;}
inline void modify(int l,int r,int v){
	for (l+=M-1,r+=M+1; l^r^1; l>>=1,r>>=1){
		if (~l&1) rw(T[l^1],v);
		if ( r&1) rw(T[r^1],v);
	}
}
inline int query(int k){
	R int res=0;
	for (k+=M; k; k>>=1)
		rw(res,T[k]);
	return res;
}
int main(){
	n=IO::read();T[M]=1;tt=mul(n-1,n-1);
	for (R int i=0,f; i<n-1; ++i){
		f=query(i);rw(ans,mul(f,tt));rw(ans,mul(f,i+1));
		rw(T[M+i+1],f);if (i+3<=n)modify(i+3,n,f);
	}rw(ans,mul(query(n-1),n));rw(ans,query(n));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 8320
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
	public static void Main()
	{
		var n = int.Parse(ReadLine());
		var count = 0;
		for(int i = 0; i < n; i++)
		{
			var a = ReadLine().Split().Select(int.Parse).ToArray();
			count += a[1] - a[0] + 1;
		}
		WriteLine(count);
	}
}


Measured memory_bytes: 19380
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <algorithm>
#include <math.h>
#include <string>
#define pi 3.1415926535897932384626
#include <cmath>
#define test(t) while(t--)

#define ll  long long int

#define in  cin>>
#define out cout<<
#define en "\n"
#define sp " "
#define pb push_back
#define fast()  ios_base::sync_with_stdio(false);cin.tie(0);
#define double long double

using namespace std;
ll form(ll n){
return (n*(n+1))/2;
}
ll exponent(ll base, ll power){
   ll res = 1;
  ll m = 1000000007;
   while(power){
    if(power&1)
        res = (res*base)%m;
    base= (base*base)%m;
    power=power>>1;
   }
return res;}
bool count_one(ll n){
    ll cnt = 0;
    while(n>0){
            cnt+=1;
       n= n&(n-1);

    }
    if(cnt>1)
        return true;
    return false;
}
void solve()
{ ll n;
   in n;
   ll ans,k=1;
   ll p=360;
  for(ll i=1;i<=100000000;i++){
    if(p==n*i){
        ans=i;
        break;
    }
    if(n*i>360*k){
        k+=1;
        p=360*k;
    }
  }
  out ans<<en;
}




int main(){ fast()
             //freopen("input.txt","r",stdin);
             //freopen("output.txt","w",stdout);
             ll t=1;
            //cin>>t;
            test(t){
            solve();
            }
return 0;}


Measured memory_bytes: 3648
#line 1 "/workspaces/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "main.cpp"

constexpr int m = 26;

// i日目のスコアを計算する
ll calc_day(const int i, const int ans, const ll s, const vl &c, const vi &last) {
  ll ret = 0;
  ret += s;
  REP(j, m) {
    if (j != ans)
      ret -= c[j] * (i + 1 - last[j]);
  }
  return ret;
}

// d日目までのスコアを計算する
ll calc_ans(const int d, const vi &ans, const vector<vl> &s, const vl &c, vi &last) {
  ll ret = 0LL;
  REP(i, d) { ret += calc_day(i, ans[i], s[i][ans[i]], c, last); }
  return ret;
}

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

  int d;
  cin >> d;

  vl c(m);
  REP(i, m) { cin >> c[i]; }

  vector<vl> s(d, vl(m, 0));
  REP(i, d) {
    REP(j, m) { cin >> s[i][j]; }
  }

  vi ans(d), last(d, 0);
  REP(i, d) {
    ll ma = -1e9;
    ll mai = -1;
    REP(j, m) {
      ll tmp = calc_day(i, j, s[i][j], c, last);
      if (ma < tmp) {
        chmax(ma, tmp);
        mai = j;
      }
    }
    last[mai] = i + 1;
    ans[i] = mai + 1;
  }

  REP(i, d) { cout << ans[i] << endl; }

  return 0;
}


Measured memory_bytes: 3760
H, W = tuple(map(int, input().split()))
s = [input() for _ in range(H)]
q = [(0, 0, 0)]
h = {(0, 0)}
opt = float('inf')
while q:
    i, j, k = q.pop(0)
    if i == H - 1 and j == W - 1:
        opt = k
        break
    a = [(u, v)
         for u, v in ((i + 1, j), (i, j + 1), (i - 1, j), (i, j - 1))
         if 0 <= u < H and 0 <= v < W and s[u][v] == '.' and (u, v) not in h]
    q += [(u, v, k + 1) for u, v in a]
    h |= set(a)
print(max(-1, sum(t.count('.') for t in s) - opt - 1))


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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(in.readLine());
				
		int S = Integer.parseInt(st.nextToken());
		int W = Integer.parseInt(st.nextToken());
		
		if (W >= S)
			System.out.println("unsafe");
		else
			System.out.println("safe");
	}
}


Measured memory_bytes: 32532
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll n;cin>>n;
    vector<pair<ll,ll>> p1(n),p(n);
    rep(i,n){
        cin>>p1[i].first>>p1[i].second;
        p[i].first=p1[i].first+p1[i].second,p[i].second=p1[i].first-p1[i].second;
    }
    sort(p.begin(),p.end());
    ll res=0;
    ll buf=abs(p[0].first-p[n-1].first);
    chmax(res,buf);
    rep(i,n)swap(p[i].first,p[i].second);
    sort(p.begin(),p.end());
    buf=abs(p[0].first-p[n-1].first);
    chmax(res,buf);
    cout<<res<<endl;
}

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

int main() {
  int N,judge=-1;
  cin >> N;
  vector<string> str(110);
  for(int i=0;i<N;i++) {
    cin >> str.at(i);
    if(i>0) {
      if(str.at(i-1).at(str.at(i-1).size()-1) == str.at(i).at(0)){
	for(int j=0;j<i;j++) {
	  if(str.at(j)==str.at(i)) {
	    judge=1;
	  }
	}
      }else judge=1;
    }
  }
  if(judge ==1) cout << "No" << endl;
  else if(judge==-1) cout << "Yes" << endl;
}

Measured memory_bytes: 256