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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int h,w,k;
    cin >> h >> w >> k;
    string s[805];
    for (int i = 0;i < h;++i) cin >> s[i];
    int d[4] = {0,1,0,-1};
    vector<vector<bool>> used(h,vector<bool>(w,false));
    queue<P> que;
    for (int i = 0;i < h;++i) for (int j = 0;j < w;++j) if (s[i][j] == 'S') {
        que.push(make_pair(i,j));
        used[i][j] = true;
    }
    int ans = 1000;
    for (int i = 0;i < k;++i) {
        int t = que.size();
        for (int j = 0;j < t;++j) {
            P p = que.front();
            que.pop();
            for (int l = 0;l < 4;++l) {
                int x = p.first+d[l],y = p.second+d[l^1];
                if (x < 0 || x >= h || y < 0 || y >= w) continue;
                if (!used[x][y] && s[x][y] == '.') {
                    used[x][y] = true;
                    que.push(make_pair(x,y));
                }
            }
        }
    }
    for (int i = 0;i < h;++i) for (int j = 0;j < w;++j) if (used[i][j]) ans = min(ans,(min({i,j,h-i-1,w-j-1})+k-1)/k+1);
    cout << ans << endl;
    return 0;    
}

Measured memory_bytes: 1152
N=int(input())
A=list(map(int,input().split()))
A.append(0)
A.sort()
winner=""
for i in range(N+1):
    if A[N-i]>i:
        if (A[N-i]-i)%2==0:
            winner="First"
        else:
            winner="Second"
    elif A[N-i]==i:
        if (A[N-i+1]-A[N-i])%2==1:
            winner="First"
            break
        else:
            count=0
            for j in range(N-i,-1,-1):
                if A[j]==i:
                    count+=1
                else:
                    break
            if count%2==1:
                winner="First"
            else:
                winner="Second"
            break
    else:
        break

print(winner)


Measured memory_bytes: 84976
S = input()

pd = [[0]*2 for _ in range(len(S))]
if S[0] != S[1] :
    pd[1][0] = 1

for i in range(2,len(S)) :
    pd[i][0] = pd[i-1][1] + 1
    if S[i] != S[i-1] :
        pd[i][0] = max(pd[i][0], pd[i-1][0]+1)
    pd[i][1] = pd[i-2][0] + 1
    if S[i-1:i+1] != S[i-3:i-1] :
        pd[i][1] = max(pd[i][1], pd[i-2][1]+1)

print(max(pd[len(S)-1])+1)


Measured memory_bytes: 65228
#define _USE_MATH_DEFINES

//#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <vector>
    
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;

//int 最大値は2147483647 > 10^9

ll gojou[200];

int main(){
    ll x;
    cin>>x;

    rep(i,200)gojou[i]=ll(i)*ll(i)*ll(i)*ll(i)*ll(i);
    //rep(i,200)printf("%d,%lld\n", i, gojou[i]);

    rep(i,200)rep(j,200){
        if(x == gojou[i]-gojou[j]){
            printf("%d %d", i,j);
            return 0;
        }else if(x == gojou[i]+gojou[j]){
            printf("%d %d", i,-1*j);
            return 0;
        }else if(x == -1*gojou[i]+gojou[j]){
            printf("%d %d", -1*i,-1*j);
            return 0;
        }
    }


} // end of main
    
//実行は、Opt + Ctl + N


//pythonの入力
//s, w = map(int, input().split())


Measured memory_bytes: 3768
lastday=[-1]*26
def last(d):
  sum=0
  for i in range(26):
    sum+=c[i]*(d-lastday[i])
  return sum

def myFunc(i,Score,depth,lastday):
  tmp_score=Score
  tmp_max_choice=0
  tmp_score-=last(i)
  tmp_max_score=tmp_score
  tmp_deep_score=tmp_score
  
  for k,j in enumerate(s[i]):
    if depth==0 or i==D-1:      
      if tmp_max_score<tmp_score+j+c[k]*(i-lastday[k]):
        tmp_max_choice=k
        tmp_max_score=tmp_score+j+c[k]*(i-lastday[k])
    else:
      l=lastday.copy()
      l[k]=i
      score,choice=myFunc(i+1,tmp_score+j+c[k]*(i-lastday[k]),depth-1,l)
      if tmp_deep_score<score:
        tmp_max_choice=k
        tmp_max_score=tmp_score+j+c[k]*(i-lastday[k])
        tmp_deep_score=score

  return tmp_max_score,tmp_max_choice

D=int(input())
c=list(map(int,input().split()))
s=[]
for i in range(D):
  s.append(list(map(int,input().split())))
Score=0
for i in range(D):
  score,choice=myFunc(i,Score,2,lastday)
  Score=score
  lastday[choice]=i
  print(choice+1)


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

const int maxn = 100010;
int n, m;
deque<int> q;
bool vis[maxn];
vector<int> G[maxn];

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 1, u, v; i <= m; i++) {
        scanf("%d %d", &u, &v);
        G[u].push_back(v), G[v].push_back(u);
    }
    q.push_back(1), vis[1] = 1;
    while (1) {
        bool flag = 0;
        int x = q.front(), y = q.back();
        for (int u : G[x]) {
            if (!vis[u]) { vis[u] = flag = 1, q.push_front(u); break; }
        }
        if (flag) continue;
        for (int u : G[y]) {
            if (!vis[u]) { vis[u] = flag = 1, q.push_back(u); break; }
        }
        if (flag) continue;
        break;
    }
    printf("%d\n", q.size());
    for (int x : q) printf("%d ", x);
    return 0;
}

Measured memory_bytes: 6784
M, D = map(int, input().split())

ans = 0

for m in range(1, M + 1):
    for d in range(1, D + 1):
        d1 = d % 10
        d10 = d // 10
        if d1 >= 2 and d10 >= 2 and m == d1*d10:
            ans += 1

print(ans)

Measured memory_bytes: 3060
h,w=gets.split.map(&:to_i)
m=h*w
a=h/3*w
b=(h-h/3)/2*w
c=h*w-a-b
if [a,b,c].max-[a,b,c].min<m
  m=[a,b,c].max-[a,b,c].min
end
b=(h-h/3)*(w/2)
c=h*w-a-b
if [a,b,c].max-[a,b,c].min<m
  m=[a,b,c].max-[a,b,c].min
end
a=(h/3+1)*w
b=(h-h/3-1)/2*w
c=h*w-a-b
if [a,b,c].max-[a,b,c].min<m
  m=[a,b,c].max-[a,b,c].min
end
b=(h-h/3-1)*(w/2)
c=h*w-a-b
if [a,b,c].max-[a,b,c].min<m
  m=[a,b,c].max-[a,b,c].min
end
a=w/3*h
b=(w-w/3)/2*h
c=h*w-a-b
if [a,b,c].max-[a,b,c].min<m
  m=[a,b,c].max-[a,b,c].min
end
b=(w-w/3)*(h/2)
c=h*w-a-b
if [a,b,c].max-[a,b,c].min<m
  m=[a,b,c].max-[a,b,c].min
end
a=(w/3+1)*h
b=(w-w/3-1)/2*h
c=h*w-a-b
if [a,b,c].max-[a,b,c].min<m
  m=[a,b,c].max-[a,b,c].min
end
b=(w-w/3-1)*(h/2)
c=h*w-a-b
if [a,b,c].max-[a,b,c].min<m
  m=[a,b,c].max-[a,b,c].min
end
puts m


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n + 1); i++)
// vector<vector<int>> A(3, vector<int>(4));
int main(){
    int K;
    cin>>K;
    rep(i,K){
        cout<<"ACL";
    }
    cout<<""<<endl;
}


Measured memory_bytes: 3652
import java.util.*;
import java.util.Collections;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String[] s = S.split("");
        int N = s.length;
        long[] ans = new long[N];
        
        int rsum = 0;
        int lsum = 0;
        for(int i = 0; i < N; i++) {
            if(lsum == 0 && s[i].equals("R")) {
                rsum++;
                continue;
            }
            
            if(s[i].equals("L") && i < N-1) {
                lsum++;
                continue;
            }
            
            if(s[i].equals("R") || i == N-1) {
                if(i == N-1) {
                    lsum++;
                    i++;
                }
                if((rsum + lsum) % 2 == 0) {
                    ans[i - lsum - 1] = (rsum+lsum) / 2;
                    ans[i - lsum] = (rsum+lsum) / 2;
                }else {
                    if(rsum % 2 == 0) {
                        ans[i - lsum - 1] = (lsum+rsum+1) / 2 - 1;
                        ans[i - lsum] = (lsum+rsum+1) / 2;
                    }else {
                        ans[i - lsum - 1] = (lsum+rsum+1) / 2;
                        ans[i - lsum] = (lsum+rsum+1) / 2 - 1;
                    }
                }
                
                lsum = 0;
                rsum = 1;
            }
            
            
        }
        
        for(int i = 0; i < N; i++) {
            if(i < N - 1) {
                System.out.print(ans[i]+" ");
            }else {
                System.out.println(ans[i]);
            }
        }
    }
}

Measured memory_bytes: 49580
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================








int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================





	ll N, A, B;
	cin >> N >> A >> B;

	ll set = N / (A+B);
	ll amari = N % (A + B);

	if (amari >= A ) {
		cout << A* set + A;
	}
	else {
		cout << A * set + amari;
	}




}


Measured memory_bytes: 256
n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i);
i = 0
c = Array.new(n,0)

n.times do
  while a[i] % 2 == 0
    c[i] += 1
    a[i] /= 2
  end
  i += 1  
end

puts c.min


Measured memory_bytes: 1788
s = input()
for k in range(len(s)-1):
    if s[k] == s[k+1]:
        print(k+1,k+2)
        exit(0)
if len(s) == 2:
    print(-1,-1)
    exit(0)

for k in range(1,len(s)-1):
    if s[k-1] == s[k+1]:
        print(k,k+2)
        exit(0)
print(-1,-1)


Measured memory_bytes: 39408
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
  
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    
    if ( A+B > C+D ) { cout << "Left" << endl; }
    else if ( A+B < C+D ) { cout << "Right" << endl; }
    else { cout << "Balanced" << endl; }
  
    return 0;
}

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

template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

const long long INF = 1LL << 60;
const int MAX_N = 1E2 + 10;
const int MAX_W = 1E5 + 10;

int N, W, w[MAX_N], v[MAX_N];
long long dp[MAX_N][MAX_W];

int main()
{
	cin >> N >> W;
	for (int i = 0; i < N; ++i)
	{
		cin >> w[i] >> v[i];
	}

	for (int i = 0; i < N; ++i)
	{
		for (int j = 0; j <= W; ++j)
		{
			if (j - w[i] >= 0)
				chmax(dp[i + 1][j], dp[i][j - w[i]] + v[i]);

			chmax(dp[i + 1][j], dp[i][j]);
		}
	}

	cout << dp[N][W] << endl;
}

Measured memory_bytes: 79360
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int X, Y; cin >> X >> Y;
	if (2 * X <= Y && Y <= 4 * X && Y%2==0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}



Measured memory_bytes: 3636
from collections import deque
def main():
    S = input()
    d = deque(S)
    Q = int(input())
    direction = True
    for _ in range(Q):
        x = input()
        if x[0] == '1':
            direction = not direction
        else:
            a,f,c = x.split(' ')
            if (int(f) == 1 and direction) or (int(f) == 2 and not direction):
                d.appendleft(c)
            else:
                d.append(c)
    if direction:
        print(''.join(d))
    else:
        print(''.join(reversed(d)))
                
main()


Measured memory_bytes: 8564
import sys
str = input()
f = True
for s in str[0::2]:
    if s == "L":
       f = False
       break

if f == False:
    print("No")
    sys.exit()

for s in str[1::2]:
    if s == "R":
        f = False
        break

if f:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int H = sc.nextInt();
		int W = sc.nextInt();

		int[][] c = new int[10][10];
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				c[i][j] = sc.nextInt();
			}
		}

		int[][] A = new int[H][W];
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				A[i][j] = sc.nextInt();
			}
		}

		sc.close();

		for (int k = 0; k < 10; k++) {
			for (int i = 0; i < 10; i++) {
				for (int j = 0; j < 10; j++) {
					c[i][j] = Math.min(c[i][j], c[i][k] + c[k][j]);
				}
			}
		}

		int ans = 0;

		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (A[i][j] != -1) {
					ans += c[A[i][j]][1];
				}
			}
		}

		out.println(ans);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


Measured memory_bytes: 46988
n =int(input())
s = input()


ans = n
if n < 10:
	for i in range(n):
		ans = min((s[:i].count("W")+s[i+1:].count("E")),ans)
else:
	change = (s[1:].count("E"))
	ans = change
	for i in range(1,n):

		t = 0
		if s[i-1] == "W":
			t += 1
		if s[i] == "E":
			t -= 1
		change += t
		ans = min(ans,change)

print(ans)

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int main()
{
	int r;
	cin>>r;
	printf("%.5lf\n",(double)r*2*3.14159);
	return 0;
}

Measured memory_bytes: 3804
import sys
import copy
import string
import  math
from _bisect import *
from collections import *
from operator import itemgetter
from math import factorial
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

x = ni()
s = 0
i = 1
while True:
    s += i
    if s >= x:
        ans = i
        break
    i += 1
print(ans)

Measured memory_bytes: 3900
#include<bits/stdc++.h>
using namespace std;
int f(char ch)
{
	int b=(int)(ch-'0');
	return b;
}
int main()
{
	long long k;
	string s;
	cin>>s>>k;
	if(s.size()==1&&s[0]=='1')
	{
		cout<<1;
		return 0;
	}
	for(long long i=0;i<s.size();i++)
	if(f(s[i])!=1&&k>i)
	{
		cout<<s[i];
		return 0;
	}
	cout<<1;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys

S = input()
if S[0] != 'A':
    print('WA')
    sys.exit(0)
for l in S:
    if l in list('BDEFGHIJKLMNOPQRSTUVWXYZ'):
        print('WA')
        sys.exit(0)

re = len(list(filter( lambda x: x == 'C', S[2:-1])))
if re == 1:
    print('AC')
else:
    print('WA')

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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, m;
  cin >> n >> m;
  vvll to(n);
  rep(i, m) { ll a, b;
    cin >> a >> b;
    a--, b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  vll ans(n, -1);

  queue<ll> que;
  que.push(0);
  while(!que.empty()){
    ll u = que.front();
    que.pop();
    for(ll v : to[u]){
      if (ans[v] != -1) continue;
      ans[v] = u;
      que.push(v);
    }
  }

  cout << "Yes" << endl;
  rep(i, n - 1) cout << ans[i + 1]+1 << endl;

  return 0;
}


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

#pragma region Macro
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define vvi vector<vector<int>>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#pragma endregion

// auto mod int
// source : https://github.com/atcoder-live/library
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
const int MOD = 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;}

void solve(){
	#define int ll
	// ここに処理を記述
	// コンパイル時はエイリアス「gpp」--> c++17でコンパイル
	
	int n;
	cin >> n;

	vi a(n);
	mint sum = 0;
	rep(i,n){
		cin >> a[i];
		sum += a[i];
	}

	mint ans=0;

	rep(i,n-1){
		sum -= a[i];
		mint add = (mint)a[i] * sum;
		ans += add;
	}

	cout << ans << endl;

}

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

Measured memory_bytes: 4768
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
using namespace std;
int main(){
    const int t=100001;
    LLI a[t]={},b[t]={},c[t]={},d[t]={};
    int n,k; cin>>n>>k;
    LLI z=0;
    n++;
    FOR(i,1,n){
        cin>>a[i];
        c[i]=max(a[i],z);
        b[i]=b[i-1]+a[i];
        d[i]=d[i-1]+c[i];
    }
    LLI M=-(1<<18);
    n--;
    FOR(i,0,n-k+1){
        M=max(M,d[i]-d[0]+d[n]-d[i+k]+max(z,b[i+k]-b[i]));
    }
    cout<<M<<endl;
}


Measured memory_bytes: 2560
package main

import (
	"fmt"
)

func main() {
	var a, b, x int
	ans := "NO"
	fmt.Scan(&a, &b, &x)
	for i := 0; i <= b; i++ {
		if i + a == x {
			ans = "YES"
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string s;
  cin >> s;
  int n=s.size();
  bool judge=true;
  if(n%2!=0){
    judge=false;
  }
  for(int i=0;i<n;i+=2){
    if(judge==false){
      break;
    }
    if(s.at(i)!='h'||s.at(i+1)!='i'){
      judge=false;
    }
  }
  if(judge){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
typedef pair<int,int>   ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef set<int>        si;
typedef set<ii>         sii;

#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define clr(x,v) memset(x,v,sizeof x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define re return

template<typename T> T sgn (T x)      {re x<0? -1:(x>0? 1:0); }
template<typename T> T gcd (T a, T b) {re a ? gcd (b % a, a) : b; }
template<typename T> T abs (T x)      {re x < 0 ? -x : x; }
template<typename T> T sqr (T x)      {re x*x;}

#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define popcount __builtin_popcount
#define mp make_pair
#define pb push_back
#define ins insert
#define sc second
#define fr first
#define endl "\n"
#define MOD ((int)1e9+7)
#define N ((int)2e5+123)

ll n,i,x;

void solve(){
    cin >> x;
    n=100;
    while(n<x){
        n+=n/100;
        i++;
    }
    cout<<i<<endl;
}
int main(){_
    solve();
    /*
    int t; cin >> t;
    while(t--){
        solve();
    }
     */
}

Measured memory_bytes: 3652
n = int(input())

def prime(n):
  i = 2
  while i < n:
    if n%i == 0:
      return False
    else:
      i += 1
  return True

nums = []
k = 11
while len(nums) <= n:
  if prime(k) == True:
    nums.append(k)
  k += 10

ans = str(nums[0])
i = 1
while i < n:
  ans = ans +' '+str(nums[i])
  i += 1
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>
#include <unordered_map>

using namespace std;

typedef long long ll;

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  ll n; cin >> n;
  unordered_map<char, ll> cnt;
  cnt['M'] = 0;
  cnt['A'] = 0;
  cnt['R'] = 0;
  cnt['C'] = 0;
  cnt['H'] = 0;
  for(int i=0;i<n;i++){
    string str; cin >> str;
    cnt[str[0]]++;
  }
  ll ans = cnt['M']*cnt['A']*cnt['R'] + cnt['M']*cnt['A']*cnt['C']+
  cnt['M']*cnt['A']*cnt['H'] + cnt['M']*cnt['R']*cnt['C'] +
  cnt['M']*cnt['R']*cnt['H'] + cnt['A']*cnt['R']*cnt['C'] +
  cnt['A']*cnt['R']*cnt['H'] + cnt['A']*cnt['C']*cnt['H'] +
  cnt['M']*cnt['C']*cnt['H'] + cnt['R']*cnt['C']*cnt['H'];
  cout << ans << endl;
}

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

int main() {
    ll n, h;
    cin >> h >> n;
    int allDamage = 0;
    for (int i = 0; i < n; i++)
    {
        ll attack;
        cin >> attack;
        allDamage += attack;
    }
    puts(allDamage >= h ? "Yes" : "No");
    return 0;   
    
}

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

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

int main(void) {
    int h, w;
    string a[100];
    bool col[100] = {false}, row[100] = {false};

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> h >> w;
    REP(i, h) {
        cin >> a[i];
        REP(j, w) {
            if (a[i][j] == '#') {
                col[i] = true;
                row[j] = true;
            }
        }
    }

    REP(i, h) {
        if (col[i]) {
            REP(j, w) {
                if (row[j]) {
                    cout << a[i][j];
                }
            }
            cout << "\n";
        }
    }

    return 0;
}

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

using namespace std;

struct unionfind
{
	//rankのオーバーフローに注意
	vector<int> par, rank;
	unionfind(int n)
	{
		par.resize(n);
		rank.resize(n);
		for (int i = 0; i < n; i++)
		{
			par[i] = i;
			rank[i] = 1;
		}
	}

	bool same(int u, int v)
	{
		return root(u) == root(v);
	}

	void unite(int u, int v)
	{
		if (same(u, v)) return;
		u = root(u), v = root(v);
		if (rank[u] > rank[v]) swap(u, v);
		par[u] = v;
		rank[v] += rank[u];
	}

	int root(int v)
	{
		if (par[v] == v) return v;
		return par[v] = root(par[v]);
	}
};

void solve()
{
	int N;
	cin >> N;
	vector<int> ws(N), cs(N);
	set<int> s;
	map<int, int> mp;
	int m = INT_MAX;
	for (int i = 0; i < N; i++)
	{
		cin >> ws[i];
		s.insert(ws[i]);
		m = min(m, ws[i]);
	}

	int cnt = 0;
	for (int v : s)
	{
		mp[v] = cnt++;
	}
	for (int i = 0; i < N; i++)
	{
		cs[i] = mp[ws[i]];
	}

	unionfind uf(N);
	vector<int> es[N];

	for(int i = 0; i < N; i++)
	{
		uf.unite(i, cs[i]);
	}

	for(int i = 0; i < N; i++)
	{
		es[uf.root(cs[i])].push_back(ws[cs[i]]);
		//cout << cs[i] << ' ';
	}
	//cout << endl;

	int ans = 0;

	for(int i = 0; i < N; i++)
	{
		auto e = es[i];
		int n = e.size(), x = INT_MAX, sum = 0;
		if (n < 2) continue;
		for (int v : e)
		{
			sum += v;
			x = min(v, x);
		}
		sum -= x;
		sum += min((n-1)*x, 2*(x+m)+(n-1)*m);
		ans += sum;
		//cout << ans << endl;
	}

	cout << ans << endl;

}

int main(void)
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}



Measured memory_bytes: 3236
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    S = input()
    left = 0
    right = 1
    ans = 0
    while left < N:
        S1 = S[left:right]
        S2 = S[right:]
        if S1 in S2:
            ans = max(ans, len(S1))
            right += 1
        else:
            left += 1
    print(ans)

if __name__ == '__main__': main()

Measured memory_bytes: 3064
n = int(input())
ar = [input() for _ in range(n)]

d = {}

for a in ar:
    if a in d:
        d[a] += 1
    else:
        d[a] = 1

max_val = max(d.values())
print("\n".join(sorted([key for key in d if d[key] == max_val])))

Measured memory_bytes: 35596
use std::io;
use std::f64;

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line).ok();
    let mut iter = line.split_whitespace().map(|x| x.parse::<f64>().unwrap());
    let a = iter.next().unwrap();
    let b = iter.next().unwrap();
    let c = iter.next().unwrap();

    let rad = f64::consts::PI * c / 180.0;
    let s = a * b * rad.sin() / 2.0;
    let l = a + b + (a * a + b * b - 2.0 * a * b * rad.cos()).sqrt();
    let h = b * rad.sin();

    println!("{}", s);
    println!("{}", l);
    println!("{}", h);
}



Measured memory_bytes: 5192
#include "bits/stdc++.h"

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
#define OUT(P) cout << (P) << endl
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)
typedef long long ll;

int sum_digits(int num);
template <class T>
vector<T> copy_vector(vector<T> vec);
int gcd(int a, int b);

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];

    sort(a.rbegin(), a.rend());
    int max_elem = a[0];
    if(a.size() > 2 && gcd(max_elem, a[1]) == 1 && gcd(a[1], a[2]) > 1) {
        max_elem = a[1];
    }
    vector<int> changed(n, 0);
    vector<int> not_changed(n, 0);
    vector<int> all_not_changed(n, 0);

    changed[0] = max_elem;
    not_changed[0] = max_elem; 
    all_not_changed[0] = max_elem;
    for(int i=1; i<n; i++) {
        all_not_changed[i] = gcd(all_not_changed[i-1], a[i]);

        changed[i] = gcd(all_not_changed[i-1], max_elem);
        not_changed[i] = max(gcd(changed[i-1], a[i]), gcd(not_changed[i-1], a[i]));
    }
    cout << max(changed[n-1], not_changed[n-1]) << endl;


    return 0;
}

/******************************/
/***** DECRARED FUNCTIONS *****/
/******************************/

int sum_digits(int num) {
    int rtn = 0;
    while(num != 0) {
        int tmp = num % 10; 
        rtn += tmp;
        num /= 10; 
    }   
    return rtn;
}
//int sum_digits(int num) {
//    int rtn = 0;
//    string num_str = to_string(num);
//    for(int i=0; i<num_str.size(); i++) {
//        rtn += num_str[i] - '0';
//    }   
//    return rtn;
//}

// vectorのコピー
template <class T>
vector<T> copy_vector(vector<T> vec) {
    vector<T> rtn;
    rtn.reserve(vec.size());
    copy(vec.begin(), vec.end(), back_inserter(rtn));
    return rtn;
}

// ユークリウッドの互除法
int gcd(int a, int b) {
    if(b==0) return a;
    else return gcd(b, a % b);
}



Measured memory_bytes: 1792
import java.util.*;
public class Main {
	public static void main(String[] args) {
		C();
	}
	
	public static void A() {
		Scanner sc = new Scanner(System.in);
		String s1 = sc.next();
		String s2 = sc.next();
		for(int i=0;i<3;i++) {
			if(s1.charAt(i)!=s2.charAt(2-i)) {
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");
	}
	
	// 1から順に２乗を計算して、Nを超えるかどうか確認する。 O(root(N))
	//２分探索するなら、O(logN)
	// 二分探索で、Nの２乗を超えない最小の平方数を発見
	public static long binsearchN2(long left, long right, int N) {
		if(left >= right) return (long) Math.pow(right, 2);
		long mid = (left+right)/2;
		if(Math.pow(mid, 2) > N ) return binsearchN2(left, mid-1, N);
		else {
			//無限ループを防ぐ　再起する時は必ず、探索範囲が１以上小さくなる
			if(Math.pow(mid+1, 2) > N) return (long) Math.pow(mid, 2) ;
			else return binsearchN2(mid+1,right, N);
		}
	}
	
	public static void B() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(binsearchN2(0,N,N));
	}

	// Bを中心にして二分探索してAとCの数を掛け合わせる
	//　Aを中心とすると、O(N^2)
	
	// Bを超えない要素数を返す
	public static void C() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		double[] A=new double[N],  C = new double[N];
		int[] B=new int[N];
		for(int i=0;i<N;i++) {
			A[i] = sc.nextDouble();
		}
		for(int i=0;i<N;i++) {
			B[i] = sc.nextInt();
		}
		for(int i=0;i<N;i++) {
			C[i] = sc.nextDouble();
		}
		Arrays.sort(A);
		Arrays.sort(B);
		Arrays.sort(C);
		long sum = 0;
		for(int i=0;i<N;i++) {
			double b = B[i];
			sum += numlessB(A,b)*(long)numlargerB(C,b);
		}
		System.out.println(sum);
		
	}
	//Bよりも小さい要素の数　==Bは含まない Bを少しずらす
	public static int numlessB(double[] A, double B){
		int idx = Arrays.binarySearch(A, B-0.1);
		return -idx-1;
	}
	public static int numlargerB(double[] A, double B) {
		int idx = Arrays.binarySearch(A, B+0.1);
		return A.length-(-idx-1);
	}
}


Measured memory_bytes: 175216
#include<iostream>
#include<string>
 
using namespace std;
 
int main(void) {
	int a, b;
	cin >> a >> b;
	if ((a % 3 == 0) || (b % 3 == 0) || ((a + b) % 3 == 0)) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}
 
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define MAX_N 100000

// 入力
int n;
int a[MAX_N];

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

    long long sum1 = 0, sum2 = 0;
    bool positive1 = true, positive2 = false;
    long long opeNum1 = 0, opeNum2 = 0;
    for (int i = 0; i < n; ++i) {
//        cout << opeNum1 << " " << opeNum2 << endl;
        sum1 += a[i];
        if (positive1) {
            if (sum1 <= 0) {
                opeNum1 += abs(1 - sum1);
                sum1 = 1;
            }
            positive1 = false;
        } else {
            if (sum1 >= 0) {
                opeNum1 += abs(-1 - sum1);
                sum1 = -1;
            }
            positive1 = true;
        }

        sum2 += a[i];
        if (positive2) {
            if (sum2 <= 0) {
                opeNum2 += abs(1 - sum2);
                sum2 = 1;
            }
            positive2 = false;
        } else {
            if (sum2 >= 0) {
                opeNum2 += abs(-1 - sum2);
                sum2 = -1;
            }
            positive2 = true;
        }
    }

    cout << min(opeNum1, opeNum2) << endl;
    return 0;
}

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

using namespace std;

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

void solve() {
  int n;
  cin >> n;
  cout << "Christmas";
  while(n++ < 25) cout << " Eve";
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int P[200002];
bool eranda[200002];

int Find(int A) {
	if (P[A] < 0) return A;
	return P[A] = Find(P[A]);
}

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


	int N, H, W;
	cin >> N >> H >> W;

	pair<int, pair<int, int>> E[100000];
	rep(i, N) {
		int r, c, a;
		cin >> r >> c >> a;
		E[i] = mp(a, mp(r - 1, H + c - 1));
	}
	sort(E, E + N);
	reverse(E, E + N);

	rep(i, H + W) P[i] = -1;
	ll kotae = 0;
	rep(i, N) {
		int r = Find(E[i].second.first);
		int c = Find(E[i].second.second);
		if (r != c) {
			if (!(eranda[r] && eranda[c])) {
				if (P[r] > P[c]) swap(r, c);
				P[r] += P[c];
				eranda[r] |= eranda[c];
				P[c] = r;
				kotae += E[i].first;
			}
		}
		else {
			if (eranda[r] == 0) {
				eranda[r] = 1;
				kotae += E[i].first;
			}
		}
	}

	printf("%lld", kotae);


	Would you please return 0;
}

Measured memory_bytes: 2304
import collections
N = int(input())


def generate(n):
    _list = []
    queue = collections.deque([0])
    while queue:
        _temp = queue.popleft()
        if _temp <= n and '3' in str(_temp) and '7' in str(_temp) and '5' in str(_temp):
            _list.append(_temp)
        if len(str(_temp)) > 9:
            break
        queue.append(_temp * 10 + 7)
        queue.append(_temp * 10 + 5)
        queue.append(_temp * 10 + 3)
    return _list


_list = generate(N)
print(len(_list))


Measured memory_bytes: 76056
//love yjl forever
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int INF=0x3f3f3f3f,N=2e5+5;
ll n;
ll a[N];
ll b[N];
int main()
{
/*	freopen("","r",stdin);
	freopen("","w",stdout);*/
	int i;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		b[a[i]]++;
	}
	ll ans=0;
	for(i=1;i<=n;i++)
	{
		if(b[i]) ans+=(b[i]*(b[i]-1))/2;
	}
	for(i=1;i<=n;i++)
	{
		printf("%lld\n",ans-b[a[i]]+1);
	}
	
}

Measured memory_bytes: 4736
N,M=list(map(int,input().split()))

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
Mdiv = make_divisors(M)
out = 1
for k in Mdiv:
    A = M//k
    if A>=N:
        out = max(out,k)
print(out)


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define iter(v, i) for (__typeof__((v).begin()) i = (v).begin(); i != (v).end(); i++)
#define fast_io_without_cstdio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define all(v) (v).begin(), (v).end()
#define rep(i, s, e) for (int i = s; i < e; i++)

// START for segment tree
#define params int p, int L, int R
#define housekeep int mid = (L + R) >> 1, left = p << 1, right = left | 1
// END

#ifdef __linux__
#define gc getchar_unlocked
#define pc putchar_unlocked
#else
#define gc getchar
#define pc putchar
#endif

#if __cplusplus <= 199711L
template<class BidirIt>
BidirIt prev(BidirIt it, typename iterator_traits<BidirIt>::difference_type n = 1) {
    advance(it, -n);
    return it;
}

template<class ForwardIt>
ForwardIt next(ForwardIt it, typename iterator_traits<ForwardIt>::difference_type n = 1) {
    advance(it, n);
    return it;
}
#endif

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ldouble;

const double EPS = 1e-9;
const double PI = 3.141592653589793238462;

template<typename T>
inline T sq(T a) { return a * a; }

//#ifdef LOCAL_MACHINE
//#endif

const char dir[4] = {'N', 'W', 'S', 'E'};
bool found[4];
char str[1005];

int main() {
    //freopen("", "r", stdin);
    //freopen("", "w", stdout);
    scanf("%s", str);
    int n = strlen(str);
    for (int i = 0; i < n; i++) {
        int pos = find(dir, dir + 4, str[i]) - dir;
        found[pos] = true;
    }
    bool ans = true;
    for (int i = 0; i < 4; i++)
        if (found[i] != found[(i + 2) % 4])
            ans = false;
    puts(ans ? "Yes" : "No");
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
main(){
  double v,t,h,n;
  while(~scanf("%lf",&v)){
    t=v/9.8;
    h=4.9*t*t;
    n=(h+5)/5;
    printf("%.0f\n",ceil(n));
  }
  return 0;
}

Measured memory_bytes: 652
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

ll N;
double xs[50], ans = 0.0;
string us[50];

void solve(){
    rep(i,N){
        if(us[i] == "BTC")
            xs[i] *= 380000.0;

        ans += xs[i];
    }

    cout << ans << endl;
}

int main(){
    cin >> N;

    rep(i,N){
        cin >> xs[i] >> us[i];
    }

    solve();
}


Measured memory_bytes: 256
INF = 10 ** 10
n = int(input())
a = [INF] + list(map(int, input().split())) + [-INF]
l = []
for i in range(n):
    if len(l) % 2 == 0:
        if a[i + 1] < a[i + 2]:
            l.append(a[i + 1])
    else:
        if a[i + 1] > a[i + 2]:
            l.append(a[i + 1])
t = 1000
for i in range(1, len(l), 2):
    t = t // l[i - 1] * l[i] + t % l[i - 1]
print(t)


Measured memory_bytes: 61772
#include<bits/stdc++.h>
using namespace std;
int n,a[200010],b[200010],cnt[200010],L,R,l,r;
inline int read()
{
	int x=0,w=0;char ch=0;
	while(!isdigit(ch)){w|=ch=='-';ch=getchar();}
	while(isdigit(ch)){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return w?-x:x;
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)cnt[a[i]=read()]++;
	for(int i=1;i<=n;i++)cnt[b[n-i+1]=read()]++;
	for(int i=1;i<=n;i++)
	if(cnt[i]>n){cout<<"No";return 0;}
	cout<<"Yes\n";
	L=n;R=1;l=1;r=n;
	for(int i=1;i<=n;i++)
	if(a[i]==b[i]){
		L=min(L,i);
		R=max(R,i);
	}
	for(int i=L;i<=R;i++)
	if(a[i]==b[i]){
		if(b[i]!=a[l]&&b[i]!=b[l]){
			swap(b[i],b[l]);
			l++;
		}else{
			swap(b[i],b[r]);
			r--;
		}
	}
	/*for(int i=L;i<=R;i++)
	if(l<L&&b[l]!=b[i])swap(b[i],b[l++]);
	else swap(b[i],b[r--]);*/
	for(int i=1;i<=n;i++)
		printf("%d ",b[i]);
}

Measured memory_bytes: 5928
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#ifdef ONLINE_JUDGE
  #define debug(x)
  #define debug2(x,y)
  #define debug3(x,y,z)
  #define assert(e) if(!(e)){stod("");}
#else
  #define debug(x) std::cerr<<#x<<": "<<x<<"\n"
  #define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
  #define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"
#endif

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

void solve() {
  ll n;
  scan(n);
  ll ans = 0;
  FOR (i, 1, n+1) {
    // begin = 1
    ll end = n / i;
    ans += (end + 1) * end / 2 * i;
  }
  print(ans);
}

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


Measured memory_bytes: 3220
def partition(A, p, r):
  (suite, x) = A[r]
  i = p - 1
  for j in range(p, r):
    if A[j][1] <= x:
      i = i + 1
      A[i], A[j] = A[j], A[i]
  A[i+1], A[r] = A[r], A[i+1]
  return i + 1

def quick_sort(A, p, r):
  if p < r:
    q = partition(A, p, r)
    quick_sort(A, p, q - 1)
    quick_sort(A, q + 1, r)

if __name__ == "__main__":
  import sys
  n = sys.stdin.readline()
  items = []
  suite_order = {}
  for line in sys.stdin:
    item  = line.strip().split()
    items.append(item)
    if item[1] not in suite_order:
      suite_order[item[1]] = []
    suite_order[item[1]].append(item[0])

  items = [ (item[0], int(item[1])) for item in items ]
  quick_sort(items, 0, len(items) - 1)

  is_stable = True
  for item in items:
    if suite_order[str(item[1])][0] != item[0]:
      is_stable = False
    suite_order[str(item[1])].pop(0)
  if is_stable:
    print "Stable"
  else:
    print "Not stable"

  for item in items:
    print "%s %s" % (item[0], str(item[1]))

Measured memory_bytes: 46144
#include<iostream>
#include<queue>
#include<cstring>
#include<cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<(n);i++)
#define long long ll


int main(){
    int T;
    scanf("%d",&T);
    // while(T--){
    //     int l,r;
    //     scanf("%d %d",&l,&r);
    //     if(r< 2*l){
    //         cout<<"-1 -1\n";
    //     }
    //     else cout<<l<<" "<<2*l<<endl;
    // }
    if(T>=30)cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
#include<iomanip>
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define N 1000000
#define ar array
#define inf 1e18
#define mod 998244353
#define ld long double
#define pb push_back
#define f first
#define s second
typedef long long int ll;
using namespace std;
/*

ll d[N];
set<pair<ll,ll>>s;
ll par[N];
vector<pair<ll,ll>>adj[N];
void Dijkstra(ll v){
	d[v]=0;
	s.insert({d[v],v});
	par[v]=v;
	while(!s.empty()){
		ll u=s.begin()->second;
		s.erase(s.begin());
		for(auto x:adj[u]){
			if(d[x.first]>d[u]+x.second){
				s.erase({d[x.first],x.first});
				d[x.first]=d[u]+x.second;
				s.insert({d[x.first],x.first});
				par[x.first]=u;
			}
		}
	}
}*/
int main(void){
	fast;
	int h,w,k,x,y,i,j,cr,lans,ans=0,p;
	cin>>h>>w>>k;
	int a=1<<h;
	int b=1<<w;
	char m[h][w];
	for(i=0;i<h;i++){
		for(j=0;j<w;j++)
		cin>>m[i][j];
	}
	char l[h][w];
	for(i=0;i<a;i++){
		//cout<<"*"
		for(j=0;j<b;j++){
			int u=j,v=i;		
			for(x=0;x<h;x++){
				for(y=0;y<w;y++){
					l[x][y]=m[x][y];
				}
			}
			cr=0;
			while(u!=0){
				if(u&1){
					for(p=0;p<h;p++)
					l[p][cr]='.';
				}
				cr++;
				u/=2;
			}
			cr=0;
			while(v!=0){
				if(v&1){
					for(p=0;p<w;p++)
					l[cr][p]='.';
				}
				cr++;
				v/=2;
			}
			lans=0;
			for(x=0;x<h;x++){
				for(y=0;y<w;y++){
					if(l[x][y]=='#')
					lans++;
				}
			}
			if(lans==k)
			ans++;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main () {
    int X, N, tmp;
    int p_max = 100;
    int p[p_max] = {};
    string S;
    cin >> X >> N;
    for (int i = 0; i < N; i++) {
        cin >> tmp;
        p[tmp - 1] = 1;
    }
  
    int diff = 101;
    int diff_tmp = 101;
    int min = -1;
    for (int i = 0; i < p_max; i++) {
        if (p[i] == 0) {
            diff_tmp = abs(i+1 - X);
        }
        if (diff > diff_tmp) {
            diff = diff_tmp;
            min = i + 1;
        }
    }
    
    if (min == -1) {
        if ((101 - X) > X) { min = 0; }
        else               { min = 101; }
    } else {
        if (abs(X - min) >= X) { min = 0; }
        if (abs(X - min) > (101 - X)) { min = 101; }
    }

    cout << min << endl;
    return 0;
}

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

int main()
{
    int n,m;
    cin >> n>> m;
    int y=n*(n-1)/2+m* (m-1)/2;
    cout <<y;
}


Measured memory_bytes: 256