akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;

ll dp[40000];
ll num[110];//?????°
ll n, S, r, c = 0, k = 0;
vector<ll> vl;

int main(){
	FOR(i,1, 20000){
		k += (i - 1);
		dp[i] = k;
	}
	while (cin >> n >> S){
		if (n + S == 0)break;
		REP(i, n){
			cin >> r;
			vl.push_back(r);
			num[r]++;
		}
		sort(ALL(vl));
		vl.erase(unique(ALL(vl)), vl.end());
		REP(i, vl.size()){
			FOR(j, i, vl.size()){
				if (vl[i] + vl[j] > S){
					if (i == j){
						if (num[vl[i]] != 1){
							c += dp[num[vl[i]]];
						}
					}
					else{
						c += num[vl[i]] * num[vl[j]];
					}
				}
			}
		}
		cout << c << endl;
		c = 0;
		vl.clear();
		REP(i, 110){
			num[i] = 0;
		}
	}
}

Measured memory_bytes: 1532
#include<bits/stdc++.h>
#define rf freopen("inputf.in", "r", stdin)
#define wf freopen("outputf.in", "w", stdout)
#define endl "\n"

using namespace std;
int main(void){//rf;wf;
               int flag=0;
    string a;std::cin >> a;
    for(int i=0;i<a.length();i++){
        if(a[i]=='7'){
            flag=1;
        }
    }
    if(flag==1){
        cout<<"Yes\n";
    }
    else{cout<<"No\n";}
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define MOD 1000000007

int main() {
    int n;
    cin >> n;
    int cnt = 0;
    rep2(i, 1, n) {
        for (int j = 1; j * j <= i; j++) {
            if (i % j == 0) {
                cnt++;
                if (i / j != j) {
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int power(int a, int b){ int S = 1; while(b--)S *= a; return S;}

int32_t main(){
	int n, m;
	cin >> n >> m;
	int s = 0;
	if(n > 1)
	s += n*(n-1)/2;
	if(m > 1)
	s += m*(m-1)/2;
	cout << s;
	return 0;
}



Measured memory_bytes: 256
import sys

n = int(input())
arr= list(map(int,sys.stdin.readline().split()))
arr = sorted(arr)
max_num = max(arr)
dp = [0 for i in range(max_num+1)]
for i in arr:
    j = i
    while j<=max_num:
        dp[j]+=1
        j+=i
ans = 0
for i in arr:
    if dp[i] == 1:
        ans+=1
print(ans)

Measured memory_bytes: 31408
n,k=map(int,input().split())
a=[0]+list(map(int,input().split()))

MAX_N=2*10**5
b=[1]
visited=[-1]*(n+10)
for i in range(1,2*MAX_N+1):
    nxt=a[b[-1]]
    b.append(nxt)
        
if k<=n:
    print(b[k])
    exit()
# print(b)  
for i,bi in enumerate(b):
    if visited[bi]==-1:
        visited[bi]=i
    else:
        m=i-visited[bi]
        l=visited[bi]
        break
k=k%m

while k<n:
    k+=m
print(b[k])
    

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

int main()
{
int min,max,input;
cin >> min;
max=min;
for(int i=1;i<=3;i++)
{cin >> input;
if(input<min)
{min=input;}
if(input>max)
{max=input;}
}
cout << min << " " << max << endl;
}


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

int main(void){
    int N,m,cnt=0;
    cin>>N;
    string n=to_string(N);

    if((N%10)%2==0)
        m=n.length()/2;
    else
        m=n.length()/2+1;

    for(int i=0;i<m;i++){
       if(n[i]!=n[n.length()-1-i])
            cnt++;
    }

    cout<<((cnt==0)?"Yes":"No")<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	static public void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] aArray = new int[n];
		for (int i = 0; i < n; i++) {
			aArray[i] = scan.nextInt();
		}
		scan.close();

		long count = 0L;
		long sum = 0L;
		Map<Long, Integer> sumMap = new HashMap<>();
		sumMap.put(0L, 1);
		for (int i = 0; i < n; i++) {
			sum += aArray[i];
			if (sumMap.containsKey(sum)) {
				count += sumMap.get(sum);
			} else {
				sumMap.put(sum, 0);
			}
			sumMap.put(sum, sumMap.get(sum) + 1);
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 91452
#include<stdio.h>
#include<stdlib.h>
 
int main(){
  	int money;
  	char str[256];
 	fgets(str, 256, stdin); 
  	money = atoi(str) % 1000;
  	if(money != 0){
        money = 1000 - money;
    }
	printf("%d",money);  
  	return 0;
}

Measured memory_bytes: 1704
n = gets.to_i
array = gets.split().map(&:to_i)
start = 1
flag = 1
count = 0
while flag == 1
  flag = 0
  (start..n-1).reverse_each do |i|
    if array[i] < array[i-1]
      count += 1
      array[i], array[i-1] = array[i-1], array[i]
      flag = 1
    end
  end
  start += 1
end

puts array.join(" ")
puts count


Measured memory_bytes: 6912
#n,k=gets.split(' ').map(&:to_i)
#h=gets.split(' ').map(&:to_i)
#tajigen = Array.new(4) { Array.new(2,0) }
#BC = gets.chomp.to_i.times.map { gets.split.map(&:to_i) }
#bc=q.times.map{gets.split.map(&:to_i)}
s=gets.chomp
t=gets.chomp
count=0
for i in 0..s.length
  if s[i]!=t[i]
    count+=1
  end
end
#puts s.length
puts count


Measured memory_bytes: 15068
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef map<int, int> mii;
typedef map<int, string> mis;
typedef map<string, int> msi;
typedef set<int> si;
typedef set<ll> sl;
typedef map<ll, ll> mll;
typedef queue<int> qi;
typedef queue<ii> qii;
typedef vector<string> vs;
typedef pair<ll, ll> iil;
typedef vector<iil> viil;
typedef vector<vi> vvi;
typedef long double ld;
typedef vector<pair<pair<int,int>,int>> viii;
typedef vector<pair<pair<ll,ll>,ll>> viiil;

#define pb push_back
#define mp make_pair
#define rep(i, n) for (int i = 0 ; i < n ; i++)
#define INF 1000000000
#define MOD 1000000007;

void solve() {
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    ll ans = 1000;
    for (int i = 1 ; i < n ; i++) {
        if (a[i] > a[i - 1]) {
            ll ft = ans / a[i - 1];
            ans -= (ans / a[i - 1]) * a[i - 1];
            ans += ft * a[i];
        }
    }
    
    cout << ans << '\n';
    
}

void querySolve() {
    int n;
    cin >> n;
    while (n--) {
        solve();
    }
}

int main() {
    //querySolve();
    solve();

}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n,k;cin>>n>>k;
  vector<int>a(n);
  rep(i, n)cin>>a[i];
  ll sum = 0;
  rep(i, n)sum += a[i];
  set<ll> candidates;
  for(int i=1; i*i<=sum; i++){
    if(sum%i)continue;
    candidates.insert(i);
    candidates.insert(sum/i);
  }

  ll ans = 1;
  for(ll x:candidates){
    ll need=INF;

    vector<ll> r(n);
    rep(i, n)r[i]=a[i]%x;
    sort(r.begin(), r.end());
    ll B = 0;
    rep(i, n)B += x-r[i];
    ll A = 0;
    rep(i, n){
      A += r[i];
      B -= x-r[i];
      need = min(need, max(A, B));
    }

    if(need <= k)ans = max(ans, x);

  }

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>

int main () {
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	int max = (a > b) ? a : b;
	max = (max > c) ? max : c;
	
	int res = a + b + c - max;
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

struct UnionFind {
  vector<int> data;
  void init(int n) { data.assign(n, -1); }
  int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
  bool same(int x, int y) { return root(x) == root(y); }
  bool unite(int x, int y) {
    x = root(x), y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
  int size(int x) { return -data[root(x)]; }
};

int main() {
  int v, e;
  cin >> v >> e;
  vector<pair<int, pair<int, int> > > p(e);
  for (int i = 0; i < e; ++i) {
    int s, t, w;
    cin >> s >> t >> w;
    p[i].first = w;
    p[i].second.first = s;
    p[i].second.second = t;
  }
  sort(p.begin(), p.end());
  int ans = 0;
  UnionFind uf;
  uf.init(v);
  for (int i = 0; i < e; ++i) {
    if (!uf.same(p[i].second.first, p[i].second.second)) {
      ans += p[i].first;
      uf.unite(p[i].second.first, p[i].second.second);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4020
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <map>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)(n);i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
typedef long long ll;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int inf=2020000000;

int n;
int R[200010];

int main() {
	
	cin>>n;
	Rep(i,n) cin>>R[i];
	int ans = -inf;
	int max = 0;
	int min = inf;
	int kouho;
	Rep(i,n){
		if(R[i]<min){
			if(ans<R[i]-min) ans = R[i] - min;
			min = R[i];
			max = 0;
		}
		else if(R[i]>max){
			max = R[i];
		
		
		if(ans<max-min){
			ans = max-min;
		}
    }
		
		
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3868
#include<stdio.h>
int main(void) {
	int N;
	int a, b, c, i;
	scanf("%d", &N);
	a = N / 100;
	N = N % 100;
	b = N / 10;
	N = N % 10;
	c = N;
	if (a == 7)
		printf("Yes");
	else if (b==7)
		printf("Yes");
	else if (c==7)
		printf("Yes");
	else
		printf("No");
	return 0;
}

Measured memory_bytes: 1688
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(long long int i=a; i<n; i++)
#define rloop(i,a,n) for(long long int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcount(a)
#define mod 1000000007
#define ll long long int
#define ull unsigned long long int 
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define stkll stack<ll>
#define qll queue<ll>
#define pqll priority_queue<ll>
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power)
{
    ll ans=1;
    while(power>0)
    {
        if(power%2==1)
        {
            ans=(ans*B)%mod;
        }
        B=(B*B)%mod;
        power/=2;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1)
    { 
        return false; 
    }
    if(n<=3)
    { 
        return true;
    } 
    if(n%2==0 || n%3==0) 
    {
        return false; 
    }
    for(ll i=5; i*i<=n; i+=6) 
    {
        if(n%i==0 || n%(i+2)==0) 
        {
            return false; 
        }
    }
    return true; 
}
using namespace std;
int main() 
{
    FAST
    FO
    FI
    int a,b;
    IN a>>b;
    if(a>9 || b>9)
    {
        OUT "-1";
    }
    else
    {
        OUT a*b;
    }
    return 0;
}

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

using namespace std;

int main(void) {
  int K, N, fst; cin >> K >> N >> fst;
  int len = 0, now;

  now = fst;
  for (int i = 1; i < N; i++) {
    int next; cin >> next;
    len = max(len, next - now);

    now = next;
  }

  len = max(len, K-now + fst);

  cout << K - len << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

public class Main {

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();
        int ans = 0;
        if (A + B <= 2 * C) {
            ans = A * X + B * Y;
        } else {
            int c = 0;
            if (X > Y) {
                ans = 2 * Y * C;
                ans += (X - Y) * A;
                ans = Math.min(ans, 2 * X * C);
            } else {
                ans = 2 * X * C;
                ans += (Y - X) * B;
                ans = Math.min(ans, 2 * Y * C);
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
n,c = list(map(int,input().split()))
xv = [list(map(int,input().split())) for i in range(n)]

frontGet = [0]*n
frontRuiseki = [0]*(n+1)
backGet = [0]*n
backRuiseki = [0]*(n+1)

for i in range(n):
    frontRuiseki[i+1] = frontRuiseki[i]+xv[i][1] 
    frontGet[i] = frontRuiseki[i+1] - xv[i][0]
    idx = -1 - i
    backRuiseki[idx-1] = backRuiseki[idx]+xv[idx][1] 
    backGet[idx] = backRuiseki[idx-1] + xv[idx][0] - c

backGet.reverse()
frontGet = [0] + frontGet
backGet = [0] + backGet
xv = [[0,0]] + xv
frontMax = [0]*(n+1)
backMax = [0]*(n+1)

for i in range(n):
    frontMax[i+1] = max(frontMax[i],frontGet[i+1])
    backMax[i+1] = max(backGet[i+1],backMax[i])

ans = max(frontMax[-1],backMax[-1],0)
for i in range(n+1):
    front = frontGet[i] - xv[i][0]
    front += backMax[n - i]
    back = backGet[i] + xv[-i][0] - c
    back += frontMax[n - i]
    ans = max(ans,front,back)
print(ans)

Measured memory_bytes: 97072
from collections import *
N = int(input())
V = list(map(int,input().split()))
E = Counter(V[0::2]).most_common()+[(0,0)]
O = Counter(V[1::2]).most_common()+[(0,0)]

if E[0][0]!=O[0][0]:
  print(N-E[0][1]-O[0][1])
else:
  print(N-max(E[0][1]+O[1][1],E[1][1]+O[0][1]))

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

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

  int a[100][100] = {};
  for(int i=0;i<n;i++)
    for(int j=0;j<m;j++) cin>>a[i][j];

  int b[100][100] = {};
  for(int i=0;i<m;i++)
    for(int j=0;j<l;j++) cin>>b[i][j];

  long long c[100][100] = {};
  for(int i=0;i<n;i++)
    for(int j=0;j<l;j++)
      for(int k=0;k<m;k++)
        c[i][j] += a[i][k] * b[k][j];

  for(int i=0;i<n;i++){
    for(int j=0;j<l;j++){
      if(j) cout<<" ";
      cout<<c[i][j];
    }
    cout<<endl;
  }
   
  return 0;
}


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

int main(){
	double t,mx,mn;
	cin >> t;
	mx = mn = t;
	while(cin >> t){
		mx = max(mx,t);
		mn = min(mn,t);
	}
	cout << mx - mn << endl;
	return 0;
}



Measured memory_bytes: 3192
#include <iostream>

using namespace std;

int f(int);

int main() {
	int d, i, s;

	while(cin >> d) {
		s=0;
		for(i=1; (i*d)!=600; i++) {
			s+=f(i*d)*d;
		}
		cout << s << endl;
	}


}

int f(int x) {
	return x*x;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


enum ORDER{
	PLUS,
	HALF,
};

int x[200000],y[200000],z[200000];

int main(){

	int N;
	scanf("%d",&N);

	int a,d;
	scanf("%d %d",&a,&d);

	int M;
	scanf("%d",&M);

	for(int i = 0; i < M; i++){
		scanf("%d %d %d",&x[i],&y[i],&z[i]);
		y[i]--;
		z[i]--;
	}

	int loc;
	scanf("%d",&loc);
	loc--;

	stack<ORDER> S;

	for(int i = M-1; i >= 0; i--){

		switch(x[i]){
		case 0:
			if(loc >= y[i] && loc <= z[i]){
				loc = z[i]-(loc-y[i]);
			}
			break;
		case 1:
			if(loc >= y[i] && loc <= z[i]){
				S.push(PLUS);
			}
			break;
		case 2:
			if(loc >= y[i] && loc <= z[i]){
				S.push(HALF);
			}
			break;
		}
	}

	int ans = a+loc*d;

	while(!S.empty()){

		if(S.top() == PLUS){
			ans++;
		}else{
			ans /= 2;
		}

		S.pop();
	}

	printf("%d\n",ans);

	return 0;
}



Measured memory_bytes: 5520
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
    int A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;

    if (W >= V) {
        cout << "NO" << endl;
        return 0;
    }

    int diff = abs(A - B);
    int vdiff = V - W;

    if (diff <= vdiff * T) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 3620
s = gets.chomp
q = gets.chomp.to_i

q.times do
  op, a, b, p = gets.split
  a = a.to_i
  b = b.to_i

  if op == 'print'
    puts s[a..b]
  elsif op == 'reverse'
    s[a..b] = s[a..b].reverse
  else
    s[a..b] = p
  end
end



Measured memory_bytes: 6916
fun main(args: Array<String>) {
    val sumOfMoney = readLine()!!.toInt()
    val count500yen = sumOfMoney / 500
    val restMoney = sumOfMoney % 500
    val count5yen = restMoney / 5
    val joyPoint = 1000 * count500yen + 5 * count5yen
    println(joyPoint)
}


Measured memory_bytes: 33744
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

int cntS[26],cntT[26];
int main(){
  string S,T;
  cin>>S>>T;
  repeat(i,S.length()){
    cntS[S[i]-'a']++;
    cntT[T[i]-'a']++;
  }
  sort(cntS,cntS+26);
  sort(cntT,cntT+26);
  bool isok=true;
  repeat(i,26){
    isok &= cntS[i]==cntT[i];
  }
  cout<<(isok? "Yes":"No")<<endl;
  return 0;
}


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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    vector<ll> a(3);
    rep(i, 3) cin >> a[i];
    sort(ALL(a), greater<ll>());
    cout << 10*a[0]+a[1]+a[2] << endl;

    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


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

int main(){
    int N;
    cin >> N;
    vector<string> S(N);
    map<char, long long> name;
    string str = "MARCH";
    for(int i = 0; i < str.length(); i++)name[str[i]] = 0;
    for(int i = 0; i < N; i++){
        cin >> S[i];
        for(int j = 0; j < str.length(); j++){
            if(S[i][0] == str[j]){
                name[str[j]]++;
                break;
            }
        }
    }
            
    long long ans = 0;
    for(int i = 0; i < str.length() - 2; i++){
        for(int j = i + 1; j < str.length() - 1; j++){
            for(int k = j + 1; k < str.length(); k++){
                ans += name[str[i]] * name[str[j]] * name[str[k]];
            }
        }
    }
    
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 6144
#include <stdio.h>

#define MAXSTRSIZE 200000

int main()
{
	int c=0, i, j, z_count=0;
	char s[MAXSTRSIZE]={};
	
	scanf("%s",s);
	j=sizeof(s);
	while(s[i]!='A') i++;
	c++;
	while(j>=0)
	{
		if(s[j]=='Z'&&j>i)	z_count++;
		j--;
	}
	while(1)
	{
		if(s[i]=='Z')
		{
			z_count--;
			if(z_count==0)	break;
		}
		c++;
		i++;
	}
	printf("%d",c);
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
void spin1(int a[]);
void spin2(int a[]);
void spin3(int a[]);
int judge(int a[],int b[]);
  
int main(void){
  int d[100][6],n,f=0,i,j,k,l,m;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<6;j++)
      scanf("%d",&d[i][j]);
  }
  for(l=0;l<n;l++){
    for(m=0;m<n;m++){
      for(i=0;i<10;i++){
    spin1(d[l]);
    for(j=0;j<10;j++){
      spin2(d[l]);
      for(k=0;k<4;k++){
        spin3(d[l]);
        if(l!=m&&judge(d[l],d[m])){
          f=1;
          break;
        }
      }
      if(f)
        break;
    }
    if(f)
      break;
      }
      if(f)
    break;
    }
    if(f)
      break;
  }
  if(f)
    printf("No\n");
  else
    printf("Yes\n");
  return 0;
}
  
void spin1(int a[]){
    int t=a[0];
    a[0]=a[4];
    a[4]=a[5];
    a[5]=a[1];
    a[1]=t;
}
void spin2(int a[]){
    int t=a[1];
    a[1]=a[2];
    a[2]=a[4];
    a[4]=a[3];
    a[3]=t;
}
void spin3(int a[]){
    int t=a[0];
    a[0]=a[2];
    a[2]=a[5];
    a[5]=a[3];
    a[3]=t;
}
int judge(int a[],int b[]){
  int i;
  for(i=0;i<6;i++){
    if(a[i]!=b[i])
      return 0;
  }
  return 1;
}

Measured memory_bytes: 584
import java.util.Arrays;
import java.util.Scanner;

/**
 * Knapsack 1
 */
public class Main {

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

            int[] w = new int[N + 1];
            int[] v = new int[N + 1];
            for (int i = 1; i <= N; i++) {
                w[i] = sc.nextInt();
                v[i] = sc.nextInt();
            }

            int V = Arrays.stream(v).sum();

            long[][] dp = new long[N + 1][V + 1];

            for (int i = 0; i <= N; i++) {
                for (int j = 1; j <= V; j++) {
                    dp[i][j] = Long.MAX_VALUE / 2;
                }
            }

            for (int i = 1; i <= N; i++) {
                for (int j = 1; j <= V; j++) {
                    if (j < v[i]) {
                        dp[i][j] = dp[i - 1][j];
                    } else {
                        dp[i][j] = Math.min(dp[i - 1][j], dp[i - 1][j - v[i]] + w[i]);
                    }
                }
            }

            long max = 0;
            for (int j = V; j >= 0; j--) {
                if (dp[N][j] <= W) {
                    max = j;
                    break;
                }
            }

            System.out.println(max);
        }
    }

}


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

int z[100005];

int main()
{
	int a,b,c,d,e,f;
	string wa="WA",ac="AC",now;
	memset(z,0,sizeof(z));
	scanf("%d%d",&a,&b);
	c=0;d=0;
	while(b--)
	{
		scanf("%d",&e);
		cin>>now;
		if(z[e]==-1)continue;//AC-1
		if(now==wa)z[e]++;
		else if(now==ac)
		{
			d+=z[e];
			c++;
			z[e]=-1;
		}
	}
	printf("%d %d",c,d);
}

Measured memory_bytes: 640
s = gets.chomp
if s[0] == "R" && s[1] == "R" && s[2] == "R"
  puts 3
elsif (s[0] == "S" && s[1] == "R" && s[2] == "R") || (s[0] == "R" && s[1] == "R" && s[2] == "S")
  puts 2
elsif (s[0] == "S" && s[1] == "S" && s[2] == "R") || (s[0] == "S" && s[1] == "R" && s[2] == "S") || (s[0] == "R" && s[1] == "S" && s[2] == "S") ||  (s[0] == "R" && s[1] == "S" && s[2] == "R")
  puts 1
else
  puts 0
end


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef pair<ll, ll> pll;
const ll INF = 0x3f3f3f3f;
const ll LINF = 1ll << 55;
const ll MOD = 1e9 + 7;
const ll MAXN = 400 + 5;
const ll MAXK = 1e5 + 10;

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

template<typename T>
ostream& operator<< (ostream& out, vector<T>& vec) {
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        out << *it << " ";
    }
    return out;
}

template<typename T>
istream& operator>> (istream& in, vector<T>& vec) {
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        in >> *it;
    }
    return in;
}

int main() {
    ll Q;
    cin >> Q;
    while (Q --) {
        ll A, B;
        cin >> A >> B;
        if (A == B) {
            cout << 2 * A - 2 << endl;
        } else {
            if (A > B) {
                swap(A, B);
            }
            if (A + 1 == B) {
                cout << 2 * A - 2 << endl;
            } else {
                ll C = sqrt(A * B);
                if (C * C >= A * B) --C;
                if (C * (C + 1) >= A * B) {
                    cout << 2 * C - 2 << endl;
                } else {
                    cout << 2 * C - 1 << endl;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int x, a,b; cin>>x; bool found=false;
    for(long long i=-200; i<=200; i++){
        for(long long j=-200; j<=200; j++){
            if(((i*i*i*i*i)-(j*j*j*j*j))==x){
                cout<<i<<" "<<j;
                found=true;
                break;
            }
            if(found) break;
        }
    }
    return 0;
}


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


#define mod                1000000000000000007
#define pi                 3.1415926535897932384626433832795
#define ll                 long long
#define pb                 push_back
#define pii                pair < int , int >
#define vecsort(v)         sort(v.begin(),v.end())
#define lcm(x,y)           (x/__gcd(x,y))*y
#define forn(i,n)          for(i = 0 ; i < n ; i++)
#define deb(x)             cout << #x << " " << x << endl;
#define vecsum(v)          accumulate(v.begin(), v.end(), 0)
#define T(t)               cout << "Case " << t <<": ";
#define fast_cin           ios_base::sync_with_stdio(false);cin.tie(NULL)


char a[10][10];
char b[10][10];
int n , m , k;


void copy_matrix(){

    for( int i = 0 ; i < n ; i++  ){
        for( int j = 0 ; j < m ; j++ ){
            b[i][j] = a[i][j];
        }
    }
}

void color( int i , int j){

      for( int x = 0 ; x< n ; x++ ){

          if( i & ( 1 <<  x) ){
              for( int y = 0 ; y < m ; y++ ){
                  b[x][y] = '$';
              }
          }
      }


    for( int x = 0 ; x< m ; x++ ){

        if( j & ( 1 <<  x) ){
            for( int y = 0 ; y < n ; y++ ){
                b[y][x] = '$';
            }
        }
    }
      return;

}

bool check(){

    int cnt = 0 ;
    for (int i = 0; i < n; i++){
        for( int j = 0 ; j < m ; j++ ){
            if( b[i][j] == '#'){
                cnt++;
            }
        }
    }

    if( cnt == k ){
        return true;
    }
    else{
        return false;
    }
}

void solve( ){

    int ans = 0 ;
    cin >> n >> m >> k;

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

   for( int i = 0 ; i < (1<<n) ; i++ ){
       for( int j = 0 ; j < (1<<m) ; j++){
           copy_matrix();
           color(i,j);
           if(check()==true){
               ans++;
           }
       }
   }

   cout << ans << endl;

}
int main() {


    solve();



    return 0;
}

Measured memory_bytes: 3640
import numpy as np
a,b,c,x,y = map(int,input().split())
ans = min(a+b,c*2)*min(x,y)
if x > y:
    ans += min(a,c*2) * (x-y)
elif x < y:
    ans += min(b,c*2) * (y-x)
print(ans)

Measured memory_bytes: 12496
#include <iostream>
#include <cstring>

using namespace std;

#define MAX 15

int H,W;
char field[MAX][MAX];
string ans;
const int dx[] = {0,1,0,-1};
const int dy[] = {-1,0,1,0};
const char mark[] = {'U','R','D','L'};

bool inField(int y,int x){
  return 0 <= y && y < H && 0 <= x && x < W;
}

int getDir(char ch){
  if(ch == 'U') return 0;
  if(ch == 'R') return 1;
  if(ch == 'D') return 2;
  if(ch == 'L') return 3;
  return -1;
}

void solve(int y,int x,int dir,int cnt,string s){
  if(cnt == 0){
    ans = s;
    return;
  }

  for(int i = 0 ; i < 4 ; i++){
    int nx = x, ny = y;
    if(dir == 0 && i == 2) continue;
    if(dir == 1 && i == 3) continue;
    if(dir == 2 && i == 0) continue;
    if(dir == 3 && i == 1) continue;

    while(inField(ny,nx)){
      nx += dx[i];
      ny += dy[i];
      if(field[ny][nx] == 'o'){
        field[ny][nx] = '.';
        solve(ny,nx,i,cnt-1,s+mark[i]);
        field[ny][nx] = 'o';
        break;
      }
    }
  }
}

int main(){
  int x,y,dir,cnt = 0;
  cin >> H >> W;
  for(int i = 0 ; i < H ; i++){
    for(int j = 0 ; j < W ; j++){
      cin >> field[i][j];
      int num = getDir(field[i][j]);
      if(num != -1){
        x = j, y = i; dir = num;
      }else if(field[i][j] == 'o'){
        cnt++;
      }
    }
  }
  field[y][x] = '.';
  solve(y,x,dir,cnt,"");
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

static const ll MAX = 100001;
ll a[MAX] = {};
ll sum[MAX] = {};
int main() {
    
    ll n,m;
    cin >> n >> m;

    for (ll i=1;i<=n;i++){
        cin >> a[i];
    }
    ll now = 0;
    unordered_map <ll, ll> memo;
    for (ll i=1;i<=n;i++){
        now += a[i];
        sum[i] = now;
        sum[i] %= m;
        memo[sum[i]]++;
    }
    ll ans = 0;
//    for (auto itr = memo.begin();itr != memo.end();itr++){
//        cout << itr -> first << " " << itr ->second << endl;
//    }
    for (auto itr = memo.begin();itr != memo.end();itr++){
        ll p = itr -> second;
        ans += p*(p-1)/2;
    }
    ans += memo[0];
    cout << ans << endl;
}




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

int main(){
    
    long long A,B,C;
    
    cin >> A >> B >> C;
    
    if(B < C)swap(B,C);
    if(A < B)swap(A,B);
    if(B < C)swap(B,C);
    
    cout << (A*B*C - (B*C)*(A/2)) - (B*C)*(A/2)<<endl;
    
}
    
    



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

int main(){
    string s;
    cin >> s;
    int res=0;
    for(int i = 0; i < s.length(); ++i){
        if(s[i] == '1'){
            res ++;
        }
    }
    cout << res << endl;
}

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

#define io ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ll long long
#define ull unsigned long long
#define pii pair<ll, ll>
#define piii pair<ll, pair<ll, ll>>
#define debug(x) cout<<#x<<" = "<<x<<endl

using namespace std;
const int N = 200005;
ll t, n, m, k, q, a, b, x, y, ans, arr[N];
ll mod = 998244353;
string s;
bool vis[N];
ll edges[N], higher[N];

int main() {
    io;
    t = 1;
//    cin >> t;
    while (t--) {
        cin >> n >> m;
        for (int i = 1; i <= n; ++i) {
            cin >> arr[i];
        }
        for (int i = 0; i < m; ++i) {
            cin >> a >> b;
            ++edges[a], ++edges[b];
            if (arr[a] > arr[b])
                ++higher[a];
            if (arr[b] > arr[a])
                ++higher[b];
        }
        for (int i = 1; i <= n; ++i) {
            ans += (higher[i] == edges[i]);
//            cout << higher[i] << " " << edges[i] << endl;
        }
        cout << ans << endl;
    }
    return 0;
}
//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);


Measured memory_bytes: 5992
n = int(input())
h = [int(i) for i in input().split()] 

c = h[0]
cnt = 0
ans = 0
for i in h[1:]:
  if c >= i:
    cnt += 1
    c = i
    if cnt >= ans:
      ans = cnt
  else:
    cnt = 0
    c = i

print(ans)

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

using namespace std;

using int64 = long long;

template<typename T>
vector<vector<T>> Make2DVector(int d1, int d2, T default_value) {
  return vector<vector<T>>(d1, vector<T>(d2, default_value));
}

struct PairHash {
    template <class T1, class T2>
    std::size_t operator () (const std::pair<T1,T2> &p) const {
        auto h1 = std::hash<T1>{}(p.first);
        auto h2 = std::hash<T2>{}(p.second);

        // Mainly for demonstration purposes, i.e. works but is overly simple
        // In the real world, use sth. like boost.hash_combine
        return h1 ^ h2;  
    }
};

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

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

  int n;
  cin >> n;
  vector<int64> xs(n);
  for (int i = 0; i < n; i++) cin >> xs[i];

  // auto hash_fn = [](pair<int64, int64> p) {
  //   return hash<int64>()(p.first) * 1000000007 + hash<int64>()(p.second);
  // };
  auto dp = Make2DVector( n, n, vector<pair<int64, int64>>());
  function<void(int, int)> solve = [&](int l, int r) {
    // cout << "l: " << l << " r: " << r << endl;
    if (!dp[l][r].empty()) return;
    if (r - l == 1) {
      dp[l][r].push_back(make_pair(0, 0));
      return;
    }

    for (int m = l + 1; m <= r - 1; m++) {
      solve(l, m);
      solve(m, r);
      for (const auto& pair1 : dp[l][m]) {
        for (const auto& pair2 : dp[m][r]) {
          int64 next_l = pair1.first + xs[m] + pair1.second + pair2.first;
          int64 next_r = xs[m] + pair1.second + pair2.first + pair2.second;
          dp[l][r].push_back(make_pair(next_l, next_r));
        }
      }
      vector<pair<int64, int64>>& v = dp[l][r];
      sort(v.begin(), v.end());
      vector<pair<int64, int64>> new_v;
      int64 min_second = INT64_MAX;
      for (const auto& p : v) {
        if (UpdateMin(min_second, p.second)) {
          new_v.push_back(p);
        }
      }
      dp[l][r] = new_v;
    }
  };
  solve(0, n - 1);
  int64 ans = INT64_MAX;
  for (const auto& pair : dp[0][n - 1]) {
    // cout << pair.first << " " << pair.second << endl;
    UpdateMin(ans, xs[0] + pair.first + xs[n - 1] + pair.second);
  }
  // cout << "size: " << dp[0][n - 1].size() << endl;
  cout << ans << endl;
}


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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)

li a, b;
string s;

inline bool ok() {
    rep(i, s.size()) {
        if (i == a) {
            if (s[i] != '-') {
                return false;
            }
        } else {
            if (s[i] < '0' || s[i] > '9') {
                return false;
            }
        }
    }
    return true;
}

int main(void) {
    cin >> a >> b;
    cin >> s;
    cout << (ok() ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n):
        self.v = [-1 for _ in range(n)]
        # 負:=連結頂点数, 自身が根
        # 正:=親index, 0-indexed

    def is_root(self, x):
        return self.v[x] < 0

    def find(self, x):
        if self.v[x] < 0:
            return x
        else:
            self.v[x] = self.find(self.v[x])
            return self.v[x]

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def merge(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return

        if -self.v[x] < -self.v[y]:
            x, y = y, x
        # x を連結頂点数最大にする

        self.v[x] += self.v[y]
        self.v[y] = x

    def get_size(self, x):
        x = self.find(x)
        return -self.v[x]


n, m = map(int, input().split())
e = []

uf = UnionFind(n + m)
for i in range(n):
    k, *l = map(int, input().split())
    l = tuple(map(lambda x: x - 1, l))
    e.append(l)

for i, lang_lst in enumerate(e):
    for lg in lang_lst:
        uf.merge(i, n + lg)

root = uf.find(0)
print('YES' if all(uf.find(i) == root for i in range(1, n)) else 'NO')


Measured memory_bytes: 14180
import java.util.*;
import java.io.*;

public class Main {
	
	public static boolean[] sieve (int n) {
		
		boolean[] isPrime = new boolean[n];
		Arrays.fill(isPrime, true);
		
		int lim = (int)Math.sqrt(n);
		
		for (int i = 4; i < isPrime.length; i += 2)
			isPrime[i] = false;
		for (int i = 3; i <= lim; i += 2) {
			for (int j = 3; i * j < isPrime.length; j += 2)
				isPrime[i * j] = false;
		}
		
		return isPrime;
		
	}
	
	public static int solve (int n) {
		
		int sum = 0;
		boolean[] prime = sieve(1000000);
		
		for (int i = 2, cnt = 0; cnt < n; i++) {
			
			if (prime[i]) {
				sum += i;
				cnt++;
			}
			
		}
		
		return sum;
		
	}
	
	public static void main (String[] args) throws IOException {

		BufferedReader br =
			new BufferedReader(new InputStreamReader(System.in));
		
		while (true) {
			
			int num = Integer.parseInt(br.readLine());
			
			if (num == 0) break;
			
			System.out.println(solve(num));
			
		}
		
	}
}

Measured memory_bytes: 13000
#include<bits/stdc++.h>
using namespace std;
#define ll "%I64d"
const int max1=100010;
//long long a[max1],b[max1];
int main()
{
    long long n,a=0,b;
    cin>>n;
    if(n==1)
    {
        cout<<0<<"\n";
    }
    else
    {
        vector<long long int>s1;
        long long t1;
        t1=((n-1)*n)/2;
        /*for(long long i=1; i<n; i++)
        {
            a+=i;
            s1.push_back(a);
        }
        int h=s1.size()-1;
*/
        cout<<t1<<"\n";
    }

}



Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
 #define mod 1000000007
 const int N=200005;
 const int inf=1e18;
 const double eps=1e-9;
int pow(int a,int b){
    int res=1;
    while(b>0){
        if(b&1){
        	res=res*a;
		}
        a=a*a;
        b>>=1;
    }
    return res;
}
vector<int>adj[N];
bool vis[N]={0};
int ans[N]={0};
void dfs(int x,int v){
    vis[x]=1;
    ans[x]=v;
    for(int i=0;i<adj[x].size();i++){
        if(!vis[adj[x][i]]){
            dfs(adj[x][i],v+ans[adj[x][i]]);
        }
    }
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n,q;
    cin>>n>>q;

    for(int x=0;x<n-1;x++){
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    while(q--){
        int p,x;
        cin>>p>>x;
        ans[p]+=x;
    }
    dfs(1,ans[1]);
for(int x=1;x<=n;x++){
    cout<<ans[x]<<" ";
}







	
return 0;
}


Measured memory_bytes: 24448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10;
int n, m;
ll k;
int p[maxn];
ll x[maxn], d[maxn];
bool vis[maxn];
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) scanf("%lld", &x[i]);
	for(int i = 1; i < n; ++i) d[i] = x[i + 1] - x[i];
	scanf("%d%lld", &m, &k);
	for(int i = 1; i < n; ++i) p[i] = i;
	for(int i = 1; i <= m; ++i)
	{
		int pos;
		scanf("%d", &pos);
		swap(p[pos], p[pos - 1]);
	}
	vector<int> cycle;
	for(int i = 1; i < n; ++i)
		if(!vis[i])
		{
			cycle.clear();
			int cur = i;
			while(!vis[cur])
			{
				vis[cur] = 1;
				cycle.push_back(cur);
				cur = p[cur];
			}
			int pos = k % cycle.size();
			for(int i = 0; i < cycle.size(); ++i)
				p[cycle[i]] = cycle[(i + pos) % cycle.size()];
		}
	/*
	for(int i = 1; i < n; ++i) printf("%d ", p[i]);
	puts("");
	*/
	printf("%lld\n", x[1]);
	ll cur = x[1];
	for(int i = 1; i < n; ++i)
	{
		cur += d[p[i]];
		printf("%lld\n", cur);
	}
	return 0;
}
/*
5
0 1 3 6 10
3 99999999999999
2 3 4
*/
		 
			
			

Measured memory_bytes: 5880
N = gets.to_i
S = gets.chomp

W = [0]
E = [0]

S.each_char.with_index(1) do |d, i|
  if d == 'W'
    W[i] = W[i - 1] + 1
    E[i] = E[i - 1]
  else
    W[i] = W[i - 1]
    E[i] = E[i - 1] + 1
  end
end

ans = Float::INFINITY

S.each_char.with_index(1) do |d, i|
  v = W[i - 1] + (E[N] - E[i])

  ans = v if ans > v
end

puts ans


Measured memory_bytes: 7160
MOD = 10**9+7
N = int(input())
A = list(map(int, input().split()))

ans = 0
for i in range(60):
    x = 0
    for a in A:
        if a >> i & 1:
            x += 1
    ans += x * (N-x) * (2**i)
    ans %= MOD

print(ans)


Measured memory_bytes: 122936
package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	var ans, plug int
	for i := 0; i <= 100; i++ {
		plug = 1 + (a-1)*i
		if b <= plug {
			ans = i
			break
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	int t = 0;

	int x = 0, y = 0;

	for (int i = 0; i < n; i++) {
		int time, nx, ny; cin >> time >> nx >> ny;
		
		int dt = time - t;
		int dx = abs(nx - x);
		int dy = abs(ny - y);

		int d = dx + dy;

		if (d > dt) {
			cout << "No" << endl;
			return 0;
		}
		else if((d-dt)%2!=0){
			cout << "No" << endl;
			return 0;
		}
		
		t = time;
		x = nx;
		y = ny;

	}

	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin >> n;
	vector<int> p(n);
	for(int i = 0; i < n; i++) cin >> p[i];
	int ans = 0;
	for(int i = 1; i < n - 1; i++){
		int cu = (p[i - 1] < p[i]) + (p[i + 1] < p[i]);
		int cd = (p[i - 1] > p[i]) + (p[i + 1] > p[i]);
		if(cu == 1 && cd == 1) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const ll LL_INF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int prex = 0, prey = 0, pret = 0;
  REP(i,N){
    int t,x,y;
    cin>>t>>x>>y;
    if((abs(x-prex) + abs(y-prey)) <= t - pret
       && ((t-pret) - (abs(x-prex) + abs(y-prey))) % 2 == 0){
      pret = t;
      prex = x;
      prey = y;
    }else{
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int N;
int A[1000];
int main()
{
	while (true){
		cin >> N;
		if (N == 0)break;
		for (int i = 0; i <= N; i++)cin >> A[i];
		int ans;
		for (int i = 0; i <= N; i++){
			bool F = true;
			int Sa;
			if (i == 0)Sa = A[2] - A[1];
			else if (i == 1)Sa = A[2] - A[0];
			else Sa = A[1] - A[0];
			int Former;
			if (i == 0){
				for (int j = 2; j <= N; j++){
					if (Sa != A[j] - A[j - 1])F = false;
				}
			}
			else{
				Former = A[0];
				for (int j = 1; j <= N; j++){
					if (i == j)continue;
					if (Sa != A[j] - Former)F = false;
					Former = A[j];
				}
			}
			if (F){
				ans = A[i];
				break;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>

int main(void){
  int five, one, page, total;

  scanf("%d%d", &page, &total);
  total /= 1000;

  for(five = 0; five <= page; five++){
    for(one = 0; one <= page- five; one++){
      if(5 * five + 9 * one == 10 * page - total){
        printf("%d %d %d\n", page - five - one, five, one);
        return 0;
      }
    }
  }

  puts("-1 -1 -1");

  return 0;
}

Measured memory_bytes: 128