akhauriyash/Code-Regression huggingface dataset:
/*
  AOJ 1077
  Title:The Great Summer Contest
  @kankichi573
*/
#include <stdio.h>
#define max(x,y) (((x)>(y))?(x):(y))
#define min(x,y) (((x)<(y))?(x):(y))

int n[6];

int solve(int x1,int x2,int x3)
{
  int ret=0;
  ret=max(ret,x1/3+x2/3+x3/3);
  if(x1>0 && x2>0 && x3>0)
    ret=max(ret,(x1-1)/3+(x2-1)/3+(x3-1)/3+1);
  if(x1>1 && x2>1 && x3>1)
    ret=max(ret,(x1-2)/3+(x2-2)/3+(x3-2)/3+2);
  return(ret);
}
main()
{
  int ret;

  while(scanf("%d %d %d %d %d %d",&n[0],&n[1],&n[2],&n[3],&n[4],&n[5]) &&
	(n[0]||n[1]||n[2]||n[3]||n[4]||n[5]||n[6]))
    {
      ret=solve(n[0]+n[3],n[1]+n[4],n[2]+n[5]);
      printf("%d\n",ret);
    }
  return(0);
}

Measured memory_bytes: 600
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll n;
  string s;
  cin >> n >> s;
  string str = s.substr(0, n/2);
  string str2 = s.substr(n/2, n);
  if(str == str2) cout << "Yes"; 
  else cout << "No";
  return 0;
} //good night.

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#define INF 3000

using namespace std;
int A, B, C, N;
int l[1001];

int solve(int n,int a,int b,int c)
{
	if (n == N) {
		if (min(min(a,b),c)==0) {
			return INF;
		}
		else {
			return abs(A - a) + abs(B - b) + abs(C - c)-30;
		}
	}
	else {
		int ans;
		ans = solve(n + 1, a, b, c);
		ans = min(ans, solve(n + 1, a + l[n], b, c) + 10);
		ans = min(ans, solve(n + 1, a, b + l[n], c) + 10);
		ans = min(ans, solve(n + 1, a, b, c + l[n]) + 10);
		return ans;
	}
}

int main(void)
{

	int i;

	cin >> N >> A >> B >> C;
	for (i = 0; i < N; i++) {
		cin >> l[i];
	}

	cout << solve(0,0,0,0) << endl;
	return 0;
}


Measured memory_bytes: 256
def max(a,b):
    if a>b:
        return a
    else:
        return b

def min(a,b):
    if a>b:
        return b
    else:
        return a

def gcd(a,b):
    a,b = max(a,b),min(a,b)
    while a%b!=0:
        a,b = b,a%b
    return b

from collections import defaultdict
def factorize(n,dd):
    #print(int(n**0.5))
    for i in range(2,int(n**0.5)+1):
        flag=True
        while n%i==0 and n>0:
            if flag:
                if dd[i]>0:
                    return False
                else:
                    flag=False
            dd[i]+=1
            n//=i
    if n>1:
        if dd[n]>0:
            return False
        dd[n]+=1
    #print(dd)
    return True

def gcdl(A):
    if len(A)==2:
        return gcd(A[0],A[1])
    elif len(A)==1:
        return A[0]
    else:
        return gcd(gcdl(A[:len(A)//2]),gcdl(A[len(A)//2:]))

import sys

sys.setrecursionlimit(500000)
def input():
    return sys.stdin.readline()[:-1]

def main():
    N = int(input())

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

    B = [a for a in A if a!=1]

    if len(B)<=1:
        print("pairwise coprime")
    else:
        N = len(B)
        if N>78498:
            if len(B)!=len(A):
                print("setwise coprime")
            else:
                print("not coprime")
        else:
            dd = defaultdict(int)
            flag=True
            for b in B:
                if factorize(b,dd)==False:
                    flag=False
                    break
            if flag:
                print("pairwise coprime")
            else:
                if len(B)!=len(A):
                    print("setwise coprime")
                elif gcdl(B)==1:
                    print("setwise coprime")
                else:
                    print("not coprime")        
        
if __name__ == '__main__':
    main()



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

int main(){
    int N;
    cin >> N;
    int count = 0;
    
    for (int i = 1; i <= N; i++)
    {   
        if(i % 2 == 0) continue;
        int num = 0;
        for (int j = 1; j <= i; j++)
        {
            if(i % j == 0) num++;
        }
        if(num == 8) count++;
    }
    cout << count << "\n";
    return 0;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

int nxt[111111];
int tsutaJ[111111];
	
int main(){
	int n,q;cin >> n >> q;
	vector<int> seica(n);
	REP(i,n){
		cin >> seica[i];
	}
	
	if(n == 1){
		REP(i,q){
			int tyome;cin >> tyome;
		}
		cout << 1 << endl;
		return 0;
	}
	
	REP(i,n-1){
		nxt[seica[i]] = seica[i+1];
		tsutaJ[seica[i+1]] = seica[i];
	}
	nxt[0] = seica[0];
	tsutaJ[0] = -1;
	nxt[seica[n-1]] = n+1;
	tsutaJ[n+1] = seica[n-1];
	tsutaJ[seica[0]] = 0;
	REP(i,q){
		int neko;
		cin >> neko;
		if(nxt[neko] == n+1){
			int aaa = nxt[0];
			int bbb = tsutaJ[neko];
			nxt[0] = neko;
			tsutaJ[neko] = 0;
			nxt[neko] = aaa;
			tsutaJ[aaa] = neko;
			nxt[bbb] = n+1;
			tsutaJ[n+1] = bbb;
		} else if(tsutaJ[neko] == 0){
			int aaa = nxt[neko];
			int bbb = tsutaJ[n+1];
			nxt[0] = aaa;
			tsutaJ[aaa] = 0;
			nxt[bbb] = neko;
			tsutaJ[neko] = bbb;
			nxt[neko] = n+1;
			tsutaJ[n+1] = neko;
		}
		else{
			int aaa = nxt[0];
			int bbb = tsutaJ[neko];
			int ccc = nxt[neko];
			int ddd = tsutaJ[n+1];
			nxt[0] = ccc;
			tsutaJ[ccc] = 0;
			nxt[ddd] = neko;
			tsutaJ[neko] = ddd;
			nxt[neko] = aaa;
			tsutaJ[aaa] = neko;
			nxt[bbb] = n+1;
			tsutaJ[n+1] = bbb;
		}
	}
	int neko = nxt[0];
	REP(i,n){
		cout << neko;
		if(i != n-1)cout << " ";
		neko = nxt[neko];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3900
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend
#define all(x) (x).begin(),(x).end()
int n,ser=0;
std::vector<int> a;
int main(){
  cin >> n;
  a.resize(n);
  for (size_t i = 0; i < n; i++) {
    cin >> a[i];
  }
  while(1) {
    int min=INT_MAX,mini=-1,flag=0;
    for (size_t i = 0; i < n; i++) {
      if(a[i] < min && a[i] != 0){
        min = a[i];
        mini = i;
      }
    }
    for (size_t i = 0; i < n; i++) {
      if(i == mini)continue;
      a[i] = a[i]%min;
      if(a[i] == 0)flag++;
    }
    if(flag == n-1)break;
  }
  int ans = INT_MAX;
  for (size_t i = 0; i < n; i++) {
    if(a[i] < ans && a[i] != 0)ans = a[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define INF 9223372036854775807
const ll mod=1e9+7;


int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    string s,t;
    cin>>s>>t;
    ll f=1;
    for(ll i=0;i<s.size();i++){
        if(t[i]!=s[i]){
            f=0;
            break;
        }
    }
    if(f)
        cout<<"Yes\n";
    else
        cout<<"No";

    return 0;
}


Measured memory_bytes: 3608
#include <cstdio>
#include <algorithm>
using namespace std;

long long ten[16];
int main()
{
    long long y,n;
    long long sum=0,d=0,x;

    ten[0]=10;
    for(x=1;x<17;x++)
        ten[x]=ten[x-1]*10;

    scanf("%lld",&n);

    y=n;
    while(y){
        sum+=y%10;
        y=y/10;
        d++;
    }

    y=9*(d-1);
    if(n>=10&&n/ten[d-2]-1)
        y+=n/ten[d-2]-1;
    printf("%lld",max(sum,y));

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int MAX = 200009;
int A[2 * MAX];
int a[MAX];
int f[2 * MAX];
main(){
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        f[n - a[i] + 1]++;
        a[i] = n + 1 - a[i];
    }
    for(int i = 1; i <= n; i++){
        A[i + f[i]] --;
        A[i] ++;
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        A[i] += A[i - 1];
        if(A[i] == 0) ans++;
    }
    while( m --){
        int x, y;
        cin >> x >> y;
        y = n + 1 - y;
        int o = a[x]; a[x] = y;
        int mn = o + f[o] - 1;
        A[mn] --;
        f[o] --;
        if(A[mn] == 0 && mn <= n) ans++;
        f[y] ++;
        int pl = y + f[y] - 1;
        A[pl] ++;
        if(A[pl] == 1 && pl <= n) ans --;
        cout << ans << endl;
    }

}


Measured memory_bytes: 3840
import java.util.Scanner;

public class Main {

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

		int[] Ms = new int[31];
		for (int i=0; i<N; i++) {
			int K = sc.nextInt();
			for (int j=0; j<K; j++) {
				int Aij = sc.nextInt();
				Ms[Aij]++;
			}
		}
		int cnt = 0;
		for (int i=0; i<Ms.length; i++) {
			if ( Ms[i] == N ) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}

}


Measured memory_bytes: 22228
import java.util.*;

public class Main {
     public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arrA = new int[n];
        int[] arrB = new int[n];
        for (int i = 0; i < n; i++) {
            arrA[i] = sc.nextInt();
            arrB[i] = sc.nextInt();
        }
        long added = 0;
        for (int i = n - 1; i >= 0; i--) {
            long mod = (arrA[i] + added) % arrB[i];
            if (mod != 0) {
                added += arrB[i] - mod;
            }
        }
       System.out.println(added);
    }
}


Measured memory_bytes: 76792
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <bitset>
#include <cmath>
#include <iomanip>

using namespace std;

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////


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

    int N, W, S = 0;
    cin >> N >> W;

    vector<pair<int, int>> items(N + 1);
    for (int i = 1; i <= N; i++) {
        cin >> items[i].first >> items[i].second;
        S += items[i].second;
    }

    vector<vector<int64>> dp(N + 1, vector<int64>(S + 1, W + 1));

    dp[0][0] = 0;

    for (int i = 1; i <= N; i++) {
        for (int v = 0; v <= S; v++) {
            dp[i][v] = dp[i-1][v];
            if (v >= items[i].second) {
                dp[i][v] = min(dp[i][v], dp[i-1][v - items[i].second] + items[i].first);
            }
        }
    }

    for (int v = S; v >= 0; v--) {
        if (dp[N][v] <= W) {
            cout << v << "\n";
            return 0;
        }
    }

    return 0;
}


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

int main() {
    string str;
    cin >> str;
    int n = 0, p = 0;
    bool inf = false;
    int pcnt = str.find('.'), cnt = 0;
    int cnt2 = 0;
    for(int i=0; i<str.size(); ++i) {
        inf |= str[i] == '(';
        if(isdigit(str[i])) {
            n *= 10;
            n += str[i] - '0';
            if(!inf) {
                p *= 10;
                p += str[i] - '0';
            }
            cnt++;
            cnt2 += inf;
        }
    }
    cnt -= pcnt;
    if(inf) {
        n -= p;
    }
    int del = pow(10, cnt) - (inf ? pow(10, cnt-cnt2) : 0);
    int g = __gcd(n, del);
    n /= g;
    del /= g;
    cout << n << '/' << del << endl;
}


Measured memory_bytes: 3340
N,M=map(int, input().split())
A = [str(input()) for i in range(N)]
B = [list(map(str, input())) for i in range(M)]
ans=True

for p in range(N-M+1):
    for q in range(N-M+1):
        data=[[A[p+j][q+i] for i in range(M)]  for j in range(M)]
        if data == B:
            ans=True
            break
        else:
            ans=False
            continue
    if ans:break
if ans:print('Yes')
else:print('No')

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	static int ans;
	static String s;
	static ArrayList<String> sArray;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			s = sc.next();
			if (s.equals("#")) {
				break;
			}
			sArray = new ArrayList<String>();
			char[] sca = s.toCharArray();
			//System.out.println(new String(sca));
			ans = 0;
			decode(sca, 0);
			//encode();
			Collections.sort(sArray);
			System.out.println(ans);
			/*
			if (ans > 0) {
				if (10 >= ans) {
					for (int i = 0; i < sArray.size(); i++) {
						System.out.println(sArray.get(i));
					}
				} else {
					for (int i = 0; i < 5; i++) {
						System.out.println(sArray.get(i));
					}
					for (int i = 5; i > 0; i--) {
						System.out.println(sArray.get(sArray.size() - i));
					}
				}
			}*/
			for (int i = 0; i < sArray.size(); i++) {
				System.out.println(sArray.get(i));
			}
		}
	}
	
	public static void decode(char[] sca, int pos) {
		//System.out.println(new String(sca) + " " + sca[0] + " " + pos + " " + sca.length);
		if (pos == sca.length) {
			if (encode(sca)) {
				ans++;
				String tmp = new String(sca);
				sArray.add(tmp);
				Collections.sort(sArray);
				if (sArray.size() > 10) {
					sArray.remove(5);
				}
			}
			return;
		}
		decode(sca, pos + 1);
		if (sca[pos] != 'z') {
			//System.out.println(sca[pos]);
			sca[pos]++;
			decode(sca, pos + 1);
			sca[pos]--;
		}
	}
	
	public static boolean encode(char[] sca) {
		char[] tmp = Arrays.copyOf(sca, sca.length);
		for (int i = 1; i <= 25; i++) {
			char c = (char)('a' + i);
			for (int j = 0; j < tmp.length; j++) {
				if (tmp[j] == c) {
					tmp[j]--;
					break;
				}
			}
		}
		//System.out.println(sca);
		if (s.equals(new String(tmp))) {
			return true;
		} else {
			return false;
		}
	}
}

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

int main() {
    int A, B;
    cin >> A >> B;
    string S;
    cin >> S;
    bool frag = true;
    for (int i = 0; i <= A+B; i++) {
        if ((i != A) && (S[i] == '-')){
            cout << "No" << endl;
            frag = false;
            break;
        }
        if ((i == A) && (S[i] != '-')){
            cout << "No" << endl;
            frag = false;
            break;
        }
    }
    if (frag){
        cout << "Yes" << endl;
    }

}


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

#define MAX 50

int main() {
  int n, m;
  int i;
  int buf1, buf2;
  vector<int> x(MAX);
  
  cin >> n >> m;
  
  for (i = 0; i < n; i++) {
    x.at(i) = 0;
  }
  
  for (i = 0; i < m; i++) {
    cin >> buf1 >> buf2;
    x.at(buf1 - 1)++;
    x.at(buf2 - 1)++;
  }
  
  for (i = 0; i < n; i++) {
    cout << x.at(i) << endl;
  }
}

Measured memory_bytes: 256
N, M, Q = map(int, input().split())

query = []
for i in range(Q):
    a, b, c, d = map(int, input().split())
    query.append([a, b, c, d])


def calcPoint(num):
    ret = 0
    for q in range(Q):
        if num[query[q][1] - 1] - num[query[q][0] - 1] == query[q][2]:
            ret += query[q][3]

    return ret


ans = 0


def dfs(suu, keta):
    global ans
    if keta == N:
        ans = max(ans, calcPoint(suu))
        # print(*suu)
        return

    co = suu.copy()

    for i in range(suu[keta - 1], M):
        co[keta] = i
        dfs(co, keta + 1)


retsu = [0] * N

dfs(retsu, 1)
print(ans)

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

struct unionfindtree {
    vector<int> parent;
    int group;
  
    unionfindtree(int size): parent(size), group(size) {
        iota(begin(parent), end(parent), 0);
    }
    
    int find(int n) {
        return parent[n] == n ? n : parent[n] = find(parent[n]);
    }
    
    void unite(int n, int m) {
        n = find(n), m = find(m);
        parent[n] = m;
        if (n != m) group--;
    }
    
    bool unified() {
        return group == 1;
    }
    
    bool issame(int n, int m) {
        return find(n) == find(m);
    }
};

int main() {
    int64_t n;
    cin >> n;
    vector<pair<int64_t, int64_t>> x, y;
    for (int64_t i = 0; i < n; i++) {
        int xx, yy;
        cin >> xx >> yy;
        x.emplace_back(xx, i);
        y.emplace_back(yy, i);
    }
    sort(begin(x), end(x));
    sort(begin(y), end(y));

    using tuple3 = tuple<int64_t, int64_t, int64_t>;
    priority_queue<tuple3, vector<tuple3>, greater<tuple3>> pq;
    for (int i = 0; i + 1 < n; i++) {
        pq.emplace(x[i+1].first - x[i].first, x[i].second, x[i+1].second);
        pq.emplace(y[i+1].first - y[i].first, y[i].second, y[i+1].second);
    }

    unionfindtree uft(n);
    int64_t ans = 0;
    while (!uft.unified()) {
        int64_t d, a, b;
        tie(d, a, b) = pq.top(); pq.pop();
        if (!uft.issame(a, b)) {
            ans += d;
            uft.unite(a, b);
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 13152
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

int n;
int k;
int a[101];

int dp[101][101];
int dfs(int from,int to){
    if(dp[from][to]!=-1)return dp[from][to];
    int res=0;
    for(int i=(from+1)%k;i!=(to+1)%k;i=(i+1)%k)
        res=max(res,abs(a[from]-a[i])+dfs(from,(i-1+k)%k)+dfs(i,to));
    return dp[from][to]=res;
}

int main(){
    
    cin>>n;
    while(n--){
        memset(dp,-1,sizeof(dp));
        cin>>k;
        for(int i=0;i<k;i++)cin>>a[i];
        int res=0;
        for(int i=0;i<k;i++)res=max(res,dfs(i,(i-1+k)%k));
        cout<<res<<endl;
    }

    return 0;
}

Measured memory_bytes: 908
#include<stdio.h>
const int t=100005;
int a[t];
int n,m;
bool Find(int x)
{
    int sum=0;
    int fuck=0;
    for(int i=1;i<=n;i++)
    {
        sum+=a[i];
        if(sum>x)
        {
            ++fuck;
            sum=a[i];
            if(sum>x)
            {
                return 0;
            }
        }
    }
    return fuck<m;
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    int l=1,r=t*10000;
    while(l<=r)
    {
        int mid=l+r>>1;
        if(Find(mid))
        {
            r=mid-1;
        }
        else
            l=mid+1;
    }
    printf("%d\n",l);
}

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

int main() {
  int n, m;
  cin >> n;
  m = 1;
  vector<int> num(n);
  
  for (int i = 0; i < n; i++) {
    cin >> num.at(i);
  }
  
  for (int i = 0; i < n; i++) {
    if (num.at(m - 1) == 2) {
      cout << i + 1 << endl;
      break;
    }
    m = num.at(m - 1);
    if (i + 1 == n) {
      cout << -1 << endl;
  	}
  }
}



Measured memory_bytes: 640
n = int(input())
a = list(map(int, input().split()))
b1 = a[::2]
b2 = a[1::2]
if n % 2 == 1:
    b1 = b1[::-1]
    b1.extend(b2)
    b = b1
else:
    b2 = b2[::-1]
    b2.extend(b1)
    b = b2
print(*b, sep=' ')


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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  cout << n * 180 - 360 << endl;

}
























Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  // wrong answer
  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {
    
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(in.readLine());
      String line = in.readLine();

      int[] aW = new int[n+1];
      int[] aE = new int[n+1];
      for(int i=1, cw=0, ce=0; i<=n; i++) {
        if(line.charAt(i-1) == 'W')
          cw++;
        else
          ce++;
        
        aW[i] = cw;
        aE[i] = ce;
      }

      int maxE = aE[n];
      int ans = n;
      for(int i=1; i<=n; i++) {
        ans = Math.min(ans, aW[i-1] + (maxE - aE[i]));
        // System.out.println(i + ":" + aW[i-1] + "+" + (maxE - aE[i]));
      }
      System.out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int m, d;cin >> m >> d;
    int ans = 0;
    for(int i=1;i<=m;i++){
        for(int j=1;j<=d;j++){
            int d1 = j%10;
            int d10 = j/10%10;
            if(d1 >= 2 && d10 >= 2){
                if(d1*d10 == i) ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import math
import collections
N, D, A = map(int, input().split())
XH = [tuple(map(int, input().split())) for i in range(N)]
XH.sort()
q = collections.deque()
c = 0
ans = 0
for x, h in XH:
    while(q):
        if q[0][0] < x:
            t = q.popleft()
            c -= t[1]
        else:
            break
    h -= c*A
    k = math.ceil(max(h, 0) / A)
    ans += k
    c += k
    if k > 0:
        q.append((x+(2*D), k))
print(ans)


Measured memory_bytes: 44540
#include <stdio.h>
int main (void)
{
    int a,b,c,d,e,k,max,min;
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&k);
    max=a;
    if(max<=b)
        max=b;
    if(max<=c)
        max=c;
    if(max<=d)
        max=d;
    if(max<=e)
        max=e;
    min=e;
    if(min>=d)
        min=d;
    if(min>=c)
        min=c;
    if(min>=b)
        min=b;
    if(min>=a)
        min=a;
    if((max-min)>k)
        printf(":(\n");
    else
        printf("Yay!\n");
    return 0 ;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string>
#include<map>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
 
using namespace std;

int main(){
    int N;  string S;
    cin >> N >> S;
    int cnt = 0, tmp = 0;
    int r = N-1, l = 0;
    int mode = 0;
    while(r > l){
        if(S[l] == 'W'){
            cnt++;
            if(S[r] == 'R') r--;
            else{
                while(S[r] == 'W'){
                    r--;
                    if(l == r){
                        cnt--;
                        cout << cnt;
                        return 0;
                    }
                }
                r--;
            }
        }
        l++;
    }
    cout << cnt;
}

Measured memory_bytes: 3720
D = int(input())
c = list(map(int, input().split()))
s = []
for i in range(D):
    s.append(list(map(int, input().split())))
t = []
for i in range(D):
    t.append(int(input()))

score = 0
last = [0] * 26
for d in range(D):
    score += s[d][t[d] - 1]
    last[t[d] - 1] = d + 1
    for _type in range(26):
        score -= (d + 1 - last[_type]) * c[_type]
    print(score)


Measured memory_bytes: 9256
#include <iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>

using namespace std;

int main(){
    int k;
    vector<int> v(5,0);
    for(int i=0;i<5;i++){
        cin >> v[i];
    }
    cin >> k;
    sort(v.begin(),v.end());
    if(v[4]-v[0]>k){
        cout << ":(" << endl;
    }
    else{
        cout << "Yay!" << endl;
    }
    return 0;
}


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

int main(){
  long int N, num;
  int dig, keta;
  int sum = 0;
  int max_sum = 0;

  cin >> N;
  keta = log10(N) + 1;

  int n[keta];
  num = N;
  int i = 0;
  while (num != 0){
    dig = num % 10;
    n[i] = dig;
    sum = sum + dig;
    num = num / 10;
    i++;
  }

  if(keta >= 2){
    int nine = 0;
    for (int j = 0; j < keta - 1; j++){
      if(n[j] != 9){
        break;
      }
      nine++;
    }
    if (nine == keta - 1){
      max_sum = 9 * (keta - 1) + n[keta - 1];
    }
    else{
      max_sum = 9 * (keta - 1) + n[keta - 1] - 1;
    }
  }else{
    max_sum = N;
  }

  cout << max_sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
 
using namespace std;
 
int main(void){
 
    long double x1,y1,x2,y2,x3,y3,x4,y4;
    int n;
 
    cin>>n;
 
    for(int i=0;i<n;i++){
        cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
        if(y2-y1==0){
            if(y4-y3==0) cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }
        else if((x2-x1)/(y2-y1)==(x4-x3)/(y4-y3)) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
 
    return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
// ミント
const int mod = 1e9+7 ;
//998244353;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
//昆布
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}   ;
 
 
int main(){
  ll n,m,k ; cin>>n>>m>>k ;
  combination c(n*m) ;
  mint ans=0 ;
  // nについて
  mint x=c(n*m-2,k-2) ;
  mint md=m*m ; mint nd=n*n ;
  rep2(i,1,n-1){
   mint ai=i ;
   mint j=n-i ;
   ans+= ai*j*md*x ; 
  }
  rep2(i,1,m-1){
   mint ai=i ;
   mint j=m-i ;
   ans+= ai*j*nd*x ;
  }
  cout<<ans<<endl ;
    return 0;
  }

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


int main() {
  int N;
  int first = 0, second = 0;
  vector<int> A(200003, 0);
  cin >> N;
  rep (i, N) {
    cin >> A[i];
    if (first < A[i]) {
      second = first;
      first = A[i];
    } else if (second < A[i]) {
      second = A[i];
    }
  }
  rep (i, N) {
    cout << (A[i] == first ? second : first) << endl;
  }

  return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <bitset>
#include <cstdio>
#include <iomanip>
#include <climits>
#include <string>
#include <sstream>
#include <numeric>
#include <stack>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
int check(vector< int > &A, int m) {
	vector< int > B(N);
	B[0] = m;
	rep(i, N - 1) {
		B[i + 1] = A[i] - B[i];
	}
	return B[N - 1] + B[0] <= A[N - 1];
}
signed main() {
	cin >> N;
	vector< int > A(N);
	rep(i, N) cin >> A[i];
	int l = 0, r = LINF;
	while (r - l > 1) {
		int m = (l + r) / 2;
		if (check(A, m)) {
			l = m;
		} else {
			r = m;
		}
	}
	vector< int > ans(N);
	ans[0] = l;
	rep(i, N - 1) {
		ans[i + 1] = A[i] - ans[i];
	}
	rep(i, N) cout << ans[i] * 2 << " ";
	cout << endl;
	return 0;
}

Measured memory_bytes: 2928
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String S = scan.nextLine();
		String T = scan.nextLine();
		String ans = "No";

		for (int i = 0; i < S.length(); i++){
			S = S.substring(S.length() - 1) + S.substring(0,S.length() - 1);
			if (S.equals(T)){
				ans = "Yes";
				break;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 39464
#include <stdio.h>
#include <math.h>

int main() {
	double x1,x2,y1,y2=0;
	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	double x,y=0;
	x=(x2-x1);
	x=x*x;
	y=(y2-y1);
	y=y*y;
	x=x+y;
	x=sqrt(x);
	printf("%lf\n",x);
	
	return 0;
}

Measured memory_bytes: 652
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
long long getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;

// code
// ------------------------------------------------
int main()
{
  ll n;
  cin >> n;
  map<char,ll> m;

  rep(i,n)
  {
    string buf;
    cin >> buf;

    switch (buf[0])
    {
      case 'M':
      case 'A':
      case 'R':
      case 'C':
      case 'H':
        m[buf[0]]++;
        break;
      default:
        break;
    }
  }

  ll num = sz(m);
  if(num < 3)
  {
    cout << 0 << endl;
    return 0;
  }
  vll a;

  for(auto it: m)
  {
    a.push_back(it.second);
  }

  ll ans = 0;
  for(ll bit = 0; bit < (1 << num); ++bit)
  {
    ll cnt = 0;
    ll ans_once = 1;
    for(ll i = 0; i < num; ++i)
    {
      if(bit & (1 << i))
      {
        cnt++;
        ans_once *= a[i];
      }
    }

    if(cnt != 3) continue;

    ans += ans_once;
  }

  cout << ans << endl;


  return 0;
}
// funcの実体
// ------------------------------------------------
ll getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
ll CalcSumOfDigit(ll n)
{
  ll s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll N;
    cin >> N;
    ll ans = 0;
    rep2(i, 1, N + 1) {
        ll c = N / i;
        ans += (c * (i + i * c)) / 2;
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, VL, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N;
string S[2];

signed main() {
    cin >> N >> S[0] >> S[1];
    ll ans = 1, pre = -1;
    REP(i, N) {
        if(S[0][i] == S[1][i]) {
            if(pre == 0)
                ans *= 2;
            else if(pre == 1)
                ans *= 1;
            else
                ans *= 3;
            ans %= MOD;
            pre = 0;
        } else {
            if(pre == 0)
                ans *= 2;
            else if(pre == 1)
                ans *= 3;
            else
                ans *= 6;
            ans %= MOD;
            pre = 1;
            i++;
        }
    }
    cout << ans << "\n";
}


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

int main(){
  const int min = 0;
  const int max = 10000;
  std::vector<int> mount(10);
  int temp;

  for(int i = 0; i < 10; ++i){
    std::cin >> temp;
    if(temp >= min && temp <= max)
      mount[i] = temp;
    else
      --i;
  }

  std::sort(mount.begin(),mount.end(),std::greater<int>());

  for(int i = 0; i < 3; ++i)
    std::cout << mount[i] << std::endl;

  return 0;
}

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

using namespace std;

typedef long long int ll;
typedef long long unsigned int llu;
#define tc long long int t; cin>>t; while(t--)
#define  sync ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define mpi unordered_map<ll, ll>
#define mpc unordered_map<char, ll>
#define map_loop(it,m) for(auto it = m.begin(); it!=m.end(); it++)
#define rep(i,n) for(ll i=0;i<n;i++)


int main(){
  
  ll n;
  cin>>n;
  ll a[n+1]={0};
  for(int i=1;i<=n;i++){
	  if(i%3==0||i%5==0||i%15==0)
	  a[i]=0;
	  else
	  a[i]=i;
  }
  ll sum=0;
  for(int i=1;i<=n;i++)
  sum+=a[i];
  
  cout<<sum<<endl;
    
}






















Measured memory_bytes: 11448
#include <iostream>

using namespace std;

int main() {
   long long int a,b;
   cin>>a;
   cin>>b;
   long long int c[b],sum=0;
   for(int i=0;i<b;i++)
   {
       cin>>c[i];
   }
   for(int i=0;i<b;i++)
 {
     sum=sum+c[i];
  }
  if(sum>=a)
  {
      cout<<"Yes"<<endl;
  }
  else
  {
      cout<<"No"<<endl;
  }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 1e5 + 5;
const ll maxm = 1e3 + 5;
namespace IO{
    const int SIZE = (1 << 20) + 1;
    char ibuf[SIZE], *iS, *iT, obuf[SIZE],*oS = obuf, *oT = obuf + SIZE - 1;
    char _st[55];
    int _qr = 0;
    inline char gc(){
        return (iS == iT ? iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS++) : *iS++);
    }
    inline void qread(){}
    template<class T1, class ...T2>
    inline void qread(T1 &IEE, T2&... ls){
        register T1 __ = 0, ___ = 1;
        register char ch;
        while(!isdigit(ch = gc())) ___ = (ch == '-') ? -___ : ___;
        do{
            __ = (__ << 1) + (__ << 3) + (ch ^ 48);
        }while(isdigit(ch = gc()));
        __ *= ___;
        IEE = __;
        qread(ls...);
        return ;
    }
    inline void flush(){
        fwrite(obuf, 1, oS - obuf, stdout);
        oS = obuf;
        return ;
    }
    inline void putc_(char _x){
        *oS++ = _x;
        if(oS == oT) flush();
    }
    inline void qwrite(){}
    template<class T1, class ...T2>
    inline void qwrite(T1 IEE, T2... ls){
        if(!IEE) putc_('0');
        if(IEE < 0) putc_('-'), IEE = -IEE;
        while(IEE) _st[++_qr] = IEE % 10 + '0', IEE /= 10;
        while(_qr) putc_(_st[_qr--]);
        qwrite(ls...);
        return ;
    }
    struct Flusher_{~Flusher_(){flush();}}io_flusher;
}
using namespace IO;
ll gcd(ll a, ll b){
    return !b ? a : gcd(b, a % b);
}
int main(){
    ll x;
    qread(x);
    printf("%lld\n", 360 / gcd(x, 360));
    return 0;
}

Measured memory_bytes: 3696
def inner_prod(vec_a, vec_b):
    ans = 0
    for a, b in zip(vec_a, vec_b):
        ans += a * b
    return ans


N = int(input())
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]
ans = -float("inf")
for i in range(1, 1024):
    flags = [(i & (2 ** b)) // (2 ** b) for b in range(10)]
    benefit = 0
    for j, f in enumerate(F):
        benefit += P[j][inner_prod(flags, f)]
    ans = max(ans, benefit)
print(ans)


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

#define loop(i,a,b) for(ll i=a; i<b; i++)
#define rloop(i,a,b) for(ll i=a; i>b; i--)
#define all(var) var.begin(), var.end()
#define eloop(var) for(auto elem : var)
#define debug(x) cerr<<#x<<" ----> "<<x<<endl;
#define TT ll tt; cin>>tt; while(tt--)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define INF 0x7fffffff
#define LINF 2000000000000000007
#define MOD 1000000007
#define MAX 100005
typedef long long ll;
typedef long double ld;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    //TT
    {
        ll n, k;
        cin>>n>>k;
        ll h[n];
        loop(i,0,n)
            cin>>h[i];
        sort(h, h+n);

        ll sum = 0;
        loop(i,0,n-k) {
            sum += h[i];
        }
        cout<<sum<<'\n';

    }
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using edge = pair<int, ll>;
using graph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

long long f(long long n) {
  long long res = 0;
  while (n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}

double g(long long n) {
  return (double)(n)/f(n);
}

int main() {
  vector<long long> res;
  long long base = 1;

  // まずは候補を (1〜150)99999 的なやつを全列挙
  for (int i = 0; i < 15; ++i) {
    for (int j = 1; j < 150; ++j) {
      res.push_back(base * (j+1) - 1);
    }
    base *= 10;
  }
  sort(res.begin(), res.end());
  res.erase(unique(res.begin(), res.end()), res.end());

  // ダメなやつを除く: O(n^2) かかる効率悪い実装だけどとりあえず
  for (long long i = 0; i < res.size(); ++i) {
    for (long long j = i+1; j < res.size(); ++j) {
      if (g(res[i]) > g(res[j])) {
        res.erase(res.begin() + i--);
        break;
      }
    }
  }

  long long K;
  cin >> K;
  for (long long i = 0; i < K; ++i) {
    cout << res[i] << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n, m,c;
    cin >> n >> m >> c;
    int ans = 0;
    vector<int> b(m);
    for(int i = 0; i < m; i++) cin >> b[i];
    for(int i = 0; i < n; i++) {
        int sum = 0;
        for(int j = 0; j < m; j++) {
            int a; cin >> a;
            sum += b[j]*a;
        }
        if(sum + c > 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
using namespace std;

int main() {
    long long N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;

    long long m = min({ A,B,C,D,E });
    if (N%m == 0)cout << 4 + N / m << endl;
    else cout << 5 + N / m << endl;

    return 0;

}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()
    s = 0
    ans = "YES"
    for i in range(n):
        k = input()
        if k == "Un":
            s -= 1
        else:
            s += 1
        if s < 0:
            ans = "NO"
    if s:
        print("NO")
    else:
        print(ans)
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#I
def I_():
    return

#J
def J():
    return

#Solve
if __name__ == "__main__":
    A()



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

bool p(int a){
  return (a % 10 == a / 10000 && (a % 100 - a % 10) / 10 == (a / 1000 - a / 10000 * 10));
}

int main(){
  int a,b;
  cin >> a >> b;
  int ans = 0;
  for(int i = a; i < b + 1; i++){
    if(p(i)) ans++;
  }
  cout << ans << endl;
}

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

vector<int> h(100000), dp(100000, -1);

int cost(int n) {
  if (dp[n] != -1) return dp[n];
  return dp[n] = min(cost(n - 1) + abs(h[n] - h[n - 1])
                      , cost(n - 2) + abs(h[n] - h[n - 2]));
}

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

  for (int i = 0; i < N; i++) cin >> h[i];

  dp[0] = 0;
  dp[1] = abs(h[0] - h[1]);
  cout << cost(N - 1);
  return 0;
}

Measured memory_bytes: 3328