akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n,c,sn,tn;
	int cn;
	int cc[100002*2]={};
	cin>>n>>c;
	FOR(i,0,n){
		cin>>sn>>tn>>cn;
		sn*=2;
		tn*=2;
		cn=1<<cn;
		FOR(j,sn-1,tn+1){
			cc[j]|=cn;
		}
	}
	int smax=0;
	/*
	FOR(i,1,c+1){
		FOR(j,0,100002*2){
			cc[0][j]+=cc[i][j];
		}
	}//*/
	FOR(j,0,100002*2){
		int cnt=0;
		FOR(i,1,31){
			cnt+=((cc[j]>>i)&1);
		}
		if(cnt>smax)smax=cnt;
	}
	cout<<smax<<endl;

    return 0;
}


Measured memory_bytes: 1024
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
tt = [[] for _ in range(k)]
# print(n, k, r, s, p, t)

def win(c):
	if c == 'r': return p
	elif c == 's': return r
	elif c == 'p': return s
	return 0

for i, c in enumerate(t):
	tt[i%k].append(c)
# print(tt)

score = 0
for ttt in tt:
	preC = 'X'
	for i, c in enumerate(ttt):
		if c != preC:
			score += win(c)
			preC = c
		else:
			preC = 'X'
print(score)



Measured memory_bytes: 55932
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
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; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int dp[100010];
int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> h(N);
    for(int i=0;i<N;i++) cin >> h[i];
    dp[0] = 0;
    for(int i = 1; i < N;i++){
        if(i == 1) dp[i] = dp[0] + abs(h[0] - h[1]);
        else{
            dp[i] = min(dp[i-1] + abs(h[i-1] - h[i]),
                        dp[i-2] + abs(h[i-2] - h[i]));
        }
    }
    cout << dp[N - 1] << endl;
}

Measured memory_bytes: 4028
#include <iostream>
#include <vector>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

int main(int argc, const char * argv[]) {
  int a, b, k;
  cin >> a >> b >> k;
  vector<int> divisor;
  repd(i, 1, 101){
    if(a%i == 0 && b%i == 0){
      divisor.push_back(i);
    }
  }
  cout << divisor[divisor.size() - k] << endl;
 
  return 0;
}


Measured memory_bytes: 888
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    s = list(input())
    r_s = list(reversed(s))
    if s != r_s:
        print('No')
        exit()
    n = len(s)
    s1 = s[:(n - 1) // 2]
    r_s1 = list(reversed(s1))
    if s1 != r_s1:
        print('No')
        exit()
    s2 = s[(n + 3) // 2 - 1:]
    r_s2 = list(reversed(s2))
    if s2 != r_s2:
        print('No')
        exit()
    print('Yes')

    
if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

vector<int> used;

vector<vector<int>> g;

void dfs(int cur, int ch, vector<int> &h) {
    h[cur] = ch;
    used[cur] = 1;
    for (auto t : g[cur]) {
        if (!used[t]) {
            dfs(t, ch + 1, h);
        }
    }
}

int mys(int len) {
    return len - 1;
}

int solve(int len) {
    int ca = len;
    int cb = 0;
    int ans = 0;
    
    for (int i = 0; ; i++) {
        if (i & 1) {
            ca--;
            ans++;
        } else {
            cb ^= 1;
        }
        if (ca == cb) {
            return ans;
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    int a, b;
    cin >> n >> a >> b;
    a--;
    b--;
    used.resize(n);
    g.resize(n);
    for (int i = 0; i + 1 < n; i++) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    vector<int> ha(n);
    vector<int> hb(n);
    dfs(a, 0, ha);
    fill(used.begin(), used.end(), 0);
    dfs(b, 0, hb);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (hb[i] > ha[i]) {
            ans = max(ans, ha[i] + mys(hb[i] - ha[i]));
        }
    }
    cout << ans << endl;

    // for (int i = 1; i <= 100; i++) {
    //     if (mys(i) != solve(i)) {
    //         cout << i << endl;
    //     }
    // }
}


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

using namespace std;

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

  long long int A[n];
  for(int i=0; i<n; i++) cin>>A[i];
  
  long long int mon=1000;
  long long int kabu=0;

  for(int i=0; i<n-1; i++){
    if(A[i]<A[i+1] and kabu == 0 and mon!=0){
      kabu=kabu+(mon/A[i]);
      mon=mon-(mon/A[i])*A[i];
    }else if(A[i]>A[i+1] and kabu!=0 ){
      mon=mon+kabu*A[i];
      kabu=0;
    }
  }

  if(kabu!=0){
    mon+=kabu*A[n-1];
  }

  cout<<mon<<endl;
}


Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

// Problem https://atcoder.jp/contests/abc098/tasks/arc098_a
// C++ 3rd Try
long int solver(long int MEMBERS,string POSITIONINF){
    long int result;
    result = MEMBERS;
    // EとWを0,1で各専用ベクトルに納める
    vector<int> EMembers(MEMBERS,0);
    vector<int> WMembers(MEMBERS,0);

    for(long int j = 0;j<MEMBERS;j++){
        if(POSITIONINF[j]=='E'){
            EMembers[j] = 1;
        }
        else if(POSITIONINF[j]=='W'){
            WMembers[j] = 1;
        }            
    }
    vector<int> accEMEM(MEMBERS+1,0);
    vector<int> accWMEM(MEMBERS+1,0);
    // E,Wの累積和を作成
    for(long int j=0;j<MEMBERS;j++){
        accEMEM[j+1] = accEMEM[j]+EMembers[j];
        accWMEM[j+1] = accWMEM[j]+WMembers[j];
    }
    // 各人間がリーダーの時のE,Wが向く方向を求める
    for(long int j=0;j<MEMBERS;j++){
        long int switchMember = 0;
        switchMember = accWMEM[j]+accEMEM[MEMBERS]-accEMEM[j+1];
        result = min(result,switchMember);
    }
    return result;
}


int main(void){
    long int answer=0;
    long int N;
    cin >> N;
    string S;
    cin >> S;
    answer = solver(N,S);
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 5764
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
int64_t INF = 1000000007;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    vi t(n+1), x(n+1), y(n+1);
    t.at(0) = 0;
    x.at(0) = 0;
    y.at(0) = 0;
    rep(i,n) cin >> t.at(i+1) >> x.at(i+1) >> y.at(i+1);
    bool res = true;
    rep(i,n){
        int64_t dt = t.at(i+1) - t.at(i);
        int64_t dx = x.at(i+1) - x.at(i);
        int64_t dy = y.at(i+1) - y.at(i);
        int64_t step = abs(dx) + abs(dy);
        // 偶奇が同じかつ dx + dy <= dt
        if(step>dt || step%2 != dt%2){
            res = false;
            break;
        }
    }
    cout << (res?"Yes":"No") << endl;
}

Measured memory_bytes: 2560
import std.array;
import std.algorithm;
import std.range;
import std.stdio;
import std.c.stdio : scanf;

void main() {
  int n;
  scanf("%d", &n);
  int[] d;
  d.length = n;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &d[i]);
  }
  writeln(d.sort.uniq.count!"true");
}

Measured memory_bytes: 380
#include <iostream>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

using namespace std;

typedef long long ll;

ll ans = 100000000000;
ll A, B, C, X, Y;

int main(void) {
    scanf("%lld %lld %lld %lld %lld", &A, &B, &C, &X, &Y);

    for (int i = 0; i <= max(X,Y)*2; i +=2 ) {
    	ll sum = i * C;
    	sum += max(0LL, (X - (i/2))) * A;
    	sum += max(0LL, (Y - (i/2))) * B;
    	ans = min(ans, sum);
    }
    
    printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 256
N,P=map(int,input().split())
nums = list(map(int,input().split()))
even,odd = 0,0
for num in nums:
  if num%2 == 0:
    even +=1
  else:
    odd +=1
if odd == 0:
  if P == 1:
    print(0)
  else:
    print(2**even)
else:
  print((2**even)*(2**odd)//2)

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <cassert>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
#include <type_traits>

typedef long long ll;
const ll INF = (ll)1e18 + 1;

void print(){ std::cout << std::endl; }
template <typename Head> void print(Head&& head) { std::cout << head << std::endl; }
template <typename Head, typename... Tail> void print(Head&& head, Tail&&... tail)
{
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...); // or print(tail...);
}
template<typename Iterator> void printVec(Iterator begin, Iterator end)
{
  for (Iterator it = begin; it != end; it++) {
    std::cout << "[" << std::distance(begin, it) << "] " << *it << " ";
    if ((it - begin) % 20 == 19 || it == end - 1) { std::cout << std::endl; }
  }
}
template<typename Iterator> void printVecPair(Iterator begin, Iterator end)
{
  for (Iterator it = begin; it != end; it++) {
    std::cout << "[" << it - begin << "] " << it->first << " " << it->second << " ";
    if ((it - begin) % 10 == 9 || it == end - 1) { std::cout << std::endl; }
  }
}

ll match_num[10] = {9999, 2, 5, 5, 4, 5, 6, 3, 7, 6};

int main(int argc, char* argv[])
{
  ll N, M;
  std::cin >> N >> M;
  std::map< ll, ll > mused;

  ll use_cnt = 0;
  std::vector< ll > va;
  for (ll i = 0; i < M; i++) {
    ll a;
    std::cin >> a;
    if (mused.find(match_num[a]) == mused.end() || a > mused[match_num[a]]) {
      va.push_back(a);
      use_cnt++;
    }
    mused[match_num[a]] = true;
  }

  // N本使用したときの数字個数の最大
  std::vector<ll> dp(N+10, -INF);
  dp[0] = 0LL;
  for (ll i = 0; i <= N; i++) {
    for (ll j = 0; j < use_cnt; j++) {
      ll m = match_num[va[j]];
      dp[i+m] = std::max(dp[i] + 1, dp[i+m]);
    }
  }
  //printVec(va.begin(), va.end());
  //printVec(dp.begin(), dp.end());

  std::sort(va.begin(), va.end(), std::greater<ll>());

  ll n = N;
  std::string ans;
  for (std::vector<ll>::iterator it = va.begin(); it != va.end(); it++) {
    while (n-match_num[*it] >= 0 && dp[n-match_num[*it]] == dp[n] - 1) {
      n -= match_num[*it];
      ans += std::to_string(*it);
    }
  }

  print(ans);
  return 0;
}


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




int main(){

	int x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	vector<int> arr(a),brr(b),crr(c);
	for(int i=0;i<a;i++){
		cin>>arr[i];
	}
	for(int i=0;i<b;i++){
		cin>>brr[i];
	}
	for(int i=0;i<c;i++){
		cin>>crr[i];
	}
	sort(arr.begin(),arr.end());
	sort(brr.begin(),brr.end());
	vector<int> ans;
	int cnt = 0;
	for(int i=a-1;i>=0;i--){
		if(cnt >= x)
			break;
		ans.push_back(arr[i]);
		cnt += 1;
	}
	cnt = 0;
	for(int i=b-1;i>=0;i--){
		if(cnt >= y)
			break;
		ans.push_back(brr[i]);
		cnt += 1;
	}
	for(int i=0;i<c;i++){
		ans.push_back(crr[i]);
	}
	sort(ans.begin(),ans.end());
	long long suma = 0;
	int n = ans.size();
	cnt = 0;
	for(int i=n-1;i>=0;i--){
		if(cnt >= x+y)
			break;
		suma += ans[i];
		cnt += 1;
	}
	cout<<suma<<endl;
	
	
	
	return 0;
  
}

Measured memory_bytes: 3572
def pickup(vote, choice):
	flag = 0
	sum_vote = 0
	for i in vote:
		sum_vote = sum_vote + i
	for i in vote:
		if i >= sum_vote / (choice * 4):
			continue
		else:
			flag = flag + 1
	if  choice <= int(len(vote)) - flag:
		return 0
	else:
		return 1

numbers, choice = list(map(int, input().split()))

vote = [numbers - 1]
vote = list(map(int, input().split()))

if pickup(vote, choice) == 0:
	print("Yes")
else:
	print("No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
 
template <typename T> T inf;
template <> constexpr int inf<int> = 1e9;
template <> constexpr ll inf<ll> = 1e18;

int dfs(vector<vector<int>> const& g, int v, vector<bool>& visited) {
    visited[v] = true;
    int res = 1;
    for(auto to : g[v]) {
        if(visited[to]) {
            continue;
        }
        res += dfs(g, to, visited);
    }
    return res;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<pii> es(M);
    for(int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        es[i].first = a - 1;
        es[i].second = b - 1;
    }

    int res = 0;
    for(int i = 0; i < M; ++i) {
        vector<vector<int>> g(N);
        for(int j = 0; j < M; ++j) {
            if(i == j) {
                continue;
            }
            g[es[j].first].push_back(es[j].second);
            g[es[j].second].push_back(es[j].first);
        }
        vector<bool> visited(N);
        res += dfs(g, 0, visited) != N;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
n = int(raw_input())
for _ in range(n):
    s = raw_input()
    for a in range(100):
        for b in range(26):
            ss = ''
            for c in s:
                if 'a' <= c <= 'z':
                    ss += chr((a * (ord(c) - 0x61 + b) % 26) + 0x61)
                else:
                    ss += c
            if 'that' in ss or 'this' in ss:
                r = ss
    print r

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

int main()
{
	int side1[1000], side2[1000], side3[1000], N;
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> side1[i] >> side2[i] >> side3[i];
	}
	for (int i = 0; i < N; ++i) {
		int a = side1[i] * side1[i], b = side2[i] * side2[i], c = side3[i] * side3[i];
		if (a + b == c || a + c == b || b + c == a)cout << "YES" << endl;
		else cout << "NO" << endl;
	}

	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define graph vector<vi>

const ll MAX = 2000001;
const ll mod = 1000000007;
ll po(ll x, ll n ){ 
	ll ans=1;
     while(n>0){
     	if(n&1) ans=(ans*x)%mod;
     	x=(x*x)%mod;
     	n/=2;
     }
     return ans;
}

ll add(ll a,ll b){
	return ((a%mod)+(b%mod))%mod;
}

ll multiply(ll a,ll b){
	return ((a%mod)*(b%mod))%mod;
}

ll sub(ll a,ll b){
	return ((a%mod)-(b%mod)+mod)%mod;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
	//reopen("input.txt", "r" , stdin);
	//freopen("output.txt", "w" , stdout);
	#endif

	ll n,k,total=0;
	cin>>n>>k;
	
	for(ll i=k;i<=n+1;i++){
		ll lower=(i*(i-1))/2;
		ll upper=((n*(n+1))/2-((n-i)*(n-i+1))/2);
		
		total=add(total,(upper-lower)+1);
	}
	cout<<total%mod<<el;
	return 0;
}


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

int main(){
	string s; cin>>s;
	int k=s.size();
	while(1){
		s.erase(k-2,2);
		k=s.size();
		string s1=s.substr(0,k/2);
		string s2=s.substr(k/2,k/2);
		if(s1==s2){cout<<s.size()<<endl; return 0;}
	}
}

Measured memory_bytes: 3636
n = int(input())
mode = 0
memo = 0
for i in range(n):
	a,b = map(int,input().split())
	if a == b:
		memo += 1
	else:
		memo = 0
	if memo == 3:
		mode = 1
		break
if mode:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 62388
seat = [list(map(int, input().split())) for i in range(3)]
n = int(input())
for i in range(n):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if seat[j][k] == b:
                seat[j][k] = 0
for i in range(3):
    if seat[i].count(0) == 3:
        print('Yes')
        exit()
for i in range(3):
    for j in range(3):
        if seat[j][i] != 0:
            break
    else:
        print('Yes')
        exit()
if seat[0][0] == seat[1][1] == seat[2][2] == 0:
    print('Yes')
    exit()
if seat[0][2] == seat[1][1] == seat[2][0] == 0:
    print('Yes')
    exit()
print('No')

Measured memory_bytes: 38384
from collections import defaultdict
from math import gcd
N = int(input())
mod = 10**9 + 7
D = defaultdict(int)
corner = 0
D[(0,1)]=0
D[(1,0)]=0
for i in range(N):
    x, y = map(int, input().split())
    if x*y != 0:
        x, y = x//gcd(x, y), y//gcd(x, y)
        if y > 0:
            D[(x, y)] += 1
        elif y < 0:
            D[(-x, -y)] += 1
    else:
        if x == 0 and y == 0:
            corner += 1
            continue
        else:
            if x == 0:
                D[(0, 1)] += 1
            elif y == 0:
                D[(1, 0)] += 1
ans = corner
# 以下、(0,0) を入れない時。(X,Y) のYは全て0以上で統一する（何も入れないも一応カウント）
c = 1
sub=[]
for x, y in D.keys():
    if x<0 and y>0:
        if not (y,-x) in D.keys():
            sub.append((y,-x))
for some in sub:
    D[some]=0

K=list(D.keys())
for x, y in K:
    if x > 0 and y > 0:
        a = D[(x, y)]
        b = D[(-y, x)]
        c *= (pow(2, a, mod)+pow(2, b, mod)-1)
        c %= mod
    elif y == 0:
        a = D[(1, 0)]
        b = D[(0, 1)]
        c *= (pow(2, a, mod)+pow(2, b, mod)-1)
        c %= mod
ans += c-1

print(ans % mod)

Measured memory_bytes: 82892
#include<iostream>
using namespace std;
int main(void){
  int a,b,c = 0;
 cin >> a;
  string s = to_string(a);
  for(int i =0;i < s.size();i++){
    if(s.at(i) == '2'){
      c++;
    }
  }
  cout << c;
}

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

using namespace std;
typedef long long ll;
const int MAX = 3001;

ll dp[MAX][MAX];
int v[MAX];
int main()
{
    int n;

    cin >> n;

    for(int i = 1; i <= n; ++i)
        cin >> v[i];

    for(int i = 1; i <= n; i++)
        dp[i][i] = v[i];


    for(int i = n - 1; i >= 0; i--)
        for(int j = i + 1; j <= n; j++)
            dp[i][j] = max(v[i] - dp[i + 1][j], v[j] - dp[i][j - 1]);

    cout << dp[1][n];

    return 0;
}


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    int x;
    cin >> x;
    cout << !x << endl;
    return 0;
}


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

#define rep(i, a, b) for (int i = a, i##end = b; i <= i##end; ++i)
#define per(i, a, b) for (int i = a, i##end = b; i >= i##end; --i)
#define rep0(i, a) for (int i = 0, i##end = a; i < i##end; ++i)
#define per0(i, a) for (int i = (int)a-1; ~i; --i)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define chkmax(a, b) a = max(a, b)
#define chkmin(a, b) a = min(a, b)
#define x first
#define y second

typedef long long ll;

const double eps = 1e-10;

struct Point { double x, y; };
Point operator + (Point a, Point b) { return (Point){a.x + b.x, a.y + b.y}; }
Point operator - (Point a, Point b) { return (Point){a.x - b.x, a.y - b.y}; }
Point operator * (double k, Point a) { return (Point){k * a.x, k * a.y}; }
double dot(Point a, Point b) { return a.x * b.x + a.y * b.y; }
double cross(Point a, Point b) { return a.x * b.y - a.y * b.x; }
double disc(Point a) { return sqrt(dot(a, a)); }

Point P1, P2;
int q;

int main() {
	scanf("%lf%lf%lf%lf", &P1.x, &P1.y, &P2.x, &P2.y);
	scanf("%d", &q);
	while (q--) {
		Point P3; scanf("%lf%lf", &P3.x, &P3.y);
		Point vec1 = P2-P1, vec2 = P3-P1; double t1 = cross(vec1, vec2), t2 = dot(vec1, vec2);
		if (fabs(t1) < eps) {
			if (t2 < -eps) printf("ONLINE_BACK\n");
			else printf("%s\n", disc(vec2) < disc(vec1) + eps ? "ON_SEGMENT" : "ONLINE_FRONT");
		} else printf("%s\n", t1 > 0 ? "COUNTER_CLOCKWISE" : "CLOCKWISE");
	}
	return 0;
}


Measured memory_bytes: 3256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int V, E;
const int MAX_V = 3e5 + 5;
using DD = int;
#define INF 1e9+7
DD d[MAX_V];
struct edge {int to; DD cost; };
vector<edge> G[MAX_V];

int pprev[MAX_V];

int R[200005];
int main() {
    string S, T;
    
    cin >> S;
    T = S;
    
    int renzoku = 0;
    for (int i = S.size() - 1; i >= 0; i--){
        if (S[i] == '?'){
            renzoku++;
        } else {
            renzoku = 0;
        }
        R[i] = renzoku;
    }
    rep(i, S.size()){
        if (S[i] == '?'){
            char next = i < S.size() ? S[i + R[i]]: '0';
            char prev = i > 0 ? S[i - 1]: '0';
            //fprintf(stderr, "%d: r %d, %c, %c\n", i, R[i], prev, next);
            if (prev == 'P'){
                T[i] = 'D';
            } else if (next == 'D'){
                if (R[i] % 2 == 1){
                    T[i] =  'P';
                } else {
                    T[i] =  'D';
                }
            } else if (R[i] % 2 == 0){
                T[i] = 'P';
            } else {
                T[i] = 'D';
            }
        }
    }
    cout << T;
    return 0;
}



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

int main(void) {
	int N;
	scanf("%d", &N);
	if (N % 2 == 1) {
		printf("No\n");
		return 0;
	}
	char s[110];
	scanf("%s", s);

	bool ans = true;
	for (int i = 0; i < N / 2; i++) {
		// cout << s[i] << endl;
		if (s[i] != s[N / 2 + i]) {
			ans = false;
			break;
		}
	}

	printf(ans ? "Yes" : "No");

	return 0;
}


Measured memory_bytes: 3812
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
ll n, x;
ll asize[51], psize[51];
ll buger(int n, ll x)
{

    if (n == 0)
    {
        return 1;
    }
    if (x == 1)
    {
        return 0;
    }
    if (x <= asize[n - 1] + 1)
    {
        return buger(n - 1, x - 1);
    }
    if (x == asize[n - 1] + 2)
    {
        return ll(psize[n - 1] + 1);
    }
    else
    {
        return ll(buger(n - 1, x - asize[n - 1] - 2) + psize[n - 1] + 1);
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> x;
    asize[0] = 1;
    psize[0] = 1;
    for (int i = 1; i <= 50; i++)
    {
        asize[i] = 2 * asize[i - 1] + 3;
        psize[i] = 2 * psize[i - 1] + 1;
    }
    cout << buger(n, x) << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <complex>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <stack>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <cassert>

using namespace std;

typedef long long ll;
typedef ll li;
typedef pair<int,int> PI;
#define EPS (1e-10L)
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define F first
#define S second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(),a.end()
#define FOR(it,a) for(__typeof(a.begin())it=a.begin();it!=a.end();++it)
void pkuassert(bool t){t=1/t;};
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,-1,1,1,-1};


string in[100];
int H,W;
int pos[1000];
void solve(){
  cin >> H >> W;
  map<char,int> minx,miny,maxx,maxy;
  rep(i, H) cin >> in[i];
  rep(i, H) rep(j, W){
    char ch=in[i][j];
    if(ch=='.') continue;
    if(minx.count(ch))
      minx[ch]=min(minx[ch],i);
    else minx[ch]=i;

    if(miny.count(ch))
      miny[ch]=min(miny[ch],j);
    else miny[ch]=j;

    maxx[ch] = max(maxx[ch],i);
    maxy[ch] = max(maxy[ch],j);
  }

  string str;
  FOR(it,maxx) str += it->F;
  pos['.']=100;
  do{
    rep(i,SZ(str)) pos[(int)str[i]] = i;
    bool ok=true;
    rep(i,SZ(str)){
      char ch=str[i];
      int x1=minx[ch];
      int x2=maxx[ch];
      int y1=miny[ch];
      int y2=maxy[ch];
      for(int j=x1;j<=x2;++j)
        for(int k=y1;k<=y2;++k)
          if(pos[(int)in[j][k]]>i){
            ok=false;
            break;
          }
    }
    
    if(ok){
      cout << "SAFE" << endl;
      return;
    }
      
  }while(next_permutation(ALL(str)));

  cout << "SUSPICIOUS" << endl;
}

int main(int argc, char *argv[])
{
  int n;
  cin >> n;
  rep(i, n) solve();
  return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<char,LL> P;
const LL mod=998244353;
const LL LINF=1LL<<62;
const int INF=1<<30;

vector<vector<int>> nextIndex(const string &s){
    int n = s.length();
    vector<vector<int>> ret(n+1,vector<int> (26,n));
    for (int i = n-1; i >= 0; i--) {
        for (int j = 0; j < 26; j++) ret[i][j] = ret[i+1][j];
        ret[i][s[i]-'a'] = i;
    }
    return ret;
}


int main(){
    string s;cin >> s;
    int n = s.length();
    auto p = nextIndex(s);
    vector<int> dp(n+1,INF);
    vector<P> res(n+1,make_pair(',',n));
    dp[n] = 1;
    for (int i = n-1; i >= 0; i--) {
        for (int j = 0; j < 26; j++) {
            if(p[i][j]==n){
                if(dp[i]>1){
                    dp[i] = 1;
                    res[i] = make_pair('a'+j,n);
                }
            }
            else if(dp[i] > dp[p[i][j]+1]+1){
                dp[i] = dp[p[i][j]+1]+1;
                res[i] = make_pair('a'+j,p[i][j]+1);
            }
        }
    }
    int indx = 0;
    string ans = "";
    while(indx < n){
        ans += res[indx].fs;
        indx = res[indx].sc;
    }
    cout << ans << endl;
    return 0;
}



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

int main(){
	int n;	cin>>n;
	vector<int> p(n),q(n),p2(n),q2(n);

	for(int i=0;i<n;i++){
		cin>>p[i];	p2[i]=p[i];
	}
	for(int i=0;i<n;i++){
		cin>>q[i];	q2[i]=q[i];
	}

	sort(p2.begin(),p2.end());
	sort(q2.begin(),q2.end());

	int a=0,b=0;

	do{
		a++;
		bool flag=true;
		for(int i=0;i<n;i++){
			if(p[i]!=p2[i]){
				flag=false;
				break;
			}
		}
		if(flag)break;
	}while(next_permutation(p2.begin(),p2.end()));
	do{
		b++;
		bool flag=true;
		for(int i=0;i<n;i++){
			if(q[i]!=q2[i]){
				flag=false;
				break;
			}
		}
		if(flag)break;
	}while(next_permutation(q2.begin(),q2.end()));

	cout<<abs(a-b)<<endl;
	return 0;
}


Measured memory_bytes: 256
A = [int(input()) for i in range(5)]
B = []
for a in A:
    b = a
    if b%10!=0:
        b+=9
        b = b//10*10
    B.append(b)
min_time = 10**10
for i in range(5):
    time = A[i]
    for j in range(5):
        if j==i:
            continue
        time+=B[j]
    min_time = min(min_time,time)
print(min_time)

Measured memory_bytes: 3064
N, K = gets.chomp.split(" ").map(&:to_i)
H = []
N.times{
  H << gets.to_i
}

H.sort!
ans = 10 ** 10
0.upto(N-K){|i|
  wk = H[i+K-1] - H[i]
  ans = wk if ans > wk
}

puts ans


Measured memory_bytes: 4016
var
    s:string;
    n:int64;
    i,j:longint;
begin
    read(n);
    for i:=trunc(sqrt(n)) downto 1 do
        if n mod i=0 then
        begin
            j:=n div i;
            str(j,s);
            writeln(length(s));
            halt;
        end;
end.

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

int main()
{
	string S;
	long long int K;

	cin >> S >> K;

	long long int ans = 0;

	if (S.length() == 1)
	{
		cout << K / 2 << endl;
		return 0;
	}

	//全部同じか

	bool zenbuonaji = true;
	for (int i = 1; i < S.length(); i++)
	{
		if (S[i] != S[i - 1])
		{
			zenbuonaji = false;
			break;
		}
	}

	if (zenbuonaji == true)
	{

		ans = S.length() * K / 2;
		cout << ans << endl;
		return 0;
	}

	// 全部同じでないとき

	// 両端異なるとき

	int count = 1;

	char Sbegin = S[0];
	char Send = S[S.length() - 1];

	if (Sbegin != Send)
	{
		for (int i = 1; i < S.length(); i++)
		{
			if (S[i] == S[i - 1])
			{
				count++;
			}

			if ((S[i] != S[i - 1]) || (i == S.length() - 1))
			{
				if (count != 1)
				{
					ans += (count / 2) * K;
					count = 1;
				}
			}
		}
	}
	else // 両端同じとき
	{
		int begincount = 1;
		int endcount = 1;

		int ibegin;
		int iend;

		for (int i = 1;; i++)
		{
			if (S[i] == S[i - 1])
			{
				begincount++;
			}
			else
			{
				ibegin = i;
				break;
			}
		}

		for (int i = S.length() - 2;; i--)
		{
			if (S[i] == S[i + 1])
			{
				endcount++;
			}
			else
			{
				iend = i + 1;
				break;
			}
		}

		for (int i = ibegin + 1; i < iend; i++)
		{
			if (S[i] == S[i - 1])
			{
				count++;
			}

			if ((S[i] != S[i - 1]) || (i == iend - 1))
			{
				if (count != 1)
				{
					ans += (count / 2) * K;
					count = 1;
				}
			}
		}

		if (begincount > 1)
		{
			ans += begincount / 2;
		}

		if (endcount > 1)
		{
			ans += endcount / 2;
		}

		ans += (begincount + endcount) / 2 * (K - 1);
	}

	cout << ans << endl;

	return 0;
}


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

int main() {
  int n;
  cin >> n;
  long a[n], s[n], sum = 0, cnt = 0, num = 0, ans;
  for (int i=0; i<n; i++) {
    cin >> a[i];
    sum += a[i];
    s[i] = sum;
  }
  for (int i=0; i<n; i++) {
    if (i%2) {
      if (s[i]+num<0)
        continue;
      cnt += s[i]+num+1;
      num = -s[i]-1;
    } else {
      if (s[i]+num>0)
        continue;
      cnt += -s[i]-num+1;
      num = -s[i]+1;
    }
  }
  ans = cnt;
  cnt = 0;
  num = 0;
  for (int i=0; i<n; i++) {
    if (i%2) {
      if (s[i]+num>0)
        continue;
      cnt += -s[i]-num+1;
      num = -s[i]+1;
    } else {
      if (s[i]+num<0)
        continue;
      cnt += s[i]+num+1;
      num = -s[i]-1;
    }
  }
  ans = min(ans, cnt);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>

using namespace std;

const long long MAXN = 5e3+5;

vector<long long> v1[MAXN];
long long dp[MAXN][MAXN][3];
long long temp[MAXN][3];
long long sz[MAXN];
long long arr[MAXN];
void dfs(long long curr,long long par){
    for(long long x:v1[curr]){
        if(x!=par){
            dfs(x,curr);
            
        }
        
    }
    long long sum = 1; //current subtree sz
    dp[curr][0][arr[curr]<0] = arr[curr]; //0 edges cut, is a computer = 1, not a computer  = 0 
    for(long long x:v1[curr]){
        if(x!=par){
            for(long long i=0;i<sum;i++){
                for(long long j=0;j<sz[x];j++){
                    for(long long k1=0;k1<2;k1++){
                        for(long long k2=0;k2<2;k2++){
                            //merge components together(all possible cuts)
                            temp[i+j][k1|k2] = min(temp[i+j][k1|k2],dp[curr][i][k1]+dp[x][j][k2]);
                            if((k2 == 0 && dp[x][j][k2]<1e18)||(k2 == 1 && dp[x][j][k2]<0)){
                                //cut edge between curr and x, cuts++, whether or not a computer exists 
                                //depends on the current component itself. You can only do this if x's subtree
                                //has a value less than 0 when it has a computer, or if x's subtree doesn't currently have a computer.
                                temp[i+j+1][k1] = min(temp[i+j+1][k1],dp[curr][i][k1]);
                            }
                        }
                    }
                }
            }
            //(actually O(n))
            sum+=sz[x];
            for(long long i=0;i<sum;i++){
                for(long long k=0;k<2;k++){
                    dp[curr][i][k] = temp[i][k];
                    temp[i][k] = 1e18;
                    //update all values to dp
                }
            }
        }
    }
    sz[curr] = sum;
}
int main(){
    long long n;
    cin>>n;
    for(long long i=1;i<=n;i++){
        cin>>arr[i];
    }
    for(long long i=1;i<n;i++){
        long long u,v;
        cin>>u>>v;
        v1[u].push_back(v);
        v1[v].push_back(u);
    }
    for(long long i=1;i<=n;i++){
        for(long long j=0;j<=n;j++){
            for(long long k=0;k<=1;k++){
                dp[i][j][k] = 1e18;
                temp[j][k] = 1e18;
            }
        }
    }
    dfs(1,1);
    long long ans = n-1;
    for(long long i=0;i<n;i++){
        if(dp[1][i][0]<1e18){
            ans = min(ans,i);
        }
        if(dp[1][i][1]<0){
            ans = min(ans,i);
        }
    }
    cout<<ans<<endl;
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){
  if(x==0)return y;else if(y==0)return x;
  ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

template <typename T>
struct SegmentTree{
  using F = function<T(T,T)>;
  int n;
  F f;
  T ti;
  vector<T> dat;
  SegmentTree(){};
  SegmentTree(F f,T ti):f(f),ti(ti){}
  void init(ll n_){    
    n=1;
    while(n<n_) n<<=1;
    dat.assign(n<<1,ti);
  }
  void build(const vector<T> &v){
    ll n_=v.size();
    init(n_);
    for(ll i=0;i<n_;i++) dat[n+i]=v[i];
    for(ll i=n-1;i;i--)
      dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);
  }
  void set_val(ll k,T x){
    dat[k+=n]=x;
    while(k>>=1)
      dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]);    
  }
  T query(ll a,ll b){
    T vl=ti,vr=ti;
    for(ll l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
      if(l&1) vl=f(vl,dat[l++]);
      if(r&1) vr=f(dat[--r],vr);
    }
    return f(vl,vr);
  }
};

int main(){
  ll res=0;
  ll n;
  cin>>n;
  SegmentTree<ll>rmq(
			   [](ll a,ll b){return gcd(a,b);},
			   0);
  vector<ll> a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  rmq.build(a);       
  for(int i=0;i<n;i++){
    ll k;
    if(i==0)k=rmq.query(1,n);
    else if(i==n-1)k=rmq.query(0,n-1);
    else k=gcd(rmq.query(0,i),rmq.query(i+1,n));
    chmax(res,k);
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  deque<int> d;
  for(int i=0;i<n;i++){
    if(i%2) d.push_front(a[i]);
    else d.push_back(a[i]);
  }
  if(n%2) reverse(d.begin(),d.end());
  for(int i=0;i<n;i++){
    if(i) cout<<" ";
    cout<<d[i];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 5376
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(usize);
    println!("{}", (N - 2) * 180);
}


Measured memory_bytes: 4352
H,W = map(int,input().split())
S = []
flag = "Yes"
for i in range(0,H):
    S.append(list(input()))

    
for i in range(0,H):
    for j in range(0,W):
        if S[i][j] == "#":
            if i != 0 and S[i-1][j] == "#" : continue
            elif i != H-1 and S[i+1][j] == "#": continue
            elif j != 0 and S[i][j-1] == "#": continue
            elif j != W-1 and S[i][j+1] == "#":continue
            else: flag = "No"
            
print(flag)
          

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

typedef long long ll;

struct Node
{
	int x, y;
}a[1010];
string ans[1010];
int n, cnt, d[45];

void solve(int x)
{
	d[++cnt] = x;
	for(int i = 1; i <= n; ++i)
	{
		if(abs(a[i].x) > abs(a[i].y))
		{
			if(a[i].x > 0) ans[i] += "R", a[i].x -= x;
			else ans[i] += "L", a[i].x += x;
		}
		else
		{
			if(a[i].y > 0) ans[i] += "U", a[i].y -= x;
			else ans[i] += "D", a[i].y += x;
		}
	}
}

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
		scanf("%d %d", &a[i].x, &a[i].y);
	for(int i = 30; ~i; --i) solve(1 << i);
	if(a[1].x || a[1].y) solve(1);
	for(int i = 1; i <= n; ++i)
		if(a[i].x || a[i].y) return puts("-1"), 0;
	printf("%d\n", cnt);
	for(int i = 1; i <= cnt; ++i) printf("%d ", d[i]); puts("");
	for(int i = 1; i <= n; ++i) cout << ans[i] << "\n";
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
	long long a,b,k;
	cin>>a>>b>>k;
	if(k<=a) a=a-k;
	else if(k>a) {
		b-=(k-a);
		a=0;
	}
	
	if(b<0) b=0;
	cout<<a<<" "<<b;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn calc_point(r: i64, s: i64, p: i64, ch: char) -> i64 {
    if ch == 'r' {
        return p;
    }
    if ch == 's' {
        return r;
    }
    s
}

fn main() {
    let v = read_vec::<usize>();
    let (n, k) = (v[0], v[1]);
    let v = read_vec::<i64>();
    let (r, s, p) = (v[0], v[1], v[2]);
    let t = read::<String>().chars().collect::<Vec<_>>();
    let mut winned = vec![true; n];

    let mut ans = 0;
    for i in 0..n {
        if i < k {
            ans += calc_point(r, s, p, t[i]);
            continue;
        }
        if t[i - k] == t[i] && winned[i - k] {
            winned[i] = false;
        } else {
            ans += calc_point(r, s, p, t[i]);
        }
    }
    println!("{}", ans);
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
# -*- coding: utf-8 -*-
# B - Homework
# 標準入力の取得
N,M = list(map(int, input().split()))
A = list(map(int, input().split()))

# 求解処理
result = N - sum(A)
if result >= 0:
    print(result)
else:
    print(-1)

Measured memory_bytes: 10016
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
vector<P> G[1111];
int p[1111],d[1111];
bool leaf[1111];
int q,res;
void dfs(int v,int b=-1,int d=0){
  if(res<d){
    res=d;
    q=v;
  }
  for(P e:G[v]){
    if(e.first==b) continue;
    if(leaf[e.first]) continue;
    dfs(e.first,v,d+e.second);
  }
}
signed main(){
  int n;
  while(cin>>n,n){
    for(int i=0;i<1111;i++) G[i].clear();
    for(int i=1;i<n;i++) cin>>p[i];
    for(int i=1;i<n;i++) cin>>d[i];
    for(int i=1;i<n;i++){
      p[i]--;
      G[i].emplace_back(p[i],d[i]);
      G[p[i]].emplace_back(i,d[i]);
    }
    int ans=0;
    for(int i=1;i<n;i++) ans+=d[i]*3;
    memset(leaf,0,sizeof(leaf));
    for(int i=0;i<n;i++){
      if((int)G[i].size()==1){
	leaf[i]=1;
	ans-=G[i][0].second*2;
      }
    }
    q=0;res=0;
    for(int i=0;i<n;i++){
      if(leaf[i]) continue;
      dfs(0);
      break;
    }
    res=0;
    dfs(q);
    cout<<ans-res<<endl;
  }
  return 0;
}

Measured memory_bytes: 3300
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e18;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

vector<ll> a;
vector<ll> b;
vector<ll> c;
int main() {
	cin >> N;
	rep(i, N){
		cin >> A;
		a.push_back(A);
	}
	rep(i, N){
		cin >> A;
		b.push_back(A);
	}
	rep(i, N){
		cin >> A;
		c.push_back(A);
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());

	ll ans = 0;
	rep(i, N){
		ans += (lower_bound(a.begin(), a.end(), b[i]) - a.begin())*(N - (upper_bound(c.begin(), c.end(), b[i]) - c.begin()));
	}
	cout << ans;
}

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
static const int MAXN = 1e3 + 10;
ll a[MAXN];
int main()
{
    int n;
    scanf("%d" , &n);
    if(n == 1)
    {
        ll a;
        cin >> a;
        cout << a << "\n";
        return 0;
    }
    for(int i = 1 ; i <= n ; ++i)
    {
        cin >> a[i];
    }
    ll g = __gcd(a[1] , a[2]);
    ll pre = a[1] / g * a[2];
    for(int i = 3 ; i <= n ; ++i)
    {
        g = __gcd(pre , a[i]);
        pre = pre / g * a[i];
    }
    cout << pre << "\n";
}


Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;

typedef long long ll;

const ll INF = 1e18;
const int BIG = 1e9;
const int maxN = 100 * 1000 + 9;
const string FILENAME = "sample";

int n, a, b, c, d;
string s;

void read(){
	cin >> n >> a >> b >> c >> d;
	cin >> s;
}

void solv(){
	s = '#' + s + '#';
	for(int i = b; i + 1 <= d; i++){
		if(s[i] == '#' && s[i + 1] == '#'){
			cout << "No\n";
			return;
		}
	}

	for(int i = a; i + 1 <= c; i++){
		if(s[i] == '#' && s[i + 1] == '#'){
			cout << "No\n";
			return;
		}
	}
	
	if(c < d){
		cout << "Yes\n";
		return;
	}

	if(c > d){
		for(int i = b; i <= d; i++){
			if(s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.'){
				cout << "Yes\n";
				return;
			}
		}

		cout << "No\n";
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
#ifdef h4h4
	freopen((FILENAME + ".inp").c_str(), "r", stdin);
	freopen((FILENAME + ".out").c_str(), "w", stdout);
#endif

	read();
	solv();

	return 0;
}

Measured memory_bytes: 720
#include<stdio.h>
#include<iostream>
#include<deque>
using namespace std;
char c;
int m=0,n,i,k;
int main()
{
	scanf("%d%d",&n,&k);
	for(i=n;i>=1;i--);
	{
		scanf("%d",&m);
	}
	printf("%d",(n-2)/(k-1)+1);
}

Measured memory_bytes: 256