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

#define MOD 1000000007

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

char s[1000010];

int main()
{
	int N, M;
	while (1) {
		int ans = 0;
		char str[1000010] = "IOI";
		cin >> N >> M;

		if (N == 0)break;
	    cin >> s;
		if (N == 1) {
			for (int i = 0; i < M; i++) {
				if (s[i] == 'I') {
					if (strncmp(str, s + i, 3) == 0)
						ans++;
				}
			}
		}
		else {
			int a = 3;
			for (int i = 1; i <= N -1; i++) {
				str[a] = 'O';
				str[a + 1] = 'I';
				a += 2;
			}
			for (int i = 0; i < M; i++) {
				if (s[i] == 'I') {
					if (strncmp(str, s + i, (3 + 2 * (N - 1))) == 0)
						ans++;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 5020
#D問題
N = int(input())
A = list(map(int,input().split()))
C = [0 for i in range(N)]
for i in range(N):
    I = N-1-i
    n = N//(I+1)
    check = 0
    for j in range(n):
        check+=C[(I+1)*(j+1)-1]
    
    
    if A[I] == check%2:
        C[I] = 0
    else:
        C[I] = 1

b = 0
B = []
for i in range(N):
    if C[i] == 1:
        b+=1
        B.append(i+1)
print(b)
for i in range(b):
    print(B[i],end=" ")
    

Measured memory_bytes: 12088
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;

int[200][200] mk_map()
{
    int[200][200] ret;
    foreach (ref e; ret) e = int.max / 3;
    return ret;
}

int[200][200] MAP = mk_map();

void main()
{
    auto nmr = readln.split.to!(int[]);
    auto N = nmr[0];
    auto M = nmr[1];
    auto R = nmr[2];
    auto rs = readln.split.map!(s => s.to!int - 1).array;

    foreach (_; 0..M) {
        auto abc = readln.split.to!(int[]);
        auto a = abc[0] - 1;
        auto b = abc[1] - 1;
        auto c = abc[2];
        MAP[a][b] = c;
        MAP[b][a] = c;
    }

    foreach (k; 0..N)
        foreach (i; 0..N)
            foreach (j; 0..N)
                if (MAP[i][j] > MAP[i][k] + MAP[k][j])
                    MAP[i][j] = MAP[i][k] + MAP[k][j];

    int[string][200] MEMO;
    int solve(int before, int[] rest) {
        if (rest.empty) return 0;
        auto key = rest.to!string;
        if (before != -1 && key in MEMO[before]) return MEMO[before][key];
        int min_ret = int.max;
        foreach (i, next; rest) {
            int ret;
            if (before >= 0) ret = MAP[before][next];
            ret += solve(next, rest[0..i] ~ rest[i+1..$]);
            min_ret = min(min_ret, ret);
        }
        if (before == -1) return min_ret;
        return MEMO[before][key] = min_ret;
    }

    writeln(solve(-1, rs));
}

Measured memory_bytes: 1532
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let input = readIntSplit(by: " ")
let (H, W) = (input[0], input[1])
let a = (0..<H).map{_ in readLine()!.toArray()}

var row = [Bool](repeating: false, count: H)
var col = [Bool](repeating: false, count: W)
for i in 0..<H {
    for j in 0..<W {
        if a[i][j] == "#" {
            row[i] = true
            col[j] = true
        }
    }
}

for i in 0..<H {
    if row[i] == true {
        for j in 0..<W {
            if col[j] == true {
                print(a[i][j], terminator: "")
            }
        }
        print()
    }
}


Measured memory_bytes: 7528
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<deque>


using namespace std;
using ll = long long;

int n;
int d[105];

int main(){
  cin >> n;
  for(int i = 0; i < n; ++i){
    cin >> d[i];
  }
  ll ans = 0;
  for(int i = 0; i < n; ++i){
    for(int j = i + 1; j < n; ++j){
      ans += d[i] * d[j];
    }
  }
  cout << ans << endl;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<char,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


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

    string s;
    cin >> s;

    int ans = 0;
    int n = s.size();
    rep(i, n){
        string tmp = s.substr(0, s.size()-i);
        string l = tmp.substr(0, tmp.size()/2);
        string r = tmp.substr(tmp.size()/2, tmp.size());

        if(l == r && tmp != s){
            ans = tmp.size();
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

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

int dp[101][4][4][4];
int main() {
    int N;
    cin >> N;

    dp[0][3][3][3] = 1;
    int mod = 1000000007;

    for (int len = 0; len < N; len++) {
        for (int c1 = 0; c1 < 4; c1++) {
            for (int c2 = 0; c2 < 4; c2++) {
                for (int c3 = 0; c3 < 4; c3++) {
                    if (dp[len][c1][c2][c3] == 0) continue;
                    for (int a = 0; a < 4; a++) {
                        if (a == 2 && c1 == 1 && c2 == 0) continue;
                        if (a == 2 && c1 == 0 && c2 == 1) continue;
                        if (a == 1 && c1 == 2 && c2 == 0) continue;
                        if (a == 2 && c1 == 1 && c3 == 0) continue;
                        if (a == 2 && c2 == 1 && c3 == 0) continue;

                        dp[len + 1][a][c1][c2] += dp[len][c1][c2][c3];
                        dp[len + 1][a][c1][c2] %= mod;
                    }
                }
            }
        }
    }

    int ans = 0;
    for (int c1 = 0; c1 < 4; c1++) {
        for (int c2 = 0; c2 < 4; c2++) {
            for (int c3 = 0; c3 < 4; c3++) {
                ans += dp[N][c1][c2][c3];
                ans %= mod;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
alpha=list('abcdefghijklmnopqrstuvwxyz')

def sin(l):
    sinsu=[]
    m=l
    while(m>0):
        if(m%26==0):
            m-=1
            sinsu.append((m%26))
        else:
            sinsu.append((m%26)-1)
        m//=26

    #print(sinsu)
    ans=[]
    for i in range(len(sinsu)):
        ans.append(alpha[sinsu[i]])
    ans=ans[::-1]
#    print(l,end=" ")
    print(''.join(ans))

sin(n)

Measured memory_bytes: 9200
from operator import add, mul, sub, or_


class BIT:
    def __init__(self, n, op, ie):
        self.n = n
        self.tree = [ie]*(n+1)
        self.op = op

    def update(self, i, v):
        while i <= self.n:
            self.tree[i] = self.op(self.tree[i], v)
            i += i & (-i)

    def query(self, i):
        v = 0
        while i:
            v = self.op(self.tree[i], v)
            i -= i & (-i)
        return v


N, Q = map(int, input().split())
*c, = map(int, input().split())

q = [[] for _ in range(N+1)]
for i in range(Q):
    x, y = map(int, input().split())
    q[y-1].append([i, x-1])

bit = BIT(N, add, 0)
finds = [-1]*(N+1)
ans = [0]*Q
for i in range(N):
    if finds[c[i]] != -1:
        bit.update(finds[c[i]]+1, -1)

    finds[c[i]] = i
    bit.update(finds[c[i]]+1, 1)

    for j, x in q[i]:
        ans[j] = bit.query(i+1) - bit.query(x)

for a in ans:
    print(a)


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

bool c, f;

int main()
{
	string s;
	cin >> s;
	
	int n = s.size();
	for (int i = 0; i < n; i++)
	{
		if (s[i] == 'C')
		{
			c = 1;
		}
		if (s[i] == 'F' && c == 1)
		{
			f = 1;
			break;
		}
	}
	
	if (c == 1 && f == 1)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
	cout << endl;
	return 0;
}

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

tree=[[] for _ in range(n)]

for _ in range(n-1):
    a,b=map(int,input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

ans=[0]*n
ans[0]="B"
ans[n-1]="W"

from collections import deque

stack = deque([0,n-1])

while len(stack)>1:
    tmp=stack.popleft()

    for item in tree[tmp]:
        if ans[item]==0:
            if ans[tmp]=="W":
                ans[item]="W"
            else:
                ans[item]="B"
            stack.append(item)

if ans.count("B")>ans.count("W"):
    print("Fennec")
else:
    print("Snuke")



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

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

const int N = 3e6;

void solve() {
  int n; cin >> n;
  ll a, b; cin >> a >> b;
  vector<ll> x(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  ll res = 0;
  for (int i = 0; i + 1 < n; i++) {
    ll delta = x[i + 1] - x[i];
    if (delta * a > b)
      res += b;
    else
      res += delta * a;
  }
  cout << res;
}

// CHECK LIMITS (n <= 10^5)
// CHECK CORNER CASES (n == 1)

int main() {
  ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
  cout.setf(ios::fixed), cout.precision(20);
  //cout << 1.0 * clock() / CLOCKS_PER_SEC << endl;
  solve();
}


Measured memory_bytes: 3996
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;
// const int MOD = 998244353;

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

   int x, y, A, B, C;
   cin >> x >> y >> A >> B >> C;
   vector<int> p(A), q(B), r(C);
   rep(i, 0, A) cin >> p[i];
   sort(p.rbegin(), p.rend());
   rep(i, 0, B) cin >> q[i];
   sort(q.rbegin(), q.rend());
   rep(i, 0, C) cin >> r[i];
   vector<int> s;
   rep(i, 0, x) s.push_back(p[i]);
   rep(i, 0, y) s.push_back(q[i]);
   rep(i, 0, C) s.push_back(r[i]);
   sort(s.rbegin(), s.rend());
   ll ans = 0;
   rep(i, 0, x + y) ans += s[i];

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

Measured memory_bytes: 3572
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque, Counter
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

def res(n, cur, ln, k):
    if ln == n:
        print(cur)
        return
    for i in range(k+2):
        res(n, cur + chr(ord("a") + i), ln+1, max(k,i))
    # res(n, cur + chr(ord("a") + k+1), ln + 1, k+1)


def main():
    n = getN()
    res(n, "a", 1, 0)
if __name__ == "__main__":
    main()

Measured memory_bytes: 57304
#include <bits/stdc++.h>
using namespace std;
#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, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
#define dame { printf("No\n"); return 0;}
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)


signed main(){
    int a,b,c,n;
    cin >> a >> b >> c >> n;
    int ans = 0;
    FOR(i,0,n + 1){
        int su = i * a;
        FOR(j,0,n + 1){
            if( (n  - i * a - j * b) % c == 0 and (n  - i * a - j * b) >= 0 )  ans ++ ;
        }
    }
    cout << ans << endl;

}


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

int main() {
    int a,b,seki;
    cin >> a >> b;
    seki= a*b;

    if(a*b%2 == 0){
        cout << "Even" << endl;
    }

    else{
        cout << "Odd" << endl;
    }
}



Measured memory_bytes: 256
def main():
  n,x,y = map(int,input().split())
  a = [0 for _ in range(n-1)]
  for i in range(1,n):
    for j in range(i+1,n+1):
      l = min(j-i,abs(x-i)+1+abs(j-y))
      a[l-1] += 1
  print("\n".join(map(str,a)))

main()

Measured memory_bytes: 3316
#AAAAAAAAAAA

import sys
import math
import itertools
import collections
import heapq
import numpy as np

rl = sys.stdin.readline

h1, m1, h2, m2, k = map(int, rl().split())
m = h2*60 + m2 - h1*60 - m1
print(m-k)



Measured memory_bytes: 27124
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;

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

const int inf = 1e9 + 1;
const double eps = 1e-9;
const int MAXN = 1e5 + 1;

bool imam[4];
int a;

int main(){

    for (int i = 0; i < 4; i++){
        cin >> a;
        if (a == 1) imam[0] = 1;
        if (a == 4) imam[1] = 1;
        if (a == 7) imam[2] = 1;
        if (a == 9) imam[3] = 1;
    }

    if (imam[0] == 1 && imam[1] == 1 && imam[2] == 1 && imam[3] == 1) cout << "YES";
    else cout << "NO";

    return 0;

}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    int h, n; cin >> h >> n;
    V<int> dp(h + 1, 1001001001);
    dp[0] = 0;
    for(int i = 0; i < n; i++){
        int a, b; cin >> a >> b;
        for(int j = 0; j < h; j++){
            int nj = min(j + a, h);
            dp[nj] = min(dp[nj], dp[j] + b);
        }
    }
    cout << dp[h] << endl;

    return 0;
}


Measured memory_bytes: 3668
# Studying https://atcoder.jp/contests/abc140/submissions/7411285

N = gets.to_i
P = gets.split.map &:to_i
Pi = (0...N).sort_by{|i| P[i] }

RU = (1..N).to_a + [N, N]
LU = (-1..(N-2)).to_a + [-1, -1]

p Pi.inject(0){|sum, i|
	 l,  r = LU[i], RU[i]
	ll, rr = LU[l], RU[r]
	LU[r], RU[l] = l, r
	next sum + P[i] * ((i-l)*(rr-r) + (r-i)*(l-ll))
}


Measured memory_bytes: 12072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll N, P;
ll a[200];
ll nk[200];
int main() {
  cin >> N >> P;
  int odd = 0;
  int even = 0;
  for (int i = 0; i < N; ++i) {
    int c;
    cin >> c;
    if (c & 1)
      odd++;
    else
      even++;
    a[i] = c;
  }

  ll ret = 0;
  nk[0] = 1;
  for (int i = 1; i <= odd; ++i) {
    nk[i] = nk[i - 1] * (odd - i + 1);
    nk[i] /= i;
  }

  ret = (1LL << even);
  ll c = 0;
  if (P == 0) {
    for (int i = 0; i <= odd; i += 2) {
      c += nk[i];
    }

  } else {
    for (int i = 1; i <= odd; i += 2) {
      c += nk[i];
    }
  }
  ret *= c;
  cout << ret << endl;
}

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

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	char now = 'a';
	int index_a = 0, index_b = 0, index_c = 0;
	while (true)
	{
		if (now == 'a') {
			if (a.size() == index_a) {
				cout << 'A' << endl;
				break;
			}
			now = a.at(index_a++);
		}
		else if (now == 'b') {
			if (b.size() == index_b) {
				cout << 'B' << endl;
				break;
			}
			now = b.at(index_b++);
		}
		else {
			if (c.size() == index_c) {
				cout << 'C' << endl;
				break;
			}
			now = c.at(index_c++);
		}
	}

	return 0;
}

Measured memory_bytes: 256
N=int(input())
S=list(input())
import collections
c=collections.Counter(S)
if len(c)==3:
  
  u=1
  for i in c.values():
    u=u*i 
  for i in range(N-2):
    for j in range(i+1,int((N-1+i)/2)+1):
      
        if set([S[i],S[j],S[2*j-i]])=={'B','R','G'} :
          u=u-1
  print(u)       
else:
  print(0)


Measured memory_bytes: 9500
A=int(input())
B=int(input())
C=int(input())
X=int(input())

count=0

for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            total=500*a+100*b+50*c
            if(total==X):
                count+=1

print(count)


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

int main() {
  long long N;
  string T;
  cin >> T;
  
  N = T.size();
  
  for (int i=0; i<N; i++) {
    if (T[i] == '?') {
      T[i] = 'D';
    }
  }
  
  
  cout << T << endl;
  
}

Measured memory_bytes: 3748
import java.util.Scanner;

class Main {

    static long lcm (long a, long b) {
	long temp;
	long c = a;
	c *= b;

	while((temp = a % b) != 0) {
	    a = b;
	    b = temp;
	}

	return c / b;
    }
    
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);

	long A, B;
	A = sc.nextLong();
	B = sc.nextLong();

	System.out.println(lcm(A, B));
    }
}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a,b;
    cin>>a>>b;
    // cout<<a<<" "<<b;
    char array[a.length()+1][b.length()+1];
    int arr[a.length()+1][b.length()+1];
    for(int i=0;i<=a.length();i++)
    {
        for(int j=0;j<=b.length();j++)
        {
            if(i==0 || j==0)
            {
                arr[i][j]=0;
            }
            else if(a[i-1]==b[j-1])
            {
                array[i][j]='c';
                arr[i][j]=1+arr[i-1][j-1];
                // cout<<arr[i][j];
            }
            else if(arr[i-1][j]>=arr[i][j-1])
            {
                array[i][j]='u';
                arr[i][j]=arr[i-1][j];
            }
            else
            {
                array[i][j]='l';
                arr[i][j]=arr[i][j-1];
            }
        }
    }
    vector<char> v;
    int i=a.length(),j=b.length();
    while(i>0 && j>0)
    {
        if(array[i][j]=='c')
        {
            v.push_back(a[i-1]);
            i--;
            j--;
        }
        else if(array[i][j]=='u')
        {
            i--;
        }
        else {
            j--;
        }
    }
    for(int i=v.size()-1;i>=0;i--)cout<<v[i];
    
    return 0;
}

Measured memory_bytes: 44288
r,c,n = map(int,input().split())
a = [list(map(int, input().split())) for _ in range(n)]
iru = []
for i in range(n):
  if ((a[i][0] == 0 or a[i][0] == r or a[i][1] == 0 or a[i][1] == c) and (a[i][2] == 0 or a[i][2] == r or a[i][3] == 0 or a[i][3] == c)):
    b = a[i]
    b1 = [b[0],b[1]]
    b2 = [b[2],b[3]]
    if b1[0] == 0:
      b1 = b1[1]
    elif b1[1] == c:
      b1 = b1[0] + b1[1]
    elif b1[0] == r:
      b1 = c +r+c -b1[1]
    else:
      b1 = c*2 + r*2 - b1[0]
      
    if b2[0] == 0:
      b2 = b2[1]
    elif b2[1] == c:
      b2 = b2[0] + b2[1]
    elif b2[0] == r:
      b2 = c*2 +r -b2[1]
    else:
      b2 = c*2 + r*2 - b2[0]
    if b1 > b2:
      tmp = b1 +0
      b1 = b2 +0
      b2 = tmp + 0
    iru.append([b1,b2])
iru = sorted(iru)
ato = 0
stack = [r+r+c+c]
flag = 'YES'
for a,b in iru:
  while a >= stack[-1]:
    stack.pop()
 
  if b > stack[-1]:
    flag = 'NO'
    break
  else:
    stack.append(b)
 
print(flag)

Measured memory_bytes: 45308
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep (i, n) {
    cin >> v[i];
  }
  vector<int> v2 = v;
  sort(v.begin(), v.end());
  int count = 0;
  rep (i, n) {
    if (v[i] != v2[i]) count++;
  }
  if (count == 0 || count == 2) YES;
  else NO;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void solve(){
  int x;
  cin>>x;
  cout<<(1-x)<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main()
{
    int n; cin >> n;
    vector<ll> a(n);rep(i,n)cin >> a[i];
    ll ans = 0;
    ll sum = 0;
    ll temp_xor = 0;
    int left = 0;
    int right = 0;
    for( left= 0; left < n; left++)
    {
        if(left>right)
        {
            right = left;
        }
        while(right < n && (sum+a[right])==(temp_xor^a[right]))
        {
            sum += a[right];
            temp_xor = temp_xor^a[right];
            //cout << sum << " " << temp_xor << endl;
            right++;
        }
        
        ans += right-left;
        // cout << right << endl;
        sum = sum-a[left];
        temp_xor = a[left]^temp_xor;
    }
    cout << ans << endl;
    

}

Measured memory_bytes: 1792
from __future__ import print_function
import sys

if sys.subversion[0] == "PyPy":
    import io, atexit

    sys.stdout = io.BytesIO()
    atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

    sys.stdin = io.BytesIO(sys.stdin.read())
    input = lambda: sys.stdin.readline().rstrip()
RS = raw_input
RA = lambda x=int: map(x, RS().split())
RN = lambda x=int: x(RS())


def solve():
    s = 0
    for ai in a:
        s ^= ai
    ans = []
    for ai in a:
        ans.append(s ^ ai)
    print(*ans)
    return




n = RN()
a = RA()
solve()


Measured memory_bytes: 115420
def main():
  #n = int(input())
  #s = input()
  #s = input().split()
  #a,b = list(map(int,input().split()))
  #a = [list(map(int,input().split())) for i in range(6)]
  a = [int(input()) for i in range(5)]
  ans = 0
  hi = 9 
  count = 0
  
  for i in range(5):
    if a[i] % 10 >= 1:
      ans += a[i] + (10-a[i]%10)
      hi = min(hi,a[i]%10) 
    else:
      ans += a[i]
      count += 1

  if count == 5:
    print(ans)
  else:
    print(ans-10+hi)
  
      
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int k = 38; int n = k * k - k + 1;
	cout << n << " " << k << endl;
	int trans[38];
	rep(i, k) {
		cout << 1;
		int s = 1 + i * (k - 1);
		Rep(j, s, s + k - 1) {
			cout << " " << j + 1;
		}
		cout << endl;
	}
	rep(i, k - 1) {
		rep(j, k - 1) {
			trans[j] = (i + j) % (k - 1);
		}
		rep(j, k - 1) {
			cout << i + 2;
			int now = j;
			rep(l, k - 1) {
				int s = k + l * (k - 1) + now;
				now = trans[now];
				cout << " " << s + 1;
			}
			cout << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
	int N,M;
	cin>>N>>M;
	int A[M],total;
	for(int i=0;i<M;i++){
		cin>>A[i];
		total+=A[i];
	}
	if(total>N)cout<<"-1"<<endl;
	else cout<<N-total<<endl;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
LL N, K;
VEC<LL> A;
LL answer(LL x) {
  LL sum = 0;
  REP(i, 0, N) {
    sum += (x xor A[i]);
    // DUMP(sum, x, A[i], x xor A[i]);
  }
  return sum;
}
/* test case
3 2
2 0 0

this: 5
true: 5
my previous wrong sub(but AC): 4
*/
int main() {
  cin >> N >> K;
  A = VEC<LL>(N);
  REP(i, 0, N) cin >> A[i];
  LL ma = pow(2, (LL)log2(K+1));
  DUMP(ma);
  LL x = 0;
  LL ans = 0;
  for (LL digit = ma; digit > 0; digit >>= 1) {
    if (((K + 1) & digit) == 0) continue;
    x = K + 1 - digit;
    for (LL i = (digit >> 1); i > 0; i >>= 1) {
      if ((x & i) > 0) x -= i;
    }

    for (LL bit = (digit >> 1); bit > 0; bit >>= 1) {
      // DUMP("bit: ", bit);
      LL cnt = 0;
      REP(i, 0, N) {
        // if on
        if ((bit & A[i]) > 0) {
          ++cnt;
        }
      }
      // DUMP("cnt: ", cnt);
      if (cnt < (double)N / 2) x += bit;
    }
    ans = max(ans, answer(x));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
// *
// *
// *  Created By :hozaifa wahid
// * "mai maut ko takia aur kafan ko chadar banakar sota hu" 
// *------------------------------------
// *  OS : Ubuntu 16.04
// *  Language : CPP14
// *  Editor : Sublime Text 3
// *  C++ compiler : g++
// *https://www.geeksforgeeks.org/space-and-time-efficient-binomial-coefficient/
// *https://www.geeksforgeeks.org/binomial-coefficient-dp-9/
//https://www.geeksforgeeks.org/compute-ncr-p-set-2-lucas-theorem/
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define inf 1000000007
#define fr first
#define sc second
#define eps 1e-9
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define sni(x) scanf("%d",&x)
#define snl(x) scanf("%lld", &x)
#define snc(x) scanf("%c", &c);
#define rep(n) for(int i = 0 ; i < n ;i ++)
#define repc(i, n) for(int i = 0 ; i < n ; i ++)
#define FOR(i, x, y) for(int i = x ; i < y ; i ++)
#define DEC(i, x, y) for(int i = x ; i >= y ; i --)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b,c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a+n
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
ll MOD=1000000007;
ll C[2005][2005];
ll min(ll a,ll b)
{
 return a<b?a:b;
}
 
 
ll pw(ll a,ll b){
    if(b==0) return 1;
    ll x=pw(a,b/2);
    x=(x*x)%MOD;
    if(b%2) x=(x*a)%MOD;
    return x;
}
ll comb2(ll n,ll k, ll x)
{
ll res = 1LL; 
  
   
    if ( k > n - k ) 
        k = n - k; 
  
   
    for (int i = 0; i < k; ++i) 
    { 
        res = (res%MOD*(n - i)%MOD)%MOD; 
        res =(res%MOD* pw((i + 1),MOD-2)%MOD)%MOD; 
    } 
  
    //return res; 
return res%MOD;
}


void solve()
{
//comb(2001,2001);
std::ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
ll t;
t=1;

while(t--)
{
    ll n;
   cin>>n;
   map<pair<ll,ll>,ll>mp;
   ll x,y;
   FOR(i,0,n)
   cin>>x>>y,mp[{x,y}]++;
   ll mini=1000000000000000000,maxi=-1000000000000000000;
   ll mini1=1000000000000000000,maxi1=-1000000000000000000;
   for(auto it:mp)
   {
     mini=min(mini,it.first.first+it.first.second);
      maxi=max(maxi,it.first.first+it.first.second);
      mini1=min(mini1,it.first.first-it.first.second);
      maxi1=max(maxi1,it.first.first-it.first.second);
   }
   cout<<max(abs(mini-maxi),abs(mini1-maxi1));
   
 
}
}
 
 
 
int main(){
    std::ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    
    solve();
    
}
 
 
 
 
 
 
 
 
 
 

Measured memory_bytes: 16140
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long int ll;
template<typename T> T changeMax(T& a, T b){if(a < b)a = b;return 0;}

int main()
{
    int a, b;
    cin >> a >> b;
    cout << a-b+1 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define NIL NULL
 
typedef struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
}*N;
 
N root = NIL;

void insert(int);
void inorder(N);
void preorder(N);
 
int main(){
  int m, i, n;
  char str[256];

  scanf("%d", &m);
 
  for(i = 0; i < m; i++){
    scanf("%s", str);
    if(strcmp(str, "insert") == 0){
      scanf("%d", &n);
      insert(n);
    }else if(strcmp(str, "print") == 0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
 
  return 0;
}
  
void insert(int v){
  N y = NIL, x = root, z;

  z = malloc(sizeof(struct node));
  z->key = v;
  z->left = z -> right = NIL;
     
  while(x != NIL){
    y = x;
    if(z->key < x->key)   x = x->left;
    else                  x = x->right;
  }

  z->parent = y;

  if(y == NIL)               root = z;
  else if(z->key < y->key)   y->left = z;
  else                       y->right = z;
}
 
void inorder(N u){
  if(u->left != NIL)     inorder(u->left);
  printf(" %d",u->key);
  if(u->right != NIL)    inorder(u->right);
}

void preorder(N u){
  printf(" %d",u->key);
  if(u->left != NIL)     preorder(u->left);
  if(u->right != NIL)    preorder(u->right);
}

Measured memory_bytes: 24036
//
// Created by kashi on 27-07-2020.
//
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define Endl endl
#define int long long
int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}
bool cmps(pair<int,int>p1,pair<int,int>p2) {
    return p1.ss<p2.ss;
}
int lcm(int a, int b){
    return (a*b)/gcd(a, b);
}

int32_t main() {
    int d,t,s;
    cin>>d>>t>>s;
    if(s*t>=d)
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;

}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;

int main(){
    int n,mm;cin>>n>>mm;
    map<int,int> m;
    vector<pair<int,int> > v(n);
    for(int i=0;i<mm;i++){cin>>v[i].first>>v[i].second;
        if(m[v[i].first]&&m[v[i].first]!=v[i].second){
            cout<<-1;return 0;
        }
        m[v[i].first]=v[i].second;
        if(n!=1){
            if(v[i].first==1&&v[i].second==0){cout<<-1;return 0;}
        }
    }
        bool ok=0;
        if(n==1){
            for(int i=0;i<10;i++){
                ok=1;
                string s=to_string(i);
                for(int j=1;j<=s.length();j++){
                   if(m[j]) if(s[j-1]!=m[j]+'0'){ok=0;break;}
                }
                if(ok){cout<<i;return 0;}
            }
        }
        if(n==2){
            for(int i=10;i<100;i++){
                ok=1;
                string s=to_string(i);
                for(int j=1;j<=s.length();j++){
                   if(m[j]) if(s[j-1]!='0'+m[j]){ok=0;break;}
                   else continue;
                }
                if(ok){cout<<i;return 0;}
            }
        }
        if(n==3){
            for(int i=100;i<1000;i++){
                ok=1;
                string s=to_string(i);
                for(int j=1;j<=s.length();j++){
                    if(m[j])if(s[j-1]!='0'+m[j]){ok=0;break;}
                }
                if(ok){cout<<i;return 0;}
            }
        }
        cout<<-1;
    }

Measured memory_bytes: 256
N=gets.to_i
a = gets.split.map(&:to_i)
num_odd = a.select(&:odd?).size
num_2 = a.select{|ai| ai%2==0&&ai%4!=0}.size
num_4 = a.select{|ai| ai%4==0}.size
if num_4 >= num_odd
  puts N == num_2+num_4+num_odd ? 'Yes' : 'No'
elsif num_4 == num_odd-1
  puts num_2 == 0 ? 'Yes' : 'No'
else
  puts 'No'
end

Measured memory_bytes: 9228
N=int(input())
XY=[list(map(int,input().split())) for i in range(N)]
from itertools import permutations
r=0
for xy in permutations(XY):
    for i in range(N-1):
        r+=((xy[i][0]-xy[i+1][0])**2+(xy[i][1]-xy[i+1][1])**2)**.5
p=1
for i in range(N):
    p*=i+1
print(r/p)

Measured memory_bytes: 3188
n,m=map(int,input().split())
def f(n):
    c=1
    for i in range(1,n+1):
        c*=i
        if c>=(10**9+7):
            c=c%(10**9+7)
    return c
if abs(n-m)==1:
    s=f(n)*f(m)%(10**9+7)
    print(s)
elif n==m:
    s=f(n)*f(m)*2%(10**9+7)
    print(s)
else:
    print(0)
#print(f(100))

Measured memory_bytes: 3064
n = int(input())
ans = 0
last_a = 0
start_b = 0
sl_ba = 0
for i in range(n):
    s = input()
    ans += s.count("AB")
    if s.rfind("A") == len(s) - 1:
        last_a += 1
    if s.find("B") == 0:
        start_b += 1
    if s.find("B") == 0 and s.rfind("A") == len(s) - 1:
        sl_ba += 1
ans += min(last_a, start_b)
if sl_ba >= 2 and last_a == sl_ba and start_b == sl_ba:
    ans -= 1
print(ans)

Measured memory_bytes: 44648
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define int long long
using namespace std;
typedef pair<int,int> P;
//void read(int &N,int &M,vector<vector<int>> &g,vector<int>&p);
signed main(){
    int N,M;
    vector<vector<int>> to(N);
    vector<int> p(N);
    cin>>N>>M;
    REP(i,M){
        int k;cin>>k;
        REP(j,k){
            int s;cin>>s;
            s--;
            to[s].push_back(i);
        }
    }
    REP(i,M) cin>>p[i];
    int ans=0;
    REP(i,1<<N){//2^nパターン列挙
        vector<int> bulb(M,0);
        REP(j,N){//スイッチjに対してビット走査
            int bit=(i>>j)&1;
            if(bit==1) REP(k,to[j].size()) bulb[to[j][k]]++;
        }
        bool ok=true;
        REP(j,M) if(bulb[j]%2!=p[j]) ok=false;
        if(ok) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

//void read(int &N,int &M,vector<vector<int>> &g,vector<int>&p){
    
//}

Measured memory_bytes: 197120
'''A - Five Antennas
https://atcoder.jp/contests/abc123/tasks/abc123_a

>>> main([1, 2, 4, 8, 9], 15)
Yay!
>>> main([15, 18, 26, 35, 36], 18)
:(

in1.txt
>>> main([0, 7, 9, 52, 123], 123)
Yay!'''

from itertools import permutations


def main(_input, k):
    for p in permutations(_input, 2):
        if p[0] - p[1] > k:
            print(':(')
            return

    print('Yay!')


if __name__ == "__main__":
    _input = []

    for _ in range(5):
        _input.append(int(input()))

    k = int(input())

    main(_input, k)


Measured memory_bytes: 3064
//https://atcoder.jp/contests/abc140/tasks/abc140_a
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
// clang-format on
int main()
{
    int N;
    cin >> N;
    cout << pow(N, 3) << endl;
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
	int n,i;
	float a,x;
	scanf("%d",&n);
	x=0.0000000;
	for(i=0;i<n;i++){
		scanf("%f",&a);
		x+=1/a;
	}
	printf("%f\n",1/x);
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>

using namespace std;
bool f[100010];

int main(){
	int n, ans = 0;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
		if(i != a[i] - 1) f[i] = true;
	}
	for(int i = 0; i < n; i++){
		if(!f[i]){
			ans++;
			f[i] = true;
			f[i + 1] = true;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 768
import bisect

n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
a.sort()
c.sort()
cnt = 0
for i in b:
    a_i = bisect.bisect_left(a,i)
    c_i = bisect.bisect_right(c,i)
    cnt += a_i * (n - c_i)
print(cnt)

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

int main(){
    int n;
    cin>>n;
    for(int i=0; i<=n+4; i+=4){
        for(int j=0; i+j<=n; j+=7){
            if(i+j==n){
                cout<<"Yes\n";
                return 0;
            }
        }
    }
    cout<<"No\n";
    return 0;
}


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

void bubbleSort(int A[], int N);
void trace(int A[], int N);

int main(void)
{
	int N;
	int A[100];

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

	bubbleSort(A, N);

	
}

void bubbleSort(int A[], int N)
{
	int count = 0;
	int flag = 1;
	int i = 1;
	while(flag)
	{
		flag = 0;
		for(int j = N - 1; j > i - 1; j--)
		{
			if(A[j] < A[j - 1])
			{
				int box = A[j];
				A[j] = A[j - 1];
				A[j - 1] = box;
				flag = 1;
				count++;
			}
		}
	}
	trace(A, N);
	cout << count << endl;
}

void trace(int A[], int N)
{
	for(int i = 0; i < N; i++)
	{
		if(i > 0)
			cout << " ";
		cout << A[i];
	}
	cout << "\n";
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,t;
	cin>>s>>t;
	int ans=0;
	for(int i=0;i<t.size();i++)
	{
		if(s[i]!=t[i])
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

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


int main()
{
  int n;
  cin >> n;
  vector<ll> v(n, 0);
  for (int i = 0; i < n; i++){
    cin >> v[i];
  }
  vector<ll> tmp(n,0);
  tmp = v;
  sort(tmp.begin(), tmp.end());
  ll center1 = tmp[n/2 - 1];
  ll center2 = tmp[n/2];
  // cout << center1 << endl;
  // cout << center2 << endl;

  for(ll i : v){
    if (i <= center1) {
      cout << center2 << endl;
    }else if (i >= center2){
      cout << center1 << endl;
    }
  }

  return 0;
}


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

int main() {

  vector<int> vec; // int型の配列変数vecを宣言
  int K;
  cin >> K;

  vec = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 }; // 25, 100, 64 という整数(int)の列を代入

  cout << vec.at(K - 1) << endl; // 1つめである25を出力

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
struct XY{
  int x;
  int y;
};
int main(){
  //W,H,x,y,r
  int W,H,r;
  XY o;
  cin >> W >> H >> o.x >> o.y >> r;

  XY deg0   = {o.x + r, o.y};
  XY deg90  = {o.x, o.y + r};
  XY deg180 = {o.x - r, o.y};
  XY deg270 = {o.x, o.y - r};

  if( deg0.x >= 0 &&  deg0.x <= W && deg0.y >= 0 &&  deg0.y <= H &&
      deg90.x >= 0 &&  deg90.x <= W && deg90.y >= 0 &&  deg90.y <= H &&
      deg180.x >= 0 &&  deg180.x <= W && deg180.y >= 0 &&  deg180.y <= H &&
      deg270.x >= 0 &&  deg270.x <= W && deg270.y >= 0 &&  deg270.y <= H    )
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }

  return 0;
}



Measured memory_bytes: 3096
from collections import defaultdict

def mapt(fn, *args):
    return tuple(map(fn, *args))


def Atom(strings):
    return int(strings) if strings.isdigit() else strings


def symmetric(setseq):
    a = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}
    return a^setseq

    
n = int(input())
dataset = [mapt(Atom, input().split(" ")) for i in range(n)]
a = defaultdict(list)

for key, value in dataset:
    a[key].append(value)

for key, value in a.items():
    a[key] = symmetric(set(value))
    
for i in ("S", "H", "C", "D"):
    for value in (a.get(i)):
        print(i, value)


Measured memory_bytes: 6000
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    string s,t;cin>>s>>t;
    cout<<(t.substr(0,s.length())==s?"Yes":"No")<<endl;
}


Measured memory_bytes: 3600
n,k=map(int,input().split())
a=list(map(int,input().split()))
mod=10**9+7
c=[]
ans=0
for i in range(2002):
    c.append([0,0])
for i in range(n):
    c[a[i]][0]+=1
    for j in range(a[i]+1,2001):
        ans+=c[j][0]
for i in range(1999,-1,-1):
    c[i][0]+=c[i+1][0]
d=0
for i in a:
    d+=c[i+1][0]
print((k*ans+d*(k*(k-1))//2)%mod)

Measured memory_bytes: 3316
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cmath>
#include<iomanip>
#include<set>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;

int main() {
    int h, w; cin >> h >> w;
    int cnt = 0;
    char a[h][w]; rep(i, h) rep(j, w) {cin >> a[i][j]; if (a[i][j] == '#') cnt++;}
    if (cnt == h + w - 1) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}




Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] A = new int[N];
		for (int i=0;i<N;i++) {
			A[i]=sc.nextInt();
		}
		int cnt=0;
		List<int[]> b_c = new ArrayList<int[]>();
		for (int i=0;i<M;i++) {
			int b=sc.nextInt();
			if (cnt<100005) {
				cnt+=b;
			}
			int c=sc.nextInt();
			int[] b__c={b,c};
			b_c.add(b__c);
		}
		Arrays.sort(A);

        Comparator<int[]> comparator = new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                return Integer.valueOf(o2[1]).compareTo(Integer.valueOf(o1[1]));
            }
        };
        Collections.sort(b_c,comparator);

        List<Integer> C = new ArrayList<Integer>();
        int len=0;
        loop:for (int i=0;i<M;i++) {
        	int b=b_c.get(i)[0];
        	int c=b_c.get(i)[1];
        	for (int j=0;j<b;j++) {
        		C.add(c);
        		len++;
        		if (len>100005) {
        			break loop;
        		}
        	}
        }
 //       System.out.println(Arrays.toString(A));
   //     System.out.println(C);

        for (int i=0;i<Math.min(cnt,N);i++) {
        	if (A[i]<=C.get(i)) {
        		A[i]=C.get(i);
        	} else {
        		break;
        	}
        }
        long ans=0L;
        for (int i=0;i<N;i++) {
        	ans+=(long)A[i];
        }
        System.out.println(ans);

	}
}

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

bool beki[1000];

int main()
{
    int N, M;
    cin >> N;
    vector<int> T;
    for (int i = 0; i < N; i++)
    {
        int temp;
        cin >> temp;
        T.push_back(temp);
    }
    int sum = accumulate(T.begin(), T.end(), 0);
    cin >> M;
    int ans[110] = {};
    for (int i = 0; i < M; ++i)
    {
        int p, x;
        cin >> p >> x;
        ans[i] = sum - T[p - 1] + x;
    }
    for (int i = 0; i < M; ++i)
    {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 256
n=int(input())
N=n
a=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
t=1
for i in range(1,20):
    if n>26**i:
        n=n-26**i
        t+=1
p=[0]*t
s=0
A=""
for i in range(1,t+1):
    s=N%26
    if s==0:
        s=26
    N=(N-s)//26
    p[t-i]=s
for i in range(t):
    A+=(a[p[i]-1])
print(A)

Measured memory_bytes: 62124
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>

using namespace std;
typedef long long int ll;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)
#define MOD 1000000007

int main(){
  string L;
  cin >> L;
  ll len = L.size();
  ll ans = 0;
  ll pow3[len];
  pow3[0] = 3;
  repi(i, 1, len) pow3[i] = (pow3[i-1] * 3) % MOD;
  ans = L[len-1] == '1' ? 3 : 1;
  repi(i, 1, len){
    if(L[len-i-1] == '1') ans = (ans * 2 + pow3[i-1]) % MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1280
#include <stdio.h>

int main(void)
{
	int a[11][11];
	int n, i, j;

	scanf("%d", &n);
	while (n != 0)
	{
		for (i = 0; i < n; i++)
			for (j = 0; j < n; j++)
				scanf("%d", &a[i][j]);

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

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

		for (i = 0; i <= n; i++)
		{
			for (j = 0; j <= n; j++)
				printf("%5d", a[i][j]);
			printf("\n");
		}
		
		scanf("%d", &n);
	}

	return 0;
}

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

int main() {
  string s;
  cin >> s;
  string a = "", b = "";
  a += s[0];
  a += s[1];
  b += s[2];
  b += s[3];
  vector<string> vec = {"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"};
  bool YYMM = false, MMYY = false;
  for (int i = 0; i < 12; i ++) {
    if (a == vec[i]) MMYY = true;
    if (b == vec[i]) YYMM = true;
  }

  if (MMYY && YYMM) {
    cout << "AMBIGUOUS" << endl;
  } else if (MMYY) {
    cout << "MMYY" << endl;
  } else if (YYMM) {
    cout << "YYMM" << endl;
  } else {
    cout << "NA" << endl;
  }
}

Measured memory_bytes: 256