akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>  
using namespace std;
using ll = long long int;
using pii = pair<int, int>;
#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
ll l=1000000007;
string alphabet="abcdefghijklmnopqrstuvwxyz";

int main() {
  int n; cin>>n;
  set<int> s;
  vector<pii> v;
  rep(i,n){
    int a; cin>>a; 
    s.insert(a);
    if(v.size()<s.size()){pii p= make_pair(a,1);v.push_back(p);}
    else{
      rep(j,v.size()){
        if(v[j].first==a){v[j].second++;}
      }
    }
        
  }
  if(v.size()>3){cout<<"No";}
  else if(v.size()==1){
    if(v[0].first==0){cout<<"Yes";}
    else{cout<<"No";}
  }
  else if(v.size()==2){
    if(n%3==0 && v[0].first*v[1].first==0){
      if(v[0].second*2==v[1].second 
         || v[1].second*2==v[0].second){cout<<"Yes";}
      else{cout<<"No";}
    }
    else{cout<<"No";}
  }
  else if(v.size()==3){
    bitset<17> x(v[0].first);
    bitset<17> y(v[1].first);
    bitset<17> z(v[2].first);
    if(v[0].second==v[1].second && v[1].second==v[2].second
      &&((x ^ y) ==z||(y ^ z)==x||(z ^ x) ==y )){cout<<"Yes";}
    else{cout<<"No";}
  }
}



Measured memory_bytes: 7436
n,k=map(int,input().split())
x=list(map(int,input().split()))

ans=float('inf')
for i in range(n-k+1):
    nowx=(x[i],x[i+k-1])
    if nowx[0]>=0 and nowx[-1]>=0:
        ans=min(ans, nowx[-1])
    elif nowx[0]<=0 and nowx[-1]<=0:
        ans=min(ans, abs(nowx[0]))
    elif nowx[0]<0 and nowx[-1]>=0:
        ans=min(ans, 2*abs(nowx[0])+nowx[-1], abs(nowx[0])+2*nowx[-1])
print(ans)

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

#define ll long long
#define mx  505
#define mod 1000000009
#define lim 100000000000000000
#define inf 2000000000
#define N 18
#define eps 100000
#define PI acos(-1)

using namespace std;

bool C(int n)
{
    int pd=n%10;
    n/=10;

    while(n)
    {
        if(pd!=n%10)
           return false;
        pd=n%10;
        n/=10;   
    }

    return true;
}

int main()
{
    ios_base::sync_with_stdio(false);
    int n;cin>>n;
    while(!C(n))
       n++;
    cout<<n<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

string s, t;
int dp[3300][3300];
int main(){
    cin >> s >> t;
    int n = s.size(), m = t.size();

    for(int i = 0;i <= n;i++){
        for(int j = 0;j <= m;j++){
            if(i == 0 || j == 0){
                dp[i][j] = 0;
                continue;
            }
            dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            if(s[i-1] == t[j-1]){
                dp[i][j] = max(dp[i-1][j-1] + 1, dp[i][j]);
            }
        }
    }

    string rewsna = "";

    while(n > 0 && m > 0){
        if(dp[n][m] == dp[n-1][m])n--;
        else if(dp[n][m] == dp[n][m-1])m--;
        else {
            rewsna += s[n-1];
            n--;
            m--;
        }
    }
    int l = rewsna.size();
    for(int i = 0;i < l;i++){
        cout << rewsna[l-i-1];
    }cout << endl;
    
    return 0;
}

Measured memory_bytes: 39168
module Main where

import Data.Functor
import Data.List

main :: IO ()
main = do
  { [w,h,x,y,r] <- getInts
  ; if x < r then putStrLn "No"
    else if y < r then putStrLn "No"
        else if x + r > w then putStrLn "No"
            else if y + r > h then putStrLn "No"
                else putStrLn "Yes"
  }


getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

Measured memory_bytes: 3656
def kakuritu(N, n, K):
    t = 1
    count = 0
    while N * t < K:
        t = t * 2
        count += 1
    return count

N, K = map(int, input().split())

n = 1
kt = 0
for i in range(1,N+1):
    kt += (1 / N) * ((1/2)**kakuritu(i, n, K))
    n += 1

print(kt)

Measured memory_bytes: 3060
#include <iostream>
#include <queue>
using namespace std;
typedef pair<int, int> P;
#define H 50
#define W 50
#define INF 3000

char map[H][W];
int d[H][W];

int search (int h, int w) {
	int dx[4] = {1,0,-1,0};
	int dy[4] = {0,1,0,-1};
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++) d[i][j] = INF;

	queue<P> que;
	que.push(P(0,0));
	d[0][0] = 0;

	while (que.size()) {
		P p = que.front(); que.pop();
		if (p.first == h && p.second == w) break;
		for (int i = 0; i < 4; i++) {
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if (0 <= nx && nx < h
					&& 0 <= ny && ny < w
					&& map[nx][ny] != '#' && d[nx][ny] == INF) {
				que.push(P(nx,ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}

	// for (int i = 0; i < h; i++) {
	// 	for (int j = 0; j < w; j++)
	// 		cout << d[i][j] << " ";
	// 	cout << endl;
	// }
	return d[h-1][w-1];
}

int main () {
	int h, w, white = 0;
	cin >> h >> w;
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++) {
			cin >> map[i][j];
			if (map[i][j] == '.') white++;
		}

	int dis = search(h,w);
	cout << (dis == INF ? -1 : white-dis-1) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,m,sum=0;
  cin>>n>>m;
  int a[m];
  int x=n-sum;
  for(int i=0;i<m;i++)
      {
      cin>>a[i];
      sum=sum+a[i];
      }
      if(sum>n)
          cout<<"-1"<<endl;//10
          else
            cout<<n-sum<<endl;
  }



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

int main() {
  int n;
  scanf("%d", &n);
  vector<pair<int, int>> vp(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &vp[i].first);
    vp[i].second = i + 1;
  }
  sort(vp.begin(), vp.end());
  for (auto v : vp) {
    printf("%d ", v.second);
  }
  return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef vector<ll> vll;
ll INF = 1e9;
int main(){
  ll n, m, R;
  cin >> n >> m >> R;
  
  vll r(R);
  for (ll i = 0; i < R; i++) cin >> r[i];
  sort(r.begin(), r.end());
  
  vector<vll> d(n, vll(n, INF));
  for (ll i = 0; i < m; i++) {
    ll a, b, c;
    cin >> a >> b >> c;
    d[a - 1][b - 1] = c;
    d[b - 1][a - 1] = c;
  }
  
  for (ll k = 0; k < n; k++) {
    for (ll i = 0; i < n; i++) {
      for (ll j = 0; j < n; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  
  do {
    ll dist = 0;
    for (ll i = 0; i < R - 1; i++) {
      dist += d[r[i] - 1][r[i + 1] - 1];
    }
    if (INF > dist) INF = dist;
  } while (next_permutation(r.begin(), r.end()));
  
  cout << INF << endl;
}

Measured memory_bytes: 512
def solve(N):
    ans_list = []
    for n in range(1,N+1):
        ans_list.append(n)
        if n * (n+1) // 2 == N:
            return ans_list
        elif n * (n+1) // 2 > N:
            ans_list.remove(sum(ans_list) - N)
            return ans_list
        else:
            continue

def main():
    N = int(input())

    ans = solve(N)
    for i in range(len(ans)):
        print(ans[i])

if __name__ == "__main__":
    main()


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 25+7;
struct node{ int parent, left, right; };
node tree[MAXN];
int sib(int i){
	int parent = tree[i].parent;
	if(parent == -1) return -1;
	int l = tree[parent].left;
	int r = tree[parent].right;
	return l==i?r:l;
}
int degree(int i){
	return (tree[i].left != -1) + (tree[i].right != -1);
}
int dep[MAXN];
void setDepth(int i, int p){
	dep[i] = p;
	if(tree[i].left!=-1) setDepth(tree[i].left, p+1);
	if(tree[i].right!=-1) setDepth(tree[i].right, p+1);
}
int height(int i){
	if(i == -1) return -1;
	return max(height(tree[i].left), height(tree[i].right)) + 1;
}
char* type(int i){
	if(tree[i].parent==-1) return "root";
	if(tree[i].left == -1 && tree[i].right == -1) return "leaf";
	return "internal node";
}
int main(){
	int n;
	scanf("%d", &n);
	
	for(int i = 0; i < n; i++){
		tree[i].parent = tree[i].left = tree[i].right = -1;
	} 
	
	for(int i = 0; i < n; i++){
		int id, l, r;
		scanf("%d", &id);
		scanf("%d", &l);
		scanf("%d", &r);
		tree[id].left = l; 
		tree[id].right = r;
		tree[l].parent = id; 
		tree[r].parent = id; 
	}
	int root;
	for(int i = 0; i < n; i++){
		if(tree[i].parent == -1){
			root = i; break;
		}
	}
	setDepth(root, 0);
	
	for(int i = 0; i < n; i++){
		printf("node %d:", i);
		printf(" parent = %d,", tree[i].parent);
		printf(" sibling = %d,", sib(i));
		printf(" degree = %d,", degree(i));
		printf(" depth = %d,", dep[i]);
		printf(" height = %d,", height(i));
		printf(" %s", type(i));	
		printf("\n");
	}
	return 0;
	
}


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_0 = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());

struct mint {
    long long x;
    mint(long long x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
    	return *this;
    }
    mint& operator*=(const mint a) {
    	(x *= a.x) %= MOD;
    	return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
    	if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
    	return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
 

signed main()
{   
    gearup;
    string s; cin >> s;
    int n = s.size();
    vector<vector<mint> > dp(n+10,vector<mint>(2));
    dp[0][0] = 1; //ギリギリ
    dp[0][1] = 0; //それ未満が確定
    rep(i,n){
        dp[i+1][1] += dp[i][1]*3;
        if(s[i] == '0'){ //この時(A,B) = (0, 0)のみ
            dp[i+1][0] += dp[i][0]; //ギリギリからギリギリ
        }
        else{ //この時(0, 1), (1, 0)
            dp[i+1][0] += dp[i][0]*2;
            dp[i+1][1] += dp[i][0];
        }
    }
    mint res = dp[n][0] + dp[n][1];
    out(res.x);
}



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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

signed main(){
	int n=read(),p=read();
	int dp[2]={1,0};
	REP(i,n){
		int x=read()%2;
		if(x){
			dp[0]=dp[1]=dp[0]+dp[1];
		}else{
			dp[0]*=2;
			dp[1]*=2;
		}
	}
	cout<<dp[p]<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner input=new Scanner(System.in);
        String N=input.next();
        int a=N.charAt(N.length()-1)-48;
        if(a==3){
        System.out.print("bon");
        }else if(a==0||a==1||a==6||a==8){
        System.out.print("pon");
        }else{
        System.out.print("hon");
        }
    }   
}

Measured memory_bytes: 35636
#include <iostream>
#include <vector>
#include <map>
#define llint long long int

#define SIZE 100002
#define MOD 1000000007
llint fac[SIZE] = {};
llint finv[SIZE] = {};

llint power(llint base, llint pow){
  llint result = 1;
  while(pow > 1){
    if(pow%2 == 1){
      result = (result * base)%MOD;
    }
    pow/=2;
    base = (base*base)%MOD;
  }
  return (result * base)%MOD;
}

void COMBinit(){
  for(int i=0; i<SIZE; i++){
    if(i<2) fac[i] = 1;
    else fac[i] = (fac[i-1]*i)%MOD;
  }

  finv[SIZE-1] = power(fac[SIZE-1], MOD-2);
  for(int i=SIZE-2; i>=0; i--){
    if(i==0) finv[i] = 1;
    else finv[i] = (finv[i+1]*(i+1))%MOD;
  }
}
llint comb(int a, int b){
  if(a < b) return 0;
  return ((fac[a] * finv[a-b])%MOD * finv[b])%MOD;
}

int main(void){

  int n;
  std::cin >> n;

  COMBinit();

  std::vector<int> a(n+1);
  std::map<int, int> count;
  for(int i=0; i<a.size(); i++){
    std::cin >> a[i];
    if(count.find(a[i]) == count.end()) count[a[i]] = 0;
    count[a[i]]++;
  } //sum^N_k O(logk) = O(nlogn)

  int doubled = -1;
  for(const auto& elem: count){
    if(elem.second == 2){
      doubled = elem.first;
      break;
    } 
  } // O(n)

  int doubled_first = -1;
  int doubled_second = -1;
  for(int i=0; i<a.size(); i++){
    if(a[i] == doubled){
      if(doubled_first==-1) doubled_first = i;
      else                  doubled_second = i;
    }
  } //O(n)

  int count_left = doubled_first;
  int count_right = a.size() - doubled_second - 1;
  for(int k=1; k<=n+1; k++){
    llint ret = (comb(n+1, k) - comb(count_left+count_right, k-1) + MOD)%MOD;
    //std::cout << n+1 << " " << k << " " << count_left+count_right << " " << k-1 << " " << std::endl;
    std::cout << ret << std::endl;
  }
  
  
}


Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int H,W,M;
    cin >> H >> W >> M;
    vector<ll> tate(W),yoko(H);
    vector<ll> tate2(W),yoko2(H);
    vector<pair<ll,ll>> mine(M);
    rep(i,M){
        int h,w;
        cin >> h >> w;
        h--;w--;
        mine[i] = make_pair(h,w);
        yoko[h]++;
        tate[w]++;
        yoko2[h]++;
        tate2[w]++;
    }
    sort(yoko2.rbegin(),yoko2.rend());
    sort(tate2.rbegin(),tate2.rend());
    vector<int> tate_i,yoko_i;
    map<int,bool> mp1,mp2;
    rep(i,W){
        if(tate[i]==tate2[0]){
            tate_i.push_back(i);
            mp1[i] = true;
        }
    }
    rep(i,H){
        if(yoko[i]==yoko2[0]){
            yoko_i.push_back(i);
            mp2[i] = true;
        }
    }
    ll kouho = tate_i.size() * yoko_i.size();
    ll cnt = 0;
    rep(i,M){
        int h,w;
        h = mine[i].first;
        w = mine[i].second;
        if(mp1[w]==true && mp2[h]==true) cnt++;
    }
    if(cnt<kouho) cout << yoko2[0]+tate2[0] << endl;
    else cout << yoko2[0]+ tate2[0] -1 << endl;
    return 0;
}

Measured memory_bytes: 47900
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

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

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

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

const int MAX_N=51;
int a[MAX_N],b[MAX_N];
int N,M;

bool graph[MAX_N][MAX_N];
bool visited[MAX_N];

void dfs(int node){

    visited[node]=true;
    REP(i,N){
        if(graph[node][i]==false){continue;}
        if(visited[i]==true){continue;}
        dfs(i);
    }
}

int main(){
    
    cin>>N>>M;
    REP(m,M){
        cin>>a[m]>>b[m];
        a[m]--;
        b[m]--;
    }

    int ans=0;



    REP(m,M){
        //ここでm番目のgraphを取り除いたときにすべての頂点に移動できるかどうかを確認する
        CLR(visited);
        //m番目の辺を取り除いている
        REP(i,M){
            if(i==m){
                graph[a[i]][b[i]]=false;
                graph[b[i]][a[i]]=false;
            }
            else{
            graph[a[i]][b[i]]=true;
            graph[b[i]][a[i]]=true;
            }
        }

        //結合確認DFS
        dfs(0);

        //すべてvisitedか確認
        REP(i,N){
            if(!visited[i]){ans++; break;}
        }


        NEXT:;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define out(x) cerr << #x << " = " << x << "\n"
using namespace std;
// by piano
template<typename tp> inline void read(tp &x) {
  x = 0;char c = getchar();bool f = 0;
  for(; c < '0' || c > '9'; f |= (c == '-'), c = getchar());
  for(; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if(f) x = -x;
}
const int N = 2e6 + 233;
int a[N], b[N], cnt = 0, ans = 0, x, n, k;
main() {
  read(n); read(k);
  for(int i = 1; i <= n; i ++) read(x), b[x] ++;
  for(int i = 1; i <= n; i ++) {
    if(b[i]) a[++ cnt] = b[i];
  }
  sort(a + 1, a + cnt + 1, greater<int>());
  for(int i = cnt; i >= k + 1; i --) ans += a[i];
  cout << ans << "\n";
}


Measured memory_bytes: 5888
#include <stdio.h>
#include <math.h>

int main(void) {
	int n;
	while (scanf("%d", &n) == 1 && n != 0) {
		double s[1024];
		int i;
		double average = 0, sd = 0;
		for (i = 0; i < n; i++) {
			if (scanf("%lf", &s[i]) != 1) return 1;
			average += s[i];
		}
		average /= n;
		for (i = 0; i < n; i++) {
			sd += (s[i] - average) * (s[i] - average);
		}
		printf("%.15f\n", sqrt(sd / n));
	}
	return 0;
}



Measured memory_bytes: 2060
from collections import deque

def bfs(i):
    q = deque()
    q.append(i)
    c[i] = 1
    while q:
        p = q.popleft()
        f = G[p]
        z = W[p]
        for j in range(len(f)):
            if c[f[j]] == 0:
                q.append(f[j])
                c[f[j]] = 1
                d[f[j]] = d[p] + z[j]
    return

n = int(input())
G = [[] for _ in range(n)]
W = [[] for _ in range(n)]
c = [0] * n
d = [0] * n
for _ in range(n - 1):
    u, v, w = map(int, input().split())
    G[u - 1].append(v - 1)
    G[v - 1].append(u - 1)
    W[u - 1].append(w)
    W[v - 1].append(w)
bfs(0)
for i in d:
    print(i % 2)

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, ans = 0;
  string s;
  cin >> n >> s;
  ll r = 0, g = 0, b = 0;
  rep(i, n) {
    if (s[i] == 'R') {
      r++;
    } else if (s[i] == 'G') {
      g++;
    } else {
      b++;
    }
  }

  if (r == 0 || b == 0 || g == 0) {
    cout << 0 << endl;
    return 0;
  }

  ans = r * g * b;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (s[i] == s[j]) continue;
      int k = 2 * j - i;
      if (k >= n || s[k] == s[i] || s[k] == s[j]) continue;
      ans--;
    }
  }

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


Measured memory_bytes: 3608
a, b, m = map(int,input().split())
a_l = list(map(int,input().split()))
b_l = list(map(int,input().split()))
xyc = []
for _ in range(m):
    xyc.append(list(map(int,input().split())))

ans = min(a_l) + min(b_l)
for x, y, c in xyc:
    ans = min(ans, a_l[x-1]+b_l[y-1]-c)

print(ans)

Measured memory_bytes: 38372
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define ull unsigned long long
using namespace std;
const int maxx = 1007;
const ll mod1 = 1e7;
const ll mod = 1e9 + 7;
const ll base = 311;
const ll base1 = 113;
const ll maxn = 1e6 + 7;
bool check;
ll t, T, n, a[maxn], b[maxn], m1, m, tong, r, ans, mx, k, ma[maxx][maxx], pw[maxx][maxx];
//ll , c[maxx], st1[maxx];
//ll  , pw[maxx];
//string s[maxx], ss[maxx], str, f[maxx][10];
struct dang
{
    ll mn, gcd, val, pos, dd, n1, n2, n3;
};
dang f[maxx][maxx];
string s;
struct les
{
    bool operator()(ll x, ll y)
    {
        return x > y;
    }
};
dang c[maxn];
deque<ll> st;
priority_queue<ll, vector<ll>, les >st1;
map<ll, ll> mp;
vector<ll> adj;
void sol()
{

    cin >> n;
    ans = 0;
    for(int i = 1; i <= n; i ++)
        cin >> a[i];
    for(int i = 1; i <= n; i ++)
        cin >> b[i];
    for(int i = 1; i <= n; i ++)
    {
        while(!st.empty() && b[st.back()] < b[i])st.pop_back();
        while(!st.empty() && b[st.front()] > a[i])st.pop_front();
        if(a[i] != b[i] && (st.empty() || b[st.back()] != b[i]))
        {
            ++ans;
            st.push_back(i);
        }
    }
    cout << ans;
}

void ntu()
{
    long double r;
    cin >> r;

    cout <<fixed<<setprecision(20)<< r * 2.0 * 3.141592654;
}
int main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    //freopen("Test.INP", "r", stdin);
    ntu();
}
/*
3 4
0 3 -1 2
3 3 3 3
3 1 3 0
*/


Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    long long X;
    cin >>X;
    long long ans=0;
    long long y=100;
    while(y<X){
        ans++;
        y*=1.01;
    }
    cout << ans << endl;



}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <string.h>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include <set>
#include <assert.h>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define MOD 1000000007
#define int long long
#ifdef int
const long long INF = LLONG_MAX / 10;
#else
const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<vector<ll> > mat;
typedef pair<int, int> P;
//typedef pair<double, double> P;
const int dx[9] = {-1, 0, 0, 1, -1, -1, 1, 1, 0};
const int dy[9] = {0, -1, 1, 0, -1, 1, -1, 1, 0};
 
int a[3];
int even_num;
int ma;

signed main() {
  REP(i,3) {
    cin >> a[i];
    if (a[i] % 2 == 0) even_num++;
    ma = max(ma, a[i]);
  }

  int ans = 0;
  if (even_num == 0 || even_num == 3) {
    REP(i,3) {
      ans += (ma - a[i]) / 2;
    }
    cout << ans << endl;
    return 0;
  }

  if (even_num == 1) {
    ans++;
    REP(i,3) if (a[i] % 2 == 1) {
      a[i]++;
      ma = max(ma, a[i]);
    }
    REP(i,3) {
      ans += (ma - a[i]) / 2;
    }
    cout << ans << endl;
    return 0;
  } else if (even_num == 2) {
    ans++;
    REP(i,3) if (a[i] % 2 == 0) {
      a[i]++;
      ma = max(ma, a[i]);
    }
    REP(i,3) {
      ans += (ma - a[i]) / 2;
    }
    cout << ans << endl;
    return 0;
  }
}

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

int keta(int x) {
  int k = 0;
  while(x) {
    x/=10;
    ++k;
  }
  return k;
}

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 1; i <= n; ++i) {
  if(!(keta(i)%2 == 0)) {
    ++ans; 
    }
  } 

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

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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int N; cin >> N;

	int sum = 0;
	int tmp = N;

	while(tmp){
		sum += tmp%10;
		tmp /= 10;
	}

	if(N%sum == 0) cout << "Yes" << endl;
	else cout << "No" << endl;


	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <functional>
using namespace std;
int main() {
	int A, B;
	cin >> A >> B;
	if (A <= 8 & B <= 8)
		cout << "Yay!" << endl;
	else
		cout << ":(" << endl;
	return 0;
}

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

int main() {
  int K;
  string S;
  cin >> K >> S;
  for (size_t i = 0; i < S.size(); ++i) {
    if (i == K) {
      cout << "..." << endl;
      break;
    }
    cout << S[i];
  }
}

Measured memory_bytes: 3612
number = input().split(" ")
X = int(number[0])
N = int(number[1])

while True:
    try:
        numbers = input().split(" ")
        i = 0
        n = X
        while n > -1000 :
            if str(n) in numbers:
                i += 1
                n = n - (i * (-1)**(i-1))
            else:
                print(n)
                break
        break
    except:
        print(X)
        break

Measured memory_bytes: 9140
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
int main(int argc, char* argv[])
{
	string s,t;
	cin>>s>>t;
	vector<char> s1;
	vector<char> t1;
	int i;
	for (i=0;i<s.size();i++){
		s1.push_back(s[i]);
	}
	for (i=0;i<t.size();i++){
		t1.push_back(t[i]);
	}
	sort(s1.begin(),s1.end());
	sort(t1.begin(),t1.end(),greater<char>());
	string S,T;
	for (i=0;i<s1.size();i++){
		S+=s1[i];
	}
	for (i=0;i<t1.size();i++){
		T+=t1[i];
	}
	if (S.compare(T)<0){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

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

int main(void){
	char ch;
	while(1){
		scanf("%c",&ch);
		if(islower(ch)){
			printf("%c",toupper(ch));
		}else if(isupper(ch)){
			printf("%c",tolower(ch));
		}else{
			printf("%c",ch);
		}
		if(ch == '\n'){
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 940
#include <bits/stdc++.h>
using namespace std;
int main(){
    string a,b; cin >> a >> b;
    if(a[0] == b[2] && a[1] == b[1] && a[2] == b[0]) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
// header {{{
#include <bits/stdc++.h>
using namespace std;
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
#define ASSERT(expr...) assert((expr))
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
// }}}
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

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

signed main() {
    int a1,a2,a3;
    cin>>a1>>a2>>a3;
    if(a1+a2+a3>=22) cout<<"bust"<<endl;
    else cout<<"win"<<endl;

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

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

const int N = 100000;

int n, p;
int pre[N+1];

int find(int x)
{
    while (x != pre[x])
        x = pre[x];
    return x;
}

int main(void)
{
    while (scanf("%d%d", &n, &p) != EOF) {
        if (!n && !p) break;
        pre[1] = 1;
        for (int i = 2; i <= n; i ++)
            scanf("%d", &pre[i]);
        long long sum = 0;
        for (int i = 1; i <= p; i ++) {
            char s[2];
            int x;
            scanf("%s%d", s, &x);
            if (s[0] == 'M')
                pre[x] = x;
            else
                sum += find(x);
        }
        printf("%lld\n", sum);
    }

    return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
int main()
{
	int n;
	cin>>n;
	int a[n+1];
	for(int i=2;i<=n;i++)
	cin>>a[i];
	int v[n+1];
	for(int i=1;i<=n;i++)
	{
		v[i]=0;
	}
	for(int i=2;i<=n;i++)
	{
		v[a[i]]++;
	}
		for(int i=1;i<=n;i++)
	{
		cout<<v[i]<<"\n";
	}
	
	
}

Measured memory_bytes: 5184
#include<bits/stdc++.h>
using namespace std;
 
int main(){
     
     
   int a[10];  
   int k;
   scanf("%d%d%d%d",&a[0],&a[1],&a[2],&k);
   sort(a,a+3);
   printf("%d\n",a[0]+a[1]+a[2]*(int)pow(2,k));   

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int N;
  cin >> N;
  vector<ll> as(N + 1);
  vector<ll> ass(N + 1);
  vector<ll> bs(N);
  for(int i = 0; i < N + 1; ++i) {
    cin >> as[i];
    ass[i] = as[i];
  }
  for(int i = 0; i < N; ++i) {
    cin >> bs[i];
  }
  for(int i = 0; i < N; ++i) {
    if(as[i] < bs[i]) {
      bs[i] -= as[i];
      as[i] = 0;
      as[i + 1] = max(as[i + 1] - bs[i], 0LL);
    } else {
      as[i] -= bs[i];
      bs[i] = 0;
    }
  }
  ll ans = 0;
  for(int i = 0; i < N + 1; ++i) {
    ans += ass[i] - as[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2560
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include <functional>

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

int main()
{
	int H,W,mv[5]={0,1,0,-1,0};
	char M[60][60];
	cin>>H>>W;
	memset(M,'.',sizeof(char)*60*60);
	for(int i=0;i<H;i++)
	{
		string c;
		cin>>c;
		for(int k=0;k<W;k++)M[i+1][k+1]=c[k];
	}
	bool ok=true;
	for(int i=1;i<=H;i++)
		for(int j=1;j<=W;j++)
		{
			if(M[i][j]=='#')
			{
				bool f=false;
				for(int m=0;m<4;m++)
				{
					if(M[i+mv[m]][j+mv[m+1]]=='#')
						f=true;
				}
				if(!f)ok=false;
			}
		}
	cout<<(ok?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
import java.awt.Point;
import java.util.ArrayDeque;
import java.util.Scanner;
import java.util.*;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;
import java.util.Collection;


 
public class Main{
	
        static final Scanner sc=new Scanner(System.in);
        static int A=sc.nextInt();
        static int B=sc.nextInt();
        
        public static void main(String[]args){
                if((A<=8)&&(B<=8)){
                        System.out.println("Yay!");
                }else{
                        System.out.println(":(");
                }

                

        }
        
        
        

		
	
}


Measured memory_bytes: 21844
N, A, B = map(int, input().split())

if (B - A) % 2 == 0:
    print((B - A) // 2)
else:
    # Aが左に到着
    ans1 = 0
    ans1 += A - 1 + 1
    a = 1
    b = B - A
    ans1 += (b - a) // 2

    # Bが右に到着
    ans2 = 0
    ans2 += N - B + 1
    a = A + (N - B + 1)
    b = N
    ans2 += (b - a) // 2

    ans = min(ans1, ans2)
    print(ans)


Measured memory_bytes: 3060
K,S = map(int, input().split())

ans = 0
if K*3<S:
  print(0)
  exit()

for x in range(K, -1, -1):
  if x >S:
    continue
  for y in range(min(S-x, K), -1, -1):
    if x+y >S:
      continue
    for z in range(min(S-x-y, K), -1, -1):
      if x+y+z==S:
        ans+=1
      elif x+y+z<S:
        break

print(ans)

Measured memory_bytes: 42204
#include<deque>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(s...)  fprintf(stderr, s)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }

int N, A[4011], X;

int main() {
    scanf("%d%d", &N, &X);
    REP (i, N) {
	scanf("%d", A+i);
	A[i+N] = A[i];
    }

    LL ans = 1LL<<60;
    REP (i, N) {
	LL tmp = (LL) X * i;
	deque<int> D;
	REP (j, i) {
	    while (!D.empty() && D.back() > A[j]) D.pop_back();
	    D.push_back(A[j]);
	}

	REP (j, N) {
	    int k = i + j;
	    while (!D.empty() && D.back() > A[k]) D.pop_back();
	    D.push_back(A[k]);

	    tmp += D[0];
	    if (D[0] == A[j]) D.pop_front();
	}

	amin(ans, tmp);
    }

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


    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <unordered_set>

using namespace std;
using ll = long long;
using ull = unsigned long long;

int main() {
  ull N, K;
  cin >> N >> K;
  unordered_set<ull> S;

  for(ull i = 0; i < K; ++i) {
    ull di;
    cin >> di;
    for(ull j = 1; j <= di; ++j) {
      ull Aij;
      cin >> Aij;
      S.insert(Aij);
    }
  }
  auto const ans = N - S.size();
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3260
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

int main() {
    int n, d;
    cin>>n>>d;
    cout<<(n + 2*d+1 - 1)/(2*d+1)<<endl;
    return 0;
}

Measured memory_bytes: 256
def f_pond_skater():
    from heapq import heappush, heappop
    H, W, K = [int(i) for i in input().split()]
    start_row, start_col, target_row, target_col = [int(i) - 1 for i in input().split()]
    Grid = [input() for _ in range(H)]

    heap = []
    dist = [[float('inf')] * W for _ in range(H)]
    dist[start_row][start_col] = 0

    diff = ((0, 1), (1, 0), (0, -1), (-1, 0))
    heappush(heap, (0, start_row, start_col))
    while heap:
        cost, row, col = heappop(heap)
        cost_next = cost + 1

        if row == target_row and col == target_col:
            return cost

        for dr, dc in diff:
            nr, nc = row, col
            for _ in range(K):
                nr += dr
                nc += dc
                if not (0 <= nr < H and 0 <= nc < W) or Grid[nr][nc] == '@':
                    break
                if dist[nr][nc] > cost_next:
                    dist[nr][nc] = cost_next
                    heappush(heap, (cost_next, nr, nc))
                elif dist[nr][nc] == cost_next:
                    continue
                else:
                    break
    return -1

print(f_pond_skater())

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

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


Measured memory_bytes: 256
str1 = input()
str2  = input()

if str1 == str2:
	print('No')
else:
	arr1 = [ ord(s) for s in str1 ]
	arr2 = [ ord(s) for s in str2 ]

	
	arr1.sort()
	arr2.sort(reverse=True)

	flag = True
	for s, t, in zip(arr1, arr2):
		if s == t:
			continue
		else:
			if t > s:
				flag = False
				print('Yes')
				break
			else:
				flag = False
				print('No')
				break
	
	if flag:
		if len(arr1) > len(arr2):
			print('No')
		else:
			print('Yes')

	


#ratcode altas >> yes


Measured memory_bytes: 3064
n = int(input())
ls = list(map(int,input().split()))

ls = sorted(ls)

ans = 10000000000000
x = 0
for i in range(ls[0],ls[-1]+1):
  tmp = 0
  for a in ls:
    tmp += (a-i)**2
  if ans > tmp:
    x = i
    ans = tmp
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)

#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))

#define endl "\n"
#define pb push_back
#define rtn return
#define elif else if

#define MOD 1000000007
 
const int dx_4[]={1,0,-1,0}, dy_4[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};

typedef long long ll;
typedef unsigned long long ull;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int a, b;
	cin >> a >> b;
	if(a % 2 == 1 and b % 2 == 1) cout << "Yes" << endl;
	else cout << "No" << endl;

	rtn 0;
}

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


int N, Q;
string S;
int AC[100010] = {0};
bool h[100010] = {false};

int main() {
    cin >> N >> Q;
    cin >> S;
    int cnt = 0;
    for (int i = 0; i < N-1; i++) {
        if (S[i] == 'A' and S[i+1] == 'C') {
            cnt++;
            h[i] = true;
        }
        AC[i] = cnt;
    }
    int l, r;
    for (int i = 0; i < Q; i++ ) {
        cin >> l >> r;
        int a = AC[r-2] - AC[l-1];
        //if (h[r-2] == true) a++;
        if (h[l-1] == true) a++;
        cout << a << '\n';
    }

}


Measured memory_bytes: 1536
#import<iostream>
using namespace std;

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

    int team_e_after = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'E') team_e_after++;
    }
    int ans = 99999999; //INF
    int team_w_before = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'E') {
            team_e_after--;
        }

        ans = min(ans, team_w_before + team_e_after);

        if (s[i] == 'W') {
            team_w_before++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 900
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<map>
#define ll long long
#define N 105
using namespace std;
int n,x,y,ans;
int did(int x,int y)
{
	if (!(x%y))
		return x/y;
	int k=x/y+1;
	return did(x-max(x%y/k,1)*k,y);
}
int main()
{
	scanf("%d",&n);
	while (n--)
		scanf("%d%d",&x,&y),ans^=did(x,y);
	(ans)?printf("Takahashi"):printf("Aoki");
} 

Measured memory_bytes: 1708
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String s = br.readLine();
            long k = Long.parseLong(br.readLine());
            int ans = 1;
            for (int i = 0; i < s.length(); i++) {
                int tempNum = Integer.parseInt(s.substring(i, i + 1));
                if (tempNum != 1) {
                    ans = tempNum;
                    break;
                } else {
                    if (k == i + 1) {
                        break;
                    }
                }
            }
            System.out.println(ans);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}


Measured memory_bytes: 21204
#include<iostream>
#include<vector>
using namespace std;
#define ARRAY_MAX 100001 

int main(){

    
    int N,hoge,num_max = 0,ans = 0,sum = 0;
    cin >> N;


    vector<int> count(ARRAY_MAX,0);
    while(N > 0){
        cin >> hoge;
        count[hoge]++;
        count[hoge+1]++;
        if(hoge > 0){
            count[hoge-1]++;
        }else{
            sum++;
        }
            
        if(num_max < hoge){
            num_max = hoge;
        }
        N--;
    }
    for(int i = 0;i < num_max;i++){
        if(ans < count[i]){
            ans = count[i];
        }
    }
    if(ans < sum){
        ans = sum;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
K = int(input())
A = [1, 9, 30, 76, 141, 267, 400, 624, 885, 1249, 1590, 2208, 2689, 3411, 4248, 5248, 6081, 7485, 8530, 10248, 11889, 13687, 15228, 17988, 20053, 22569, 25242, 28588, 31053, 35463, 38284, 42540, 46581, 50893, 55362, 61824, 65857, 71247, 76884, 84388, 89349, 97881, 103342, 111528, 120141, 128047, 134580, 146316, 154177, 164817, 174438, 185836, 194157, 207927, 218812, 233268, 245277, 257857, 268182, 288216, 299257, 313635, 330204, 347836, 362973, 383709, 397042, 416448, 434025, 456967, 471948, 499740, 515581, 536073, 559758, 583960, 604833, 633651, 652216, 683712, 709065, 734233, 754734, 793188, 818917, 846603, 874512, 909496, 933081, 977145, 1006126, 1041504, 1073385, 1106467, 1138536, 1187112, 1215145, 1255101, 1295142, 1342852, 1373253, 1422195, 1453816, 1502376, 1553361, 1595437, 1629570, 1691292, 1726717, 1782111, 1827492, 1887772, 1925853, 1986837, 2033674, 2089776, 2145333, 2197483, 2246640, 2332104, 2379085, 2434833, 2490534, 2554600, 2609625, 2693919, 2742052, 2813988, 2875245, 2952085, 3003306, 3096024, 3157249, 3224511, 3306240, 3388576, 3444609, 3533637, 3591322, 3693924, 3767085, 3842623, 3912324, 4027884, 4102093, 4181949, 4270422, 4361548, 4427853, 4548003, 4616104, 4718640, 4812789, 4918561, 5003286, 5131848, 5205481, 5299011, 5392008, 5521384, 5610705, 5739009, 5818390, 5930196, 6052893, 6156139, 6239472, 6402720, 6493681, 6623853, 6741078, 6864016, 6953457, 7094451, 7215016, 7359936, 7475145, 7593865, 7689630, 7886244, 7984165, 8130747, 8253888, 8403448, 8523897, 8684853, 8802826, 8949612, 9105537, 9267595, 9376656, 9574704, 9686065, 9827097, 9997134, 10174780, 10290813, 10493367, 10611772, 10813692]
print(A[K-1])

Measured memory_bytes: 9364
#include <iostream>

int main(int argc, char const *argv[]) {
	int a,b;
	std::cin >> a >> b;

	if (a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0) {
		std::cout << "Possible" << '\n';
	}
	else {
		std::cout << "Impossible" << '\n';
	}
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int main()
{
	while(true) {
	
		int n, m;
		char table[256];
		
		for(int i = 0; i < 256; ++i)
			table[i] = i;
		
		scanf("%d", &n);
		if(n == 0)
			break;
		
		for(int i = 0; i < n; ++i) {
		
			char a[16], b[16];
			scanf("%s%s", a, b);
			table[a[0]] = b[0];
		}
		
		scanf("%d", &m);
		for(int i = 0; i < m; ++i) {
		
			char c[16];
			
			scanf("%s", c);
			printf("%c", table[c[0]]);
		}
		
		printf("\n");
	}

	return 0;
}

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

int main()
{
    int n;
    cin>>n;
    map<int,int> mp;
    for(int i=1;i<=n;i++){
        int a;
        cin>>a;
        mp[a]=i;
    }
    for(auto p:mp){
        cout<<p.second<<" ";
    }
}

Measured memory_bytes: 8124
d=input().split()
for o in input():
 s={'N':(1,5,2,3,0,4),'W':(2,1,5,0,4,3),'E':(3,1,0,5,4,2),'S':(4,0,2,3,5,1)}[o]
 d=[d[i]for i in s]
print(d[0])


Measured memory_bytes: 5568
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
 
public class Main {
    @SuppressWarnings("unchecked")
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int V = in.nextInt();
        int E = in.nextInt();
 
        used = new boolean[V];
        lEdge = new List[V];
        for (int i=0;i<V;i++) {
            lEdge[i] = new ArrayList<Edge>();
        }
         
        for (int i=0;i<E;i++) {
            addEdge(in.nextInt(), in.nextInt(), in.nextInt());
        }
         
        int res = 0;
        while(true) {
            Arrays.fill(used, false);
            int ret = dfs(0, V-1, Integer.MAX_VALUE);
            if (ret==0) break;
            res += ret;
        }
        System.out.println(res);
    }
    static List<Edge>[] lEdge;
    static void addEdge(int fr, int to, int cap) {
        lEdge[fr].add(new Edge(to, cap, lEdge[to].size()));
        lEdge[to].add(new Edge(fr, 0, lEdge[fr].size()-1));
    }
     
    static class Edge {
        int to, cap, rev;
        public Edge(int to, int cap, int rev) {
            this.to= to;
            this.cap = cap;
            this.rev = rev;
        }
    }
 
    static boolean[] used;
     
    static int dfs (int fr, int to, int f) {
        if (fr==to) return f;
        used[fr] = true;
         
        for (int i=0;i<lEdge[fr].size();i++) {
            Edge e = lEdge[fr].get(i);
            if (!used[e.to] && e.cap>0) {
                int dist = dfs(e.to, to, Math.min(f, e.cap));
                if (dist>0) {
                    e.cap -=dist;
                    lEdge[e.to].get(e.rev).cap += dist;
                    return dist;
                }
            }
        }
        return 0;
    }
     
}

Measured memory_bytes: 35060