akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);

		int n = scanner.nextInt();

		int[] a = new int[n];
		for(int i = 0; i < n; i++){
			a[i] = scanner.nextInt();
		}


		Arrays.sort(a);
		String result = "YES";
		for(int i = 0; i<a.length-1; i++){
			if(a[i] == a[i+1]){
				result = "NO";
				break;
			}
		}

		System.out.println(result);
	}

}


Measured memory_bytes: 88644
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, MOD = map(int, read().split())

N *= 3

# (並べた個数、1つ組 - 2つ組 + N)
dp = np.zeros((N + 10, N + N + 1), np.int64)
dp[0, N] = 1
for n in range(N + 1):
    dp[n] %= MOD
    dp[n + 1, 1:] += dp[n, :-1]
    dp[n + 2, :-1] += dp[n, 1:] * (n + 1)
    dp[n + 3] += dp[n] * ((n + 1) * (n + 2))

x = dp[N, N:].sum() % MOD
print(x)

Measured memory_bytes: 589696
from sys import stdin

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
  
A,B,C,D = map(int,stdin.readline().rstrip().split())
lcm=(C * D) // gcd(C, D)

AdivLcm=A//lcm
BdivLcm=B//lcm
ABdivLcmNum=BdivLcm-AdivLcm
if A%lcm==0:
  ABdivLcmNum+=1

AdivC = A//C
BdivC = B//C
ABdivCNum = BdivC-AdivC
if A%C==0:
  ABdivCNum+=1

AdivD = A//D
BdivD = B//D
ABdivDNum = BdivD-AdivD
if A%D==0:
  ABdivDNum+=1

candiv=ABdivCNum+ABdivDNum-ABdivLcmNum
print(B-A+1-candiv)

Measured memory_bytes: 38256
#ifndef ___Rank_Union_Find
#define ___Rank_Union_Find

#include <vector>

class UnionFind {
private:
	unsigned size_; std::vector<unsigned> par, rank;
public:
	UnionFind() : size_(0), par(std::vector<unsigned>()), rank(std::vector<unsigned>()) {};
	UnionFind(unsigned size__) : size_(size__) {
		par.resize(size_); rank.resize(size_);
		for (unsigned i = 0; i < size_; i++) par[i] = i, rank[i] = 0;
	}
	unsigned size() { return size_; }
	unsigned root(unsigned x) { return par[x] == x ? x : par[x] = root(par[x]); }
	bool same(unsigned x, unsigned y) { return root(x) == root(y); }
	void unite(unsigned x, unsigned y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++;
		else par[y] = x;
	}
	bool operator==(const UnionFind &u) { return par == u.par; }
	bool operator!=(const UnionFind &u) { return par != u.par; }
};

#endif

#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
struct edge { int a, b, cost; };
bool operator<(const edge& e1, const edge& e2) {
	return e1.cost < e2.cost;
}
int n, m, x;
int main() {
	while (cin >> n >> m, n) {
		vector<edge> v;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				cin >> x;
				if(x != 0) v.push_back(edge{ i, n + j, x });
			}
		}
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < m - i - 1; j++) {
				cin >> x;
				if(x != 0) v.push_back(edge{ n + i, n + i + j + 1, x });
			}
		}
		sort(v.begin(), v.end());
		UnionFind uf(n + m);
		for (int i = 0; i < n - 1; i++) uf.unite(i, i + 1);
		int ret = 0;
		for (int i = 0; i < v.size(); i++) {
			if (!uf.same(v[i].a, v[i].b)) {
				uf.unite(v[i].a, v[i].b);
				ret += v[i].cost;
			}
		}
		cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 3100
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
 
#include <stdio.h>
#include <bits/stdc++.h>
 
using namespace std;
 
#include <x86intrin.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
  
#define pb push_back
#define mp make_pair
#define in insert
#define f first
#define s second
#define ll long long
#define dd double
  
const int mod = 1e9 + 7;
const int N = 2e5 + 7;
const int inf = 2e9;
const ll INF = 1e18;

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	// freopen("*.in", "r", stdin);freopen("*.out", "w", stdout);
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) cout << "Yes";
	else cout << "No";
}

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

using namespace std;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef pair<int, int> pii;

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

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

void solve() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i,n) cin >> v[i];
  int ans = v[0];
  for(int i = 1; i < n; i++) ans = gcd(ans, v[i]);
  cout << ans << endl;

}

int main() {
  solve();
  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		
		Scanner scan = new Scanner(System.in);	
		
		String str = scan.next();
		String s = "CODEFESTIVAL2016";
		int cnt = 0;
		for(int i = 0 ; i < s.length(); i++){
			if(str.charAt(i) == s.charAt(i)){
				
			} else {
				cnt++;
			}
		}
		
		System.out.println(cnt);
		
		
	}
}


Measured memory_bytes: 10192
import sys
sys.setrecursionlimit(1000000)


def input():
    return sys.stdin.readline()


n = int(input())
e = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = [int(i) - 1 for i in input().split()]
    e[a].append(b)
    e[b].append(a)

mod = 10**9+7

kkai = [1]
for i in range(1, 2*10 ** 5):
    kkai.append(kkai[-1] * i % mod)


def kai(x, p=mod):
    return kkai[x]


def comb(a, b, p=mod):
    if a < 0 or b < 0:
        return 0
    elif a < b:
        return 0
    if b == 0:
        return 1
    c = 1
    c *= kai(a, p)
    c *= pow(kai(b, p), p - 2, p)
    c *= pow(kai(a - b, p), p - 2, p)
    return c % p


child = [0] * n


def dfs1(i=0, r=-1):
    s = 1
    for j in e[i]:
        if j == r:
            continue
        s += dfs1(j, i)
    child[i] = s
    return s


dfs1()
a = [0] * n


def dfs2(i=0, r=-1):
    s = kai(child[i]-1)
    t = 1
    for j in e[i]:
        if j == r:
            continue
        s *= dfs2(j, i)
        s %= mod
        t *= kai(child[j])
        t %= mod
    s *= pow(t, mod - 2, mod)
    s %= mod
    a[i] = s
    return s


dfs2()
b = [0] * n


def dfs3(i=0, r=-1):
    if r == -1:
        b[i] = a[i]
    else:
        s = b[r] * child[i] % mod
        s *= pow(n-child[i], mod - 2, mod)
        s %= mod
        b[i] = s

    for j in e[i]:
        if j == r:
            continue
        dfs3(j, i)


dfs3()
print("\n".join(map(str, b)))


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

using namespace std;

long long dp[105][100005];
long long MOD = 1000000007;

int main() {int n,k; scanf("%i%i", &n, &k); dp[0][0] = 1;for (int x = 1; x <= n; x++) {long long a; scanf("%lli", &a); for (int y = 0; y <= k; y++) {dp[x][y] += dp[x-1][y] - (y-a > 0 ? dp[x-1][y-a-1] : 0); if (y > 0) dp[x][y] += dp[x][y-1]; dp[x][y] %= MOD; dp[x][y] += MOD; dp[x][y] %= MOD;}}printf("%lli\n", dp[n][k] % MOD);}


Measured memory_bytes: 81812
//17571@nith.ac.in @Ankit Verma
#include <bits/stdc++.h>
using namespace std;
#define ff          first
#define ss          second
#define pb          push_back
#define MP          make_pair
#define int         long long
#define ll          long long
#define inf         0x3f3f3f3f
#define MOD         1000000007
#define ld          long double
#define eb          emplace_back
#define pii         pair<int,int>
#define ull         unsigned long long
#define all(v)      v.begin(), v.end()
#define f(i,x,n)    for(int i=x;i<n;i++)
#define fr(i,x,n)   for(int i=x;i>=n;i--)
#define fastio      ios::sync_with_stdio(false)

void IO() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

int32_t main() {
    //IO();
    fastio;
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll a, b, n; cin >> a >> b >> n;
    ll x, y;
    if (n < b) {
    	x = n;
    	y = (a * x) / b - a * (x / b);
    	cout << y << endl;
    } 
    else if (n % b == 0) {
    	x = b - 1;
    	y = (a * x) / b - a * (x / b);
    	cout << y << endl;
    } 
    else {
    	x = b - 1;
    	y = (a * x) / b - a * (x / b);
    	cout << y << endl;
    }
    

    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a[4]={};
    for(int i=0;i<4;i++) {
        char b;
        cin >> b;
        a[i]=b-48;
    }
    for(int i=0;i<(1<<3);i++){
        int  cnt =a[0];
        bitset<3> s(i);
        for(int j=0;j<3;j++){
            if(s.test(j)) cnt+=a[j+1];
            else cnt-=a[j+1];
        }
        if(cnt==7){
            for(int i=0;i<3;i++){
                char l = '-';
                if(s.test(i)) l = '+'; 
                cout << a[i] << l;
            }
            cout << a[3] <<"=7"<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from itertools import accumulate
from bisect import bisect
n = int(input())
a = list(map(int, input().split()))
ans = 10**9
cs = [0] + list(accumulate(a))
for i in range(2, n - 1):
    left = cs[i]
    right = cs[-1] - cs[i]
    lm = bisect(cs, left // 2)
    l1, l2 = cs[lm], left - cs[lm]
    l3, l4 = cs[lm - 1], left - cs[lm - 1]
    if abs(l1 - l2) > abs(l3 - l4):
        l1 = l3
        l2 = l4
    rm = bisect(cs, left + right // 2)
    r1, r2 = cs[rm] - cs[i], right - (cs[rm] - cs[i])
    r3, r4 = cs[rm - 1] - cs[i], right - (cs[rm - 1] - cs[i])
    if abs(r1 - r2) > abs(r3 - r4):
        r1 = r3
        r2 = r4
    ans = min(ans, max(l1, l2, r1, r2) - min(l1, l2, r1, r2))
print(ans)


Measured memory_bytes: 24176
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = INF+7;
const ll LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define all(v) v.begin(),v.end()
#define MP make_pair
#define pb push_back

int main(){
    int N;
    string S[2];
    cin >> N >> S[0] >> S[1];

    long ans = 1;
    bool W = true;

    for(int i=0;i<N;++i){
        if(S[0][i] == S[1][i]){
            if(!W) ans = 2*ans%MOD;
            if(i == 0) ans = 3*ans%MOD;
            W = false; 
        }
        else{
            if(W) ans = 3*ans%MOD;
            else ans = 2*ans%MOD;
            if(i == 0) ans = 2*ans%MOD;
            W = true;
            ++i;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
cir = (str(input()))
cir_l = list(cir)
a = list(cir)
word = str(input())
word_l = list(word)
c = 0
for i in range(len(a)):
    cir_l.append(a[i])
for i in range(len(a)):
    w = ''
    for k in range(len(word_l)):
        w = w + cir_l[i+k]
    if (w == word):
        c = 1
if (c):
    print('Yes')
else:
    print('No')
    


Measured memory_bytes: 5560
n = int(input())
a_list = list(map(int,input().split()))
pr_abs = []
for i in range(n):
  pr_abs.append(a_list[i] - i-1)


pr_abs.sort()
if len(a_list) % 2 == 1:
  median = pr_abs[(n-1)//2]
  ans = 0
  for i in range(n):
    ans += abs(pr_abs[i] - median)
else:
  median = (pr_abs[(n-2)//2] + pr_abs[n//2])//2
  ans = 0
  for i in range(n):
    ans += abs(pr_abs[i] - median)
    
print(ans)    
  

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


template <typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v){
    if(!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &p) {
    out << "[" << p.first << ", " << p.second << "]";
    return out;
}
//---------


int wh[103][103];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int w, h, n;
    cin >> w >> h >> n;
    rep(i, 0, n){
        int x, y, a;
        cin >> x >> y >> a;
        if(a == 1){
            rep(j, 0, h){
                rep(k, 0, x){
                    wh[j][k] = 1;
                }
            }
        }else if(a == 2){
            rep(j, 0, h){
                rep(k, x, w){
                    wh[j][k] = 1;
                }
            }
        }else if(a == 3){
            rep(j, 0, y){
                rep(k, 0, w){
                    wh[j][k] = 1;
                }
            }
        }else if(a == 4){
            rep(j, y, h){
                rep(k, 0, w){
                    wh[j][k] = 1;
                }
            }
        }
    }

    int ans = 0;
    rep(i, 0, h){
        rep(j, 0, w){
            if(wh[i][j] == 0) ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())

a = tuple(map(int,input().split()))

c = Counter(a)

temp = sorted(c.items())

h = 0
w = 0

while(len(temp)>0):
  k,v = temp.pop()
  if v>=4:
    print(k**2)
    exit()
  elif v>=2:
    h = k
    break
    
while(len(temp)>0):
  k,v = temp.pop()
  if v>=2:
    w = k
    break
    
print(h*w)

Measured memory_bytes: 21284
if __name__ == "__main__":
    # 1 <= N <= 2 * 10^5
    # 1 <= K <= N + 1
    N, K = map(int, input().split(" "))

    total_num = 0
    for k in range(K, N+2):
        # NからN-(k-1)までの和
        sum_max = int(k*(2*N - k + 1) / 2)
        # 0から(k-1)までの和
        sum_min = int(k*(k-1) / 2)
        # 個数を計上
        total_num += sum_max - sum_min + 1
        total_num %= 1000000007
    
    print(total_num)

Measured memory_bytes: 9164
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <ctime>
#include <climits>
#include <cfloat>
#include <cstdint>
#include <cstddef>
#include <cinttypes>
#include <memory>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <array>
#include <valarray>
#include <string>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <bitset>
#include <queue>
#include <complex>
#include <tuple>
#include <utility>
#include <functional>
#include <algorithm>
#include <numeric>

using namespace std;

const double EPS = 1e-10;
const int64_t INF = 1e9;
//typedef long long ll;
typedef int ll;

const int QMAX = 530000;
const int MOD = 998244353;

int n;
ll dat[QMAX];

void init(int _n)
{
	n = 1;
	while (n < _n) n *= 2;

	for (int i = 0; i < 2 * n - 1; i++) dat[i] = 0;
}

ll val(int k)
{
	k += n - 1;
	ll ans = dat[k];
	while (k > 0)
	{
		k = (k - 1) / 2;
		ans = (ans + dat[k]) % MOD;
	}
	return ans;
}

void add(int a, int b, ll x, int k, int l, int r)
{
	if (r <= a || b <= l) return;

	if (a <= l && r <= b) {
		dat[k] = (dat[k] + x) % MOD;
	} else {
		add(a, b, x, k * 2 + 1, l, (l + r) / 2);
		add(a, b, x, k * 2 + 2, (l + r) / 2, r);
	}
}

int main()
{
	int m, k;
	int l[10], r[10];
	scanf("%d%d", &m, &k);
	for (int i = 0; i < k; ++i) {
		scanf("%d%d", &l[i], &r[i]);
	}

	init(m+2);

	add(1, 2, 1, 0, 0, n);
	for (int i = 1; i < m; ++i) {
		ll a = val(i);
		for (int j = 0; j < k; ++j) {
			if (i + l[j] > n) continue;
			int ed = min(i + r[j], n);
			add(i + l[j], ed + 1, a, 0, 0, n);
		}

		/*
		for (int j = 0; j <= m; ++j) {
			printf("%d: %d\n", j, val(j));
		}
		printf("\n");
		*/
	}

	printf("%lld\n", val(m));

	return 0;
}


Measured memory_bytes: 5276
def gcd(x, y):
  b = max(x, y)
  s = min(x, y)
  r = b % s
  while r != 0:
    b = s
    s = r
    r = b % s
  return s

def lcm(x, y):
  return (x * y) // gcd(x,y)

X = int(input())

t = lcm(360, X)
k = t // X
print(k)

Measured memory_bytes: 9116
#include <stdio.h>
int n,x,s,i,j,k;
int main(){
  for(;;){
    scanf(" %d %d",&n,&x);
    if(n==0&&x==0){
      return 0;
    }
    s=0;
    for(i=1;i<=n;i++){
      for(j=1;j<=n;j++){
        for(k=1;k<=n;k++){
          if(i!=j&&j!=k&&k!=i&&i+j+k==x){
            s+=1;
          }
        }
      }
    }
    printf("%d\n",s/6);
  }
}

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

int main(){
    int N;
    string S;
    cin >> N;
    cin >> S;
    int count = 0;
    for (int i = 0; i < N - 2; i++){
        if (S.substr(i, 3) == "ABC"){
            count += 1;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
n = 10**5+1
mod = 10**9+7
fun = [1]*(n+1)
for i in range(1,n+1):
    fun[i] = fun[i-1]*i%mod
rev = [1]*(n+1)
rev[n] = pow(fun[n],mod-2,mod)
for i in range(n-1,0,-1):
    rev[i] = rev[i+1]*(i+1)%mod

def nCr(n,r):
    if r > n:
        return 0
    return fun[n]*rev[r]%mod*rev[n-r]%mod

n = int(input())
l = list(map(int,input().split()))
db = sum(l) - n*(n+1)//2
idx = [i for i in range(n+1) if l[i] == db]
a,b,c = idx[0],idx[1]-idx[0]-1,n-idx[1]
print(n)
for k in range(2,n+2):
  print((nCr(a+b+c,k)+nCr(a+b+c,k-2)+nCr(a+b+c,k-1)*2-nCr(a+c,k-1))%mod)


Measured memory_bytes: 21748
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
#define SG getchar()
#define P putchar
using namespace std;
signed main()
{
	char c;
	while((c=SG)!=10){((c-',')?(P(c)):(P(32)));}
	return putchar(10),0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define maxx 1000000000
int main(){
  int n,k,s;
  cin>>n>>k>>s;
    for(int i=0;i<n;i++){
        if(k==0){
            if(s==maxx){
                cout<<maxx-1<<" ";
            }
            else{
                cout<<maxx<<" ";
            }
        }
        else{
            cout<<s<<" ";
            k--;
        }
    }
    cout<<"\n";
    
  return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,m,k,sum;
  cin >> n >> m >> k;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=m;j++){
      sum=(m-j)*i+(n-i)*j;
      if(sum==k){
        cout << "Yes\n";
        return 0;
      }
    }
  }
  cout << "No\n";
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int cmpnum(const void * n1, const void * n2)
{
	if (*(int *)n1 > *(int *)n2)
	{
		return 1;
	}
	else if (*(int *)n1 < *(int *)n2)
	{
		return -1;
	}
	else
	{
		return 0;
	}
}

int main(void)
{
	int i,n,k,d,min;
	scanf("%d%d",&n,&k);
	int h[n];
	for(i=0;i<n;i++)
		scanf("%d",&h[i]);

	qsort(h, sizeof(h) / sizeof(h[0]), sizeof(int), cmpnum);
	
	min=h[k-1]-h[0];
	for(i=0;i<n-k;i++){
		d=h[k+i]-h[i+1];
		if(d<min)
			min=d;
	}
	printf("%d",min);

	return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>

using namespace std;
template<class T1, class T2> inline void chkmin(T1 &x, const T2 &y) {if (x > y) x = y;}
template<class T1, class T2> inline void chkmax(T1 &x, const T2 &y) {if (x < y) x = y;}
#define all(c) (c).begin(), (c).end()
#define sz(c) (int)(c).size()
#define mp make_pair
#define pb push_back
#define read(FILENAME) freopen((string(FILENAME) + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((string(FILENAME) + ".out").c_str(), "w", stdout);





int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//read("input");
	int n;
	cin >> n;
	cout << (n - 2) * 180 << '\n';
	return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  int n;
  std::cin >> n;
  std::cout << "ABC" << n <<endl;

  return 0;
}


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

int main() {
    int N,M;
    cin>>N>>M;
    
    int s[M],c[M],d[3],e[3];
    int a=0;
    int b;
    
    if(N==3){
        d[0]=100;
        d[1]=10;
        d[2]=1;
    }
    else if(N==2){
        d[0]=10;
        d[1]=1;
        d[2]=0;
    }
    else{
        d[0]=1;
        d[1]=0;
        d[2]=0;
    }
    e[0]=1;
    e[1]=0;
    e[2]=0;
    if(M==0 && N==1)e[0]=0;
    
    for(int i=0;i<M;i++){
        cin>>s[i]>>c[i];
        e[s[i]-1]=c[i];
        if(N>1 && s[i]==1 && c[i]==0){
            a=-1;
        }
    }
    for(int i=0;i<M;i++){
        for(int j=0;j<i;j++){
        if(s[i] == s[j] && c[i] != c[j]){
            a=-1;
        }
        }
    }
    b=d[0]*e[0]+d[1]*e[1]+d[2]*e[2];
    if(a==-1){
        cout<<a<<endl;
    }
    else{
        cout<<b<<endl;
    }

	return 0;
}

Measured memory_bytes: 256
#include        <map>
#include      <cmath>
#include      <queue>
#include     <string>
#include     <cstdio>
#include     <vector>
#include    <cstring>
#include   <iostream>
#include  <algorithm>
using namespace std;
#define ll long long
const ll inf = 0x3f3f3f3f3f3f3f3f;
const int maxn = 200+5;
const ll mod = 1e9+7;

int n;
int matching[maxn];
int check[maxn];
struct point{
    int x, y;
}red[maxn], blue[maxn];
int vis[maxn];
int link[maxn];
int t;
int find(int x){
    for(int i=1;i<=n;i++){
        int y=i;
        if(red[x].x < blue[y].x && red[x].y < blue[y].y)
        if(vis[y]!=t){
            vis[y]=t;
            if(link[y]==0||find(link[y]))
            {
                link[y]=x;
                return 1;
            }
        }
    }
    return 0;
}

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d%d",&red[i].x,&red[i].y);
    for(int i=1;i<=n;i++)
        scanf("%d%d",&blue[i].x,&blue[i].y);
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        t++;
        if(find(i)){
            ans++;
        }
    }
    printf("%d\n",ans);
    return 0;
}
/**
bool dfs(int u){
    for (int i = 0; i < n; ++i) { // 对 u 的每个邻接点
        int v = i;
        if(red[u].x < blue[v].x && red[u].y < blue[v].y)
        if (!check[v]) {     // 要求不在交替路中
            check[v] = true; // 放入交替路
            if(matching[v] == -1 || dfs(matching[v])) {
                // 如果是未盖点，说明交替路为增广路，则交换路径，并返回成功
                matching[v] = u;
                matching[u] = v;
                return true;
            }
        }
    }
    return false; // 不存在增广路，返回失败
}

int hungarian(){
    int ans = 0;
    memset(matching, -1, sizeof(matching));
    for(int u=0; u < n; ++u){
        if (matching[u] == -1){
            memset(check, 0, sizeof(check));
            if (dfs(u))
                ++ans;
        }
    }
    return ans;
}

int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d%d",&red[i].x,&red[i].y);
    for(int i=0;i<n;i++)
        scanf("%d%d",&blue[i].x,&blue[i].y);
    printf("%d\n",hungarian());
    return 0;
}
*/
/**
struct point{
    int x, y;
    bool operator <(const point& b)const {
        return x < b.x;
    }
} red[maxn], blue[maxn];
int vis[maxn];

int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d%d",&red[i].x,&red[i].y);
    for(int i=0;i<n;i++)
        scanf("%d%d",&blue[i].x,&blue[i].y);
    int ans = 0;
    sort(red,red+n);
    sort(blue,blue+n);
    memset(vis,0,sizeof(vis));
    for(int i=0;i<n;i++){
        int tl = -1;
        for(int j=0;j<n;j++)if(vis[j]==0){
            if(red[i].x < blue[j].x && red[i].y < blue[j].y){
                if(tl == -1 || blue[j].y < blue[tl].y)
                    tl = j;
            }
        }
        if(tl!=-1){
            vis[tl] = 1;
            ans ++;
        }
    }
    printf("%d\n",ans);
    return 0;
}
*/


Measured memory_bytes: 256
//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;
#define MAX 100005
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n, x, y; cin>>n>>x>>y;
    map<ll,ll> mp;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            ll val= j-i;
            val=min(val,abs(x-i)+1+abs(y-j));
            val=min(val,abs(y-i)+1+abs(x-j));
            mp[val]++;
        }
    }
    for(int i=1;i<=n-1;i++) cout<<mp[i]<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
 
int main(){
	long long n,k,ans=0;
	long long list[100001];
	long long a,b,m=0;
	scanf("%lld %lld",&n,&k);
	int i;
        for(i=0;i<100001;i++){
                list[i] = 0;
        }
	for(i=0;i<n;i++){
		scanf("%lld %lld",&a,&b);
		list[a] += b;
	}
	for(i=0;i<100001;i++){
		m = m + list[i];
		if(m>=k){
			ans = i;
			break;
		}
	}
	printf("%d\n",ans);
}

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

int main(){
  int N;
  int W[110];
  int sum1=0,sum2=0;
  int sumabs[110];
  cin >> N;
  for (int i=0 ; i<N;i++){
    cin >> W[i];
  }
  for(int T=1;T<N;T++){
    for(int i=0; i<T;i++){
      sum1 += W[i];
    }
    for(int i=T;i<N;i++){
      sum2 += W[i];
    }
    sumabs[T-1] = abs(sum1-sum2);
    sum1=0;
    sum2=0;
  }
  int ans=sumabs[0];
  for(int i =0;i<N-1;i++){
    if(ans>sumabs[i]){
      ans=sumabs[i];
    }
  }
  cout<<ans;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define prique2(T) priority_queue<T>
struct edge { int to, cost; };
using P = pair<int, int>;
using PP = pair<P, int>;
const int mod2 = 998244353;
const int mod = 1e9 + 7, inf = 1e16;

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

int fact_memo[114514];
int fact(int n) {
	int ans = 1;
	if (fact_memo[n]) return fact_memo[n];
	rep(i, n) {
		ans *= (i + 1);
		if (mod <= ans) ans %= mod;
		fact_memo[i + 1] = ans;
	}
	return (ans + mod) % mod;
}

int comb(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) + mod) % mod;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod + mod) % mod;
}

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

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

bool pri(int p) {
	for (int i = 2; i * i <= p; i++) if (p % i == 0) return false;
	return p > 1;
}

map<int, int>factring(int n) {
	map<int, int>ans;
	for (int i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			n /= i;
			ans[i]++;
		}
	}
	if (n != 1) ans[n]++;
	return ans;
}

P operator+(const P& a, const P& b) {
	return P(a.first + b.first, a.second + b.second);
}
P operator-(const P& a, const P& b) {
	return P(a.first - b.first, a.second - b.second);
}

signed main() {
	int a;
	string s;
	cin >> a >> s;
	if (3200 <= a) cout << s << endl;
	else cout << "red" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int N=105;
using namespace std;
long long dp[N],n,ar[N];
int32_t main()
{
    cin>>n;
    for(int i=1;i<=n;i++)cin>>ar[i];
    dp[1]=1000;
    for(int i=1;i<=n;i++){
        long long j=i+1;
        long long cnt=dp[i]/ar[i];
        long long lef=dp[i]-cnt*ar[i];
        long long vl=lef+cnt*ar[j];
        dp[j]=max(dp[j],vl);
        dp[j]=max(dp[j],dp[j-1]);

    }
    cout<<dp[n]<<'\n';
    return 0;
}


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

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

	vector<string> d{"SUN","MON","TUE","WED","THU","FRI","SAT"};
	for (int i = 0; i <= 7; ++i){
		if (d[i] == s){
			cout<<(7-i)%8<<endl;
			break;
		}
	}
}


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

int main() {
  int N;
  cin >> N;
  
  int kmin = 100; // count
  
  for (int i = 0; i < N ; i++){
    int A;
    cin >> A;
    
    int k = 0;
    while (A % 2 == 0){
      A /= 2;
      k++;
    }
    
    kmin = min(kmin, k);
  }
  cout << kmin << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	string S, T;
	cin >> S >> T;
	int s = S.size();
	int t = T.size();
	int cnt = 0;
	for(int i=s-1;i>=0;i--){
		if (i + t-1 < s) {
			rep(j, t) {
				if(S[j+i]!=T[j]&&S[j+i]!='?'){
					cnt++;
				}
			}
			if (cnt == 0) {
				rep(j, s) {
					if (j < i || i + t <= j) {
						if (S[j] == '?') {
							cout << 'a';
						}
						else {
							cout << S[j];
						}
					}
					else {
						cout << T[j - i];
					}
				}
				cout << endl;
				return 0;
			}
			cnt = 0;
		}
	}
	cout << "UNRESTORABLE" << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define int long long
#define all(c) (c).begin(),(c).end()
#define pii pair<long long,long long>
#define endl '\n'

using namespace std;

signed main(){
    std::ios::sync_with_stdio(false);
    int x,y,z;
    cin >> x >> y >> z;
    cout << z <<" " << x << " " << y;
}

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

char s[20010];
vector<int> ans;
stack<int> S1;
stack<pair<int, int> > S2;
int main(){
	int sum = 0, a;
	char c;
	for(int i = 0; cin >> c; i++){
		if(c == '\\'){
			S1.push(i); 
		} 
		else if(c == '/'){
			if(S1.size() > 0){
				int j = S1.top();
				S1.pop();
				sum += i - j;
				a = i - j;
				while(S2.size() > 0 && S2.top().first > j){
					a += S2.top().second;
					S2.pop();
				}
				S2.push(make_pair(i, a));
			}
		}
	}
	printf("%d\n", sum);
	while(S2.size() > 0){
		ans.push_back(S2.top().second);
		S2.pop();
	}
	reverse(ans.begin(), ans.end());
	printf("%d", ans.size());
	for(int i = 0; i < ans.size(); i++) printf(" %d", ans[i]);
	printf("\n");
	return 0;
}


Measured memory_bytes: 3300
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <string>
#include <complex>
 
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <cstring>
 
#define REP(i,e) for(int i=0;i<(int)(e);i++)
#define FOR(i,b,e) for(int i=(int)(b);i<(int)(e);i++)
#define ALL(c) (c).begin(), (c).end()
#define EACH(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define RALL(c) (c).rbegin(), (c).rend()
#define ALLA(a,n) ((a)+0), ((a)+n)
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<string> vstring;
typedef vector<double> vdouble;
 
template<class T>void pp(T v,int n){ REP(i,n)cout<<v[i]<< ' ' ; cout << endl; }
template<class T>void pp(T v){ EACH(it,v) cout << *it << ' ' ; cout << endl;  }
template<class T>T& ls(T& a,T b){ if(b<a) a=b; return a; }
template<class T>T& gs(T& a,T b){ if(b>a) a=b; return a; }
inline ll to_i(const string& s){ll n;sscanf(s.c_str(),"%lld",&n);return n;}
inline string to_s(ll n){char buf[32];sprintf(buf,"%lld",n);return string(buf);}

typedef long double Double;

const Double eps = 1e-18;

typedef ll Int;


const int N = 128;


class Pascal_cls {
  static const int N = 1000;
  ll dp[N][N];
  ll rec(int n, int r) {
    if (n < 0 || r < 0) return 0;
    if (dp[n][r] != -1) return dp[n][r];
    if (n == 0 || n == r) return dp[n][r] = 1;
    return dp[n][r] = rec(n-1, r) + rec(n-1, r-1);
  }
public:
  Pascal_cls() { REP(i,N) REP(j,N) dp[i][j] = -1; }
  ll operator()(int n, int r) { return rec(n, r); }
};

Pascal_cls Pascal;


Double error(Double a, Double b) {
  Double abs_error = fabs(a - b);
  if (a > eps) { return min(abs_error, abs_error / a); }
  return abs_error;
}


int main() {
  int n, a, b;
  while (cin >> n >> a >> b) {
    vll v(n);
    REP(i,n) cin >> v[i];
    sort(RALL(v));

    Double average = 0;
    auto ave = [&](int c) { return accumulate(v.begin(), v.begin() + c, 0.0L) / c; };
    FOR(c,a,b+1) {
      gs(average, ave(c));
    }

    ll cnt = 0;
    FOR(c,a,b+1) if (error(average, ave(c)) < eps) {
      // cout << "# c = " << c << endl;
      map<ll,int> mn, mr;
      ll t = 1;
      REP(i,n) mn[v[i]]++;
      REP(i,c) mr[v[i]]++;
      for (const auto& e: mr) {
        // cout << "+= " << mn[e.first] << " C " << e.second << " = " <<
        //   C.choose(mn[e.first], e.second) << endl;
        t *= Pascal(mn[e.first], e.second);
      }
      cnt += t;
    }

    printf("%.9Lf\n%lld\n", average, cnt);
  }
}


Measured memory_bytes: 8064
package main

import(
  "strconv"
  "strings"
  "bufio"
  "os"
  "fmt"
)

func main() {
  var sc = bufio.NewScanner(os.Stdin)
  
  sc.Scan()
  var a string
  if sc.Scan() {
    a = sc.Text()
  }
 
  var b string
  if sc.Scan() {
    b = sc.Text()
  }

  var c string
  if sc.Scan() {
    c = sc.Text()
  }
  
  ar := split(a)
  br := split(b)
  cr := split(c)
  
  var prev int
  var co int
  for _,v := range ar {
    co = co + br[v - 1]
    if prev + 1 == v && prev != 0 {
      co = co + cr[v - 2]
    }
    prev = v
  }
  fmt.Println(co)
}

func split(s string) []int {
  s1 := strings.Split(s, " ")
  r := make([]int, len(s1))
  for k,v := range s1 {
    r[k], _ = strconv.Atoi(v)
  }
  return r
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int x;
char c;
inline int read()
{
	x=0; c=getchar();
	while(c<'0'||c>'9') c=getchar();
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return x;
}
int main()
{
	long n = read(), ans = n;
	for (int i = 1; i < n; ++i)
	{
        int u = read(), v = read();
		if (u > v) ans += i * (n - i + 1) - v * (n - u + 1);
        else ans += i * (n - i + 1) - u * (n - v + 1);
	}
	printf("%ld", ans);
  
    return 0;
}


Measured memory_bytes: 3744
#include <stdio.h>
 
int main(){
 
int h, w;
int x, y;
char c;
int flag;
 
while (1){
scanf("%d %d", &h, &w);
 
if (h == 0 && w == 0) break;
 
for  (y = 0; y < h; y++ ){
        for (x = 0; x < w; x++){
                if      (y % 2 == 0 && x % 2 == 0 ) c = '#';
                else if (y % 2 == 1 && x % 2 == 1 ) c = '#';
                else                                c = '.';
 
                printf("%c", c);}
                printf("\n");
                        }
                printf("\n");
}
return 0;
}

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

int main()
{
  string S;
  int64_t N, A, B, ab = 0, b = 0;
  cin >> N >> A >> B >> S;
  for (int i = 0; i < N; i++)
  {
    if (S[i] == 'a')
    {
      if (ab < A + B)
      {
        cout << "Yes" << endl;
        ab++;
        continue;
      }
    }
    else if (S[i] == 'b')
    {
      if (ab < A + B && b < B)
      {
        cout << "Yes" << endl;
        ab++;
        b++;
        continue;
      }
    }
    cout << "No" << endl;
  }
}

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

struct S {
    int id, ac, time, wa[10];
};

bool comp(S a, S b) {
    if (a.ac != b.ac) return a.ac > b.ac;
    if (a.time != b.time) return a.time < b.time;
    return a.id > b.id;
}

bool comp2(S a, S b) {
    if (a.ac != b.ac) return a.ac > b.ac;
    if (a.time != b.time) return a.time < b.time;
    return false;
}

int main() {
    int M, T, P, R;
    while (cin >> M >> T >> P >> R, M) {
        S team[50];
        for (int i = 0; i < T; i++) {
            team[i].id = i + 1;
            team[i].ac = 0;
            team[i].time = 0;
            fill_n((int*)team[i].wa, 10, 0);
        }
        for (int i = 0; i < R; i++) {
            int m, t, p, j;
            cin >> m >> t >> p >> j;
            t--;
            p--;
            if (!j) {
                team[t].ac++;
                team[t].time += m + team[t].wa[p] * 20;
            } else {
                team[t].wa[p]++;
            }
        }
        sort(team, team + T, comp);
        for (int i = 0; i + 1 < T; i++) {
            cout << team[i].id;
            if (comp2(team[i], team[i + 1])) {
                cout << ",";
            } else {
                cout << "=";
            }
        }
        cout << team[T - 1].id << endl;
    }
}


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

int main(){
    int n, m;
    cin >> n >> m;
    map<int, int> mp;
    for(int i = 0; i < n; i++){
        int k, a;
        cin >> k;
        for(int j = 0; j < k; j++){
            cin >> a;
            mp[a]++;
        }
    }
    int cnt = 0;
    for(auto e : mp) if(e.second == n) cnt++;
    cout << cnt << endl;
}

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

int main() {
  int n;
  std::cin >> n;

  auto sorted = std::vector<int>();
  auto org = std::vector<int>();
  for (int i = 0; i < n; i++) {
    int num;
    std::cin >> num;
    sorted.push_back(num);
    org.push_back(num);
  }
  std::sort(sorted.begin(), sorted.end());

  for (int i = 0; i < n; i++) {
    if (sorted[n / 2] > org[i]) {
      std::cout << sorted[n / 2] << std::endl;
    } else {
      std::cout << sorted[n / 2 - 1] << std::endl;
    }
  }
}

Measured memory_bytes: 3948
#include <iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  string keka = "No";
  for(int i = 0; s.size()-1 > i; i++){
    if(s[i] == 'A' && s[i+1] == 'C')keka="Yes";
  }
  cout << keka << endl;
}

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

Measured memory_bytes: 256
// JOI13年予選４　暑い日々
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0579
#include <iostream>
#include <cmath>
#include <cstdlib>
using namespace std;
int main(void) {
    int D,N;
    int t[201],a[201],b[201],c[201];
    int DP[201][201];
    cin >> D >> N;
    for(int j=1; j<=D; j++) {
        cin >> t[j];
    }
    for(int i=1; i<=N; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }
    for(int i=1;i<=N;i++){
        if(a[i]<=t[1] && t[1]<=b[i]){
            DP[i][1]=0;
        }
        else{
            DP[i][1]=-1;
        }
    }
    for(int j=2;j<=D;j++){
        for(int i=1;i<=N;i++){
            if(a[i]<=t[j] && t[j]<=b[i]){
                int tempmax=0;
                for(int pi=1;pi<=N;pi++){
                    if(DP[pi][j-1]>=0){
                        if(tempmax < abs(c[i]-c[pi])+DP[pi][j-1]){
                            tempmax = abs(c[i]-c[pi])+DP[pi][j-1];
                        }
                    }
                }
                DP[i][j]=tempmax;
            }
            else{
                DP[i][j]=-1;
            }
        }
    }

int max=0;
for(int i=1;i<=N;i++){
if(max<DP[i][D])max=DP[i][D];
}
cout << max << endl;
    return 0;
}



Measured memory_bytes: 3256
#include <bits/stdc++.h>
using namespace std;
#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define vi                      vector<int>
#define vld                     vector<ld>
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define fi                      first
#define se                      second
#define fastIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void inp_out()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
    #endif
}

int32_t main()
{
	fastIO
	inp_out();
	int n;
	cin>>n;
	vector<ld> a(n+1);
	for(int i=0;i<=n;++i)
		cin>>a[i];
	ld ans=0;
	ld allowed[n+1];
	allowed[0]=1;

	for(int i=1;i<=n;++i)
	{
 		allowed[i] = (allowed[i-1] - a[i-1]) * 2;

 		if(allowed[i]<0)
 		{
 			cout<<-1;
 			return 0;
 		}
	}

	ld to_cover=0;
	for(int i=n;i>=0;--i)
	{	
		if(to_cover/2 + a[i] > allowed[i])
		{
			cout<<-1;
			return 0;
		}

		if(to_cover + a[i] <= allowed[i])
		{
			ans += to_cover + a[i];
			to_cover += a[i];
		}

		else
		{
			ans += allowed[i];
			to_cover = allowed[i];
		}

	}
	cout<<fixed<<setprecision(0)<<ans;
	return 0;
}

Measured memory_bytes: 6508
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int Q = scan.nextInt();
        String S = scan.next();
        int[][] q = new int[Q][2];
        for (int i = 0; i < Q; i++) {
            q[i][0] = scan.nextInt();
            q[i][1] = scan.nextInt();
        }
        int[] dp = new int[N+1];
        boolean found_A = false;
        char[] data = S.toCharArray();
        for (int i = 1; i <= N; i++) {
            if (data[i-1] == 'A') {
                found_A = true;
                dp[i] = dp[i-1];
                continue;
            }
            if (found_A && data[i-1] == 'C') {
                dp[i] = dp[i-1] + 1;
                found_A = false;
                continue;
            }
            found_A = false;
            dp[i] = dp[i-1];
        }
        for (int i = 0; i < Q; i++) {
            System.out.println(dp[q[i][1]] - dp[q[i][0]]);
        }
    }
}


Measured memory_bytes: 101068
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //  repマクロ
#define leng(n) (int)(log10(n)+1)  //  桁数
using namespace std;

signed main() {
  int x, y;
  cin >> x >> y;
  cout << x + y/2 << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <vector>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

struct ms {
	enum {max = 300000 + 7};
	bool a[max];
	int l[max];
	int size;
	ms() : a(), l(), size() {
		for (int i = 7; i < max - 1; i += 7)
			for (int j: {i - 1, i + 1})
				a[j] = true;
		for (int i = 7; i < max - 1; i += 7)
			for (int j: {i - 1, i + 1})
				if (a[j])
					for (int k = j + j; k < max; k += j)
						a[k] = false;
	for (int i = 7; i < max - 1; i += 7)
		for (int j: {i - 1, i + 1})
			if (a[j])
				l[size++] = j;
	}
};


int main() {
	auto m = ms();
	for (int n; (n = in()) != 1;) {
		out(n, ':');
		for (int i = 0; i < m.size; i++)
			if (n % m.l[i] == 0)
				out(' ', m.l[i]);
		outl();
	}
}


Measured memory_bytes: 3968
# D - Prediction and Restriction
# https://atcoder.jp/contests/abc149/tasks/abc149_d


N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

def opt(seg):
    # dp[STEP][R/P/S]
    dp = [ [-1, -1, -1] for _ in range(len(seg))]

    dp[0][0] = (R if seg[0] == 's' else 0)
    dp[0][1] = (P if seg[0] == 'r' else 0)
    dp[0][2] = (S if seg[0] == 'p' else 0)

    for i in range(1, len(seg)):
        dp[i][0] = (R if seg[i] == 's' else 0) + max(dp[i-1][1], dp[i-1][2])
        dp[i][1] = (P if seg[i] == 'r' else 0) + max(dp[i-1][0], dp[i-1][2])
        dp[i][2] = (S if seg[i] == 'p' else 0) + max(dp[i-1][0], dp[i-1][1])

    return max(dp[-1])

segs = list()

for K_idx in range(K):
    segs.append( T[K_idx::K] )

print('{}'.format(sum(map(opt, segs))))


Measured memory_bytes: 22604
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#define INF 1000000001

using namespace std;

long long nos;

void merge(vector<int>& A, int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	vector<int> L(n1+1);
	vector<int> R(n2+1);
	for (int i = 0; i < n1; ++i) {
		L[i] = A[left+i];
	}
	L[n1] = INF;
	for (int i = 0; i < n2; ++i) {
		R[i] = A[mid+i];
	}
	R[n2] = INF;


	int lind = 0;
	int rind = 0;
	for (int i = left; i < right; ++i) {
		if (L[lind] < R[rind]) {
			A[i] = L[lind];
			++lind;
		}
		else {
			A[i] = R[rind];
			++rind;
			nos += n1-lind;
		}
	}
	return;
}

void merge_sort(vector<int>& S, int left, int right) {
	if (left+1 < right) {
		int mid = (left+right)/2;
		merge_sort(S,left,mid);
		merge_sort(S,mid,right);
		merge(S,left,mid,right);
	}
	return;
}

int main(void) {
	int n;
	cin >> n;
	vector<int> A(n);
	for (int i = 0; i < n; ++i) {
		cin >> A[i];
	}
	merge_sort(A,0,n);
	cout << nos << endl;
	return 0;
}



Measured memory_bytes: 4336
#include <iostream>

using namespace std;

int main()
{
    int x,count1=0,count2=0,i;
    for(i=0;i<3;i++){
        cin>>x;
        if(x==5)
          count1++;
        if(x==7)
          count2++;
    }
    if(count1==2&&count2==1)
      cout<<"YES";
    else
      cout<<"NO";
}


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

int cnt(int n) {
  if (n <= 3) {
    return 1;
  }

  return cnt((n + 2) / 3) + 1;
}

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

  cout << cnt(N) << endl;

  return 0;
}

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

int main()
{
    int a , b;
    cin >> a >> b;
    int ans[a+1][b+1];
    for(int i = 0; i < a ; i++){
        int sum =0,j;
        for(j = 0 ; j < b ; j++){
            int a;
            cin >> a;
            ans[i][j] = a;
            sum = sum + a;
        }
        ans[i][j] = sum;
    }
    for(int i = 0; i < (b + 1) ; i++){
        int sum =0,j;
        for(j = 0 ; j < a ; j++){
            sum = sum + ans[j][i];
        }
        ans[j][i] = sum;
    }
    for(int i = 0; i < (a + 1) ; i++){
        for(int j = 0 ; j < (b + 1) ; j++){
            if(j == b){cout << ans[i][j];}
            else cout << ans[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3092