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

#define fr first
#define se second

using namespace std;

const long long N = 2e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

string s;
string t;
int main()
{
    ios_base::sync_with_stdio(false);

    cin >> s >> t;
    s += t.back();
    if(s == t){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
}



Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int main()
{
    int N;
    string S;
    bool checker{};
    cin >> N >> S;
    int i{0}, j{N / 2};
    if (N % 2 == 1)
    {
        checker = 1;
    }
    else
    {
        for (i = 0; i < N / 2; i++)
        {
            if (S[i] != S[j])
            {
                checker = 1;
                break;
            }
            j++;
        }
    }
    cout << (checker ? "No" : "Yes") << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define mod 1000000007

lli n,m;
lli dp[1001][1001];
int a[1001][1001];

lli func(lli x,lli y){
    if(x==n && y==m) return 1;
    if(dp[x][y]!=-1) return dp[x][y];
    lli i=0,j=0;

    if(x<n && a[x+1][y]==0) i=func(x+1,y);
    if(y<m && a[x][y+1]==0) j=func(x,y+1);
    return dp[x][y] = (i+j)%mod;
}

int main(){
    cin>>n>>m;
    lli i,j,l;
    char c;
    memset(dp,-1,sizeof(dp));
    for(i=1;i<=n;i++){
        for(j=1;j<=m;j++){
            cin>>c;
            if(c=='.') a[i][j]=0;
            else a[i][j]=1;
        }
    }
    lli ans=func(1,1);
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 12032
//我们能战斗并生存下来，是因为我们是弱者－－《游戏人生》
#include<bits/stdc++.h>
using namespace std;
typedef long long s64;
#define next nxt
const int ONE = 1000005;
const int INF = 2147483640;
int get()
{
        int res = 1, Q = 1; char c;
        while( (c = getchar()) < 48 || c > 57)
            if(c == '-') Q = -1;
        if(Q) res = c - 48;
        while( (c = getchar()) >= 48 && c <= 57)
            res = res * 10 + c - 48;
        return res * Q;
}

int n, k;
int A[ONE], p[ONE];
int next[ONE], first[ONE], go[ONE], Input[ONE], tot;
priority_queue <int, vector <int>, greater <int> > q;

int res = INF;
namespace Seg
{
        struct power {int val;} Node[ONE * 4];
        void Build(int i, int l, int r)
        {
            Node[i].val = INF;
            if(l == r) return;
            int mid = l + r >> 1;
            Build(i << 1, l, mid), Build(i << 1 | 1, mid + 1, r);
        }

        void Update(int i, int l, int r, int L, int x)
        {
            if(L <= l && r <= L)
            {
                Node[i].val = x;
                return;
            }
            int mid = l + r >> 1;
            if(L <= mid) Update(i << 1, l, mid, L, x);
            else Update(i << 1 | 1, mid + 1, r, L, x);
            Node[i].val = min(Node[i << 1].val, Node[i << 1 | 1].val);
        }

        void Query(int i, int l, int r, int L, int R)
        {
            if(L > R) return;
            if(L <= l && r <= R)
            {
                res = min(res, Node[i].val);
                return;
            }
            int mid = l + r >> 1;
            if(L <= mid) Query(i << 1, l, mid, L, R);
            if(mid + 1 <= R) Query(i << 1 | 1, mid + 1, r, L, R);
        }
}

void Add(int u, int v)
{
        Input[v]++, next[++tot] = first[u], first[u] = tot, go[tot] = v;
}

void Deal()
{
        int now = 0;
        for(int i = 1; i <= n; i++)
            if(!Input[i]) q.push(i);
        while(!q.empty())
        {
            int u = q.top(); q.pop();
            A[u] = ++now;
            for(int e = first[u]; e; e = next[e])
            {
                int v = go[e];
                if(--Input[v] == 0) q.push(v);
            }
        }
        for(int i = 1; i <= n; i++) printf("%d\n", A[i]);
}

int main()
{
        n = get(), k = get();
        for(int i = 1; i <= n; i++) p[get()] = i;

        Seg::Build(1, 1, n);
        for(int i = n; i >= 1; i--)
        {
            res = INF, Seg::Query(1, 1, n, p[i] + 1, min(p[i] + k - 1, n));
            if(res != INF) Add(p[i], p[res]);

            res = INF, Seg::Query(1, 1, n, max(1, p[i] - k + 1), p[i] - 1);
            if(res != INF) Add(p[i], p[res]);

            Seg::Update(1, 1, n, p[i], i);
        }

        Deal();
}

Measured memory_bytes: 35060
#include<cstdio>
using namespace std;
int n,x,y;
double d[3001][3001],ans,p[3001];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lf",&p[i]);
	}
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n-i;j++){
			d[i][j]=0;
		}
	}
	d[0][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=i;j++){
			x=j;
			y=i-j;
			if(x>0){
				d[x][y]+=d[x-1][y]*p[i];
			}
			if(y>0){
				d[x][y]+=d[x][y-1]*(1-p[i]);
			}
		}
	}
	for(int i=n;2*i>n;i--){
		ans+=d[i][n-i];
	}
	printf("%.10lf",ans);
}

Measured memory_bytes: 69888
#include<bits/stdc++.h>
using namespace std;
int s[10010];
bool l_s(int x, int n);
int main(){
    int n; cin >> n;
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }
    int ans = 0;
    int q; cin >> q;
    for(int i = 0; i < q; i++){
        int t; cin >> t;
        if(l_s(t,n)) ans++;
    }
    cout << ans << endl;
}
bool l_s(int x, int n){
    for(int i = 0; i < n; i++){
        if(s[i] == x) return true;
    }
    return false;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define dfor(i,a,b) for(ll i=(a);i>=(b);i--)
#define mem(u, vis) memset(u, vis, sizeof(u))
#define ll long long
#define ull unsigned long long
#define MOD  1000000007
#define MAX  1e9
#define pb   push_back
#define F    first
#define S    second


signed main() {
	int t=1;
	//cin>>t;
	while(t--){
		ll a,b,n;
		cin>>a>>b>>n;
		ll x = min(b-1,n);
		cout<<a*(x%b)/b;
		
	}
	
}

Measured memory_bytes: 3644
n=int(input())
s=input()
r=0
g=0
b=0

for i in range(n):
  if s[i]=="R":
    r+=1
  elif s[i]=="G":
    g+=1
  else:
    b+=1
    
ans=r*g*b

for i in range(n-2):
  for j in range(i+1,i+1+(n-i-1)//2):
    if s[i]==s[j]:
      continue
    elif s[i]!=s[2*j-i] and s[j]!=s[2*j-i]:
      ans-=1
      
print(str(ans))

Measured memory_bytes: 9192
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <numeric>
using namespace std;

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

    int N, M;
    cin >> N >> M;

    vector<long long> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    sort(A.begin(), A.end());

    vector<pair<long long, int>> CB;
    for (int i = 0; i < M; i++)
    {
        long long x;
        int y;
        cin >> y >> x;
        CB.push_back(make_pair(x, y));
    }
    sort(CB.begin(), CB.end(), greater<pair<long long, int>>());

    int CBidx = 0;
    for (int i = 0; i < N; i++)
    {
        if (A[i] < CB[CBidx].first)
        {
            A[i] = CB[CBidx].first;
            CB[CBidx].second--;
            if (CB[CBidx].second == 0)
            {
                CBidx++;
                if (CBidx > CB.size() - 1)
                {
                    break;
                }
            }
        }
    }

    cout << accumulate(A.begin(), A.end(), 0LL) << endl;

    return 0;
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

int m,nmin,nmax;
int a[1111];

int main(){
	cin.sync_with_stdio(false);
  while(cin>>m>>nmin>>nmax){
    if(m==0)break;
    rep(i,m)cin>>a[i];
    sort(a,a+m);
    reverse(a,a+m);
    int gap=0,res=-1;
    repl(i,nmin-1,nmax){
      if(gap<=a[i]-a[i+1]){
        gap=a[i]-a[i+1];
        res=i+1;
      }
    }
    cout<<res<<endl;
  }
	return 0;
}

Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
 
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll a,ans,j,k,q,c;
    ans=0;
    cin>>a;
    fr(i,a){
        cin>>j;
        if(i%2==0){
            if(j%2==1){
                ++ans;
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int table[] = new int[26];
		while(in.hasNext()) {
			String s = in.nextLine();
			for (int i = 0; i < s.length(); i++) {
				char ch = Character.toLowerCase(s.charAt(i));
				if (Character.isAlphabetic(ch))
					table[ch - 'a']++;
			}
		}
		for(int i=0;i<26;i++) {
			char ch = (char) ('a' + i);
			System.out.println(ch + " : " + table[ch - 'a']);
		}
	}
}

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

int k[11];
int p[11];
int s[11][11];

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

	for (int i = 0; i < m; ++i) {
		cin >> k[i];
		for (int j = 0; j < k[i]; ++j) {
			cin >> s[i][j];
			s[i][j]--;
		}
	}

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

	int res = 0;
	for (int b = 0; b < (1 << n); ++b) {
		bool ok = true;
		for (int i = 0; i < m; ++i) {
			int cnt = 0;
			for (int j = 0; j < k[i]; ++j) {
				if ((b >> s[i][j] & 1) > 0) {
					continue;
				}
				cnt++;
			}
			if (cnt % 2 != p[i]) {
				ok  = false;
				break;
			}
		}
		if (ok) {
			++res;
		}
	}
	cout << res << endl;


	return 0;
}

Measured memory_bytes: 256
def check(A):
	if A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0:
		return 1
	elif A[2][0] == 0 and A[1][1] == 0 and A[0][2] == 0:
		return 1
	for i in range(3):
		if A[0][i] == 0 and A[1][i] == 0 and A[2][i] == 0:
			return 1
		elif A[i][0] == 0 and A[i][1] == 0 and A[i][2] == 0:
			return 1
	return 0
			


A = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]

for i in range(3):
	for j in range(3):
		if A[i][j] in b:
			A[i][j] = 0

if check(A):
	print('Yes')
else:
	print('No')

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

using namespace std;

int main(){
  double N;
  cin>>N;
  vector<double>x(N);
  vector<double>y(N);
  for(int i=0;i<N;i++)cin>>x[i]>>y[i];
  vector<double>ave(N);
  for(int i=0;i<N;i++){
    ave[i]=0;
    for(int j=0;j<N;j++){
      ave[i]+=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
    }
    ave[i]/=N-1;
  }
  double sum=0;
  for(int i=0;i<N;i++){
    //cout<<ave[i]<<endl;
    sum+=ave[i];
  }
  sum/=N;
  sum*=N-1;
  cout<<fixed << setprecision(10)<<sum<<endl;
 
}  
  

Measured memory_bytes: 256
N, X, Y = map(int, input().split())

ans = [0] * (N - 1)

for i in range(1, 1 + N):
    for j in range(i + 1, 1 + N):
        k = min(j - i, abs(X - i) + abs(Y - j) + 1)
        ans[k - 1] += 1

for a in ans:
    print(a)


Measured memory_bytes: 3444
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
#include<complex>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)

int n, m, r;
int rr[201];
int reached[201];
int table[201][201];
int ans = inf;
void dfs(int d, int val) {
    //cout << d << " " << val << endl;
    rep(i, r) {if (reached[i] == 0) break; if (i == r - 1) {chmin(ans, val); return;}}
    rep(i, r) {
        if (i == d || reached[i] == 1) continue;
        if (reached[i] == 0) {
            reached[i] = 1;
            dfs(i, val + table[rr[d]][rr[i]]);
            reached[i] = 0;
        }
    }
    return;
}
    
int main() {
    cin >> n >> m >> r;
    rep(i, r) {cin >> rr[i]; rr[i]--;}
    rep(i, 201) rep(j, 201) table[i][j] = inf;
    rep(i, m) {
        int a, b, c; cin >> a >> b >> c;
        a--; b--;
        table[a][b] = c;
        table[b][a] = c;
    }
    rep(k, n) rep(i, n) rep(j, n) {
        if (table[i][k] + table[k][j] < table[i][j]) table[i][j] = table[i][k] + table[k][j];
    }
    /*
    rep(i, n) {
        rep(j, n) cout << table[i][j] << " "; cout << endl;
    }*/
    rep(i, r) {
        reached[i] = 1;
        dfs(i, 0);
        reached[i] = 0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
poi = [0,0]
for mak in range(int(input())) :
    tem = input().split()
    if tem[0] == tem[1] :
        poi[0] += 1
        poi[1] += 1
    else :
        che = sorted(tem)

        if tem[0] != che[0] : poi[0] += 3
        else                : poi[1] += 3

print(poi[0],poi[1])

Measured memory_bytes: 7648
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int a,b;
string s;
signed main()
{
	cin>>a>>b;
	rep(i,a*2-1){
		cout<<b-a+1+i<<" ";
	}
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.nextLine();
    String a;
    if(S.charAt(2) == S.charAt(3) && S.charAt(4) == S.charAt(5)){
      a = "Yes";
    } else {
      a = "No";
    }
    System.out.println(a);
  }
}

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

// 強連結成分分解
//   計算量: O(V + E)
//   operator[]: 頂点kが属する強連結成分の番号を返す

class StronglyConnectedComponents {
    int V;
    vector<vector<int>> G, rG;
    vector <int> comp; // 強連結成分の番号（トポロジカル順）
    vector <int> order; // DFSで辿った順
    vector <int> used;

    void dfs(int cur) {
        if (used[cur]) return;
        used[cur] = true;
        for (int to : G[cur]) dfs(to);
        order.push_back(cur);
    }

    void rdfs(int cur, int cnt) {
        if (comp[cur] != -1) return;
        comp[cur] = cnt;
        for (int to : rG[cur]) rdfs(to, cnt);
    }

public:
    StronglyConnectedComponents(vector<vector<int>> &edge) {
        V = edge.size();
        G.resize(V);
        rG.resize(V);
        comp.assign(V, -1);
        used.assign(V, false);
        for (int i = 0; i < V; i++) {
            for (int e : edge[i]) {
                G[i].push_back(e);
                rG[e].push_back(i);
            }
        }
    }

    int operator[](int k) { return comp[k]; }

    void build(vector<vector<int>> &buff) {
        for (int i = 0; i < V; i++) dfs(i);
        reverse(order.begin(), order.end());
        int cnt = 0;
        for (int i : order) if (comp[i] == -1) rdfs(i, cnt++);
        buff.resize(cnt);
        for (int i = 0; i < V; i++) {
            for (int to : G[i]) {
                int x = comp[i], y = comp[to];
                if (x == y) continue;
                buff[x].push_back(y);
            }
        }
    }
};


// verified
//   https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/3/GRL_3_C
void AOJ_GRL_3_C() {
    int V, E;
    cin >> V >> E;

    vector<vector<int>> edge(V), buff;
    for (int i = 0; i < E; i++) {
        int s, t;
        cin >> s >> t;
        edge[s].push_back(t);
    }

    StronglyConnectedComponents scc(edge);
    scc.build(buff);

    int Q;
    cin >> Q;
    while (Q--) {
        int u, v;
        cin >> u >> v;
        cout << (scc[u] == scc[v] ? 1 : 0) << "\n";
    }
}

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


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

int main(void){
	int n, a[100];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);

	cout << a[n-1] - a[0];
}



Measured memory_bytes: 256
// Sky's the limit :)
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
    //int t = 1; cin >> t; while(t--)
    {
        int n, d, a;
        cin >> n >> d >> a;
        vector<pair<int, int>> arr(n);
        for(int i=0;i<n;i++)
            cin >> arr[i].first >> arr[i].second;
        sort(arr.begin(), arr.end());
        
        int da[2000 * 105];
        int ans = 0, j = 0;
        for(int i = 0; i < n; i++)
        {
            while(j < n && arr[j].first <= arr[i].first + 2 * d) 
                j++;
            if(i) 
                da[i] += da[i-1];

            int x = max(0LL, (arr[i].second - da[i] + a - 1) / a);
            da[i+1] += a * x;
            da[j] -= a * x;
            ans += x;
        }

        cout << ans << '\n';

        
    }
    
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}



Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define data_type long long
#define endl "\n"


int main()
{
    data_type n,i=1,c=0,a;
    cin>>n;
    while(i<=n)
    {
       cin>>a;
       c+=(a&1 && i&1);
       i++;
    }

    cout<<c<<endl;

    return 0;
}




Measured memory_bytes: 3584
n = int(input())
rate_list = [ int(v) for v in input().split() ]
color_list = [0 for i in range(8)]
free = 0
for i in rate_list:
	if  i < 3200:
		color_list[i//400] += 1
	else:
		free += 1


min_color = 8 - color_list.count(0)
max_color = free + min_color
if min_color == 0:
	min_color = 1
print(min_color,max_color)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int M=1000000007;
int main()
{
 int h,w;
 cin>>h>>w;
 char a[h][w];
 int i,j;
 for(i=0;i<h;i++)
 {
 	for(j=0;j<w;j++)
 	cin>>a[i][j];
 }
 int dp[h+1][w+1];
 memset(dp,0,sizeof(dp));
 dp[1][1]=1;
 for(i=1;i<=h;i++)
 {
 	for(j=1;j<=w;j++)
 	{
 	 if(a[i-1][j-1]=='.')
	 {
	  if(i-2<0 || a[i-2][j-1]=='.')
	  dp[i][j]+=dp[i-1][j];
	  dp[i][j]%=M;
	  if(j-2<0 || a[i-1][j-2]=='.')
	  dp[i][j]+=dp[i][j-1];
	  dp[i][j]%=M;
	 }
	}
 }
 cout<<dp[h][w]<<endl;
 return 0;
}


Measured memory_bytes: 5120
import java.util.Scanner;

//The Best Body
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int id = sc.nextInt();
			double h = sc.nextDouble()/100;
			double w = sc.nextDouble();
			double b = Math.abs(22-(w/(h*h)));
			for(int i=1;i<n;i++){
				int x = sc.nextInt();
				h = sc.nextDouble()/100;
				w = sc.nextDouble();
				double a = Math.abs(22-(w/(h*h)));
				if(a<b){
					b = a;
					id = x;
				}
				else if(a==b&&x<id)id = x;
			}
			System.out.println(id);
		}
	}
}

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

// DP テーブル
long long dp[3100][3100];

int main() {
    // 入力受け取り
    int N; cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];

    // 初期条件
    for (int i = 0; i < N; ++i) dp[i][i] = 0;

    // DP
    for (int len = 1; len <= N; ++len) {
        for (int i = 0; i + len <= N; ++i) {
            int j = i + len;

            // 先手番
            if ((N - len) % 2 == 0)
                dp[i][j] = max(dp[i + 1][j] + a[i], dp[i][j - 1] + a[j - 1]);

            // 後手番
            else
                dp[i][j] = min(dp[i + 1][j] - a[i], dp[i][j - 1] - a[j - 1]);
        }
    }

    // 答え
    cout << dp[0][N] << endl;
}

Measured memory_bytes: 50148
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTS(s) printf("%s\n",(s))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

typedef long long ll;

int prime[50000] = { 0 };
int idx;

//numまでの素数を求める
void getPrime(int num) {
	if (num < 2) {
		idx = -1;
		return;
	}
	prime[0] = 2;
	if (num < 3) {
		idx = 0;
		return;
	}
	idx=1;
	prime[0] = 2;
	prime[1] = 3;
	int i, j;
	int start;
	int flag;
	for (i = prime[idx] + 2; i <= num; i += 2) {
		flag = 1;
		for (j = 0; prime[j] <= (int)sqrt(i); j++) {
			if (i%prime[j] == 0) {
				flag = 0;
				break;
			}
		}
		if (flag)prime[++idx] = i;
	}
}


int main() {
	int Q;
	scanf("%d", &Q);
	int l[100000], r[100000];
	int max = 0;
	REP(i, Q) {
		scanf("%d %d", &l[i], &r[i]);
		if (r[i] > max)max = r[i];
	}
	getPrime(max);
	int le = 0, ri = idx;
	int cnt[50000];
	cnt[0] = 0;
	if (idx >= 0) {
		int mi;
		REPS(i, idx) {
			le = 0, ri = idx;
			cnt[i] = cnt[i - 1];
			int tar = (prime[i] + 1) / 2;
			while (le <= ri) {
				mi = (le + ri) / 2;
				if (prime[mi] == tar) {
					cnt[i]++;
					break;
				}
				else if (prime[mi] < tar) {
					//目的値が中央値よりも上なら、最小値を中央値の一つ上に設定
					le = mi + 1;
				}
				else if (prime[mi] > tar)
					//目的値が中央値よりも下なら、最大値を中央値の一つ下に設定
					ri = mi - 1;
			}
		}
		REP(i, idx + 1) {
			//PRINTD(cnt[i]);
		}
		//PRINTD(idx);
		REP(i, Q) {
			le = -1;
			ri = -1;
			REP(j, idx + 1) {
				if (l[i] == 1) {
					le = 0;
				}
				if (le < 0 && l[i] <= prime[j])le = j - 1;
				if (r[i] < prime[j]) {
					ri = j - 1;
					break;
				}
			}
			if (le == -1)le = idx;
			if (r[i] == 1)ri = 0;
			else if (ri == -1)ri = idx;
			//printf("le%d ri%d\n", le, ri);
			PRINTD(cnt[ri] - cnt[le]);
		}
	}
	else {
		PRINTD(0);
	}
}

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

int main(void){
  string s;
  long int n;
  bool flag = false;

  cin >> s;
  n = s.length();

  if (s[0] == s[n-1]){
    if (n % 2 == 1) flag = true;
  }
  else{
    if (n % 2 == 0) flag = true;
  }

  if (flag) cout << "Second" << endl;
  else cout << "First" << endl;

  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
int n, m, res, curr;
vector<vector<int>> g;
vector<bool> viz;
inline void DFS(int x) {
    if (viz[x])
        return;
    viz[x] = true;
    ++curr;
    for (const int& y : g[x])
        DFS(y);
}
int x, y;
int main() {
    DAU
    cin >> n >> m;
    g.resize(n + 1);
    while (m--) {
        cin >> x >> y;
        g[x].emplace_back(y);
        g[y].emplace_back(x);
    }
    viz.resize(n + 1);
    for (int i = 1; i <= n; ++i)
        if (!viz[i]) {
            curr = 0;
            DFS(i);
            res = max(res, curr);
        }
    cout << res;
    PLEC
}


Measured memory_bytes: 20276
n = int(input())
s = set(list("abcdefghijk"))

class Node:
    def __init__(self, char, parents):
        self.children = []
        self.string = parents+char
        self.charset = set(self.string)

    def get_children(self):
        parents = self.string
        for c in sorted(list(self.charset|set(min(s-self.charset)))):
            self.children.append(Node(c, parents))
        return self.children

root = Node("a", "")
children = [root]
for _ in range(n-1):
    parents, children = children, []
    for parent in parents:
        children.extend(parent.get_children())
for child in children:
    print(child.string)

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

int main()
{
  int a,b;
  cin>>a>>b;
  for(int i=1;i<1010;i++)
  {
    int x=i*0.08, y=i*0.1;
    if(x==a && y==b)
    {
      cout<<i;
      return 0;
    }
  }
  cout<<"-1";
  return 0;
}

Measured memory_bytes: 256
sub p{my($a,$b)=@_;$b?p($a**2%$=,$b>>1)*($b%2?$a:1)%$=:1}$==1e9+7;@s=map$%=($%+p$_,$=-2)%$=,1..<>;$\+=$_*($s[$i++]+$s[-$i]-1)%$=for glob<>;map$\=$\*++$j%$=,@s;print

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

int main() {
  
  int a,b;
  cin >> a >> b;
  
  if(b%a == 0) cout << a+b << endl;
  else cout << b-a << endl;
  
}


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

struct Kakikae
{
public:
    long b, c;
    bool operator<(const Kakikae& e) const{
        return c > e.c;
    }
};

int main()
{
    int N, M;
    std::vector<long> A;
    std::vector<Kakikae> BC;
    scanf("%d %d", &N, &M);
    A.resize(N);
    BC.resize(M);
    for(int i=0; i<N; i++)
        scanf(" %ld", &A[i]);
    for(int i=0; i<M; i++)
        scanf(" %ld %ld", &BC[i].b, &BC[i].c);

    std::sort(A.begin(), A.end());
    std::sort(BC.begin(), BC.end());
    
    int index = 0;
    for(int i=0; i<M; i++){
        if(index >= N) break;
        if(A[index] >= BC[i].c) break;
        for(int j=0; j<BC[i].b; j++){
            if(index >= N) break;
            if(A[index] >= BC[i].c) break;
            A[index] = BC[i].c;
            index++;
        }
    }

    long sum = 0;
    for(int i=0; i<N; i++){
        sum += A[i];
    }
    printf("%ld\n", sum);
}


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

int x, y, ans;

int main() {
    cin >> x >> y;
    ans = abs(abs(x) - abs(y));
    if (abs(x) > abs(y)) {
        if (x > 0) {
            if (y <= 0) ans++;
            else ans += 2;
        } else {
            if (y > 0) ans++;
        }
    } else if (abs(x) < abs(y)) {
        if (x >= 0) {
            if (y < 0) ans++;
        } else {
            ans++;
            if (y < 0) ans++;
        }
    } else {
        if (x >= 0 ^ y >= 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
module sub
	implicit none
contains
subroutine heapsort2(n,array,turn)
  implicit none
  integer,intent(in)::n
  integer,intent(out)::turn(1:n)
  integer,intent(inout)::array(1:n)
  
  integer::i,k,j,l,m
  double precision::t
  
  if(n.le.0)then
     write(6,*)"Error, at heapsort"; stop
  endif
  if(n.eq.1)return

  do i=1,N
     turn(i)=i
  enddo

  l=n/2+1
  k=n
  do while(k.ne.1)
     if(l.gt.1)then
        l=l-1
        t=array(l)
        m=turn(l)
     else
        t=array(k)
        m=turn(k)
        array(k)=array(1)
        turn(k)=turn(1)
        k=k-1
        if(k.eq.1) then
           array(1)=t
           turn(1)=m
           exit
        endif
     endif
     i=l
     j=l+l
     do while(j.le.k)
        if(j.lt.k)then
           if(array(j).lt.array(j+1))j=j+1
        endif
        if (t.lt.array(j))then
           array(i)=array(j)
           turn(i)=turn(j)
           i=j
           j=j+j
        else
           j=k+1
        endif
     enddo
     array(i)=t
     turn(i)=m
  enddo

  return
end subroutine heapsort2
end module sub



program main
	use sub
	implicit none
	integer :: N, M, i, j, counter
	integer, allocatable :: a(:), b(:), turn(:)
	read(*, *) N, M
	allocate(a(1:M))
	allocate(b(1:M))
	allocate(turn(1:M))
	do i = 1, M
		read(*, *) a(i), b(i)
	end do
	
	call heapsort2(M,a,turn)
	j = 1
	counter = 0
	do i = 2, M
		if(a(j) /= a(i)) then
			if(b(turn(j)) <= a(i)) then
				counter = counter + 1
				j = i
			else if(b(turn(j)) >= b(turn(i))) then
				j = i
			end if
		else
			if(b(turn(j)) > b(turn(i))) then
				j = i
			end if
		end if
	end do
	write(*, *) counter+1
end program main

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

long long r[100005];

int main(){
	typedef long long LL;
	int n,m;
	cin>>n>>m;
	
	r[0]=0;
	for(int i=0;i<n-1;i++){
		int a;
		cin>>a;
		r[i+1]=a+r[i];
		}
		
		LL ans=0;
		int nw=0;
		
		for(int i=0;i<m;i++){
			int a;
			cin>>a;
			
			ans+=abs(r[nw+a]-r[nw]);
			nw+=a;
			}
			
			cout<<ans%100000<<endl;
			return 0;
	}

Measured memory_bytes: 3888
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n;
    string s;
    cin >> n >> s;
    
    string u = s;
    sort(all(u));
    u.erase(unique(all(u)), u.end());

    int best = 0;
    rep(i, n-1) {
        string s1 = s.substr(0, i+1);
        string s2 = s.substr(i+1);
        int c = 0;
        rep(j, u.size()) {
            if (s1.find(u[j]) != std::string::npos && s2.find(u[j]) != std::string::npos) {
                //　どっちにも含まれる
                c++;
            }
        }
        best = max(best, c);
    }

    put(best);

    return 0;
}

Measured memory_bytes: 3604
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
const int nax = 305;
double dp[nax][nax][nax] , ev[nax][nax][nax];

int main(){
int n;
scanf("%d",&n);
vector<int> cnt(4);
for(int i = 0 ; i < n ; ++i){
		int x;
		scanf("%d",&x);
		++cnt[x];
}
dp[cnt[1]][cnt[2]][cnt[3]] = 1;

for(int c = n; c >= 0; --c){
	for(int b = n; b >= 0; --b){
		for(int a = n; a >= 0; --a){
			if(a == 0 && b == 0 && c == 0){
				continue;
			}
			
			if(a + b + c > n){
				continue;
			}
			
			double p_waste = (double)(n - (a+b+c))/n;
			double ev_waste = (double) p_waste/(1 - p_waste) + 1;
			ev[a][b][c] += ev_waste * dp[a][b][c];
		   

			if( a != 0){
				double p_transition = (double) a/(a+b+c);
				dp[a - 1][b][c]  += dp[a][b][c] * p_transition;
				ev[a - 1][b][c]  += ev[a][b][c] * p_transition;  
			}
			
			if( b != 0){
				double p_transition = (double)b/(a+b+c);
				dp[a + 1][b - 1][c]  += dp[a][b][c] * p_transition;
				ev[a + 1][b - 1][c]  += ev[a][b][c] * p_transition;  
			}
			
			if( c!= 0){
				double p_transition = (double)c/(a+b+c);
				dp[a][b + 1][c - 1]  += dp[a][b][c] * p_transition;
				ev[a][b + 1][c - 1]  += ev[a][b][c] * p_transition;  
			}
			
		}
	}
}
printf("%0.10lf\n",ev[0][0][0]);
	
}

Measured memory_bytes: 438528
N = int(input())
As = map(int, input().split())
As = map(lambda x: format(x, 'b'), As)
As = list(As)

maxlen = max(map(len, As))

for i in range(maxlen):
    test = '0'*(i+1)
    Bs = list(map(lambda x: x.endswith(test), As))

    if False in Bs:
        print(i)
        break

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

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;
 
int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    cout << max({a, b, c}) * 9 + a + b + c << endl;
}

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

using namespace std;
#define rep(i,n) for (int i =0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;

int main(){
    int N;
    ll x,y,D;
    int count=0;
 
    cin >>N>>D;

    rep(i,N){
        cin >>x>>y;
        if(D*D>=x*x+y*y)count++;
             }

    cout << count ;

    return 0;
}


Measured memory_bytes: 3628
N = int(input())
A = list(map(int, input().split()))

ans = 0

while True:
  exist_odd = False
  for a in A:
    if a % 2 != 0:
      exist_odd = True
  if exist_odd:
    break
  for i in range(N):
    A[i] /= 2
  ans += 1
  
print(ans)
    

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

int main(){
    string s;
    cin >> s;
    ll n = s.size(),c1=0,c2=0;
    rep(i,n){
        if(s[i] == '0') c1++;
        else c2++;
    }
    if(c1>c2){
        cout << c2*2 << endl;
        return 0;
    }else{
        cout << c1*2 << endl;
        return 0;
    }
}

Measured memory_bytes: 512
A,B,C,D = [ int(it) for it in input().split() ]

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm(a, b):
	return a * b // gcd (a, b)
  
R = lcm(C,D)

def chk(V):
  return V - (V//C) - (V//D) + (V//R)

print ( chk(B) - chk(A-1) )


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

using namespace std;

int main()
{
    long N;
    int K;
    cin >> N >> K;
    int count = 0;
    int tmp = 0;
    if(N < K)
    {
        cout << 1 << endl;
        return 0;
    }
    while (1)
    {
        N = N / K;
        count++;
        if(N < K)
        {
            break;
        }
    }
    cout << count + 1<< endl;

}

Measured memory_bytes: 256
# AOJ 0118 Property Distribution 
# Python3 2018.6.23 bal4u
# 隣接する同種ものを集める、Unionセットに帰着

# UNION-FIND library
class UnionSet:
	def __init__(self, nmax):
		self.size = [1]*nmax
		self.id = [i for i in range(nmax+1)]
	def root(self, i):
		while i != self.id[i]:
			self.id[i] = self.id[self.id[i]]
			i = self.id[i]
		return i
	def connected(self, p, q): return self.root(p) == self.root(q)
	def unite(self, p, q):
		i, j = self.root(p), self.root(q)
		if i == j: return
		if self.size[i] < self.size[j]:
			self.id[i] = j
			self.size[j] += self.size[i]
		else:
			self.id[j] = i
			self.size[i] += self.size[j]
# UNION-FIND library

while 1:
	H, W = map(int, input().split())
	if H == 0 and W == 0: break
	tbl = ['']*H
	for r in range(H): tbl[r] = input()
	u = UnionSet(H*W)
	rr = 0
	for r in range(H):
		for c in range(W):
			if c+1 < W and tbl[r][c] == tbl[r][c+1]: u.unite(rr+c, rr+c+1)
			if r+1 < H and tbl[r][c] == tbl[r+1][c]: u.unite(rr+c, rr+W+c)
		rr += W
	ans = 0
	for k in range(H*W):
		if u.root(k) == k: ans += 1
	print(ans)


Measured memory_bytes: 6308
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
      	int len = str.length();
 		String leftStr = str.substring(0,(len-1)/2);
      	String rightStr = str.substring((len+1)/2,len);
      	boolean isStrongPalindrome = new StringBuffer(leftStr).reverse().toString().equals(leftStr)
          && new StringBuffer(rightStr).reverse().toString().equals(rightStr)
          && new StringBuffer(str).reverse().toString().equals(str);
          
		System.out.println(isStrongPalindrome?"Yes":"No");
	}
}


Measured memory_bytes: 21844
while True :
    n,x = map(int,input().split())
    if n == x == 0 : break
    ans = 0
    L = []
    for i in range(1,n+1) :
        for j in range(i+1,n+1) :
            k = x-i-j
            if (k > 0) and (k <= n) :
                if (i != j) and (j != k) and (k != i) :
                    l = sorted([i,j,k])
                    if l not in L :
                        L.append(l)
                        ans += 1
    print(ans)



Measured memory_bytes: 5608
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if (a < 1 || 10000 < a || b < 1 || 10000 < b || c < 1 || 10000 < c) {
			System.out.println("有効範囲は1 =< a,b,c =< 10,000です。");
		} else if (a <= b) {
			if (b <= c) {
				System.out.println(a + " " + b + " " + c);
			} else if (a <= c && c <= b) {
				System.out.println(a + " " + c + " " + b);
			} else if (c <= a) {
				System.out.println(c + " " + a + " " + b);
			}
		} else if (b <= a) {
			if (a <= c) {
				System.out.println(b + " " + a + " " + c);
			} else if (b <= c && c <= a) {
				System.out.println(b + " " + c + " " + a);
			} else if (c <= b) {
				System.out.println(c + " " + b + " " + a);
			}
		}
		sc.close();
	}

}



Measured memory_bytes: 26232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int main(){
  int n;
  cin >> n;
  int ans = n;
  int a[100000];
  int cnt = 0;
  fill(a, a+100000, 0);
  for(int i = 0; i < n; i++){
    int tmp;
    cin >> tmp;
    a[tmp-1]++;
  }

  for(int i = 0; i < 100000; i++){
    if(a[i] <= 1) continue;
    if(a[i] % 2 == 0){
      cnt++;
      ans -= a[i]-2;
    }else{
      ans -= a[i]-1;
    }
  }
  if(cnt%2 == 0) ans -= cnt;
  else ans -= cnt+1;
  cout << ans <<endl;
}
      

Measured memory_bytes: 640
// UNNECESSARY
// #include <chrono>//std::chrono::/system_clock/steady_clock/high_resolution_clock/duration
// #include <cstdio>//printf/scanf/fopen/fclose/fprintf/fscanf/snprintf/putc/puts/getc/gets
// #include <fstream>//ifstream/ofstream

// DATA STRUCTURES
#include <array>
#include <bitset>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <valarray>
#include <vector>

// MISCELLANEOUS
#include <algorithm>//min/max/sort(rand-access it)/merge
#include <cassert>
#include <climits>//INT_MAX/INT_MIN/ULLONG_MAX
#include <cmath>//fmin/fmax/fabs/sin(h)/cos(h)/tan(h)/exp/log/pow/sqrt/cbrt/ceil/floor/round/trunc
#include <cstdlib>//abs/atof/atoi/atol/atoll/strtod/strtof/..., srand/rand, calloc/malloc, exit, qsort
#include <iomanip>//setfill/setw/setprecision/fixed/scientific
#include <iostream>//cin/cout/wcin/wcout/left/right/internal/dec/hex/oct/fixed/scientific
#include <iterator>
#include <limits>//numeric_limits<type>::max/min/lowest/epsilon/infinity/quiet_NaN/signaling_NaN
#include <new>
#include <string>//stoi/stol/stoul/stoll/stoull/stof/stod/stold/to_string/getline
#include <utility>//pair

#ifndef REP
#define REP(i,n) for (int i = 0; i < n; ++i)
#endif

#ifndef REPST
#define REPST(i,n) for (size_t i = 0; i < n; ++i)
#endif

#ifndef READ
#define READ(x) std::cin >> x
#endif

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> plli;
typedef std::pair<ull, int> puli;
typedef std::pair<double, int> pdi;
typedef std::pair<ll, ll> pllll;
typedef std::pair<ull, ull> pulul;
typedef std::pair<double, double> pdd;
typedef std::tuple<int, int, int> ti3;
typedef std::tuple<int, int, int, int> ti4;

const bool debug = true;

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

using namespace std;

int main(void)
{
    ui n, m;
    cin >> n >> m;
    vector<ui> count(n);
    REP(i,m) {
        int a, b;
        cin >> a >> b;
        ++count[--a];
        ++count[--b];
    }
    REP(i,n) {
        cout << count[i] << '\n';
    }

    return 0;
}


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

int main() {
    string S; cin >> S;
    int i, X, ans = 753;
    for (i = 0; i < S.size() - 2; i++) {
        X = 100 * (S.at(i) - '0') + 10 * (S.at(i+1) - '0') + (S.at(i+2) - '0');
        ans = min(ans, abs(753 - X));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/*D - ... (Triple Dots)*/

#include <bits/stdc++.h>
using namespace std;

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int k;
	string cad;
	
	cin >> k >> cad;

	int tam = cad.size();

	if(tam > k){

		for (int i = 0; i < k; ++i)
			cout << cad[i];
		
		cout << "...";
	}
	else
		cout << cad;

	return 0;
}

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

#define int long long
#define ll long long
#define f1(i,a,b) for(i=a;i<b;i++)
#define f2(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
int i,j;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    //     freopen("in.txt","r",stdin);
    //     freopen("out.txt","w",stdout);
    // #endif
    int n;
    cin>>n;
    cout<<(n-2)*180;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int r,g;
    cin>>r>>g;
    cout<<2*g-r<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 3560
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
 
//#include <x86intrin.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <bitset> 
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <stack>
#include <map>
#include <set>
//#include <ordered_set>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
//using namespace __gnu_pbds;
using namespace std;
 
//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)2e6 + 123;
const ll inf = (ll)1e18 + 1;
 
const double pi = acos (-1.0);
const double eps = 1e-9;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, k, a[N], ans, pw[N], fact[N], inv[N];
string s;

inline int add (int a, int b) {
   a += b;
   if (a >= mod) a -= mod;
   if (a < 0) a += mod;
   return a;
}

inline int mult (int a, int b) {
   return 1ll * a * b % mod;
}

inline int binpow (int a, int b) {
   int res = 1;
   while (b) {
      if (b & 1) res = mult (res, a);
      a = mult (a, a);
      b >>= 1;
   }
   return res;
}

inline int C (int n, int k) {
   if (n < k) return 0;
   return mult (fact[n], mult (inv[k], inv[n - k]));
}

inline void boost () {
   ios_base :: sync_with_stdio (0);
   cin.tie (0), cout.tie (0);
}
 
inline void Solve () {
   cin >> k >> s;
   n = sz (s);
   pw[0] = fact[0] = inv[0] = 1;
   for (int i = 1; i <= n + k; i ++) {
      pw[i] = mult (pw[i - 1], 25);
      fact[i] = mult (fact[i - 1], i);
      inv[i] = binpow (fact[i], mod - 2);
   }
   for (int i = n; i <= n + k; i ++) {
      ans = add (ans, mult (C (n + k, i), pw[n + k - i]));
   }
   cout << ans;
}               
 
signed main () {                                       
   //#ifdef QWERTY
   //   freopen("input", "r", stdin);
   //#endif
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}                   

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

int main(){

    int N;
    bool ans = false;
    cin >> N;
    
    for(int i = 0; i <= N/4; i++)
        ans += (N - i*4) % 7 == 0;
    
    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s,t,result;
  cin >> s >> t;
  vector<vector<int>> dp(s.length()+1,vector<int>(t.length()+1));
  for (int i = 1; i <= s.length(); i++) {
    for (int j = 1; j <= t.length(); j++) {
      if (s[i-1] == t[j-1]) {
        dp[i][j] = dp[i-1][j-1]+1;
      } else {
        dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
      }
    }
  }
  for (int i = s.length(), j = t.length(); i && j; i--, j--) {
    if (s[i-1] == t[j-1]) {
      result.push_back(s[i-1]);
    } else {
      if (dp[i][j] == dp[i-1][j]) {
        j++;
      } else {
        i++;
      }
    }
  }
  reverse(result.begin(),result.end());
  cout << result;
}

Measured memory_bytes: 38496
N=int(input())
d=map(int,input().split())
L=list(d)
l=len(L)
SUM=0
for i in range(l):
  for j in range(l-i):
    if (j+i+1)<l:
      SUM=SUM+L[i]*L[j+i+1]
    
print(SUM)
  

Measured memory_bytes: 9104
N = gets.to_i
Xs, Ys = readlines.map{|l| l.split.map(&:to_i)}.transpose

puts [*0 ... N].combination(2).map{|i, j| Math.sqrt((Xs[i] - Xs[j])**2 + (Ys[i] - Ys[j])**2)}.inject(:+) / (N/2.0)

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>(b);i--)
#define pb push_back

typedef long long ll;
using namespace std;
int MOD = 1000000007;
int N;
double sq, a, sum = 0;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  cin >> N;
  FOR(i, 0, N){
    cin >> a;
    sum += a;
    sq += a * a;
  }
  a = sum / N;
  if(a - floor(a) > 0.5)a++;
  a = floor(a);
  sq += (N * a - 2 * sum) * a;
  cout << int(sq) << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define all(x) (x).begin(),(x).end()
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	cout << n * n*n << endl;
	return 0;
}

Measured memory_bytes: 256