akhauriyash/Code-Regression huggingface dataset:
# include <bits/stdc++.h>
using namespace std;
namespace Base{
	# define mr make_pair
	typedef long long ll;
	typedef double db;
	const int inf = 0x3f3f3f3f, INF = 0x7fffffff;
	const ll  infll = 0x3f3f3f3f3f3f3f3fll, INFll = 0x7fffffffffffffffll;
	template<typename T> void read(T &x){
    	x = 0; int fh = 1; double num = 1.0; char ch = getchar();
		while (!isdigit(ch)){ if (ch == '-') fh = -1; ch = getchar(); }
		while (isdigit(ch)){ x = x * 10 + ch - '0'; ch = getchar(); }
	    if (ch == '.'){
	    	ch = getchar();
	    	while (isdigit(ch)){num /= 10; x = x + num * (ch - '0'); ch = getchar();}
		}
		x = x * fh;
	}
	template<typename T> void chmax(T &x, T y){x = x < y ? y : x;}
	template<typename T> void chmin(T &x, T y){x = x > y ? y : x;}
}
using namespace Base;

const int N = 51, K = 18;
ll c[N][N], sum[N], ans;
int a[N], b[N], n, k, S, T, bi2[(1 << K) + 10], fh[(1 << K) + 10];
int main(){
	read(n); read(k);
	read(S); read(T);
	for (int i = 1; i <= n; i++) read(a[i]);
	if ((S | T) != T){
		puts("0");
		return 0;
	}
	int cnt = 0;
	for (int i = 1; i <= n; i++)
		if (((a[i] & S) == S && (a[i] & T) == a[i]))
			a[++cnt] = a[i];
	
	n = cnt;
	for (int i = 0; i < (1 << K); i++){
		bi2[i] = bi2[i / 2] + i & 1;
		if (bi2[i] % 2 == 1) fh[i] = -1;
			else fh[i] = 1;
	}
	k--;
	for (int i = 0; i <= n; i++){
		c[i][0] = 1;
		for (int j = 1; j <= i; j++)
			c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]);
	}
	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= min(i, k); j++)
			sum[i] += c[i][j];
	for (int i = 1; i <= n; i++){
		for (int j = i + 1; j <= n; j++)
			b[j] = a[j] ^ a[i];
		for (int k = S ^ T; k >= 0; k = k > 0 ? (k - 1) & (S ^ T) : -1){
			int cnt = 0;
			for (int j = i + 1; j <= n; j++)
				if ((b[j] & k) == 0) cnt++;
			ans = ans + fh[k] * sum[cnt];
		}
	}
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5644
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<cctype>
#include<climits>
#include<bitset>
#include<stack>

using namespace std;

typedef long long ll;

const int dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
const int MAX = 17;
int W, H, fld[10][10];
int P, sx, sy;
map<pair<pair<int, int>, int>, int> memo;

inline int CountBit(int s)
{
	int res = 0;
	for (int i = 0; i < P; i++) res += (s >> i) & 1;
	return res;
}

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

inline bool CanDown(int x, int y, int s, int noBits)
{
	if (x == sx && y == sy && noBits == P) return true;
	if (fld[y][x] == -1) return false;
	return ((s >> fld[y][x]) & 1) == 0;
}

int DFS(int x, int y, int s)
{
	int cnt = CountBit(s);
	if (x == sx && y == sy && cnt == P) return 1;
	pair<pair<int, int>, int> state = make_pair(make_pair(x, y), s);
	if (cnt < MAX)
	{
		map<pair<pair<int, int>, int>, int>::iterator itr = memo.find(state);
		if (itr != memo.end()) return itr->second;
	}
	int sum = 0;
	for (int i = 0; i < 4; i++)
	{
		int nx = x + dx[i], ny = y + dy[i];
		while (IsInside(nx, ny) && !CanDown(nx, ny, s, cnt))
			nx += dx[i], ny += dy[i];
		if (!IsInside(nx, ny)) continue;
		sum += DFS(nx, ny, s | (1 << fld[ny][nx]));
	}
	if (cnt < MAX) memo[state] = sum;
	return sum;
}

signed main()
{
	while (cin >> W >> H, W || H)
	{
		memo.clear();
		P = 0;
		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				cin >> fld[i][j];
				if (fld[i][j] == 0) fld[i][j] = -1;
				else if (fld[i][j] == 1) fld[i][j] = P++;
				else sx = j, sy = i, fld[i][j] = -1;
			}
		}
		printf("%d\n", DFS(sx, sy, 0));
	}
	return 0;
}

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

using namespace std;

int main() {
    int n = 0;
    bool seventh = false;
    cin >> n;

    int checker = 0;

    for(int i = 0 ; i < 3 ; i++){
        checker = n % 10;
        if(checker == 7){
            seventh = true;
        }
        n /= 10;
    }
    
    if(seventh){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define per(i,a,b) for(int i = (a);i >= (b);i--)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);	
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll qw(ll x,ll y){ll res = 1;while(y){if(y & 1) res *= x;x = x * x;y >>= 1;}return res;}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int n,x,ans;
int a[maxn];
int vis[1000005];
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	rep(i,0,n-1){
		cin >> a[i];
		vis[a[i]]++;	
	}
	rep(i,0,n-1){
		x = a[i];
		bool ok = 1;
		if(vis[x] > 1 || (x != 1 && vis[1])) ok = 0; 
		for(int j = 2;j * j <= x;j++){
			if(x % j == 0){
				if(vis[j] || vis[x/j]){
					ok = 0;
					break;
				}
			}
		}
		if(ok) ans++;
	}		
	cout << ans << endl;
	return 0;
}
//do smt instead of nothing! never give up!


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

int a[3010], b[3010], be[6010];
string dp[3010];
int n;
string s;

int main(){
	cin >> n >> s;
	int cnt1 = 0, cnt2 = 0;
	for (int i = 0; i < s.length(); i++){
		if (s[i] == 'a') a[cnt1++] = i, be[i] = cnt1 - 1;
		else if (s[i] == 'b') b[cnt2++] = i, be[i] = cnt2 - 1;
	}
	for (int i = n - 1; i >= 0; i--){
		if (a[i] < b[i]){
			int maxj = -1;
			for (int j = a[i]; j <= b[i]; j++){
				maxj = max(maxj, be[j] + 1);
			}
			dp[i] = "ab" + dp[maxj];
		} else {
			int now = i;
			while (now < n - 1 && b[now + 1] < a[now]) now++;
			for (int j = 0; j < s.size(); j++){
				if (be[j] >= i && be[j] <= now) dp[i] += s[j];
			}
			dp[i] += dp[now + 1];
		}
		dp[i] = max(dp[i], dp[i + 1]);
	}
	cout << dp[0] << endl;
	return 0;
}


Measured memory_bytes: 14592
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
    int n, x, y, b, p, res;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d %d %d %d", &x, &y, &b, &p);
        res = min(b*x+p*y, (max(5,b)*x+max(2,p)*y)*4/5);
        printf("%d\n", res);
    }
    return 0;
}



Measured memory_bytes: 2736
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define first first
#define second se
using namespace std;
typedef pair<int, int> P;
typedef vector<int> vi;

signed main(){
    string s, t = "CODEFESTIVAL2016";
    cin >> s;
    int ans = 0;
    rep(i, 0, 16){
        if(s[i] != t[i]) ans++;
    }
    o(ans);
}

Measured memory_bytes: 256
nn, kk = list(map(int,input().split()))

sum = 0
for i in range(kk, nn+2):
    min = (0+i-1)*i/2
    max = (nn+nn-i+1)*i/2
    sum += (max-min)+1

sum = sum % (10**9+7)
print(int(sum))

Measured memory_bytes: 72348
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	string ans = "No";
	if (a - b == 0 || b - c == 0 || c - a == 0) {
		if (a != b || b != c || c != a)
			ans = "Yes";
	}


	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque
input = sys.stdin.readline

N = int(input())
x = [0]*N
u = [0]*N
for i in range(N):
    x[i], u[i] = input().split()
    if u[i] == 'JPY':
        x[i] = int(x[i])
    elif u[i] == 'BTC':
        x[i] = float(x[i])*380000
print(sum(x))

Measured memory_bytes: 3316
/*
    Ankit Singhal
 */
#define ll long long int
#include <bits/stdc++.h>
//#include <fstream>
using namespace std;
 
#define         ff               first
#define         ss               second
#define         mp               make_pair
#define         pb               push_back
#define         pf               push_front
#define         vi               vector<ll>
#define         pii              pair<ll,ll>
#define         qi               queue<ll>
#define         mem(a,b)         memset(a,b,sizeof(a))
#define         print(a)         cout<<a<<'\n'
#define         sorted(arr)      sort(arr.begin(),arr.end())
#define         gcd(a,b)         gcd((a),(b))
#define         lcm(a,b)         ((a)*(b))/gcd((a),(b))
#define         all(v)           v.begin(),v.end()
#define         read(a)          scanf("%d", &a)
#define         f(a,n)           for(ll i=a;i<n;i++)
#define         in2(n,m,arr)     for(ll i=0;i<n;i++){for(ll j=0;j<m;j++)cin>>arr[i][j];}
#define         debug(a)         cerr<<a<<" ";
#define         debug1(a)        cerr<<a<<'\n'
 
/*typedef tree<int, null_type, less<int>, rb_tree_tag , tree_order_statistics_node_update> Set;*/


const unsigned ll mod= (ll)1e9 ;
const ll inf = (ll)1e15 + 42;
const ll N = (ll)1e6 + 2;
 
ll power ( ll x , unsigned ll y)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x);
        y = y >> 1;
        x = (x * x);
    }
    return res;
}
 
/*struct node{
    ll x , y , z;
};
vector<set<ll>> tree;
vector<ll> ar , ans;
set<ll> s;
ll get(ll x)
{
    if(x == ar[x])
        return x;
    return ar[x] = get(ar[x]);
}
void merge(ll a ,ll b)
{
    a = get(a);
    b = get(b);
    if(a == b)
        return;
    ar[b] = ar[a];
    //ans[a] += ans[b];
 }

ll sev[1000001];


void seive()
{
    for(ll i = 2 ; i <= 1000000 ; i ++)
    {
        if(!sev[i])
        {
            for(ll j = i ; j <= 1000000 ; j += i)
            {
                if(!sev[j])
                    sev[j] = i;
            }
        }
    }
}
*/

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t ;
    t = 1;
    //cin >> t;
    while(t --)
    {
        ll n , x = -1;
        cin >> n;
        for(ll i = 1 ; i <= n ; i ++)
        {
            ll temp = i * 1.08;
            if(temp == n)
            {
                x = i ;
                break;
            }
        }
        if(x == -1)
            print(":(");
        else
            print(x);
        
    }
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
    
}
 


Measured memory_bytes: 256
//#include <bits/stdc++.h>
//
//#define int int
//using namespace std;
//
//bool Judge(int n) {
//    if (n <= 11)
//        return true;
//    vector<int> v;
//    while (n) {
//        v.push_back(n % 10);
//        n /= 10;
//    }
//    reverse(v.begin(), v.end());
//    for (int i = 1; i < v.size(); i++) {
//        if (abs(v[i] - v[i - 1]) > 1)
//            return false;
//    }
//    return true;
//}
//
//bool SS(int n){
//    vector<int>v;
//    while (n) {
//        v.push_back(n % 10);
//        n /= 10;
//    }
//    //2 1
//    reverse(v.begin(), v.end());
//    for (int i = 1;i < v.size(); i++){
//        if (v[i] - v[i - 1] < 0)
//            return false;
//    }
//    return true;
//}
//
//signed main() {
//    //freopen("in", "r", stdin);
//    ios::sync_with_stdio(false);
//    int n, ans = 0, ca = 9;
//    cin >> n;
//    for (int i = 1; i <= n; i++) {
//        if (ans < 12) ans++;
//        else {
//            if (Judge(ans + 1))
//                ans++;
//            else {
//                if (Judge(ans + ca)) ans += ca;
//                else {
//                    for (int i = ans; ; i++){
//                        if (Judge(i)){
//                            ca = i - ans;
//                            ans = i;
//                            break;
//                        }
//                    }
//                }
//            }
//        }
//    }
//    cout << ans;
//    return 0;
//}


#include<bits/stdc++.h>

#define int long long
using namespace std;
vector<int> a;
int sum, p;

bool Judge(int n) {
    if (n <= 11)
        return true;
    vector<int> v;
    while (n) {
        v.push_back(n % 10);
        n /= 10;
    }
    reverse(v.begin(), v.end());
    for (int i = 1; i < v.size(); i++) {
        if (abs(v[i] - v[i - 1]) > 1)
            return false;
    }
    return true;
}

bool SS(int n){
    vector<int>v;
    while (n) {
        v.push_back(n % 10);
        n /= 10;
    }
    //2 1
    reverse(v.begin(), v.end());
    for (int i = 1;i < v.size(); i++){
        if (v[i] - v[i - 1] < 0)
            return false;
    }
    return true;
}

signed main() {
    cin >> p;
    for (int i = 1; i < 10; i++) a.push_back(i);
    for (int i = 0; a.size() < p + 1; i++) {
        int n = a[i], mod = n % 10;
        if (mod == 0) {
            a.push_back(n * 10);
            a.push_back(n * 10 + 1);
        } else if (mod == 9) {
            a.push_back(n * 10 + 8);
            a.push_back(n * 10 + 9);
        } else {
            a.push_back(n * 10 + mod - 1);
            a.push_back(n * 10 + mod);
            a.push_back(n * 10 + 1 + mod);
        }
    }
    cout << a[p - 1] << endl;
    return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD  1000000007
#define ll long long
#define int long long
# define INF 1000005
#define ar array
# define fr first
# define sc second
#define wt(x) int x;cin>>x;while(x--)
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
//#define cerr if(false)cerr
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> pbds;

void  c_p_c(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
 
#ifndef ONLINE_JUDGE
  freopen("input1.txt","r",stdin);
  freopen("output1.txt","w",stdout);
#endif
 }
 
int power(int a,int b,int mod){
    a=a%mod;
    if(a==0){
        return 1;
    }
    int res=1;
    while(b){
        if(b&1){
            res=(res*a)%mod;
        }
        b>>=1;
        a=(a*a)%mod;
    }
    return res;
 }
 
int  MMI(int p){
    return power(p,MOD-2,MOD);
}


int32_t main()
{
    c_p_c();
    
        char c;
        cin>>c;
        if(isupper(c)){
            cout<<'A';
        }
        else{
            cout<<'a';
        }

 
    
      return 0;
       }
        
        

        
























Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)

// GCD,LCM
ll gcd(ll gcmax,ll gcmin){
  if(gcmax<gcmin)swap(gcmax,gcmin);
  return gcmax%gcmin?gcd(gcmin,gcmax%gcmin):gcmin;
}
ll lcm(ll lcmax,ll lcmin){
  return lcmax/gcd(lcmax,lcmin)*lcmin;
}

int main(){
  ll n,c=0LL;
  cin>>n;
  reps(i,1,n+1){
    c+=i;
    reps(j,i+1,n+1){
      ll g=gcd(i,j);
      c+=g*6;
      reps(k,j+1,n+1){
        c+=gcd(g,k)*6;
      }
    }
  }
  cout<<c;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;

int main() {
    int W, H, x, y;
    cin >> W >> H >> x >> y;

    double s = 1.0 * W * H / 2;
    cout << setprecision(10) << s << " ";
    if (2 * x == W && 2 * y == H) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void){
    int x,i,j;
    scanf("%d",&x);
    for(i=x;;i++){
        int flag = 1;
        int y=sqrt(i);
        for(j=2;j<y;j++){
            // printf("%d %d\n",j,y);
            if(i%j==0) flag=0;
        }
        if(flag){
            printf("%d",i);
            return 0;
        }
        // printf("-------------\n");
    }
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();
            N = input[0];
            A = input[1];
            B = input[2];
            C = input[3];
            L = Enumerable.Repeat(0, N).Select(l => ReadInt()).ToArray();

            Console.WriteLine(Dfs(0, 0, 0, 0));
            Console.ReadLine();
        }

        static int N, A, B, C;
        static int[] L;
        static int inf = (int)Math.Pow(10, 9);

        static int Dfs(int cur, int a, int b, int c)
        {
            if (cur == N)
            {
                if (Math.Min(a, Math.Min(b, c)) > 0)
                {
                    return Math.Abs(a - A) + Math.Abs(b - B) + Math.Abs(c - C) - 30;
                }
                else
                {
                    return inf;
                }
            }

            var ret0 = Dfs(cur + 1, a, b, c);
            var ret1 = Dfs(cur + 1, a + L[cur], b, c)+10;
            var ret2 = Dfs(cur + 1, a, b + L[cur], c)+10;
            var ret3 = Dfs(cur + 1, a, b, c + L[cur])+10;

            return Math.Min(ret0, Math.Min(ret1, Math.Min(ret2, ret3)));
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll MOD = 1000000007;
string _S[3] = {"Sunny", "Cloudy", "Rainy"};
int main() {
  string s;
  cin >> s;
  int id;
  REP(i, 3) {
    if (_S[i] == s) id = i;
  }
  cout << _S[(id + 1) % 3] << endl;
}

Measured memory_bytes: 3468
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;

struct RAQ{
  ll size;
  ll *tree;
  RAQ(ll sz){
    ll logsize; for(logsize=0;(1ll<<logsize)<=sz;logsize++);
    size=(1ll<<logsize);
    tree=new ll[size*2-1]; REP(i,size*2-1) tree[i]=0;
  }
  void add(ll s,ll t,ll x){
    add(s,t,0,size,x,0);
  }
  void add(ll s,ll t,ll l,ll r,ll x,ll k){
    if(r<=s||t<=l||r<=l) return;
    if(l+1==r) {tree[k]+=x; return;}
    if(s<=l&&r<=t) {tree[k]+=x; return;}
    ll mid=(l+r+1)/2;
    add(s,t,l,mid,x,k*2+1);
    add(s,t,mid,r,x,k*2+2);
  }
  ll get(ll i){
    ll k=i+size-1;
    ll ret=tree[k];
    while(k){
      k=(k-1)/2;
      ret+=tree[k];
    }
    return ret;
  }
};

int main(){
  ll n,q; cin>>n>>q;
  RAQ raq(n);
  REP(i,q){
    ll com; cin>>com;
    if(com==0) {ll s,t,x; cin>>s>>t>>x; raq.add(s,t+1,x);}
    else {ll t; cin>>t; cout<<raq.get(t)<<endl;}
  }
}

//verified

Measured memory_bytes: 5172
import sys
from collections import defaultdict


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    N = int(input())
    A = list(map(int, input().split()))
    Q = int(input())
    dict = defaultdict(int)
    for a in A:
        dict[a] += 1
    answer = sum(A)
    for _ in range(Q):
        b, c = map(int, input().split())
        B = dict[b]

        answer -= b * B
        answer += c * B

        dict[b] = 0
        dict[c] += B
        print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 23972
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int r = sc.nextInt();
        int g = sc.nextInt();
        int b = sc.nextInt();
        int sum = r*100 + g*10 + b;
        System.out.println(sum % 4 == 0 ? "YES" : "NO");
    }
}



Measured memory_bytes: 21588
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		while (true) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			if (H == 0 && W == 0) {
				break;
			}
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					if (i == 0 || i == H - 1) {
						System.out.print('#');
					} else {
						if (j == 0 || j == W - 1) {
							System.out.print('#');
						} else {
							System.out.print('.');
						}
					}
				}
				System.out.println();
			}
			System.out.println();
		}
		sc.close();
	}

}


Measured memory_bytes: 34028
// Problem : C - Bridge
// Contest : AtCoder - AtCoder Beginner Contest 075
// URL : https://atcoder.jp/contests/abc075/tasks/abc075_c
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void dfs(int i,vi v[],int vis[])
{
	vis[i]=1;
	for(int j:v[i])
	{
		if(!vis[j])
		dfs(j,v,vis);
	}
}
void dfs2(int i,vi v[],int vis2[],int x,int y)
{
	vis2[i]=1;
	for(int j:v[i])
	{
		if((i==x and j==y) or (i==y and j==x))continue;
		if(!vis2[j])
		dfs2(j,v,vis2,x,y);
	}
}
void solve()
{
	int n,m;cin>>n>>m;
	vi v[n+1];
	while(m--)
	{
		int x,y;
		cin>>x>>y;
		v[x].pb(y);
		v[y].pb(x);
	}
	int cnt=0;
	int vis[n+1]={0};
	for(int i=1;i<=n;i++)
	{
		if(!vis[i])
		cnt++,dfs(i,v,vis);
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		for(int j:v[i])
		{
			int vis2[n+1]={0},cnt2=0;
			for(int k=1;k<=n;k++)
			{
					if(!vis2[k])
					cnt2++,dfs2(k,v,vis2,i,j);
			}
			if(cnt2!=cnt)
			ans++;
		}
	}
	cout<<ans/2;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
using namespace std;
using ll =long long;
const int MOD = 1000000007;

//////検証する数,超えられない数////

long long cine(long long a, long long b) {
	if (a <= b) {
		return a;
	}
	else {
		return b;
	}
};
//vector型の初期化

void vec_initialize(vector<ll>& a, const ll N) {
	ll c;

	for (int i = 0; i < N; i++) {

		cin >> c;
		a.push_back(c);

	}

};
void vec_pair_initialize(vector<pair<ll, ll>>& a, const ll N) {
	ll c, d;
	for (int i = 0; i < N; i++) {
		cin >> c >> d;
		a.push_back(make_pair(c, d));
	}
};
int main() {
	ll K;
	ll A, B;
	cin >> K >> A >> B;
	for (int i = A; i <= B; i++) {

		if (i % K == 0){


			cout << "OK";
			return 0;
		}
	}

	cout << "NG";
}

Measured memory_bytes: 3636
#include <iostream>
#define MAXV 1000000
#define LENGTH 12
#include <math.h>
#include <stdio.h>
using namespace std;

struct ll{
double x,y;};
typedef struct ll koc;
double koch(int d,koc p1,koc p2)
{
    if(d==0)
        return 1;
    double th = M_PI*60/180;
    koc s,t,u;
    s.x = (2*p1.x+p2.x)/3;
    s.y = (2*p1.y+p2.y)/3;
    t.x = (p1.x+2*p2.x)/3;
    t.y = (p1.y+2*p2.y)/3;
    u.x = (t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
    u.y = (t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;


  
   
    koch(d-1,p1,s);
    printf("%.8f %.8f\n",s.x,s.y);
    koch(d-1,s,u);
    printf("%.8f %.8f\n",u.x,u.y);
    koch(d-1,u,t);
    printf("%.8f %.8f\n",t.x,t.y);
    koch(d-1,t,p2);
}
int main()
{
    koc p1,p2;
    p1.x = 0,p1.y = 0;
    p2.x = 100,p2.y = 0;
    int d;
    scanf("%d",&d);
    printf("%.8f %.8f\n",p1.x,p1.y);

    koch(d,p1,p2);
    printf("%.8f %.8f\n",p2.x,p2.y);
}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
  vector<int> x(3);
  cin >> x[0] >> x[1] >> x[2];
  sort(x.begin(), x.end());
  cout << x[0] * x[1] / 2 << endl;

  return 0;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;


int main() {
    ll x, k, d; cin >> x >> k >> d;
    x = abs(x);

    ll tmp = k - min(k, x / d);
    x -= (min(k, x / d) * d);
    if(tmp % 2) cout << abs(x - d) << endl;
    else cout << abs(x) << endl;
    return 0;
}


Measured memory_bytes: 3620
import sys
from numba import njit
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit('(i8,)', cache=True)
def keta(x):
    ret = -1
    while x >= 1:
        x >>= 1
        ret += 1
    return ret

@njit('(i8,i8[::1],i4[::1])', cache=True)
def solve(N, A, S):
    if np.all(S == 0):
        return True
    if S[-1] == 1:
        if A[-1] == 0:
            return solve(N - 1, A[:-1], S[:-1])
        else:
            return False
    # .....10000
    i = np.where(S == 1)[0].max() + 1
    A1 = A[:i]
    B = A[i:]
    while True:
        B = B[B != 0]
        if len(B) == 0:
            break
        x = B.max()
        k = keta(x)
        A1 ^= ((A1 >> k) & 1) * x
        B ^= ((B >> k) & 1) * x
    N = len(A1)
    return solve(N, A1, S[:N])

def main():
    T = int(readline())
    for _ in range(T):
        N = int(readline())
        A = np.array(readline().split(), np.int64)
        S = np.array(list(readline().decode().rstrip()), np.int32)
        x = 0 if solve(N, A, S) else 1
        print(x)

main()

Measured memory_bytes: 107400
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		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 nedan=a*x+b*y;
		int z=0;

		while(nedan>a*(x-1)+b*(y-1)+c*(z+2)) {
			nedan=a*(x-1)+b*(y-1)+c*(z+2);
			x--;
			y--;
			z+=2;

			if(x==0)
				x++;
			if(y==0)
				y++;
		}

		System.out.print(nedan);
	}

}


Measured memory_bytes: 23764
#include "bits/stdc++.h"
using    namespace std;
typedef  long double ld;
#define  int long long
typedef  pair<int,int> pii;
#define  RAGE ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  rep(i,n) for(i=0; i <n; i++)
#define  repv(i,k,n) for(int i=k; i<=n; i++)
#define  pb push_back
#define  mp make_pair
#define  F  first
#define  S  second
#define  sz(x)  (int)x.size()
#define  all(v) v.begin(),v.end()
#define  endl '\n'
#define  deb(x) c out<<#x<<" = "<<x<<endl
#define  gcd   __gcd
#define  inf   LLONG_MAX
#define  minf  LLONG_MIN 
#define  gi  greater<int> 
#define  gpi greater<pii>  
#define  sp(n) fixed<<setprecision(n)
const int mod = (int)(1e9+7);
int power(int x,int n)
{   
    if(n==0)    return 1;
    if(n==1)    return x%mod;
    if(n%2==0)  {   int y = power(x,n/2)%mod;return (y*y)%mod;}
    if(n&1)     {   int y = power(x,n-1);return (x%mod * y%mod)%mod;}
    return 0;
}
int pct(int x)
{   return __builtin_popcountll(x);}
int  lcm(int a,int b){return a*b/gcd(a,b);}
bool is_power_2(int n){ return log2(n)==floor(log2(n));}
bool is_prime(int n){for(int i=2; i*i<=n; i++)if(n%i==0)return 0; return 1;}
void db()
{   
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}
void timeit()
{  
    #ifndef ONLINE_JUDGE
        cout<<"\nTime Elapsed: " <<sp(5)<< 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}
int     dx []    =  {-1 , 0 , 1 , 0 ,-1,-1, 1,  1};
int     dy []    =  { 0 , 1 , 0 ,-1 ,-1, 1, 1, -1};
char    dir[]    =  {'U','R','D','L'};
/* ---------------------- ar.cpp --------------------------------- */
const int maxn = 1e5+5;
vector<int> adj[maxn] , vis(maxn , 0);
vector<int> order;
void dfs(int n)
{
    vis[n] = 1;
    for(int x:adj[n])
        if(!vis[x])
            dfs(x);
    order.pb(n);
} 
void solve(int tc)
{
    //  cout<<"Case #"<<tc<<": ";
    int n,i,j,w,k,m,q,l,r;
    cin>>n>>m;
    rep(i,m)
    {
        int a,b;
        cin>>a>>b;
        adj[a].pb(b);
    }
    vector<int> dp(maxn , 0);
    repv(i,1,n)
        if(!vis[i])dfs(i);

    for(int U:order)
    {
        dp[U] = 1;
        for(int x:adj[U])
        {
            dp[U] = max(dp[U] , dp[x] + 1);
        }
    }
    cout<<*max_element(dp.begin()+1 ,dp.begin()+n+1)-1;
}       
signed main()
{
    // ar.cpp
    RAGE;
 //   db();    
    int t=1;
    //cin>>t;
    for(int i=1; i<=t; i++)
    {
        solve(i);
    }
//    timeit();
    return 0;
}


Measured memory_bytes: 13380
///in the name of ALLAH
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,m;
    cin>>n>>m;
    ll a[m],b[m];
    for(int i=0;i<m;i++)
    {
        cin>>a[i]>>b[i];
    }
    vector<vector<ll> >v(n+1);
    for(int i=0;i<m;i++)
    {
        v[a[i]].push_back(b[i]);
    }
   /* for(int i=1;i<=n;i++)
    {
        for(int j=0;j<v[i].size();j++)
        {
            cout<<v[i][j]<<" ";
        }
        cout<<endl;
    }*/
    bool f=0;
    //cout<<v[1].size();
    for(int i=0;i<v[1].size();i++)
    {
        if(count(v[v[1][i]].begin(),v[v[1][i]].end(),n))
        {
            f=1;break;
        }
    }
    if(f==1)
        cout<<"POSSIBLE"<<endl;
    else
        cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 15004
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    rep(i,n){
        cin >> p[i];
        q[i] = p[i];
    }
    sort(q.begin(), q.end());
    int cnt = 0;
    rep(i,n){
        if(p[i] != q[i]) ++cnt;
    }
    if(cnt == 0 || cnt == 2) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 3652
list = [0 for i in range(50)]
listcounter = 0
while True:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    counter = 0
    for i in range(1, n+1):
        for j in range (i+1, n+1):
            for k in range(j+1, n+1):
                if i + j + k == x:
                    counter += 1
    list[listcounter] = counter
    listcounter += 1
for i in range(listcounter):
    print(list[i])


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

int main()
{
    string a, sd, s;
    cin >> sd >> a;

    if(sd.size() < a.size()){
        cout << "UNRESTORABLE";

        return 0;
    }

    bool f = false;
    int cnt = 0;
    string ans = "~";
    for(int i = 0;i < sd.size() - a.size() + 1;i++){
        string s2 = sd;
        bool f2 = true;
        for(int j = 0;j < a.size();j++){
            if(sd[i + j] == a[j] || sd[i + j] == '?'){
                s2[i + j] = a[j];
            }
            else{
                f2 = false;

                break;
            }
            if(j == a.size() - 1){
                f = true;
            }
        }
        if(f2){
            replace(s2.begin(),s2.end(),'?','a');
            ans = min(ans,s2);
        }
    }

    if(f){
        cout << ans;
    }
    else{
        cout << "UNRESTORABLE";
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define  uLL unsigned long long 
const int N = 2e5 + 11;
uLL qa[N], qb[N], base[N], a[N], b[N], aa[N], bb[N];
int n, tot, ans[N];
uLL get(int l, int r){
    if(l == 0)return qa[r];
    else {
        l--;
        return qa[r] - qa[l] * base[r-l];
    }
}
int main(){
    cin>>n;
    for(int i = 0;i < n; i++){
        scanf("%llu", &a[i]);
    }
    for(int i = 0;i < n; i++){
        scanf("%llu", &b[i]);
    }
    for(int i = 0;i < n - 1; i++){
        aa[i] = a[i] ^ a[i+1];
        bb[i] = b[i] ^ b[i+1];
    }
    aa[n-1] = a[n-1] ^ a[0];
    bb[n-1] = b[n-1] ^ b[0];
    base[0] = 1;
    base[1] = 1e9 + 7;
    qa[0] = aa[0]; qb[0] = bb[0];
    for(int i = 1;i <= n - 1; i++){
        base[i+1] = base[i] * base[1];
        qa[i] = qa[i-1] * base[1] + aa[i];
        qb[i] = qb[i-1] * base[1] + bb[i];
    }
    for(int k = 0;k < n; k++){
        uLL x = get(k, n - 1) * base[k] + (k - 1 >= 0 ? qa[k-1] : 0);
        if(x == qb[n-1]){
            ans[++tot] = k;
        }
    }
    for(int i = 1;i <= tot; i++){
        printf("%d %lld\n", ans[i], a[ans[i]] ^ b[0]);
    }
    return 0;
}


Measured memory_bytes: 15104
#include <iostream>
#include <algorithm>
#define int long long
using namespace std;
struct edge { int to, from, cost; };
int INF = 1000000000000000;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m, p;
  cin >> n >> m >> p;
 
  int a[m], b[m], c[m];
  for(int i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
  }
 
  edge es[m];
  for(int i = 0; i < m; i++) {
    es[i] = (edge) { b[i], a[i], p - c[i]};
  }
  int d[n];
  for(int i = 0; i < n; i++) d[i] = INF;
  d[0] = 0;
 
  bool neg_loop = false;
  for(int i = 0; i < 2 * n; i++) {
    for(int j = 0; j < m; j++) {
      edge e = es[j];
      if(d[e.to] > d[e.from] + e.cost) {
        d[e.to] = d[e.from] + e.cost;
        if(i >= n && e.to == n - 1) {
          neg_loop = true;
          break;
        }
      }
 
    }
  }
 
  if(neg_loop) {
    cout << -1 << "\n";
    return 0;
  }
 
 
  cout << max(0LL, -d[n - 1]) << "\n";
  return 0;
}

Measured memory_bytes: 512
def main():
    s=input()
    s=s[:-2]
    ans = len(s)
    while s[:len(s)//2] != s[len(s)//2:] and len(s)!=0:
        s=s[:-2]
        ans -=2
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
N,K = map(int,input().split())
mod = 10**9+7
ans = 0
X_gcd = [0]*(K+1)
for X in reversed(range(1,K+1)):
    X_gcd[X] = pow(K//X,N,mod)
    
    for nX in range(2*X,K+1,X):
        X_gcd[X] -= X_gcd[nX]
        
    ans = (ans+(X%mod)*(X_gcd[X]%mod))%mod
print(ans%mod)

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

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

constexpr ll INF = 1e15;
constexpr ll mod = 1e9 + 7;

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

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

int main() {
	string s;
	cin >> s;
	int n = s.size();
	if (s[n - 1] == 's') {
		cout << s << "es" << endl;
	}
	else {
		cout << s << "s" << endl;
	}


	return 0;
}


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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

ll ans = 1;
ll N, K;
ll mod = 1e9 + 7;
vector<ll> fact(1000000);

void init() {
    fact[0] = 1;
    for (int i = 1; i < 1000000; i++) {
        fact[i] = (fact[i - 1] * i) % mod;
    }
}

ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while(n > 0) {
        if(n & 1) res = res * x % mod;
            x = x * x % mod;
            n >>= 1;
    }
    return res;
}

ll inv(ll x) {
    return mod_pow(x, mod - 2, mod);
}

ll perm(ll n, ll r) {
    if (r == 0) return 1;
    if (n < r) return 0;

    return (fact[n] * inv(fact[n - r])) % mod;
}

void dfs(int v, int p, vector<vector<int>> &G, int depth) {
    //cout << v << endl;
    if (depth == 0) {
        ans *= K;
        //cout << "*" << K << endl;
        ans %= mod;
        ans *= perm(K - 1, G[v].size()); 
        //cout << "*" << perm(K - 1, G[v].size()) << endl;
        ans %= mod;
    } else {
        //cout << "K - 2: " << K - 2 << endl;
        //cout << "size: " << G[v].size() - 1 << endl;
        ans *= perm(K - 2, G[v].size() - 1);
        //cout << "*" << perm(K - 2, G[v].size() - 1) << endl;
        ans %= mod;
    }

    for (int i = 0; i < G[v].size(); i++) {
        if (G[v][i] == p) continue;
        dfs(G[v][i], v, G, depth + 1);
    }
}

void solve() {
    init();

    cin >> N >> K;
    vector<vector<int>> G(N);
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    dfs(0, -1, G, 0);
    cout << ans << endl;
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

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

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

	int			n;
	int			max;
	int			second_max;
	cin >> n;
	vector<int>	A(n);
	vector<int>	B(n);

	/* rep(i, n) */
	/* 	cin >> A.at(i); */
	for (int &a : A)
		cin >> a;
	B = A;
	sort(B.rbegin(), B.rend());
	max = B.at(0);
	second_max = B.at(1);
	rep(i, n)
	{
		if (A.at(i) != max)
			cout << max << endl;
		else
			cout << second_max << endl;
	}
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0))
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0))
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a))
#define Reverse(a) reverse(All(a))
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define Lower(a,t) lower_bound(All(a),t)
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int bikkuri(int a){
    int ans = 1;
    FOR(i,1,a+1){
        ans *=i;
        ans %= max_int;
    }
    return ans;
}

signed main(){
    int n,m,ans=1;
    cin >> n >> m;
    if(abs(n-m)>1){
        cout << 0 << endl;
    }
    else if(abs(n-m) == 1){
        ans = (bikkuri(n)*bikkuri(m))%max_int;
        cout << ans << endl;
    }
    else{
        ans = (bikkuri(n)*bikkuri(m)*2)%max_int;
        cout << ans << endl;
    }


    return 0;
}



void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}


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

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

vector<vector<int>> G;
vector<ll> t_dis, a_dis;

void t_dfs(int x,ll d){
    t_dis[x]=d;
    for(int y:G[x]){
        if(t_dis[y]==INF)t_dfs(y,d+1);
    }
}

void a_dfs(int x, ll d) {
    a_dis[x] = d;
    for(int y : G[x]) {
        if(a_dis[y] == INF) a_dfs(y, d + 1);
    }
}

int main() {
    ll n,a,b,t;
    cin >> n >> t >> a;
    G.resize(n+1);
    t_dis.resize(n+1,INF);
    a_dis.resize(n+1,INF);
    for(ll i=0;i<n-1;i++){
        int x,y;
        cin >> x >> y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    t_dfs(t,0ll);
    a_dfs(a,0ll);
    ll ret = 0;
    for(int i=1;i<=n;i++){
        if(t_dis[i]<a_dis[i])ret=max(ret,a_dis[i]);
    }
    cout << ret-1 << endl;
    return 0;
}

Measured memory_bytes: 11136
#include <iostream>

int main() {
	std::string buf;
	std::getline(std::cin, buf);
	int replace_cnt = 0;
	for (int i = 0; i < buf.size()/2; i++){
		if (buf[i] != buf[buf.size()-i-1]){
			replace_cnt++;
		}
	}
	std::cout << replace_cnt;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
const ll INF = ll(1e9);
const int N = 1e5 + 5;
const ll mod = 1000000007 ;
using namespace std;


ll dp[N];

ll binpow(ll x, ll y) {
	ll z = 1;
	while (y) {
		if (y % 2) z = (z * x) % mod;

		y = y / 2;
		x = (x * x) % mod;
	}
	return z % mod;
}




int main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);


	ll tc = 1;

//	cin >> tc;

	while (tc--) {

		ll n, k, i, j;
		cin >> n >> k;

		std::vector<ll> a(n + 1);

		for (i = 1; i <= n; i++) {
			cin >> a[i];
		}

		ll dp[n + 1];
		for (i = 0; i <= n; i++) {
			dp[i] = 1e10;
		}

		dp[0] = 0;
		dp[1] = 0;
		dp[2] = abs(a[2] - a[1]);

		for (i = 3; i <= n; i++) {
			if (i <= k) {
				for (j = 1; j < i; j++) {
					dp[i] = min(dp[i], abs(a[i] - a[i - j]) + dp[i - j]);
				}
			}
			else {
				for (j = 1; j <= k; j++) {
					dp[i] = min(dp[i], abs(a[i] - a[i - j]) + dp[i - j]);
				}
			}
		}

		cout << dp[n] << endl;



	}

}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;

class Solution
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var a = new int[n];
        for (int i = 0; i < n; i++)
        {
            a[i] = int.Parse(Console.ReadLine());
        }

        long ope = 0;
        var right = -1;
        for (int i = n - 1; i >= 0; i--)
        {
            if (a[i] > i)
            {
                ope = -1;
                break;
            }

            if(a[i] + 1 < right)
            {
                ope = -1;
                break;
            }

            if (a[i] + 1 != right)
            {
                ope += a[i];
            }
            right = a[i];
        }

        Console.WriteLine(ope);
    }
}

Measured memory_bytes: 15836
def chk_num(myList,i,n):
    tmp = 0
    if 0<=i-1<n:
        if myList[i-1][0]+1==myList[i][0]:
            tmp += myList[i-1][1]
    if 0<=i<n:
        tmp += myList[i][1]
    if 0<=i+1<n:
        if myList[i][0]+1==myList[i+1][0]:
            tmp += myList[i+1][1]
    return tmp

n = int(input())
a = list(map(int,input().split()))
dic = {}
for i in range(n):
    dic.setdefault(a[i],0)
    dic[a[i]] += 1
#print(dic)
sortedDict = sorted(dic.items())
#print(sortedDict)
ans = 0
for i in range(len(sortedDict)):
    ans = max(ans,chk_num(sortedDict,i,len(sortedDict)))
print(ans)

Measured memory_bytes: 20652
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(a) (a).begin(), (a).end()
#define ALLR(a) (a).rbegin(), (a).rend()
#define SZ(a) ((int)(a).size())
#define PB(a) push_back(a)
#define EMP emplace
#define EMPB(...) emplace_back(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)
#define Bit(n) (1LL << (n))
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const int INF = 1LL << 30;
const double EPS = 1e-10;

int H, W;
int c[10][10];
int A[210][210];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> H >> W;
  REP(i, 10) REP(j, 10) cin >> c[i][j];
  REP(i, H) REP(j, W) cin >> A[i][j];
  REP(k, 10) REP(i, 10) REP(j, 10) {
    chmin(c[i][j], c[i][k]+c[k][j]);
  }
  int ans = 0;
  REP(i, H) REP(j, W) if (A[i][j] >= 0) {
    ans += c[A[i][j]][1];
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N, K;
    cin >> N >> K;
    vector<ll> h(N);
    REP(i, N) cin >> h[i];
    ll ans = 0;
    REP(i, N) {
        if (h[i] >= K) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
const int MAXN = 1e5+5;
int P[MAXN]{ };
int A, K, N, Q;

int main() {
  scanf(" %d%d%d", &N, &K, &Q);
  for (int i = 0; i < Q; ++i) {
    scanf("%d", &A);
    ++P[A];
  }
  for (int i = 1; i <= N; ++i) {
    int score = K + P[i] - Q;
    puts((score > 0) ? "Yes" : "No");
  }
  return 0;
}

Measured memory_bytes: 896