akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll n;
  cin>>n;
  vll x(n);
  vll y(n);
  rep(i,n) {
    cin>>x[i];
    y[i]=x[i];
  }
  sort(all(y));
  ll k=y[n/2];
  rep(i,n){
    ll g=x[i];
    if(g<k){
      COUT(k);
    }
    else{
      COUT(y[n/2-1]);
    }
  }
}

Measured memory_bytes: 5376
#include <iostream>

int main(void) {
    auto K = 0;
    auto X = 0;
    std::cin >> K >> X;
    if (K*500 >= X) {
        std::cout << "Yes" << std::endl;
    }
    else {
        std::cout << "No" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
in_val = input()
temp_val = int(in_val) % 10
if(temp_val == 2 or temp_val == 4 or temp_val == 5 or temp_val == 7 or temp_val == 9):
  print("hon")
if(temp_val == 0 or temp_val == 1 or temp_val == 6 or temp_val == 8):
  print("pon")
if(temp_val == 3 ):
  print("bon")

Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e18;

int main()
{
	int n,m,x;
  cin>>n>>m>>x;
  int c[n],A[n][m];
  for(int i=0;i<n;i++)
  {
    cin>>c[i];
    for(int j=0;j<m;j++)
  	{
    	cin>>A[i][j];
    }
  }
   int ans = INF;
    
    for (int bit = 0; bit < (1<<n); bit++) {
        vector<int> tmpc(n);
        //memset(tmpc,0,sizeof(tmpc));
        int tmpans = 0;
        
        for (int i = 0; i < n; i++) {
            if((bit>>i) & 1) {
                tmpans += c[i];
                for (int j = 0; j < m; j++) {
                    tmpc[j] += A[i][j];
                }
            }
        }
        
        bool isCan = true;
        for (int i = 0; i < m; i++) {
            if(tmpc[i] < x) isCan = false;
        }
        if(isCan) ans = min(ans,tmpans);
        
    }
    
    cout << ((ans==INF)?-1:ans) << endl;
  return 0;
}
 

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t,a;
  while(1){
    cin>>s;
    if(s=="-")break;
    cin>>t>>a;
    int cnts=1,cntt=0,cnta=0;
    char tmp=s[0];
    string ans="",ta="";
    while(cnts<s.size()||cntt<t.size()){
      if(cnta<a.size()&&tmp==a[cnta]){
	ta.push_back(tmp);
	cnta++;
	if(cnts<s.size())tmp=s[cnts++];
	else tmp=t[cntt++];
      }else{
	ans.push_back(tmp);
	if(cntt<t.size())tmp=t[cntt++];
	else tmp=s[cnts++];
      }
    }
    if(tmp!=a[a.size()-1])ans.push_back(tmp);
    if(ta==a){
      cout<<ans<<endl;
      continue;
    }
    cnts=0,cntt=1,cnta=0;
    tmp=t[0];
    ans="",ta="";
    while(cnts<s.size()||cntt<t.size()){
      if(cnta<a.size()&&tmp==a[cnta]){
	ta.push_back(tmp);
	cnta++;
	if(cnts<s.size())tmp=s[cnts++];
	else tmp=t[cntt++];
      }else{
	ans.push_back(tmp);
	if(cntt<t.size())tmp=t[cntt++];
	else tmp=s[cnts++];
      }
    }
    if(tmp!=a[a.size()-1])ans.push_back(tmp);
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3144
#include<stdio.h>
const int inf=2147483647,mx=100;
void fmax(int&a,int b){
	if(b>a)a=b;
}
void fmin(int&a,int b){
	if(b<a)a=b;
}
int d[20][20],f[110][110];
int main(){
	int A,B,i,j,k,l,t;
	scanf("%d%d",&A,&B);
	for(i=1;i<=A;i++){
		for(j=1;j<=B;j++)scanf("%d",d[i]+j);
	}
	for(i=0;i<=mx;i++){
		for(j=0;j<=mx;j++){
			t=0;
			for(k=1;k<=A;k++){
				for(l=1;l<=B;l++)fmax(t,d[k][l]-i*k-j*l);
			}
			f[i][j]=t;
		}
	}
	for(i=1;i<=A;i++){
		for(j=1;j<=B;j++){
			t=inf;
			for(k=0;k<=mx;k++){
				for(l=0;l<=mx;l++)fmin(t,i*k+j*l+f[k][l]);
			}
			if(t!=d[i][j]){
				puts("Impossible");
				return 0;
			}
		}
	}
	printf("Possible\n%d %d\n",mx*2+2,mx*2+(mx+1)*(mx+1));
	for(i=1;i<=mx;i++)printf("%d %d X\n",i,i+1);
	for(i=mx+2;i<=2*mx+1;i++)printf("%d %d Y\n",i,i+1);
	for(i=0;i<=mx;i++){
		for(j=0;j<=mx;j++)printf("%d %d %d\n",1+i,2*mx+2-j,f[i][j]);
	}
	printf("%d %d",1,mx*2+2);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define debugP int debug_point; cin>>debug_point;
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
ll pown(ll fi,ll se){
  ll ans=1;
  rep(i,se){
    ans*=fi;
  }
  return ans;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}

/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/



int main(){
  ll n;
  cin>>n;
  string a;
  cin>>a;
  ll ans=0;
  ll Ans=LLONG_MAX;
  ll b=0;
  ll w=0;
  rep(i,a.size()){
    if(a[i]=='.')w++;
    else b++;
  }
  Ans=w;
  ans=w;
  ll tmp=0;
  rep(i,a.size()){
    if(a[i]=='.'){
      tmp=(ans-1);
    }else {
      tmp=(ans+1);
    }
    ans=tmp;
    //op(ans);
    Ans=min(Ans,ans);
    
  }
  op(Ans);
  return 0;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mp make_pair
#define vi vector<int>
#define ppi pair<int,pi>
#define ld long double
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << end
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define f(i, begin, end) for (__typeof(end) i = (begin); i != (end) ; i += 1 - 2 * ((begin) > (end)))
#define nl cout<<"\n";
#define par(a,n) f(i,0,n) cout<<a[i]<<" "; nl
//void prt(int x) {cerr << x;}
#define vv(n,m) vector <vector <int> > v(n, vector <int> (m));

#define er(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... brgs>
void err(istream_iterator<string> it, T a, brgs... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);	
}
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
typedef pair<int,int> pii;
typedef vector<pii> vpii;
const int mod = 1000000007;
const int N = 3e5;

int kadane(int*a, int n);
bool isPrime(int n);
int mpow(int a, int b);


void solve(){
    int n;
    cin>>n;
    int a[n];
    f(i,0,n) cin>>a[i];
    
      int x=0;
      f(i,0,n-1) x^=a[i];
    f(i,0,n){
      int aixoran =a[i]^a[n-1];
      int ai= aixoran^x;
      cout<<ai<<" ";
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // int t;
    // cin>>t;
    // while(t--)
    solve();
}

int mpow(int a, int b){ /* pow(a, b) % m */
  int m=mod;
  int x=1;
  while (b>0){
    if (b&1){
      x=(x * a) % m;
    }
    a=(a*a) % m; /* compute the next power of 2 */
    b>>=1; /* this is equivalent to b = floor(b / 2) */
  }
  return x;
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
    return true; 
} 

int kadane(int*a, int n){
    int max_so_far = INT_MIN, max_ending_here = 0;
    f(i,0,n){
        max_ending_here+=a[i];
        max_so_far = max(max_so_far, max_ending_here);
        if(max_ending_here<0) max_ending_here=0;
    }
    return max_so_far;
}

Measured memory_bytes: 5108
#include<bits/stdc++.h>
using namespace std;
int a[20];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	int sum=0;
	for(int i=1;i<n;i++)
		sum+=a[i];
	cout<<(sum>a[n]?"Yes":"No")<<endl;
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
n=int(input())
a=list(map(int,input().split()))
d=defaultdict(int)
for i in range(n):
    d[i+1-a[i]]+=1
ans=0
for i in range(n):
    ans+=d[i+1+a[i]]
print(sum(d[i+1+a[i]] for i in range(n)))

Measured memory_bytes: 128264
//all possible//
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d,e,f;
	cin>>a>>b>>c;
	e=a*100+b*10+c;
	if(e%4==0)
	cout<<"YES";
	else
	cout<<"NO";
	

}


Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)
s = gets.chomp

a = s.split(/(?<=0)(?=1)|(?<=1)(?=0)/).map(&:size)

if s[0] == '0'
  a.unshift(0)
end
if s[-1] == '0'
  a.push(0)
end

sum = a.inject([]) do |memo, item|
  memo << ((memo.last || 0) + item)
end

ans = 0.step([0, a.size - k*2].max, 2).map do |i|
  sum[[i + k*2, a.size - 1].min] - (i == 0 ? 0 : sum[i - 1])
end.max

puts ans


Measured memory_bytes: 11900
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

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

int main() {
	double N,K;
	cin>>N>>K;
	double ans = 0;
	cerr<<1.0/N<<endl;
	rep1(i,N+1){
		int x = int(log2f(K/double(i)))+1;
		if(log2f(K/double(i)) == int(log2f(K/double(i)))){
			x--;
		}
		if(i>=K){
			ans+=1.0/N;
			continue;
		}
		ans += 1.0/N * double(pow(0.5,x));
		cerr<<i<<": "<<x<<endl;
	}
	//cout<<ans<<endl;
	printf("%.12lf\n", ans);
}

Measured memory_bytes: 256
#include <map>
#include <vector>
#include <iostream>
using namespace std;
typedef unsigned long long ull;
const ull base = 1000000007;
int n, a, b; vector<vector<int> > G; map<ull, int> cnt;
ull solve(int pos, int pre) {
	ull ret = 1;
	for (int i : G[pos]) {
		if (i == pre) continue;
		ret += solve(i, pos) * base;
	}
	cnt[ret]++;
	return ret;
}
int main() {
	cin >> n; G.resize(n);
	for (int i = 0; i < n - 1; i++) {
		cin >> a >> b; a--, b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	solve(0, -1);
	ull ret = 0;
	for (pair<ull, int> i : cnt) ret += 1ULL * i.second * (i.second - 1) / 2;
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 20772
#include <bits/stdc++.h>
#define INF (1<<30)
#define INFLL (1ll<<60)
#define EPS (1e-10)
using namespace std;
map <int,int> mp;
typedef pair<int, int> P;
typedef long long ll;
static const int MAX=100000;
static const int NMAX=100;
int cunt;
int main(){
    int K,S; cin>>K>>S;

    for(int x=0;x<=K;x++){
        for(int y=0;y<=K;y++){
            if((x+y)<=S&&(x+y)>=S-K)cunt++;
        }
    }
    cout<<cunt<<"\n";
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    vector<char> ans;
    string s;
    cin >> s;

    int n = s.size();
    rep(i, n) {
        if (s[i] == 'B') {
            if (ans.size()) ans.pop_back();
        } else {
            ans.push_back(s[i]);
        }
    }
    rep(i, ans.size()) cout << ans[i];
    cout << endl;
}


Measured memory_bytes: 3636
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue


sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, k = ns()
    a = na()

    for _ in range(k):
        imos = [0 for _ in range(n)]

        for i, ai in enumerate(a):
            imos[max(0, i - ai)] += 1
            if i + ai + 1 < n:
                imos[i + ai + 1] -= 1

        val = 0
        for i, im in enumerate(imos):
            val += im
            a[i] = min(val, n)

        if min(a) == n:
            break

    print(*a, sep=" ")


if __name__ == '__main__':
    main()


Measured memory_bytes: 173572
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
c=Counter(a)
s=list(set(a))
p=[True]*(10**6+1)

for x in s:
    t=x*2
    while t<=10**6:
        p[t]=False
        t+=x
ans=0
for x in a:
    if c[x]==1 and p[x]==True:
        ans+=1
print(ans)



Measured memory_bytes: 44600
#include<stdio.h>
#define max 100005
#define nil -1

struct node{int p;int l;int r;};

struct node t[max];
int D[max];
int n;

void print(int u){
  int i,c;
  printf("node %d: parent = %d, depth = %d, ",u,t[u].p,D[u]);

  if(t[u].p==nil) printf("root, ");
  else if(t[u].l==nil) printf("leaf, ");
  else  printf("internal node, ");

  printf("[");

  for(i=0,c=t[u].l;c!=nil;i++,c=t[c].r){
    if(i) printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}

int rec(int u,int p){
  D[u]=p;
  if(t[u].r!=nil) rec(t[u].r,p);
  if(t[u].l!=nil) rec(t[u].l,p+1);
}

int main(){
  int i,j,d,v,c,l,r;

  scanf("%d",&n);
  for(i=0;i<n;i++) t[i].p=t[i].l=t[i].r=nil;

  for(i=0;i<n;i++){
    scanf("%d%d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0) t[v].l=c;
      else t[l].r=c;
      l=c;
      t[c].p=v;
    }
  }
  for(i=0;i<n;i++){
         if(t[i].p==nil) r=i;
  }

  rec(r,0);

  for(i=0;i<n;i++) print(i);

  return 0;
} 


Measured memory_bytes: 6380
using System.Collections.Generic;
using static System.Console;

class Program {
	static void Main() {
		var A = NextInt();
		var B = NextInt();
		var K = NextInt();

		var L = new List<int>();
		for (var i = 0; i < K; i++) {
			L.Add(A + i);
		}

		for (var j = 0; j < K; j++) {
			var tmp = B - j;
			if (!L.Contains(tmp)) {
				L.Add(tmp);
			}
		}
		L.Sort();
		foreach (var x in L) {
			if (A <= x && x <= B) {
				WriteLine(x);
			}
		}
	}

	static int NextInt() {
		return int.Parse(NextString());
	}

	static string NextString() {
		var result = new List<char>();
		while (true) {
			int next = Read();
			if (next < 0)
				break;
			var nextChar = (char)next;
			if (!char.IsWhiteSpace(nextChar))
				result.Add(nextChar);
			else if (nextChar != '\r')
				break;
		}
		return string.Join("", result);
	}
}

Measured memory_bytes: 13152
#include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;

int ceil(int x, int y) { return (x % y == 0) ? x / y : x / y + 1; }

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }

int lcm(int x, int y) { return x / gcd(x, y) * y; }

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

  int n;
  cin >> n;
  int p[n], q[n];
  for (int i = 0; i < n; i++) cin >> p[i];
  for (int i = 0; i < n; i++) cin >> q[i];

  int perm[n];
  for (int i = 0; i < n; i++) perm[i] = i + 1;

  int a = 0;
  do {
    bool ok = true;
    for (int i = 0; i < n; i++) {
      if (perm[i] != p[i]) ok = false;
    }
    if (ok) break;
    ++a;
  } while (next_permutation(perm, perm + n));

  for (int i = 0; i < n; i++) perm[i] = i + 1;
  int b = 0;
  do {
    bool ok = true;
    for (int i = 0; i < n; i++) {
      if (perm[i] != q[i]) ok = false;
    }
    if (ok) break;
    ++b;
  } while (next_permutation(perm, perm + n));

  int ans = abs(a - b);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
	char b;
	scanf("%c", &b);

	if(b == 'A') printf("T");
	if(b == 'T') printf("A");
	if(b == 'G') printf("C");
	if(b == 'C') printf("G");


	return 0;
}

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

int n, m, X;
vector<int> values; // 買うなら1、買わないなら0
vector<vector<int>> books; // 本の配列, 内側の配列に値段と理解度
int l = 100000000; //

void dfs(int x) {
    if (x == n) {
        vector<int> points(m); // 理解度の配列
        int money = 0; // トータルの値段
        rep(i,n) {
            if (values[i] == 1) {
                money += books[i][0];
                rep(j,m) {
                    points[j] += books[i][j+1];
                }
            }
        }
        bool flag = true;
        rep(i,m) {
            if (points[i] < X) {
                flag = false;
                break;
            }
        }
        if (flag) {
            l = min(l,money);
        }
    } else {
        for (int i = 0; i <= 1; ++i) {
        values[x] = i;
        dfs(x+1);
        }
    }
}

int main() {
    cin >> n >> m >> X;
    values.resize(n);
    books.resize(n);
    rep(i,n) {
        rep(j,m+1) {
            int t;
            cin >> t;
            books[i].push_back(t);
        }
    }
    dfs(0);
    if (l != 100000000) cout << l << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3608
N,M = map(int,input().split())
tree = list(map(int,input().split())) #比較用
tree_sub = list(tree) #データの削除用
for i in range(M):
    a,b = map(int,input().split())
    if tree[a-1] > tree[b-1]:
        tree_sub[b-1] = 0
    elif tree[a-1] < tree[b-1]:
        tree_sub[a-1] = 0
    else:
        tree_sub[a-1] = 0
        tree_sub[b-1] = 0
print(len(tree_sub)-tree_sub.count(0))

Measured memory_bytes: 20060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());//int型
		int[] a = new int[n];
		int ans=0;
		int max=0;
		for(int i=0; i<n; i++){
			a[i] = Integer.parseInt(sc.next());
		}
		sc.close();
		for(int i=0; i<n; i++){
			if(max<=a[i]){
				ans++;
				max=a[i];
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 23124
h,w=map(int,input().split())
ans=[]
a=[list(map(int,input().split())) for i in range(h)]
flg=True
for i in range(h):
    if flg:
        for j in range(w):
            if a[i][j]%2==1:
                if j<w-1:
                    a[i][j+1]+=1
                    ans.append((i+1,j+1,i+1,j+2))
                if j==w-1:
                    if i<h-1:
                        a[i+1][j]+=1
                        ans.append((i+1,j+1,i+2,j+1))
        flg=False
    else:
        flg=True
        for j in range(w-1,-1,-1):
            if a[i][j]%2==1:
                if j>0:
                    a[i][j-1]+=1
                    ans.append((i+1,j+1,i+1,j))
                if j==0:
                    if i<h-1:
                        a[i+1][j]+=1
                        ans.append((i+1,j+1,i+2,j+1))
print(len(ans))
for i in ans:
    print(*i)

Measured memory_bytes: 97716
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reve(a) reverse(a.begin(), a.end())
#define PI 3.14159265359
typedef long long ll;
const ll MOD = 1e9+7;

ll gcd(ll a, ll b){
  if(b==0) return a;
  return gcd(b, a%b);
}
/*ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}*/

ll lcm(ll a, ll b){
  ll g = gcd(a, b);
  b /= g;
  a *= b;
  return a;
}

//素数判定 O(√n)
bool is_prime(int64_t n){
  for(int64_t i = 2; i*i<=n; i++){
    if(n%i==0) return false;
  }
  return n!=1;
}

//約数の列挙 O(√n)
vector<int64_t> dividor(int64_t n){
  vector<int64_t> res;
  for(int64_t i=1; i*i<=n; i++){
    if(n%i==0){
      res.push_back(i);
      if(i != n/i) res.push_back(i);
    }
  }
  return res;
}

//素因数分解 O(√n)
map<int64_t, int64_t> prime_factor(int64_t n){
  map<int64_t, int64_t> res;
  for(int64_t i=2; i*i<=n; i++){
    while(n%i==0){
      res[i]++;
      n /= i;
    }
  }
  if(n != 1) res[n] = 1;
  return res;
}
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};



int main(){
  int n, m, k, i, j; cin >> n >> m >> k;
  int d=0; int ch=0;
  for(i=0; i<=n; i++){
    for(j=0; j<=m; j++){
    d = i*m;
      d += (n-i)*j;
      d -= i*j;
      if(d==k){
      cout << "Yes" << endl;
      ch=1;
      break;
    }
    }
    if(ch==1) break;
  }
  if(ch==0){
  for(i=0; i<=m; i++){
    //d = i*n;
    //cout << d << endl;
    for(j=0; j<=n; j++){
      d = i*n;
      d += (m-i)*j;
      d -= i*j;
      if(d==k){
      cout << "Yes" << endl;
      ch=1;
      break;
    }
    }
    //cout << d << endl;
    if(ch==1) break;

  }
  }
  if(ch==0) cout << "No" << endl;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 998244353
#main code here!
    n,k=MI()
    area=[LI() for i in range(k)]
    #ソース　https://juppy.hatenablog.com/entry/2018/11/17/蟻本_python_Binary_Indexed_Tree_競技プログラミング
    #A1 ... AnのBIT(1-indexed)
    m=2*n
    BIT = [0]*(2*n+1)
    #idxの一番下のbit
    #A1 ~ Aiまでの和 O(logN)
    def BIT_query(idx):
        res_sum = 0
        while idx > 0:
            res_sum += BIT[idx]%mod
            idx -= idx&(-idx)
        return res_sum%mod
    
    #Ai += x O(logN)
    def BIT_update(idx,x):
        while idx <= m:
            BIT[idx] += x%mod
            idx += idx&(-idx)
        return
    BIT_update(n+1,1)
    #print(BIT)
    for i in range(n+2,2*n+1):
        ans=0
        for j in range(k):
            l,r=area[j]
            #print(l,r)
            #print(BIT_query(i-r-1),BIT_query(i-l))
            ans=(ans+BIT_query(i-l)-BIT_query(i-r-1))%mod
        #print(ans)
        BIT_update(i,ans%mod)
        #print(BIT)
    #print(BIT)
    print((BIT_query(2*n)-BIT_query(2*n-1))%mod)
            

    
        
        
        
        
    
        
                    
            
        



        
        
        
        
        
    
if __name__=="__main__":
    main()



Measured memory_bytes: 72312
import sys
import numpy as np

input = lambda: sys.stdin.readline().rstrip()


def solve():
    a1, a2, a3 = map(int, input().split())
    s = a1 + a2 + a3
    if s <= 21:
        print('win')
    else:
        print('bust')


if __name__ == '__main__':

    solve()


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

#define times(n, i)      uptil(0, n, i)
#define rtimes(n, i)     downto((n) - 1, 0, i)
#define upto(f, t, i)    for(int _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(int _##i = (t), i = (f); i <  _##i; i++)
#define downto(f, t, i)  for(int _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(int _##i = (t), i = (f); i >  _##i; i--)
typedef long double LD;
#define long long long

#if defined(EBUG) && !defined(ONLINE_JUDGE)
#define debug true
#define ln << endl
#else
#define debug false
#define ln << '\n'
#endif
#define tb << '\t'
#define sp << ' '

#define lam [&]


signed main() { // long: 64bit
    if(!debug) {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }

    int N; scanf("%d", &N);
    cout << "ABC" << N;

    return 0;
}


Measured memory_bytes: 256
N, K, Q = list(map(int, input().split()))
A = [int(input()) for _ in range(Q)]

L = [0] * N

for i in A:
  L[i - 1] += 1

for i in range(N):
  if Q - L[i] >= K:
    print("No")
  else:
    print("Yes")

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX

signed main(){
    int H,count=0,sum=0;
    cin >> H;
    while(H>=1){
        H=(H/2);
        if (count==0) 
        {count=1;
         sum=1;
        }
        else{
        count=count*2;
        sum+=count;}
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
W, H, N = map(int, input().split())
xya = [list(map(int, input().split())) for _ in range(N)]

tW = W
tH = H

minx = 0
miny = 0

for x, y, a in xya:
    if a == 1:
        minx = max(minx, x)
    elif a == 2:
        tW = min(tW, x)
    elif a == 3:
        miny = max(miny, y)
    else:
        tH = min(tH, y)

if tW - minx >= 0 and tH - miny >= 0:
    print((tW - minx) * (tH - miny))
else:
    print(0)

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

int main() {
  int B,N,M,K,X,Y,Z;
  cin >> N;

  vector<int> P(N);

  int result = 0;
  int min;
  for(int i=0 ; i < N ; i++){
    cin >> P[i];

    if(i == 0){
      min = P[i];
    }else{
      min = std::min(P[i] ,min);
    }
    //cout << P[i] << min << endl;
    if(P[i] == min){
      result++;
      //cout << P[i] << endl;
    }
  }
  cout << result << endl;
  return(0);
}

Measured memory_bytes: 1024
#include <stdio.h>

int x[40000];

void f(int t, int sum, int *arr) {
    if (t < 1) return;
    x[arr[0]+sum] = 1;
    f(t-1, sum, arr+1);
    f(t-1, arr[0]+sum, arr+1);
}

int main() {
    int n, a[20], q;
    scanf("%d", &n);
    for(int i=0; i<n; i++) scanf("%d", a+i);
    f(n, 0, a);
    scanf("%d", &q);
    for(int i=0; i<q; i++) {
        int tmp;
        scanf("%d", &tmp);
        if (x[tmp] == 1) puts("yes");
        else puts("no");
    }
}



Measured memory_bytes: 2148
#include<bits/stdc++.h>
using namespace std;
// ABC098-A-
/*
int main(){
    int a, b;
    cin >> a >> b;
    cout << max(a + b, max(a - b, a * b)) << endl;
}
 */

// ABC099-A-

int main(){
    int a;
    bool okey = true;
    cin >> a ;
    if (a > 999) {
        okey = false;
        a -= 1000;
    }
    
    if (okey) {
        cout << "ABC" << endl;
    }else{
        cout << "ABD" << endl;
    }
}


//ABC100-A-
/*
int main(){
    int a, b;
    cin >> a >> b;
    if (a > 8 || b > 8) {
        cout << ":(" << endl;
    }else{
        cout << "Yay!" << endl;
    }
    
}
 */
//ABC101-A-
/*
int main(){
    int ans = 0;
    for (int i = 0; i < 4; i++) {
        char s;
        cin >> s;
        if(s == '+'){
            ans++;
        }else{
            ans--;
        }
    }
    cout << ans << endl;
}
*/
//ABC102-A-
/*
int main(){
    int n;
    cin >> n;
    if (n % 2 == 0) {
        cout << n << endl;
    }else{
        cout << n * 2 << endl;
    }
}
*/
//ABC102-A-
/*
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    vector<int>task;
    task = {a, b, c};
    sort(task.begin(), task.end());
    cout << task.at(2) - task.at(0) << endl;
}
*/




Measured memory_bytes: 256
#あなたは美味しいレストランを紹介する本を書くことにしました。 
#あなたは N 個のレストラン、レストラン 1、レストラン 2、…、レストラン N を紹介しようとしています。
#レストラン i は Si 市にあり、あなたは 100 点満点中 Pi 点と評価しています。
#異なる 2 個のレストランに同じ点数がついていることはありません。
#この本では、次のような順でレストランを紹介しようとしています。
#市名が辞書順で早いものから紹介していく。
#同じ市に複数レストランがある場合は、点数が高いものから紹介していく。
#この本で紹介される順にレストランの番号を出力してください

N = int(input())
l = []

for i in range(N):
    S= input().split()
    l.append([i+1, S[0], -int(S[1])])
    
l.sort(key=lambda x:x[2])
l.sort(key=lambda x:x[1])

for i in l:
    print(i[0])

Measured memory_bytes: 38384
#include <cstdio>
#include <iostream>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
using namespace std;

int N;
const int S = 1000;

struct Elem {
    bool in_room;
    int month, day, t;
    Elem() : in_room(false) {};
    Elem(int mo, int da, int h, int m) : month(mo), day(da), t(60*h+m) {
        in_room = true;
    }
};

int seg_val(int xl, int xr, int yl, int yr) {
    // x := user, y := goddess
    if(xr <= yl || yr <= xl) return 0;
    if(xl <= yl && yr <= xr) return yr - yl;
    if(yl <= xl && xr <= yr) return xr - xl;
    if(xl <= yl && yl <= xr) return xr - yl;
    return yr - xl;
}

int main() {
    while(cin >> N, N) {
        vector< pair<int, int> > seg[S][12][31];
        vector<Elem> es(S);
        for(int i=0; i<N; i++) {
            int month, day, h, m, id;
            char io;
            scanf("%02d/%02d %02d:%02d %c %03d", &month, &day, &h, &m, &io, &id);
            month--; day--;
            if(io == 'I') {
                es[id] = Elem(month, day, h, m);
            }
            else {
                assert(es[id].month == month && es[id].day == day);
                int cur_time = 60*h + m;
                // ?????????
                seg[id][month][day].push_back(make_pair(es[id].t, cur_time));
            }
        }

        vector<int> sum_time(S);
        for(int id=1; id<1000; id++) {
            for(int mo=0; mo<12; mo++) {
                for(int da=0; da<31; da++) {
                    for(auto x : seg[id][mo][da]) {
                        for(auto y : seg[0][mo][da]) {
                            int xl = x.first, xr = x.second;
                            int yl = y.first, yr = y.second;
                            sum_time[id] += seg_val(xl, xr, yl, yr);
                        }
                    }
                }
            }
        }
        cout << *max_element(sum_time.begin(), sum_time.end()) << endl;
    }
    return 0;
}

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

int main(void) {
	int a, b,c;
	c = 0;
	while (cin >> a >> b && (a != 0 || b != 0)) {
		c = 0;
		for (int i = 1; i <= a; i++) {
			for (int j = i + 1; j <= a; j++) {
				for (int k = j + 1; k <= a; k++) {
					if (i + j + k == b) c++;
				}
			}
		}
		cout << c << endl;
	}
}


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

int main()
{
int n; 
cin >> n;
vector<long long > v(n);
map<long long ,int > mp;
for(int i=0 ;i< n; i++)
{
    cin >> v[i];
    mp[v[i]]++;
}
if(mp[0]==n)
    return !printf("Yes");
if(n%3!=0)
    return !printf("No");
vector<long long > res ;

for(auto ele : mp )
{

    for(int j=0 ;j<ele.second/(n/3) ;j++)
    {
        res.push_back(ele.first);

    }
}
if(res.size()==3 && ((res[0]^res[1]^res[2])==0))
cout<<"Yes";
else cout<<"No";

    return 0;
}

Measured memory_bytes: 5632
n, m = map(int, input().split())
id_card = [0] * (n + 1)

for i in range(m):
    l, r = map(int, input().split())
    l -= 1
    id_card[l] += 1
    id_card[r] -= 1

ans = 0
cnt = 0
for i in range(n):
    cnt += id_card[i]
    if cnt == m:
        ans += 1

print(ans)

Measured memory_bytes: 9868
n=gets.to_i
a=gets
b=gets
if a[0]==b[0] then 
  i=1
  c=3
  t=1
else
  i=2
  c=6
  t=2
end
while(i<n)
  if t==1 then
    if a[i]==b[i] then
      c*=2
      i+=1
    else
      c*=2
      i+=2
      t=2
    end
  else
    if a[i]==b[i] then
      t=1
      i+=1
    else
      c*=3
      i+=2
    end
  end
end
p c%1000000007

Measured memory_bytes: 1788
import java.util.ArrayList;
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		ArrayList<String> slist = new ArrayList<String>();
		String beforeWord = null;
		String word = null;
		boolean flag = true;
		int size = sc.nextInt();
		if(size > 100){
			flag = false;
			System.out.println("No");
			return;
		}
		word = sc.nextLine();

		for (int i = 0; i < size; i++) {
			word = sc.nextLine();
			if (beforeWord != null) {
				char shiri = beforeWord.charAt(beforeWord.length() - 1);
				char atama = word.charAt(0);
				if (shiri == atama) {
					flag = true;
				} else {
					flag = false;
					break;
				}
			}

			if (!slist.contains(word)) {
				if (flag) {
					slist.add(word);
					beforeWord = word;
				}
			}else{
				flag = false;
				break;
			}

		}
		if (flag) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}
}

Measured memory_bytes: 22996
def f(x,y,z):
  return x**2+y**2+z**2+x*y+y*z+z*x
# n=int(input())
# c=[0]*n
# # for i in range(n):

# for i in range(1,10**4):
#   for j in range(1,10**4):
#     k=(n-i**2-j**2-i*j)/()
n=int(input())
a=[0]*n
for i in range(1,101):
  for j in range(1,101):
    for k in range(1,101):
      t=f(i,j,k)
      if t<=n:
        a[t-1]+=1
# print(a)
for aa in a:
  print(aa)



Measured memory_bytes: 69180
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin>>n;
	vector<double long>v(n+1);
	for(int i=1;i<=n;i++)
	    cin>>v[i];
	vector<vector<double long>>dp(n+1,vector<double long>(n+1));
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
	{
	    for(int j=0;j<=i;j++)
	    {
	        if(j==0 ) dp[i][j]=(double long )dp[i-1][j]*(1-v[i]); 
  			else if(j==i) dp[i][j]=(double long )dp[i-1][j-1]*(v[i]); 
  			else dp[i][j]=(double long )dp[i-1][j]*(1-v[i])+(double long)dp[i-1][j-1]*v[i]; 
	    }
	}
	double long ans=0.0;
	for(int i=n;i>(n/2);i--)
	    ans+=(double long )dp[n][i];
	cout<<setprecision(11)<<ans<<endl; 
	return 0;
}

Measured memory_bytes: 144140
import java.util.*;

public class Main {

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int cnt[] = new int[100000+5];
		for(int i=0; i<n; i++) {
			cnt[sc.nextInt()]++;
		}
		int odd = 0;
		int even = 0;
		for(int i=0; i<cnt.length; i++) {
			if(cnt[i]>0) {
				if(cnt[i]%2==0) {
					even++;
				}else {
					odd++;
				}
			}
		}
		int ans = even+odd;
		if(even%2 !=0) {
			ans -= 1;
		}
		System.out.println(ans);
		sc.close();
	}

}


Measured memory_bytes: 59616
H = int(input())
*A, = map(int, input().split())
A = [0] + A

for i, a in enumerate(A):
    if i == 0:
        continue
    print('node %d: ' % i, end='')
    print('key = %d, ' % A[i], end='')
    if i//2 != 0:
        print('parent key = %d, ' % A[i//2], end='')
    if i*2 <= H:
        print('left key = %d, ' % A[i*2], end='')
    if i*2+1 <= H:
        print('right key = %d, ' % A[i*2+1], end='')
    print()



Measured memory_bytes: 5716
#include <cstdio>

using namespace std;

char a[4001];

char other[255][255];
char lol[255];

long long pfx[4001][3];
int main(){
    other['R']['G'] = 'B';
    other['G']['R'] = 'B';
    other['R']['B'] = 'G';
    other['B']['R'] = 'G';
    other['B']['G'] = 'R';
    other['G']['B'] = 'R';
    lol['R'] = 0;
    lol['G'] = 1;
    lol['B'] = 2;
    int n;
    scanf("%d", &n);
    
    scanf("%s", a);
    pfx[0][lol[a[0]]] = 1;
    for (int i = 1; i < n; i++){
        for (int j = 0; j < 3; j++){
            pfx[i][j] += pfx[i-1][j]; 
        }
        pfx[i][lol[a[i]]] += 1;
    }
    long long ans = 0;
    for (int j = 1; j < n; j++){
        for (int k = j+1; k < n; k++){
            if (a[j] != a[k]){
                ans += pfx[j-1][lol[other[a[j]][a[k]]]];
                if (2 * j - k >= 0 && a[2*j-k] == other[a[j]][a[k]]){
                    ans--;
                }
            }
        }
    }
    printf("%lld", ans);
}

Measured memory_bytes: 1816
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<math.h>
using namespace std;

int main() {
	char c[3][3];
	for (int i = 0; i < 3; i++)for (int j = 0; j < 3; j++) {
		cin >> c[i][j];
	}
	for (int i = 0; i < 3; i++){
		cout<< c[i][i];
	}
}

Measured memory_bytes: 256
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const d = parseInt(args[0][0], 10)
	if (d === 22) console.log('Christmas Eve Eve Eve')
	else if (d === 23) console.log('Christmas Eve Eve')
	else if (d === 24) console.log('Christmas Eve')
	else console.log('Christmas')
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7372
import java.util.*;
import java.util.stream.IntStream;

public class Main {

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

        final int N = sc.nextInt();
        final int M = sc.nextInt();
        final int[] X = new int[M];
        for (int i = 0; i < M; i++) {
            X[i] = sc.nextInt();
        }

        Arrays.sort(X);

        final int[] dist = new int[M-1];
        for (int i = 0; i < M-1; i++) {
            dist[i] = Math.abs(X[i+1] - X[i]);
        }

        System.out.println(IntStream.of(dist).sorted().limit(Math.max(0, M-N)).sum());
    }
}


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

map<int,int> X;
int N;
int query(int a,int b){
  cout << "? " << a << " "<< b << endl;
  cout.flush();
  int ret; cin >> ret;
  return ret;
}

int solve(){
  int a = query(1, 2);
  X[0] = 1;
  X[a] = 2;
  int f = 1;
  int x = a;
  for(int i=2;i<N;i++){
    int b = query( i,i+1 );
    int c = query( i-1,i+1 );
    if( a + c == b || b+c == a ) {
      f *= -1;
    }
    x = x + f*b;
    X[x] = i+1;
    a = b;
  }
  cout << "!";
  for( auto p : X) {
    cout << " " << p.second;
  }
  cout << endl;
  cout.flush();
}

int main(){
  cin >> N;
  if( N == 1 )
    cout << "! 1" << endl;
  else
    solve();

}

Measured memory_bytes: 3624
def maximum_sum(A: int, B: int, C: int, K: int) -> int:
    A, B, C = sorted([A, B, C])
    return A + B + C * (2 ** K)


if __name__ == "__main__":
    A, B, C = map(int, input().split())
    K = int(input())
    ans = maximum_sum(A, B, C, K)
    print(ans)


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

int main() {
int x, a, b;
  cin >> x>>a>>b;
  if(b-a<=0)cout <<"delicious" << endl;  
  else if(b-a<=x) cout <<"safe" << endl;
  else cout << "dangerous"<< endl;
}

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

signed main(void)
{
	string s;
	ll n, v, p, cnt;
	map<ll, ll> mp;

	cin >> s;
	n = s.size();
	reverse(s.begin(), s.end());
	mp[0]++;
	cnt = v = 0;
	p = 1;
	rep(i, n)
	{
		v += (s[i] - '0') * p;
		v %= 2019;
		p = (p * 10) % 2019;
		cnt += mp[v];
		mp[v]++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define PI (acos(-1))
#define ct cout<<
#define cn cin>>
#define spc <<" "<<
#define nl puts("")
#define _fl(x) puts("FLAG " #x);
#define  _(x)  cout<< #x <<" is "<< x <<endl;
#define fs first
#define sc second
#define pb push_back
#define all(v)  (v).begin(), (v).end()
#define _109 (1000000000)
#define _0(arr) memset(arr,0,sizeof ( arr ) )
#define _1(arr) memset(arr,-1,sizeof ( arr ) )
#define _ninp(n,arr) for(int i=0; i<n;i++)cin>>arr[i];
#define _nout(n,arr) for(int i=0; i<n;i++)cout<<arr[i]<<" \n"[i==n-1];
double _eps=1e-6;


int cnt[2*100000+100];
int arr[2*100000+100];

int main() {
   
   int n;
   cn n;
   for (int i = 2; i <=n; ++i)
   {
   	  int a;
   	  cn a;
   	  cnt[a]++;

   }

   for (int i = 1; i <=n; ++i)
   {
   	 ct cnt[i],nl;
   }



    return 0;
}


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

typedef struct
{
	int h;
	int w;
} grid_struct;

static int h_count[300016], w_count[300016];
grid_struct grid[300016];

int main()
{
	int h_max, w_max, m;
	int h_count_max = 0, w_count_max = 0;
	long long h_max_array_count = 0, w_max_array_count = 0, bom_count = 0;
	
	cin >> h_max >> w_max >> m;
	
	for(int i = 0; i < m; i++)
	{
		/* 爆弾座標取り込み */
		cin >> grid[i].h >> grid[i].w;
		
		/* 爆弾座標それぞれをカウント */
		h_count[grid[i].h]++;
		w_count[grid[i].w]++;
	}
	
	/* H, Wそれぞれの爆弾の最大個数を求める */
	for(int h = 1; h <= h_max; h++)
	{
		if(h_count_max < h_count[h])
		{
			h_count_max = h_count[h];
		}
	}
	for(int w = 1; w <= w_max; w++)
	{
		if(w_count_max < w_count[w])
		{
			w_count_max = w_count[w];
		}
	}
	
	/* H, Wそれぞれの爆弾の最大個数のリストを作成 */
	for(int h = 1; h <= h_max; h++)
	{
		if(h_count_max == h_count[h])
		{
			h_max_array_count++;
		}
	}
	for(int w = 1; w <= w_max; w++)
	{
		if(w_count_max == w_count[w])
		{
			w_max_array_count++;
		}
	}
	
	/* 爆弾リサーチ */
	for(int i = 0; i < m; i++)
	{
		if(h_count_max == h_count[grid[i].h] && w_count_max == w_count[grid[i].w])
		{
			bom_count++;
		}
	}
	
	if(bom_count < h_max_array_count * w_max_array_count)
		cout << h_count_max + w_count_max << endl;
	else
		cout << h_count_max + w_count_max - 1 << endl;
	
	return 0;
}


Measured memory_bytes: 8240
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define MOD 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(var) (var).begin(), (var).end()
#define MAXX 9000000000000000000
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> > 
#define vvpi vector<vector<pair<int,int> > >

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	int n,m,k,l,ans = 0,i,j,x,y,q;
	string s[7];

	cin >> n >> m >> q;
	for(i=0;i<n;i++)
	{
		cin >> s[i];
	}
	
	x = pow(2, n);
	y = pow(2, m);

	// cout << n << " " << m << endl;

	for(i=0;i<x;i++)
	{
		for(j=0;j<y;j++)
		{
			char temp[10][10];
			for(k=0;k<n;k++)
			{
				for(l=0;l<m;l++)
				{
					temp[k][l] = s[k][l];
				}
			}
			int ii = i;
			int jj = j;
			int tp=0;
			while(ii)
			{
				if(ii & 1)
				{
					for(k=0;k<m;k++)
					{
						temp[tp][k] = '.';
					}
				}
				ii /= 2;
				tp++;
			}
			tp=0;
			while(jj)
			{
				if(jj & 1)
				{
					for(k=0;k<n;k++)
					{
						temp[k][tp] = '.';
					}
				}
				jj /= 2;
				tp++;
			}
			int calc = 0;
			for(k=0;k<n;k++)
			{
				for(l=0;l<m;l++)
				{
					if(temp[k][l] == '#')
					{
						calc++;
					}
				}
			}
			// cout << calc << endl;
			if(calc == q)
			{
				// cout << i << " " << j << endl;
				// for(k=0;k<n;k++)
				// {
				// 	for(l=0;l<m;l++)
				// 	{
				// 		cout << temp[k][l];
				// 	}
				// 	cout << endl;
				// }
				ans++;	
			}
		}
	}


	cout << ans ;

	return 0;
}

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

int main(){
    // long long K;
    int N;
    cin >> N;
    long double n = (long double)N;
    long double x;
    if(N%2==0){
        cout << 0.50000000 << endl;
    }

    else{
        x = (n+1.0000000)/(2.00000000*n);
        cout << x << endl;
    }
}


Measured memory_bytes: 256
class DisjointSet
	def initialize(n)
		@parent = Array.new(n){-1}
	end
	def find(a)
		return a if @parent[a]<0
		@parent[a] = find(@parent[a])
	end
	def union(a, b)
		x = find(a)
		y = find(b)
		return x if x == y
		if size(x) < size(y)
			t = x
			x = y
			y = t
		end
		@parent[x] += @parent[y]
		@parent[y] = x
		x
	end
	def size(a)
		-@parent[find(a)]
	end
end

N,M=gets.split.map(&:to_i)
P=gets.split.map{|i|i.to_i-1}
set=DisjointSet.new(N)
M.times{
	x,y=gets.split.map{|i|i.to_i-1}
	set.union(x,y)
}
warn set.inspect
c=0
N.times{|i|
	if set.find(P[i]) == set.find(i)
		warn [i,P[i]].inspect
		c+=1
	end
}
puts c


Measured memory_bytes: 23240
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long low = sc.nextLong();
    long high = sc.nextLong();
    
    long diff = high-low;
    long result = 0;
    if (diff%2==0) {
      result = diff/2;
    }
    else {
      long near;
      long far;
      if (n-high<low-1) {
        near = n-high;
        far = n-low;
      }
      else {
        near = low-1;
        far = high-1;
      }
      result += near+1;
      result += (far-near-1)/2;
      
    }
    
    System.out.println(result);
  }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const ll MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(ll i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<vector<ll>> digit(60, vector<ll>(n, 0));
    for(ll d = 0; d < 60; d++) {
        for(ll i = 0; i < n; i++) {
            if(a[i] & (1LL << d)) {
                digit[d][i] = 1;
            }
        }
    }
    vector<vector<ll>> digitsum = digit;
    for(ll i = 0; i < 60; i++) {
        for(ll j = 1; j < n; j++) {
            digitsum[i][j] += digitsum[i][j - 1];
        }
    }

    ll ans = 0;
    for(ll d = 0; d < 60; d++) {
        // cout << "digit: " << d << endl;
        for(ll i = 0; i < n - 1; i++) {
            // i+1以降の1の個数
            ll cnt = digitsum[d][n - 1] - digitsum[d][i];
            if(digit[d][i] == 1) {
                cnt = n - i - 1 - cnt;
            }
            // cout << i << ' ' << cnt << endl;
            (ans += cnt * ((1LL << d) % MOD)) %= MOD;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 283992