akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>  
  
int main(int argc, char* argv[])  
{  
  int nBinary = 0;  
  int nDigital = 1;  
  int nTemp = 0;  
  int nMark = 0;  
  int nNumber = 0;  
  int nNumberArrayOne[10000] = {0};  
  int nNumberArrayTwo[10000] = {0};  
  
  nNumberArrayOne[0] = 2;  
  nNumberArrayTwo[0] = 1;  
  
  scanf("%d", &nNumber);  
  
  for (int i = 1; i < nNumber; i++)  
  {  
    if (nMark == 0)  
    {  
      for (int j = 0; j < nDigital; j++)  
      {  
        nTemp = nNumberArrayOne[j] + nNumberArrayTwo[j] + nBinary;  
        nNumberArrayOne[j] = nTemp % 10;  
        nBinary = nTemp / 10;  
      }  
      while(nBinary)  
      {  
        nDigital++;  
        nNumberArrayOne[nDigital - 1] = nBinary % 10;  
        nBinary = nBinary / 10;   
      }  
      nMark = 1;  
    }  
    else  
    {  
      for (int j = 0; j < nDigital; j++)  
      {  
        nTemp = nNumberArrayOne[j] + nNumberArrayTwo[j] + nBinary;  
        nNumberArrayTwo[j] = nTemp % 10;  
        nBinary = nTemp / 10;  
      }  
      while(nBinary)  
      {  
        nDigital++;  
        nNumberArrayTwo[nDigital - 1] = nBinary % 10;  
        nBinary = nBinary / 10;   
      }  
      nMark = 0;  
    }  
  }  
  
  if (nMark == 0)  
  {  
    for (int k = nDigital - 1; k >= 0; k--)  
    {  
      printf("%d", nNumberArrayTwo[k]);  
    }  
    puts("");  
  }  
  else  
  {  
    for (int k = nDigital - 1; k >= 0; k--)  
    {  
      printf("%d", nNumberArrayOne[k]);  
    }  
    puts("");  
  }  
  
  return 0;  
}  

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

using int64 = long long;

int64 Solve(int64 n, int64 p) {
  int64 ret = 1;
  for (int64 a = 2; a * a <= p; ++a) {
    int e = 0;
    while (p % a == 0) {
      p /= a;
      ++e;
    }
    for (e /= n; e; e--)
      ret *= a;
  }
  if (n == 1)
    ret *= p;

  return ret;
}

int main() {
  int64 n, p;
  cin >> n >> p;
  cout << Solve(n, p) << "\n";
  return 0;
}


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


int main() {
    int h, w;
    cin >> h >> w;
    char y = 'A';
    for (int i = 0 ; i < h; i++) {
        for (int j = 0; j < w; j++) {
            string su;
            cin >> su;
            if (su == "snuke") {
                i++;
                y += j;
                
                cout << y << i << endl;
                
            }
        }
    }
    
}



Measured memory_bytes: 256
N,H=map(int,input().split())

a=[]
b=[]
damege=0
count=0

for i in range(N):
    A,B=map(int,input().split())
    a.append(A)
    b.append(B)

if N>1:
    b=sorted(b,reverse=True)

i=0
A=max(a)
while i<N and b[i]>A and damege<H:
    damege+=b[i]
    i+=1
    count+=1
count+=-(-max(0,H-damege)//A)

print(count)


Measured memory_bytes: 12064
from collections import defaultdict
A = [1, 2, 3, 5, 8, 13, 21, 34]
MOD = 10**9 + 7
H, W, K = map(int, input().split())
K -= 1
if W == 0:
    print(1)
    exit()
dp = [[0] * W for _ in range(H + 1)]
dp[0][0] = 1
for i in range(1, H + 1):
    for j in range(i + 1):
        for k in [-1, 0, 1]:
            if not 0 <= j + k < W: continue
            if not 0 <= j < W: continue
            if k == -1:
                left = max(0, j - 1 - 1)
                right = max(0, W - j - 2)
            elif k == 0:
                left = max(0, j - 1)
                right = max(0, W - j - 2)
            elif k == 1:
                left = max(0, j - 1)
                right = max(0, W - j - 2 - 1)
            dp[i][j] += dp[i - 1][j + k] * A[left] * A[right]
print(dp[H][K] % MOD)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007

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

    string n,m;
    cin>>n>>m;

    string a="",b="";
    f0(i,0,stoi(n)){
        a+=m;
    }
    f0(i,0,stoi(m)){
        b+=n;
    }

    const string c=a,d=b;

    int res=lexicographical_compare(a.begin(),a.end(),b.begin(),b.end());
    if(res) cout<<a;
    else cout<<b;
}

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

int n, q;
int A[21], M[201];

int main() {
    cin >> n;
    for (int i=0; i<n; ++i) cin >> A[i];
    cin >> q;
    for (int i=0; i<q; ++i) cin >> M[i];

    bool dp[2001] = {false};
    dp[0] = true;
    for (int i=0; i<n; ++i) {
        for (int j=2000; j>=0; --j) {
            if (dp[j] && j + A[i] < 2001) {
                dp[j + A[i]] = true;
            }
        }
    }

    for (int i=0; i<q; ++i) {
        cout << (dp[M[i]] ? "yes" : "no") << endl;
    }
    return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
 
int main(){
    int n; cin>>n;
    int a,x=0,y=0;
    FOR(i,0,n){
        cin>>a;
        if(a%4==0) y++;
        if(a%2!=0) x++;
    }
    Yes(x<=y||(x==y+1&&x+y==n));
}

Measured memory_bytes: 256
/*
*                                 Name : chaitanya
*
*                         Institute : ANITS,Visakhapatnam
*   "Don't regret anything you do, because in the end it makes you who you are."
*
*/
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#include<sstream>
#include <assert.h>
#define infy  1000000000
#define all(x) begin(x),end(x)
#define ll long long int
#define ff first
#define ss second
#define pb push_back
const ll m = 1000000007;
using namespace std;

int main()
{  
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        cout << "ACL";
    }
    return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
#define maxsize 200000
int main()
{
     long n;
     int a[maxsize];
     scanf("%ld",&n);
     int i;
     for(i=0;i<n;i++)
          scanf("%d",&a[i]);
     int flag=n%2;
     if(flag==0)
          {
      for(i=n-1;i>0;i-=2)
           printf("%d ",a[i]);
      for(i=0;i<n;i+=2)
           printf("%d ",a[i]);
}
else{
        for(i=n-1;i>=0;i-=2)
           printf("%d ",a[i]);
       for(i=1;i<n;i+=2)
           printf("%d ",a[i]);
}
return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

int main(){
    int a,b;
    cin >> a >> b;
    int ans = 0;
    ans = max(2*a-1,2*b-1);
    ans = max(ans,a+b);
    cout << ans << endl;    
}

Measured memory_bytes: 256
def main():
    n = int(input())
    A = [int(x) for x in input().split()]
    mod = 10**9+7
    a_sum = sum(A)
    a_cum = [0] * (n+1)
    for i in range(n):
        a_cum[i + 1] = a_cum[i] + A[i]
    ans = 0
    for i in range(len(A)-1):
        ans += A[i] * (a_sum - a_cum[i+1]) % mod
        ans %= mod
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 31596
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 6)

n, q = map(int, input().split())

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

li = [0]*n

for i in range(q):
    p, x = map(int, input().split())
    li[p-1] += x

def dfs(i=0, r=-1):
    for j in e[i]:
        if j != r:
            li[j] += li[i]
            dfs(j, i)

dfs()

print(*li)

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

bool is_ok(int n, const vector<bool> &d) {
    while (n > 0) {
        if (d.at(n % 10)) return false;
        n /= 10;
    }
    return true;
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<bool> d(10);
    for (int i = 0; i < k; i++) {
        int x;
        cin >> x;
        d.at(x) = true;
    }

    for (int i = 0; i <= 100000; i++) {
        if (is_ok(n + i, d)) {
            cout << n + i << endl;
            return 0;
        }
    }
}   

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)      //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++) //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)    //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))        //array size
#define SORTD(a) sort(a,a+ASIZE(a),greater<int>()) //sort in descending order for array
#define SORTA(a) sort(a,a+ASIZE(a))                //sort in ascending order for array
#define SORTS(a) sort(a.begin(),a.end())           //sort in ascending order for string type
typedef long long LL;
typedef unsigned int UINT;
typedef pair<int, int> P;
typedef vector<int> Vi;
typedef vector< Vi > VVi;
 
void SCAN(int *a){scanf("%d",a);}                             //scan for type int
void SCAN(int *a,int n){int i;REP(i,n){scanf("%d",&a[i]);}}   //scan for type int array
void SCAN(UINT *a){scanf("%u",a);}                            //scan for type unsigned int
void SCAN(UINT *a,int n){int i;REP(i,n){scanf("%u",&a[i]);}}  //scan for type unsigned int array
void SCAN(LL *a){scanf("%lld",a);}                            //scan for type long long int
void SCAN(LL *a,int n){int i;REP(i,n){scanf("%lld",&a[i]);}}  //scan for type long long int array
void SCAN(char *c){scanf(" %c",c);}                           //scan for type char
void SCAN(char *c,int n){int i;REP(i,n){scanf(" %c",&c[i]);}} //scan for type char array
 
const int MOD = 1000000007;
const int INF = 1999999999;
const LL INFLL = 999999999999999;
 
const int DX4[4]= {-1,0,1,0};
const int DY4[4]= {0,-1,0,1};
 
//fill an N-dimensional array with val
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
	fill((T*)array,(T*)(array+N),val);
}
 
long double pascalTri(int n,int r){
	long double tri[n+1][n+1];
	int i,j;
	REP(i,n+1){REP(j,n+1){tri[i][j]=0;}}
	REP(i,n+1){
		REP(j,n+1){
			if(j>i){break;}
			if(j==0||j==i){tri[i][j]=1;}else{tri[i][j]=(tri[i-1][j-1]+tri[i-1][j]);}
		}
	}
	return tri[n][r];
}
 
 
int main(){
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	int n,a,b,c,d;
	string num;
	int i,j,k;
 
	cin >> num;

	int temp;
	string ans="";
	char op[3];
	REP(i,8){
		temp=num[0]-'0';
		ans=to_string(num[0]-'0');
		REP(j,3){

			if((i>>j)%2==0){
				temp+=num[j+1]-'0';
				op[j]='+';
				
			}else{
				temp-=num[j+1]-'0';
				op[j]='-';
			}
			ans+=(op[j]+to_string(num[j+1]-'0'));
		}
		if(temp==7){
			cout<<ans<<"=7"<<endl;
			break;
		}
	}


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cerr << "[(" << __LINE__ << ") " << (#x) << "]: " << x << endl;

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

    int n;
    cin >> n;

    int a[4] = {};

    for (int i=0; i<n; i++) {
        string s;
        cin >> s;
        if (s == "AC") a[0]++;
        else if (s == "WA") a[1]++;
        else if (s == "TLE") a[2]++;
        else a[3]++;
    }

    cout << "AC x " << a[0] << "\n";
    cout << "WA x " << a[1] << "\n";
    cout << "TLE x " << a[2] << "\n";
    cout << "RE x " << a[3] << "\n";
}


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

const int MOD = 1000000007;
const int INF = 1e9;

int main(){
  long long l,r;
  cin >> l >> r;

  const long long mod = 2019;
  long long ans = 2e9 + 1;
  long long res = 0;
  for(long long i = l; i <= r; i++){
    for(long long j = i+1; j <= r; j++){
      ans = min(ans, i%mod * j%mod);
      if(ans == 0) break;
    }
    if(ans == 0) break;
  }
  cout << ans << endl;

  // int s = l % mod;
  // vector<int> a;
  // a.push_back(l%mod);
  // int cnt = 0;
  // for(int i = l + 1; i <= r; i++){
  //   if(i%mod == s) {
  //     cnt ++;
  //     if(cnt >= 3) break;
  //   }
  //   a.push_back(i%mod);
  // }
  // sort(a.begin(), a.end());
  // // for(int i = 0; i < a.size(); i++) cout << a[i] << endl;
  // cout << a[0] * a[1] % mod << endl;

  return 0;
}

Measured memory_bytes: 3644
import sys

stdin = sys.stdin

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

n = ni()
a = na()
# ans = 0
# while True:
#     dtwo = 0
#     for i in range(n):
#         if a[i] % 2 == 0 and dtwo == 0:
#             a[i]//=2
#             dtwo = 1
#         else:
#             a[i]*=3
#     if dtwo == 0:
#         break
#     ans += 1
# print(ans)
ans = 0
for i in range(n):
    tmp = a[i]
    while True:
        if tmp%2 == 0:
            ans += 1
        else:
            break
        tmp = tmp / 2
print(ans)


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

int main() {
  int x=0,n,max_x=0;
  cin >>n;
  string s;
  cin >> s;
  for (int i=0;i<n;i++) {
    if (s.at(i)=='I') x++;
    if (s.at(i)=='D') x--;
    if (max_x<x) max_x=x;
  }
  cout << max_x <<endl;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

alias Pair = Tuple!(int, "a", int, "b");

void main() {
    int N;
    scan(N);

    if (N == 1) {
        writeln("Hello World");
    }
    else {
        int a, b;
        scan(a);
        scan(b);
        writeln(a + b);
    }
}







void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


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

int main () {
  int A, B, C;
  cin >> A >> B >> C;
  
  if( A == 5 && B == 7 && C == 5 || A ==5 && B ==5 && C == 7 || A == 7 && B == 5 && C == 5) {
  cout << "YES" << endl;
  }
   else {
  cout << "NO" << endl;
   }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
int main()
{
  int i, j, n, minj, count = 0, a, b,hantei = 0;
  char c[36][3],c2[36][3], temp[3];

  scanf("%d",&n);

  for(i = 0; i < n; i++)
    {
      scanf("%s",c[i]);
    }

  for(i = 0; i < n; i++)
    {
      strcpy(c2[i],c[i]);
    }

  for(i = 0; i < n; i++)
    {
      for(j = n-1; j > i; j--)
	{
	  if(c[j][1] < c[j-1][1])
	    {
	      strcpy(temp,c[j]);
	      strcpy(c[j],c[j-1]);
	      strcpy(c[j-1],temp); 
	    }
	}
    }

  for(i = 0; i < n-1; i++)
    {
      printf("%s ",c[i]);
    }

  printf("%s\n",c[n-1]);
  printf("Stable\n");

  for(i = 0; i < n; i++)
    {
      minj = i;
      for(j = i; j < n; j++)
	{
	  if(c2[j][1] < c2[minj][1])
	    {
	      minj = j;
	      count++;
	    }
	}
       if(count != 0)
	{
	  strcpy(temp,c2[i]);
	  strcpy(c2[i],c2[minj]);
	  strcpy(c2[minj], temp); 
	  count = 0;
	}
    }

  for(i = 0; i < n; i++)
    {
      for(j = i+1; j < n; j++)
	{
	  for(a = 0; a < n; a++)
	    {
	      for(b = a+1; b < n; b++)
		{
		  if(c[i][1] == c[j][1] && strcmp(c[i],c2[b]) == 0 && strcmp(c[j],c2[a]) == 0)hantei = 1;
		}
	    }
	}
    }
  
  for(i = 0; i < n-1; i++)
    {
      printf("%s ",c2[i]);
    }
  
  printf("%s\n",c2[n-1]);

  if(hantei == 1)printf("Not stable\n");
  else printf("Stable\n");
  
  return 0;
}



Measured memory_bytes: 2108
'''
Created on 2020/08/20

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  S=pin()[:-1]
  if len(S)==2:
    print(S)
    return 
  print(S[::-1])
  return 

main()

Measured memory_bytes: 9100
N = int(input())
v_list = sorted(list(map(int,input().split())))

sum = 0
a = 0

if N == 1:
    sum += v_list[0]

elif N == 2:
    sum += (v_list[0] + v_list[1])/2

else:
    sum += (v_list[0] + v_list[1]) * 2 ** (-N + 1)
    for i in range(N-2):
        sum += v_list[i+2] * 2 ** (-N + i + 2)
        
print(sum)

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

double dp[3010][3010];

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

	int n;
	double t;
	vector <double> p;

	cin >> n;
	for(int i=0;i<n;i++)
	{
		cin >> t;
		p.push_back(t);
	}

	dp[0][0] = 1 - p[0];
	dp[0][1] = p[0];

	for(int i=1;i<n;i++)
	{
		for(int j=0;j<=n;j++)
		{
			dp[i][j] += (dp[i-1][j])*(1 - p[i]);
			dp[i][j+1] += (dp[i-1][j])*(p[i]);
		}
	}

	double res = 0;

	for(int i=(n/2)+1;i<=n;i++)
	{
		res += dp[n-1][i];
	}

	cout << fixed;
	cout.precision(9);

	cout << res << '\n';

	return 0;
}


Measured memory_bytes: 70784
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
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;
}
 
using namespace std;


void solve(){
  int n,m;
  cin>>n>>m;
  vector<int>x(n);
  map<int,int>mp,mp2;
  vector<int>v(1e5+10);
  rep(i,n)cin>>x[i],mp[x[i]%m]++,v[x[i]]++;
  rep(i,1e5+5){
    mp2[i%m]+=v[i]/2;
  }
  int ans=0;
  for(auto x: mp){
    int minv=min(x.second,mp[(m-x.first)%m]);
    if((x.first==0)||(2*x.first==m))continue;
    ans+=minv;
    mp[x.first]-=minv;
    mp[(m-x.first)%m]-=minv;
    if(mp[x.first]>=2)ans+=min(mp[x.first]/2,mp2[x.first]);
    //cerr<<x.first<<" "<<ans<<endl;
  }
  ans+=mp[0]/2;
  if(m%2==0){
    ans+=mp[m/2]/2;
  }
  cout<<ans;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
int main(){
string S;
  cin>>S;
  if(S=="SUN"){
  cout<<7<<endl;
  
  }
  if(S=="MON"){
    cout<<6<<endl;
  }
  if(S=="TUE"){
  cout<<5<<endl;
  }
if(S=="WED"){
cout<<4<<endl;
}
  if(S=="THU"){
  cout<<3<<endl;
  }
  if(S=="FRI"){
  cout<<2<<endl;
  }
  if(S=="SAT"){
  
  cout<<1<<endl;
  }
}


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

public class Main {

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

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      String op;
      String[] words;
      Tree tree = new Tree();

      for(int i=0,k=0; i<n; i++,k=0){
        words = br.readLine().split(" ");
        op  = words[k++];
        if ( op.equals("insert") ) { 
          tree.insert(Integer.parseInt(words[k++]));
        }
        else {
          tree.dispRoundPath();
        }
      }

    }
    catch(IOException e) {
      System.out.println("IOException!");
    }
  }
}

class Tree {

  static final BTreeNode NIL = new BTreeNode(-1);
  BTreeNode root;
  StringBuilder buf;

  public Tree() {
    root = NIL;
    buf = new StringBuilder();
  }

  public void insert(int val) {
    BTreeNode y = NIL;
    BTreeNode x = root;
    BTreeNode z = new BTreeNode(val);

    while( !x.equals(NIL) ) {
      y = x;
      if( z.key < x.key )
        x = x.left;
      else
        x = x.right;
    }
    z.parent = y;

    if( y.equals(NIL) ){
      root = z;
    }
    else if( z.key < y.key )
      y.left = z;
    else
      y.right = z;
  } 
  void preParse(BTreeNode u) {
    if( !u.equals(NIL) ) {
      buf.append(" ").append(u.key);
      preParse(u.left);
      preParse(u.right);
    }
  }
  void inParse(BTreeNode u) {
    if( !u.equals(NIL) ) {
      inParse(u.left);
      buf.append(" ").append(u.key);
      inParse(u.right);
    }
  }

  void dispRoundPath() {

    inParse(root);
    buf.append("\n");
    preParse(root);
    buf.append("\n");

    System.out.print(buf);
    buf.setLength(0);
  }
}

class BTreeNode {
  int key;
  BTreeNode parent,left,right;

  public BTreeNode(int key) {
    this.key = key;
    this.parent =
    this.left =
    this.right = Tree.NIL;
  }

  @Override
  public boolean equals(Object o) {
    if(o == this) return true;
    if(o == null) return false;
    if(!(o instanceof BTreeNode)) return false;

    BTreeNode node = (BTreeNode)o;
    if(!(this.key == node.key)) return false;

    return true;
  }
}


Measured memory_bytes: 126448
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	List<Integer> list = new LinkedList<>();
    	int max = 0;
    	int order = 0;
    	for (int i = 0; i < N; i++) {
    		int num = sc.nextInt();
    		if (max < num) {
    			max = num;
    			order = i;
    		}
    		list.add(num);
    	}
    	Collections.sort(list);
    	int submax = list.get(list.size() - 2);
    	for (int i = 0; i < N; i++) {
    			System.out.println(i == order ? submax : max);
    	}
    }
}

Measured memory_bytes: 104716
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <set>
using namespace std;

typedef long long LL;
multiset<LL> front, rear, Left;
const int maxn = 1e5 + 5;
int N;
LL a[maxn * 3]; int main(){
    cin >> N;
    for(int i = 1;i <= N * 3;i++){
        scanf("%lld", &a[i]);
    }
    LL pre = 0, suf = 0;
    for(int i = 1;i <= N;i++){
        front.insert(a[i]);
        pre += a[i];
    }
    for(int j = N + 1;j <= 3 * N;j++){
        suf += a[j];
        rear.insert(a[j]);
        if(rear.size() > N){
            LL val = *rear.rbegin();
            suf -= *rear.rbegin();
            auto it = rear.lower_bound(val);
            rear.erase(it);
            Left.insert(val);
        }
    }
    LL ans = pre - suf;
    for(int i = N + 1;i <= 2 * N;i++){
        pre += a[i];
        front.insert(a[i]);
        pre -= *front.begin();
        front.erase(front.begin());
        if(rear.count(a[i])){
            auto it = rear.lower_bound(a[i]);
            suf -= *it;
            rear.erase(it);
            suf += *Left.begin();
            rear.insert(*Left.begin());
            Left.erase(Left.begin());
        }else{
            auto it = Left.lower_bound(a[i]);
            Left.erase(it);
        } 
        ans = max(ans, pre - suf);
    }
    cout << ans << endl;
    return 0;
}


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

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

    int x, v_size;
    vector<int> v;

    while(1){
        cin >> x;
        if(x == 0){
            break;
        }
        else{
            v.push_back(x);
        }
    }

    v_size = v.size();

    for(int i = 0; i < v_size; i++){
        cout << "Case " << i + 1 << ": " << v[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 3184
#include <stdio.h>
#include<math.h>
#include<stdlib.h>

int main(void) {
	int a, b,i,n,m;
	scanf("%d %d", &a, &b);
	if (a > b) {
		n = a;
		m = b;
	}
	else {
		n = b;
		m = a;
	}
	for (i = 0; i < n; i++) {
		printf("%d", m);
	}

	return 0;
}

Measured memory_bytes: 128
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np
from scipy.ndimage import distance_transform_cdt

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

H, W = list(map(int, sys.stdin.readline().split()))
A = np.array([list(sys.stdin.readline().rstrip()) for _ in range(H)]) == '.'
ret = distance_transform_cdt(A, metric='taxicab')
print(ret.max())


Measured memory_bytes: 45088
#include<bits/stdc++.h>
using namespace std;
int d[110],h[110];
int main() 
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&d[i]);
		h[d[i]]++;
	}
	int ans=0;
	for(int i=1;i<=100;i++)
		if(h[i]>=1) ans++;
	printf("%d",ans);
	return 0;
}

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

using namespace std;

#define int long long
#define ar array
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)

template<class T>
bool umin(T &a, const T &b) {
    return b < a ? a = b, 1 : 0;
}

template<class T>
bool umax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

template<class A>
void read(vt<A> &v);

template<class A, size_t S>
void read(ar<A, S> &a);

template<class T>
void read(T &x) {
    cin >> x;
}

void read(double &d) {
    string t;
    read(t);
    d = stod(t);
}

void read(long double &d) {
    string t;
    read(t);
    d = stold(t);
}

template<class H, class... T>
void read(H &h, T &... t) {
    read(h);
    read(t...);
}

template<class A>
void read(vt<A> &x) {
    EACH(a, x)read(a);
}

template<class A, size_t S>
void read(array<A, S> &x) {
    EACH(a, x)read(a);
}

string to_string(char c) {
    return string(1, c);
}

string to_string(bool b) {
    return b ? "true" : "false";
}

string to_string(const char *s) {
    return string(s);
}

string to_string(string s) {
    return s;
}

string to_string(vt<bool> v) {
    string res;
    FOR(sz(v))res += char('0' + v[i]);
    return res;
}

template<size_t S>
string to_string(bitset<S> b) {
    string res;
    FOR(S)res += char('0' + b[i]);
    return res;
}

template<class T>
string to_string(T v) {
    bool f = 1;
    string res;
    EACH(x, v) {
        if (!f)
            res += ' ';
        f = 0;
        res += to_string(x);
    }
    return res;
}

template<class A>
void write(A x) {
    cout << to_string(x);
}

template<class H, class... T>
void write(const H &h, const T &... t) {
    write(h);
    write(t...);
}

void print() {
    write("\n");
}

template<class H, class... T>
void print(const H &h, const T &... t) {
    write(h);
    if (sizeof...(t))
        write(' ');
    print(t...);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n) {
    v = vt<T>(n, x);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n, size_t m...) {
    v = vt<T>(n);
    EACH(a, v)vti(a, x, m);
}

void solve() {
    
    int n;
    read(n);
    
    vt<int> a(n);
    
    read(a);
    
    sort(all(a));
    
    print(a.back() - a.front());
}

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int tt = 1;
    //read(tt);
    FOR(tt) {
//        write("Case #", i + 1, ": ");
        solve();
        
    }
    
}



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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using v = vector<T>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
void dump_debug(T list) {
#ifdef MY_DEBUG
    each(e, list) cout << e << " ";
    printf("\n");
#endif
}

inline ll inl() {
    ll x;
    cin >> x;
    return x;
}

inline string ins() {
    string x;
    cin >> x;
    return x;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        ll n = inl();
        vl a(n);
        map<ll, ll> mp;

        rep(i, n) {
            cin >> a[i];
            mp[a[i]]++;
        }

        if (n % 3 == 0) {
            if (mp.size() == 3) {
                vl tmp;
                each(e, mp) {
                    if (e.second != n / 3) {
                        cout << "No" << endl;
                        return 0;
                    }
                    tmp.eb(e.first);
                }
                if ((tmp[0] ^ tmp[1] ^ tmp[2]) == 0) {
                    cout << "Yes" << endl;
                    return 0;
                }
                cout << "No" << endl;

            } else if (mp.size() == 2) {
                if (mp[0] == n / 3 &&  (++mp.begin())->S == 2 * n / 3) {
                    cout << "Yes" << endl;
                } else {
                    cout << "No" << endl;
                }
            } else {
                if (mp[0] == n) cout << "Yes" << endl;
                else cout << "No" << endl;
            }

        } else {
            if (mp[0] == n) cout << "Yes" << endl;
            else cout << "No" << endl;
        }

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 5632
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <functional>
using namespace std;
#define int long long
int MOD = 1000000007;
template<typename T>
struct MonotoneMinima {
	using F = function<T(int, int)>;
	int n;
	F dist;
	T INF;
	vector<T> dp;

	// dist(i,l) + dist(j,k) >= dist(i,k) + dist(j,l)
	// if( i<=j && k<=l )
	MonotoneMinima(int n, F dist, T INF) :
		n(n), dist(dist), INF(INF), dp(n + 1, INF) {}

	void dfs(int l, int r, int a, int b) {
		if (l == r) return;
		int m = (l + r) >> 1;
		T ma = INF;
		int mi = -1;
		for (int i = a; i < b; i++) {
			T tmp = dp[i + 1] + dist(m, i);
			if (tmp < ma) ma = tmp, mi = i;
		}
		dp[m] = min(dp[m], ma);
		dfs(l, m, a, mi + 1);
		dfs(m + 1, r, mi, b);
	}

	void solve(int l, int r) {
		if (l + 1 == r) {
			dp[l] = min(dp[l], dp[r] + dist(l, l));
			return;
		}
		int m = (l + r) >> 1;
		solve(m, r);
		dfs(l, m, m, r);
		solve(l, m);
	}

	T solve() {
		dp[n] = 0;
		solve(0, n);
		return dp[0];
	}
};
//END CUT HERE
//INSERT ABOVE HERE


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, C;
	cin >> N >> C;
	vector<int> A(N + 1);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	const int INF = 1e18;
	auto dist =
		[&](int i, int j)->int {
		if (i > j) {
			//cerr << "hi" << endl;
			swap(i, j);
		}
		/*if (i == 0) {
			if (j == 0)return 0;
			else return INF;
		}*/
		return (A[i] - A[j + 1])*(A[i] - A[j + 1]) + C;
	};

	MonotoneMinima<int> mo(N - 1, dist, INF);
	cout << mo.solve() << endl;
}

Measured memory_bytes: 3456
num = gets.chomp.split("").map &:to_i

def solve(a, b , c, num, op)
  ret = []
  if c > num.size
    if a == 7
      puts num.map(&:to_s).zip(op).flatten!.join("") + "=7"
      exit
    else
      return nil
    end
  end
#  puts "a:#{a} b:#{b} c:#{c} num:#{num}, op:#{op}"
  ret << solve(a+b,num[c],c+1,num,op+["+"])
  ret << solve(a-b,num[c],c+1,num,op+["-"])

end

solve(num[0],num[1],2,num, [])

Measured memory_bytes: 1788
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;


typedef long long i64;
const int inf = (int)1.05e9;


int main()
{
	char s[200005];
	int len;

	scanf("%s", s);
	len = strlen(s);

	int white = 0;
	for(int i = 0; i < len; ++i) {
		if(s[i] == 'W') {
			white += 1;
		}
	}

	int remain = white;
	i64 ans = 0;

	for(int i = 0; i < len; ++i) {
		if(s[i] == 'B') {
			ans += remain;
		} else {
			remain -= 1;
		}
	}

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

	return 0;
}

/* waffle */


Measured memory_bytes: 384
#include <bits/stdc++.h>
//#pragma GCC target("avx,avx2,sse4.2")
#define rep(q, a, b) for (int q = a, q##_end_ = b; q <= q##_end_; ++q)
#define dep(q, a, b) for (int q = a, q##_end_ = b; q >= q##_end_; --q)
#define mem(a, b) memset(a, b, sizeof a)
#define debug(a) cerr << #a << ' ' << a << "___" << endl
using namespace std;
// char buf[10000000], *p1 = buf, *p2 = buf;
#define Getchar() getchar()  // p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 10000000, stdin), p1 == p2) ? EOF : *p1++
void in(int &r) {
    static char c;
    r = 0;
    while (c = Getchar(), c < 48);
        ;
    do
        r = (r << 1) + (r << 3) + (c ^ 48);
    while (c = Getchar(), c > 47);
}
const int mn=200005;
int val[mn],ans[mn];
int main(){
	int n;
	in(n);
	rep(q,1,n)in(val[q]);
	dep(q,n,1){
		int tot=0;
		for(int w=q+q;w<=n;w+=q)tot+=ans[w];
		tot&=1;
		ans[q]=tot^val[q];
	}
	int v=0;
	rep(q,1,n)if(ans[q])++v;
	cout<<v<<endl;
	rep(q,1,n)if(ans[q])printf("%d ",q);
	return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <map>

using namespace std;

struct M {
	char t, d;
};

int main() {
	long long n, q;
	cin >> n >> q;
	
	string s;
	cin >> s;
	
	vector<M> m(q);
	for (auto &&e : m) {
		cin >> e.t >> e.d;
	}
	
	long long lCount = 0, rCount = 0;
	for (long long i = q - 1; i >= 0; --i) {
//		cout << m[i].t << " " << m[i].d << endl;
		if (m[i].d == 'L') {
			if (s[lCount] == m[i].t) {
				++lCount;
//				cout << "++L" << endl;
			}
			
			if (rCount && s[n - rCount] == m[i].t) {
				--rCount;
			}
		} else {
			if (s[n - 1 - rCount] == m[i].t) {
				++rCount;
//				cout << "++R" << endl;
			}
		
			if (lCount && s[lCount - 1] == m[i].t) {
				--lCount;
			}
		}
	}
	
	cout << n - (lCount + rCount) << endl;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N; cin >> N;
    map<int, int> mp;

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

    int ans = 0;
    for(int i=1; i<=N; i++) if(i == mp[mp[i]]) ans++;

    cout << ans/2 << endl;
}

Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int turu = 2;
		int  kame = 4;
		int temp = x*turu;
		if(y < temp) {
			System.out.println("No");
		return ;
		}
		if((y-temp)%2==1) {
			System.out.println("No");
		return ;
		}
		if(temp*2<y) {
			System.out.println("No");
			return;
		}
		System.out.println("Yes");
	}
}

Measured memory_bytes: 35776
fun main(args: Array<String>) {
    val (a, b) = readLine()!!.split(" ")

    val result = if (a == "H") {
        if (b == "H") {
            "H"
        } else {
            "D"
        }
    } else {
        if (b == "H") {
            "D"
        } else {
            "H"
        }
    }
    println(result)
}

Measured memory_bytes: 35944
#include <cstdio>
const int MAXN = 105;
char S[MAXN];
char T[MAXN];
int N;

int main() {
  scanf("%d", &N);
  scanf(" %s%s", S, T);
  for (int i = 0; i < N; ++i) {
    printf("%c%c", S[i], T[i]);
  }
  putchar('\n');
  return 0;
}

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

ll inf =1e9+7;

#define pi 3.14159265358979323846L
bool isprime(ll a)
{
	
	ll cnt=0;	
	for(ll i=1;i*i<a;i++)
	{
		
	 	if(a%i==0)
	 	{
	 		cnt+=2;
		 }
		
		
	}
	
		if(cnt==2)
		return true;
		else
		return false;
		
}
ll mod(ll a)
{
	if(a<inf)return a;
	else
	return a%inf;
}
void solve()
{

	ll A,B,H,M;
	cin>>A>>B>>H>>M;
	
	
	long double angle1=((long double)H/6.0)+((long double)M/(12.0*30.0))-((long double)M/30.0);
	angle1*=pi;
	long double angle2=2*pi-angle1;
	
	angle1=min(angle1,angle2);
	



	long double z=(A*A)+(B*B )-(2*A*B )*cos(angle1);
	z=sqrt(z);
	
	cout<<setprecision(20)<<z;
	
	
	

}

int main()
{


ios::sync_with_stdio(0); 
	cin.tie(0);

		solve();
	
return 0;

		
	}
	
	
	


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

#pragma GCC optimize("O3")
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i,n,N) for(ll i=n;i<=N;++i)
#define rap(i,n,N) for(ll i=n;i>=N;--i)
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define ff fi.fi
#define fs fi.se
#define sf se.fi
#define ss se.se
#define lc (id<<1)
#define rc ((id<<1)|1)
#define db(x) cout << ">>>>>> " << #x << " -> " << x << endl;
#define all(x) x.begin(),x.end()
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define piii pair<int,pii>
#define piiii pair<pii,pii>
#define psi pair<string,int>
#define endl "\n"
const int MAX = 1e5+5;
const ll MAX2 = 11;
const ll MOD = 1000000007;
const ll INF = 2e18;
const int dr[]={1,0,-1,0,1,1,-1,-1,0};
const int dc[]={0,1,0,-1,1,-1,1,-1,0};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 450;

ll n,k,inv,x[MAX],y[MAX],bit[MAX],res,id;

inline void upd(int i,int z){
	for(; i<=n; i+=(i&-i))bit[i]+=z;
}
int ret;
inline int que(int i){
	i--;
	ret = 0;
	for(; i> 0; i-=(i&-i))ret+=bit[i];
	return ret;
}

priority_queue<int, vector<int> ,greater<int> > pq;
priority_queue<pii, vector<pii> ,greater<pii> > tmp;
vector<int> ans;

int main(){
//	cout<<fixed<<setprecision(15);
//    freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>n>>k;
    rep(i,1,n)cin>>y[i], x[y[i]] = i;
    rap(i,n,1)inv+=que(x[i]), upd(x[i],1);
    if(inv<=k)rep(i,1,n)cout<<y[i]<<endl;
    else {
    	k = inv - k;
    	rep(i,1,n)pq.push(i);
    	rep(i,1,n){
    		while(!tmp.empty()&&que(x[tmp.top().se])<=k)pq.push(tmp.top().se), tmp.pop();
    		while(!pq.empty()){
    			id = pq.top(); pq.pop();
    			res = que(x[id]);
    			if(res>k)tmp.push({x[id],id});
    			else {
    				ans.pb(id);
    				k-=res;
    				upd(x[id],-1);
    				break;
				}
			}
		}
		for(auto i:ans)cout<<i<<endl;
	}
	return 0;
}


Measured memory_bytes: 6976
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val n, a, b = sc.nextInt()
  val ar = Range(0, n).map(_ => sc.nextLong()).sorted.toArray

  println(solve)

  def solve(): Long = {
    var l = 0L
    var r = 1000L * 1000L * 1000L
    while (l + 1 < r) {
      val c = (l + r) / 2
      if (ok(c)) r = c
      else l = c
    }
    return r
  }

  def ok(cnt: Long): Boolean = {
    ar.foldLeft(0L) {
      case (sum, h) => {
        if (cnt * b >= h) {
          sum
        } else {
          sum + ((h - cnt * b - 1) / (a - b)) + 1
        }
      }
    } <= cnt
  }
}


Measured memory_bytes: 107568
n,m = map(int,raw_input().strip().split(' '))
graph = [[] for i in range(n)]
for i in range(m):
    s,t = map(int,raw_input().strip().split(' '))
    graph[s].append(t)
    graph[t].append(s)
color = {}
c = 0
for i in range(n):
    if not i in color:
        que = [i]
        color[i] = c
        while len(que) > 0:
            u = que[0]
            for v in graph[u]:
                if not v in color:
                    color[v] = c
                    que.append(v)
            del que[0]
        c += 1
q = int(raw_input())
for i in range(q):
   s,t = map(int,raw_input().strip().split(' '))
   if color[s] == color[t]:
     print 'yes'
   else:
     print 'no'

Measured memory_bytes: 32000
#include<iostream>

using namespace std;

int main()
{
	int N,K;
	string S;

	cin >> N >> S >> K;

	char check = S[K-1];

	for(int i=0;i<N;i++)
	{
		if(check != S[i])
		{
			S[i] = '*';
		}
	}

	cout << S << endl;

	return 0;
}

Measured memory_bytes: 256
"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let S = cin.getStr();
    let N = S.length;
    const ABC = ["A", "B", "C"];
    const MOD = 1000000007;
    let dp = new Array(100010).fill(0).map(() => new Array(4).fill(0));
    for (let i = N; i >= 0; --i) {
        for (let j = 3; j >= 0; --j) {
            if (i == N) {
                dp[i][j] = (j == 3 ? 1 : 0);
            } else {
                dp[i][j] = dp[i + 1][j] * (S[i] == '?' ? 3 : 1);
                if (j < 3 && (S[i] == '?' || S[i] == ABC[j])) {
                    dp[i][j] += dp[i + 1][j + 1];
                }
                dp[i][j] %= MOD;
            }
        }
    }
    console.log(dp[0][0]);
}
class Inputer{constructor(t){this.cnt=0,this.items=t.split(/\n|\s/)}getInt(){return this.items[this.cnt++]-0}getIntArray(t){let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getInt();return r}getStr(){return this.items[this.cnt++]}getStrArray(t){let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getStr();return r}}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29780
#include<bits/stdc++.h>
using namespace std;
int a[110000],sum[110000];
int b[330000];
int main() {
	int n; cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	int st=0,en=1e9,mid,ans=en;
	auto add=[&](int u,int v) {
		for(int i=u;i<=3*(n+1);i+=i&-i) b[i]+=v;
	};
	auto get=[&](int u) {
		int ret=0;
		for(int i=u;i>0;i-=i&-i) ret+=b[i];
		return ret;
	};
	auto can=[&](int mid) {
		sum[0]=0;
		for(int i=1;i<=n;i++) sum[i]=sum[i-1]+2*(a[i]<=mid);
		for(int i=0;i<=3*(n+1);i++) b[i]=0;
		long long cnt=0;
		add(0+n+1,1);
		for (int i=1;i<=n;i++){
			cnt+=get(sum[i]-i+n);
			add(sum[i]-i+n+1,1);
		}
		return cnt*2>(long long)n*(n+1)/2;
	};
	while(st<=en) {
		mid=st+en>>1;
		if (can(mid)) ans=mid,en=mid-1;
		else st=mid+1;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 5588
MOD = 10 ** 9 + 7


n = int(input())
values = list(map(int, input().split()))
pops = [sum([(value >> i) & 1 for value in values]) for i in range(60)]
print(sum([(1 << i) * pops[i] * (n - pops[i]) for i in range(60)]) % MOD)


Measured memory_bytes: 42212
N,K,Q = map(int,input().split())
lis = list()
A = K -Q
point = [A for i in range(N)]
for i in range(Q):
  lis.append(int(input()))
for i in range(Q):
  point[lis[i]-1] += 1
for i in range(N):
  if point[i] >= 1:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 10436
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public static void Main(string[] args)
	{
		string[] b = Input();
		int n = int.Parse(b[0]);
		int x = int.Parse(b[1]);
		b = Input();
		int[] l = new int[n];
		int wa = 0;
		int c=1;
		for(int i = 0; i < n; i++)
		{
			l[i] = int.Parse(b[i]);
			if(wa + l[i] <= x) {
				c++;
			}
			else {
				break;
			}
			wa+=l[i];
		}
		
		
		Console.WriteLine(c);
	}

	
	public static string[] Input()
	{
		return Console.ReadLine().Split(' ');
	}

	
	public static int Clamp(int val, int max, int min = 0)
	{
		return Math.Min(max, Math.Max(min, val));
	}

	
}



Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define N 100
const ll INF=1e15+7;
ll n,s;

ll f(ll b,ll nn){
	if(nn<b)return nn;
	return f(b,nn/b)+nn%b;
}

int main(){
	cin>>n>>s;
	if(n==s){
		cout<<n+1<<endl;
		return 0;
	}
	FOR(i,2,sqrt(n)+1){
		if(f(i,n)==s){
			cout<<i<<endl;
			return 0;
		}
	}
	ll ans=INF;
	if(n-s<=1){
		cout<<-1<<endl;
		return 0;
	}
	FOR(i,1,sqrt(n)+1){
		if(f((n-s)/i+1,n)==s){
			ans=min((n-s)/i+1,ans);
		}
	}
	if(ans==INF)ans=-1;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int size = sc.nextInt();
        int[] array = new int[size];
        for(int i = 0; i < size; i++){
            array[i] = sc.nextInt();
        }
        System.out.println(solve(array));
    }

    public static long solve(int[] array){
        BigInteger sum = new BigInteger("0");
        BigInteger modulo = new BigInteger("1000000007");
        BigInteger newSum = new BigInteger("0");
        BigInteger product = new BigInteger("1");
        if(array.length == 1){
            return array[0];
        }
        for(int i = 0; i < array.length; i++) {
            sum = sum.add(new BigInteger(String.valueOf(array[i])));
        }
        for(int i = 0; i < array.length; i++) {
            BigInteger remainingSum = sum.subtract(new BigInteger(String.valueOf(array[i])));
            sum = remainingSum;
            product = remainingSum.multiply(new BigInteger(String.valueOf(array[i])));
            newSum = newSum.add(product);
        }
        BigInteger result = newSum.mod(modulo);
        return Long.parseLong(result.toString());
    }
}

Measured memory_bytes: 62596
import sys
from collections import deque
def input(): return sys.stdin.readline().rstrip()

def main():
    N, X, Y = map(int, input().split())

    ans = [0] * N
    for i in range(1, N+1):
        dist = [-1] * (N+1)
        dist[i] = 0
        q = deque()
        q.append(i)
        def push(l, m):
            if dist[l] > -1:
                return
            q.append(l)
            dist[l] = dist[m] + 1
            ans[dist[l]] += 1

        while q:
            j = q.popleft()
            if j < N: push(j+1, j)
            if j > 1: push(j-1, j)
            if j == X: push(Y, j)
            if j == Y: push(X, j)
    print(*[i // 2for i in ans[1:]], sep='\n')

if __name__ == '__main__':
    main()


Measured memory_bytes: 49756