akhauriyash/Code-Regression huggingface dataset:
package main

import (
  "bufio"
  "fmt"
  "os"
  "sort"
  "strconv"
  "strings"
)

const size = 1000000
var reader = bufio.NewReaderSize(os.Stdin,size)

func NextLine() string {
  var line,buffer []byte
  var isPrefix bool = true
  var err error
  for ;isPrefix; {
    line,isPrefix,err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
  }
  return string(buffer)
}

func NextInt() int {
  var n int
  n,_ = strconv.Atoi(NextLine())
  return n
}

func NextIntArray() []int {
  var s []string = strings.Split(NextLine()," ")
  var n int = len(s)
  var a []int = make([]int,n)
  for i:=0;i<n;i++ {
    a[i],_ = strconv.Atoi(s[i])
  }
  return a
}

func main() {
  var n int = NextInt()
  var a []int = NextIntArray()
  var s []int = make([]int,n)
  copy(s,a)
  sort.Ints(s)
  var l int = binarySearch(n,s,a)
  fmt.Println(s[l])
}

type BinaryIndexTree struct {
  BIT []int
}

func(b *BinaryIndexTree) add(i int,v int) {
  for x:=i;x<=len(b.BIT);x+=x&-x {
    b.BIT[x-1] += v
  }
}

func(b *BinaryIndexTree) sum(i int) int {
  var r int
  for x:=i;0<x;x-=x&-x {
    r += b.BIT[x-1]
  }
  return r
}

func(b *BinaryIndexTree) renderValue() {
  fmt.Println(b.BIT)
}

func cusum(k int,a []int) ([]int,int,int,int) {
  var b []int = make([]int,len(a))
  var sum,neg int
  var min int = len(a)
  var max int = -len(a)
  for i:=0;i<len(a);i++ {
    if a[i] < k {
      sum -= 1 
    } else {
      sum += 1 
    }
    b[i] = sum
    if sum > max { max = sum }
    if sum < min { min = sum }
    if sum < 0 { neg += 1 }
  }
  return b,min,max,neg
}

func countFallNumber(a []int,k int) int {
  var x int
  b,min,max,neg := cusum(k,a)
  var n int = max-min+1
  bit := BinaryIndexTree{BIT:make([]int,n)}
  for _,v := range b {
    x += bit.sum(n) - bit.sum(v-min+1)
    bit.add(v-min+1,1)
  }
  return x + neg
}

func binarySearch(n int,s []int,a []int) int {
  th := float64((n*(n+1))/4)
  var r int = len(s)
  var l int = -1
  var m int
  for r-l > 1 {
    m = (r+l)/2
    if float64(countFallNumber(a,s[m])) > th { 
      r = m 
    } else {
      l = m 
    }
  }
  return l
}

Measured memory_bytes: 9856
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long mod = 1000000000 + 7;
        long answer = (powMod(10,n,mod)-2*powMod(9,n,mod)+powMod(8,n,mod))%mod;
        answer = (answer+mod)%mod;
        System.out.println(answer);
    }
    public static long powMod(long a, long b, long mod) {
        long p = 1;
        for (int i=0;i<b;i++) {
            p=p*a%mod;
        }
        
        return p;
    }
}


Measured memory_bytes: 35824
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n;i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b;i++)
#define repv(x, arr) for (auto& x:arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a,b) make_pair(a,b)
#define op(i) cout << (i) << endl;
#define F first
#define S second

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

const ll mod = 1e9 + 7;


int main(){
    int a, b;
    cin >> a >> b;
    if (a==b){
        cout << "Draw" << endl;
    }
    else {
        if (a==1||(b!=1 && a>b)){
            cout << "Alice" << endl;
        }
        else{
            cout << "Bob" << endl;
        }
    }
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i + 100*j + 50*k == x:
                ans += 1
print(ans)



Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        solve();
    }

    private static void solve() {
        Scanner input = new Scanner(System.in);

        int n = input.nextInt();
        int k = input.nextInt();

        int ans = n - k + 1;

        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>
#define N 100

void hanten(char str[],int n){
  char t;
  int i,j;
    for (j=0;j<n/2;j++){
      t=str[j];
      str[j]=str[n-j-1];
      str[n-j-1]=t;
    }
}

int main()
{
  int i,j,cnt=0;
  char str1[N],str2[N];
  while (scanf("%s",str1)!=EOF){
    strcpy(str2,str1);
    hanten(str1,strlen(str1));
    if (strcmp(str1,str2)==0)
      cnt++;
  }
  printf("%d\n",cnt);

  return 0;
}

Measured memory_bytes: 560
N = int(input())
A = []

for _ in range(N):
    A.append([tuple(map(int, input().split())) for _ in range(int(input()))])

def exists(state):
    ret = 0
    for i in range(N):
        if ((1 << i) & state) == 0:
            continue
        ret += 1
        for x, y in A[i]:
            if ((state & (1 << (x - 1))) > 0) != (y > 0):
                return 0
    return ret

ans = 0
for state in range(1 << N):
    ans = max(ans, exists(state))
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl
#define pno cout << "no" << endl
#define pYe cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pYE cout << "YES" << endl
#define pNO cout << "NO" << endl
#define prin(num) cout << num << endl
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 100000000000000000
#define MOD 1000000007LL
#define MAX_V 100005
#define MAX_E 100005
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef priority_queue<P> PQ;

class Edge {
public:
    ll t, w;
    Edge (ll t, ll w): t(t), w(w) {}
};

ll N;
vector<Edge> G[MAX_V];
ll color[MAX_V];
ll d[MAX_V];
vector<ll> ans;

void dijkstra(ll s) {
    ll i, u;
    for(i=0; i<N; i++) {
        d[i]=INF;
        color[i]=WHITE;
    }
    priority_queue<P> PQ;
    PQ.push(P(0, s));
    d[s]=0;
    
    while(PQ.size()) {
        P f=PQ.top(); PQ.pop();
        u=f.second;
        
        color[u]=BLACK;
        if(d[u]<f.first*(-1)) continue;
        
        for(i=0; i<G[u].size(); i++) {
            Edge &e=G[u][i];
            if(color[e.t]!=BLACK && d[e.t]>d[u]+e.w) {
                d[e.t]=d[u]+e.w;
                PQ.push(P(-d[e.t], e.t));
            }
            
        }
        
    }
}

void add_edge(ll s, ll t, ll w) {
    G[s].push_back(Edge(t, w));
    G[t].push_back(Edge(s, w));
}

int main(void) {
    cin >> N;
    ll a, b, c;
    ll i;
    
    for(i=0; i<N-1; i++) {
        cin >> a >> b >> c;
        a--; b--;
        add_edge(a, b, c);
    }
    
    ll Q, K;
    cin >> Q >> K;
    K--;
    dijkstra(K);
    for(i=0; i<Q; i++) {
        ll x, y;
        cin >> x >> y;
        x--; y--;
        prin(d[x]+d[y]);
    }
    
}


Measured memory_bytes: 11888
#include <stdio.h>
#include <string.h>

int main(){
    int m, h;
    char cards[256], temp[256], result[256];
    int i, j=0, len;

    while(1){
        scanf("%s", cards);
        len=strlen(cards);
        if(strcmp(cards, "-")==0&&len==1)break;
        scanf("%d", &m);
        for(;m>0;m--){
            scanf("%d", &h);
            strcpy(temp, cards);
            for(i=0;i<h;i++){
                cards[len-h+i]=temp[i];
            }
            for(i=0;i<len-h;i++){
                cards[i]=temp[i+h];
            }
        }
        for(i=0;i<len;i++){
            result[j++]=cards[i];
        }
        result[j++]='\n';
    }
    result[j]='\0';
    printf("%s", result);

    return 0;
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> vec(N);
    rep(i,N){
        cin >> vec[i];
    }
    sort(all(vec));
    if (N <= K){
        cout << 0 << endl;
    }
    else{
        ll ans = 0;
        for (int i = 0; i <= N - K - 1; i++){
            ans += vec[i];
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 1792
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	string s;
	cin>>s;
	int ans = 0;
	rep(i,s.size()){
		if("CODEFESTIVAL2016"[i]!=s[i]) ans++;
	}
	cout<<ans<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{

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

        int N = sc.nextInt();
        int[][] A = new int[3][N];
        for(int i = 0; i < N; i++){
            A[0][i] = sc.nextInt();
        }
        for(int i = 0; i < N; i++){
            A[1][i] = sc.nextInt();
        }
        for(int i = 0; i < N; i++){
            A[2][i] = sc.nextInt();
        }
        sc.close();
        Arrays.sort(A[0]);
        Arrays.sort(A[1]);
        Arrays.sort(A[2]);
        
        long sum = 0;
        /*for(int i = 0; i < N; i++){
            System.out.println(A[0][i]);
            if(i == N-1){
                System.out.println();
            }
        }
        for(int i = 0; i < N; i++){
            System.out.println(A[1][i]);
            if(i == N-1){
                System.out.println();
            }
        }
        for(int i = 0; i < N; i++){
            System.out.println(A[2][i]);
            if(i == N-1){
                System.out.println();
            }
        }*/
        
        for(int i = 0; i < N; i++){
            //System.out.println(Binary_search(A[0], A[1][i]) + " " + Binary_search(A[2], A[1][i]+1));
            sum += ((long)Binary_search(A[0], A[1][i]) * (long)(N-Binary_search(A[2], A[1][i]+1)));
        }
        System.out.println(sum);
    }

    static int Binary_search(int[] a, int n){
        int lower = -1;
        int upper = a.length;
        while(upper-lower != 1){
            int mid = (lower+upper) / 2;
            if(a[mid] < n){
                lower = mid;
            } else {
                upper = mid;
            }
        }
        return lower+1;
    }
}

Measured memory_bytes: 95544
n,m = map(int, input().split())
a = {}
for i in range(m):
    s,c = map(int, input().split())
    s -= 1
    if s not in a:
        a[s] = c
    elif a[s] != c:
        print(-1)
        exit()

for i in range(1000):
    ss = str(i)
    for s,c in a.items():
        # print(s,ss)
        if len(ss) <= s:
            continue
        if int(ss[s]) != c:
            break
    else:
        if len(ss) == n:
            print(i)
            break
else:
    print(-1)

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

int main()
{
	int H, W, N;
	cin >> H >> W >> N;
	vector<int> a( N );
	for( int i = 0; i < N; i++ ) {
		cin >> a[i];
	}

	vector<vector<int>> ans( H, vector<int>( W ) );
	int h = 0;
	int w = 0;
	int flag = 0;
	for( int i = 0; i < N; i++ ) {
		int A = a[i];
		for( int j = 0; j < A; j++ ) {
			ans[h][w] = i + 1;
			if( flag == 0 ) {
				w++;
				if( w >= W ) {
					flag = 1;
					w--;
					h++;
				}
			}
			else {
				w--;
				if( w < 0 ) {
					flag = 0;
					w++;
					h++;
				}
			}
		}
	}

	for( int i = 0; i < H; i++ ) {
		for( int j = 0; j < W; j++ ) {
			if( j ) cout << " ";
			cout << ans[i][j];
		}
		cout << endl;
	}
}


Measured memory_bytes: 3684
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int gcd(int x, int y) {
		if ( x < y ) swap(x, y);
		if ( y == 0 ) return x;
		return gcd(x % y, y);
}

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

		vector<int> L(N, 0), R(N, 0);
		L[0] = A[0];
		R[0] = A[N - 1];
		for ( int i = 0; i < N - 1; i++ ) {
				L[i + 1] = gcd(L[i], A[i + 1]);
		}

		for ( int i = 0; i < N - 1; i++ ) {
				R[i + 1] = gcd(R[i], A[(N - 1) - i - 1]);
		}

		int ans = 0;
		for ( int i = 0; i < N; i++ ) {
				int t;
				if ( !i ) t = R[N - (i + 1) -1];
				else if ( i == (N - 1) ) t = L[(N - 1) - 1];
				else t = gcd(L[i - 1], R[N - (i + 1) - 1]);
				if ( ans < t ) ans = t;
		}

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


Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstdlib>

using namespace std;

int main()
{
  long long N;

  cin >> N;

  vector<long long> P(N);

  for(long long i=0; i<N; i++)
    cin >> P[i];

  vector<long long> M(N);
  M[0]=P[0];
  for(long long i=1; i<N; i++)
    {
      if(M[i-1]<P[i])
	M[i]=M[i-1];
      else
	M[i]=P[i];
    }

  long long count = 0;

  for(long long i=0; i<N; i++)
    if(P[i]==M[i])
      count++;
  
  cout << count << endl;
  
  return 0;
}




Measured memory_bytes: 3456
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int a,b,c; cin>>a>>b>>c;
	if((a==b&&b!=c)||(a!=b&&b==c)||(a==c&&b!=c)) cout<<"Yes"<<endl;
	else cout <<"No"<<endl;


  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <set>
#include <iomanip>
using namespace std;

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

void print_v(vector<int> v){
    for(int i=0; i<v.size(); i++){
        cout << char(v[i]+97);
    }
    cout << endl;
}

int main()
{
	string s,t;
    cin >> s >> t;
    vector<int> from(26,-1), to(26, -1);
    int offset=(int)'a';
    
    for(int i=0; i<s.size(); i++){
        int sint=s[i]-offset, tint=t[i]-offset;
        bool flag=true;
        if(from[sint]==-1 && to[tint]==-1){
            from[sint]=tint;
            to[tint]=sint;
            continue;
        }else if(from[sint]==tint && to[tint]==sint) continue;
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 776
import java.util.Scanner;
public class Main {
    public static void main(String[] $) {
       Scanner sc = new Scanner(System.in);
       long cnt=0,ans=0;
       String s=sc.next();
       s=s.replace("BC", "D");
       for(int i=0;i<s.length();i++) {
    	   String s2=s.substring(i, i+1);
    	   if(s2.equals("A"))cnt++;
    	   else if(s2.equals("D"))ans+=cnt;
    	   else cnt=0;
       }
       System.out.println(ans);
    }
   }

Measured memory_bytes: 39380
#include <bits/stdc++.h>
#define pb push_back
using namespace std;

int n;
vector<int>v;

int main() {
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>n;
    int t=n, i=2;
    while (i<=sqrt(t)) {
        if (t%i==0) v.pb(i), t/=i;
        else ++i;
    }
    cout<<n<<":";
    for (int p:v) cout<<' '<<p;
    cout<<' '<<t<<'\n';
}


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

int main(){
  int a,b,c,d;cin >> a >> b >> c >> d;
  int ans = 0;
  for(int i=0;i<=100;++i){
    if(i >= a&&i < b&&i >= c&&i < d)ans += 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int dis[N], n;
deque<int>q;
int main()
{
	cin >> n;
	fill(dis, dis + 1 + n, ~0u >> 1);
	q.push_back(1);
	dis[1] = 0;
	while (!q.empty())
	{
		int x = q.front();
		q.pop_front();
		if (dis[x * 10 % n] > dis[x])
		{
			dis[x * 10 % n] = dis[x];
			q.push_front(x * 10 % n);
		}
		if (dis[(x + 1) % n] > dis[x] + 1)
		{
			dis[(x + 1) % n] = dis[x] + 1;
			q.push_back((x + 1) % n);
		}
	}
	cout << dis[0] + 1;
}

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

using namespace std;

using ll = long long;

void Solve(int a, int b) {
    if (a == 0 || b == 0) {
        cout << a << ' ' << b << '\n';
        cout << ((a == 0) ? "#\n" : ".\n");
        return ;
    }

    --a; --b;
    const int size = 100, half = size / 2;
    cout << size << ' ' << size << '\n';
    for (int i = 0; i < size; ++i) {
        if (i % 2 == 0) {
            cout << string(half, '#') << string(half, '.') << '\n';
        }
        else {
            for (int j = 0; j < half; j += 2) {
                if (0 < a) { cout << ".#"; --a; }
                else cout << "##";
            }

            for (int j = half; j < size; j += 2) {
                if (0 < b) { cout << ".#"; --b; }
                else cout << "..";
            }
            cout << '\n';
        }
    }
}

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

    int a, b;

    cin >> a >> b;
    Solve(a, b);

    return 0;
}


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

int main(){
	string s;
	cin>>s;
	for(int i=0;i<4;i++){
		cout<<s[i];
	}
	cout<<" ";
	for(int i=4;i<12;i++){
		cout<<s[i];
	}
	cout<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(A: int, B: int):
    if A % 2 == 0 or B % 2 == 0:
        print(NO)
    else:
        print(YES)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#define MAX 10000
#define NIL -1
using namespace std;

struct Node
{
	int parent, left, right;
};
Node T[MAX];
int n;

void Preorder(int u)
{
	if (u == NIL)
	{
		return;
	}
	cout << ' ' << u;
	Preorder(T[u].left);
	Preorder(T[u].right);
}
void Inorder(int u)
{
	if (u == NIL)
	{
		return;
	}
	Inorder(T[u].left);
	cout << ' ' << u;
	Inorder(T[u].right);
}
void Postorder(int u)
{
	if (u == NIL)
	{
		return;
	}
	Postorder(T[u].left);
	Postorder(T[u].right);
	cout << ' ' << u;
}

int main()
{
	int v, l, r, root = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		T[i].parent = NIL;
	}
	for (int i = 0; i < n; i++)
	{
		scanf("%d %d %d", &v, &l, &r);
		T[v].left = l;
		T[v].right = r;
		if (l != NIL)
		{
			T[l].parent = v;
		}
		if (r != NIL)
		{
			T[r].parent = v;
		}
	}
	for (int i = 0; i < n; i++)
	{
		if (T[i].parent == NIL)
		{
			root = i;
		}
	}
	cout << "Preorder" << endl;
	Preorder(root);
	cout << endl;
	cout << "Inorder" << endl;
	Inorder(root);
	cout << endl;
	cout << "Postorder" << endl;
	Postorder(root);
	cout << endl;
	return 0;
}


Measured memory_bytes: 3168
#include <stdio.h>    
#define N 100
#define INF 1000000
#define _CRT_SECURE_NO_WARNINGS

int map[N][N];

int main(){
	int n, m;
	int i, j;
	int num;
	int a, b;
	while (scanf("%d %d", &n, &m), n || m){
		for (i = 0; i < n; i++){
			for (j = 0; j < m; j++){
				if (i == 0 || j == 0) map[i][j] = 1;
				else map[i][j] = INF;
			}
		}

		scanf("%d", &num);
		for (i = 0; i < num; i++){
			scanf("%d %d", &a, &b);
			map[a - 1][b - 1] = 0;
			if (a - 1 == 0){
				for (j = b - 1; j < m; j++)map[a - 1][j] = 0;
			}
			if (b - 1 == 0){
				for (j = a - 1; j < n; j++)map[j][b - 1] = 0;
			}
		}

		for (i = 1; i < n; i++){
			for (j = 1; j < m; j++){
				if (map[i][j] == INF) map[i][j] = map[i - 1][j] + map[i][j - 1];
			}
		}
		printf("%d\n", map[n - 1][m - 1]);
	}
	return 0;
}

Measured memory_bytes: 604
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<map>
#include<ctime>

using namespace std;

template <typename T>

inline T read()
{
	T x=0,f=1;char c=getchar();
	while(!isdigit(c))
	{if(c=='-') f=-f;c=getchar();}
	while(isdigit(c))
	{x=(x<<3)+(x<<1)+(c-48);c=getchar();}
	return x*f;
}

#define lint long long int
#define ulint unsigned lint
#define readint read<int>()
#define readlint read<lint>()

const int inf=1e9+1e7,MAXN=1e2+1e1;

int a[MAXN];
int n,ans=0;

int main(void)
{

	// freopen("testdata.in","r",stdin);
	// freopen("testdata.out","w",stdout);

	scanf("%d",&n);

	for(int i=1;i<=n+n;i++) a[i]=readint;

	sort(a+1,a+n+n+1);

	for(int i=1;i<=n+n;i+=2) ans+=a[i];

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

	return 0;

}

Measured memory_bytes: 3820
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <map>
#include <limits>
using namespace std;
typedef long long ll;

float inf = std::numeric_limits<float>::infinity();
ll mod = 1e9+7;

/* 二次元配列の宣言
  vector<vector<int>> tb;
  tb.resize(H);
  for (size_t i = 0; i < H; i++) {
    tb[i].resize(W);
  }
*/
/*
  A.resize(N);
  for (int i = 0; i < N; i++) {scanf("%d",&A[i]);}
*/

int main(void) {
  string str;
  cin >> str;

  int left,right;
  bool flag=true;
  for (size_t i = 0; i < str.size(); i++) {
    if (str[i]=='A' && flag){
      left = i;
      flag = false;
    }else if(str[i]=='Z'){
      right = i;
    }
  }

  std::cout << right - left + 1 << '\n';

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    vector < vector <int> > v;
    v.resize(100005);
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        v[a].push_back(b);
    }
    int ans = 0;
    priority_queue <int> pq;
    for(int i = 1; i <= m; i++){
        for(auto j : v[i])
            pq.push(j);
        if(!pq.empty()){
            ans += pq.top();
            pq.pop();
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 5632
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>

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

using namespace std;

int main()
{
    int N;
    cin >> N;

    int ans=0;
    int l,r;

    REP(i,N){
        cin >> l >> r;
        ans += r-l+1;
    }

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


Measured memory_bytes: 256
import sys
n,m,v,p=map(int,sys.stdin.readline().split())
a=sorted(list(map(int, sys.stdin.readline().split())),reverse=True)[p-1:]
l,r=0,n-p

def adopt(x):
    global a,n,m,v
    b=a[x]+m
    if b<a[0]:
        return False
    al=(v-(n-x))*m
    s=x*b-sum(a[:x])
    return al<=s

while l+1<r:
    k=(l+r)//2
    if adopt(k):
        l=k
    else:
        r=k

if adopt(r):
    print(p+r)
else:
    print(p+l)


Measured memory_bytes: 14172
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
    int n, x;
    cin >> n >> x;
    int a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    sort(a, a+n);
    int ans = 0;
    for(int i=0;i<n-1;i++){
        x -= a[i];
        if(x >= 0) ans++;
        else break;
    }
    if(x == a[n-1]){
        ans++;
    }
    cout << ans << endl;
}

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

int main(){
  int N,K;
  cin >> N >> K;
  
  int a = N;
  int cnt = 1;
  for(int i = 0; i < 40; i++){
    if(a < K){
      break;
    }
    a /= K;
    cnt++;
  }
  
  cout << cnt << endl;

  
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
    }
    double h = accumulate(a.begin(), a.end(), 0.0) / N;
    double min = 1000000;
    int ans = 0;
    for (int j = 0; j < N; ++j) {
        if (min > abs(a[j] - h)) {
            ans = j;
            min = abs(a[j] - h);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
V = list(map(int, input().split()))
ans = 0
for anum in range(min(N, K) + 1):
    owned = V[:anum]
    for bnum in range(min(N, K) - anum + 1):
        if bnum > 0:
            owned.append(V[-bnum])
        owned.sort()
        cdnum = K - (anum + bnum)
        total = 0
        for v in owned:
            if v < 0 and 0 < cdnum:
                cdnum -= 1
            else:
                total += v
        ans = max(ans, total)
print(ans)

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

int main(){
	int N,K; cin>>N>>K;
	vector<int> A(N);
	rep(i, N) cin>>A[i];
	rep(i, N-K) puts(A[i] < A[i+K]? "Yes":"No");
}


Measured memory_bytes: 4004
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
 
#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif
 
const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;
 
int main() {
 
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
 
	int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	string S;
	cin >> S;
 
 
 
	if (C < D) {
 
		bool flag = true;
		for (int i = A; i < C - 1; i++) {
			if (S[i] == '#' && S[i + 1] == '#') flag = false;
		}		
		for (int i = B; i < D - 1; i++) {
			if (S[i] == '#' && S[i + 1] == '#') flag = false;
		}
 
		if (flag) cout << "Yes" << "\n";
		else cout << "No" << "\n";
 
	}
	else {
 
		bool flag = false;
		for (int i = B - 2; i < D - 1; i++) {
 
			if (S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.') flag = true;
 
		}
		if (flag) cout << "Yes" << "\n";
		else cout << "No" << "\n";
 
	}
 
	return 0;
}


Measured memory_bytes: 592
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 10000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

struct Info{
	Info(int arg_node_id,int arg_cost_sum){
		node_id = arg_node_id;
		cost_sum = arg_cost_sum;
	}
	int node_id,cost_sum;
};

int main(){

	int N,M,start,goal;
	scanf("%d %d %d %d",&N,&M,&start,&goal);

	ll* from_start_Dist = new ll[N+1];
	ll* from_goal_Dist = new ll[N+1];
	ll *Dist_num_from_start = new ll[N+1];
	ll *Dist_num_from_goal = new ll[N+1];

	vector<int> V[N+1]; //????????°???????????????:?????¢???1??¨??????

	for(int i = 1; i <= N; i++){
		from_start_Dist[i] = BIG_NUM;
		from_goal_Dist[i] = BIG_NUM;
		Dist_num_from_start[i] = 0;
		Dist_num_from_goal[i] = 0;
	}

	from_start_Dist[start] = 0;
	from_goal_Dist[goal] = 0;
	Dist_num_from_start[0] = 0;
	Dist_num_from_goal[0] = 0;

	int from,to;

	for(int i = 0; i < M; i++){
		scanf("%d %d",&from,&to);
		V[from].push_back(to);
		V[to].push_back(from);
	}

	queue<Info> Q;

	//?????????start???????????????????????§??????????????¢????¨????
	for(int i = 0; i < V[start].size(); i++){
		from_start_Dist[V[start][i]] = 1;
		Q.push(Info(V[start][i],1));
	}

	int min_index;

	while(!Q.empty()){
		if(Q.front().cost_sum > from_start_Dist[Q.front().node_id]){ //???????????????????????¶?????????????????£??????SKIP
			Q.pop();
			continue;
		}else{
			min_index = Q.front().node_id;
			Q.pop();
		}

		for(int i = 0; i < V[min_index].size();i++){
			if(from_start_Dist[V[min_index][i]] > from_start_Dist[min_index] + 1){
				from_start_Dist[V[min_index][i]] =from_start_Dist[min_index] + 1;
				Q.push(Info(V[min_index][i],from_start_Dist[V[min_index][i]]));
			}
		}
	}

	//?????¢?????¨????????°????¨????
	for(int i = 1; i <= N; i++){
		if(from_start_Dist[i] != BIG_NUM){
			Dist_num_from_start[from_start_Dist[i]]++;
		}
	}
	int length = from_start_Dist[goal];


	//?¬????goal???????????????????????§??????????????¢????¨????
	for(int i = 0; i < V[goal].size(); i++){
		from_goal_Dist[V[goal][i]] = 1;
		Q.push(Info(V[goal][i],1));
	}

	while(!Q.empty()){
		if(Q.front().cost_sum > from_goal_Dist[Q.front().node_id]){ //???????????????????????¶?????????????????£??????SKIP
			Q.pop();
			continue;
		}else{
			min_index = Q.front().node_id;
			Q.pop();
		}

		for(int i = 0; i < V[min_index].size();i++){
			if(from_goal_Dist[V[min_index][i]] > from_goal_Dist[min_index] + 1){
				from_goal_Dist[V[min_index][i]] =from_goal_Dist[min_index] + 1;
				Q.push(Info(V[min_index][i],from_goal_Dist[V[min_index][i]]));
			}
		}
	}

	//?????¢?????¨????????°????¨????
	for(int i = 1; i <= N; i++){
		if(from_goal_Dist[i] != BIG_NUM){
			Dist_num_from_goal[from_goal_Dist[i]]++;
		}
	}

	ll ans = 0;

	for(int i = 0; i <= length-2; i++){
		ans += Dist_num_from_start[i]*Dist_num_from_goal[(length-2)-i];
	}

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

	return 0;
}

Measured memory_bytes: 12356
#include <bits/stdc++.h>
#define ll long long
#define inf 1e9+10
using namespace std;
inline int read(){
	int x=0;int f=1;char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-') f=-1;ch=getchar();}
	while(isdigit(ch)) {x=x*10+ch-'0';ch=getchar();}
	return x*f;
} 
int main(){
	int n=read();
	int minn=inf;
	for(int i=1;i<n;i++){
		int k=n-i;
		int t=i;
		int sum=0;
		while(k) sum+=k%10,k/=10;
		while(t) sum+=t%10,t/=10;
		minn=min(minn,sum);
	}
	cout<<minn<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define f first
#define s second
#define int long long
#define sz(x) (ll)(x.size())
using namespace std;


const int mod = 1e9+7;

int expo_pow(int x,int y){
 if(y == 0) return 1;
  y=y%(mod-1);
  x%=mod;
  if(y==0) y=mod-1;
  int res=1;
  while(y){
    if(y&1) res=(res*x)%mod;
    x=(x*x)%mod;
    y>>=1; 
  }
  return res;
}

ll add()
{
    return 0;
}

template <typename T, typename... Types>
T add(T var1, Types... var2){
    return (((((ll)(var1)) % mod + (ll)(add(var2...))) % mod) + mod) % mod;
}

ll mul(){
    return 1;
}

template <typename T, typename... Types>
T mul(T var1, Types... var2){
    return (((ll)(var1)) % mod * (ll)(mul(var2...))) % mod;
}

const int mx = 1e5;
int fact[mx];
int inv_fact[mx];

int inv(int x) {
  return expo_pow(x,mod-2);
}

void precompute() {
  fact[0] = 1;
  for (int i = 1; i < mx; ++i) fact[i] = mul(fact[i-1],i);
  for (int i = 0; i < mx; ++i) inv_fact[i] = inv(fact[i]);
}

int ncr(int n,int r) {
  if (n < r or n < 0) return 0;
  return mul(fact[n],inv_fact[r],inv_fact[n-r]);
}

void solve(){
  int s;
  cin >> s;
  if ( s < 3) {
    cout << 0 << "\n";
    return;
  }
  
  int ans = 0;
  for (int i = 1; i <= s/3; ++i) {
    ans = add(ans,ncr(s - 3*i + i-1,i-1));
  }
  cout << ans << "\n";

}


signed main(){
  fast;
  precompute();
  int test = 1;
  int i=1;
  while(test--){
    solve();
  }
}





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

typedef long long LL;

void solve() {
    int x;
    cin >> x;
    if(400 <= x && x <= 599) puts("8");
    else if(600 <= x && x <= 799) puts("7");
    else if(800 <= x && x <= 999) puts("6");
    else if(1000 <= x && x <= 1199) puts("5");
    else if(1200 <= x && x <= 1399) puts("4");
    else if(1400 <= x && x <= 1599) puts("3");
    else if(1600 <= x && x <= 1799) puts("2");
    else puts("1");
}

int main() {
//    freopen("in.txt", "r", stdin);
    solve();
    return 0;
}


Measured memory_bytes: 3672
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int x = sc.nextInt();
		int y = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		int p[] = new int[a];
		int q[] = new int[b];
		int r[] = new int[c];
		
		for(int i = 0; i < a; i++) {
			p[i] = sc.nextInt();
		}

		for(int i = 0; i < b; i++) {
			q[i] = sc.nextInt();
		}
		
		for(int i = 0; i < c; i++) {
			r[i] = sc.nextInt();
		}
		
		Arrays.sort(p);
		Arrays.sort(q);
		Arrays.sort(r);
		
		long total = 0;
		PriorityQueue<Integer> pq = new PriorityQueue<Integer>();
		
		for(int i = 0; i < x; i++) {
			total += p[a - i - 1];
			pq.add(p[a - i - 1]);
		}

		for(int i = 0; i < y; i++) {
			total += q[b - i - 1];
			pq.add(q[b - i - 1]);
		}

		for(int i = c - 1; i >= 0; i--) {
			if(pq.isEmpty()) {
				break;
			}
			int tmp = pq.remove();
			
			if(r[i] > tmp) {
				total += r[i] - tmp;
			}
		}
		System.out.println(total);
	}

}


Measured memory_bytes: 97624
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int> judge(4);
  int N;
  string a;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> a;
    if(a =="AC")
      judge.at(0)++;
    else if(a == "WA")
      judge.at(1)++;
    else if(a == "TLE")
      judge.at(2)++;
    else
      judge.at(3)++;
  }
  cout << "AC x " << judge.at(0) << endl;
  cout << "WA x " << judge.at(1) << endl;
  cout << "TLE x " << judge.at(2) << endl;
  cout << "RE x " << judge.at(3) << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define INF 1e9+7
#define rep(i,n) for(ll i=0;i<n;i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
const int maxn = 200000;
ll mod = INF;


int main(){
    map<string,int> m; 
    int n;
    int M=0;
    cin >> n;
    rep(i,n){
        string s;
        cin >> s;
        m[s]++;
        M=max(M,m[s]);
    }

    vector<string> ans;
    for(auto ite=m.begin();ite!=m.end();ite++){
        if(M==ite->second){
            ans.push_back(ite->first);
        }
    }

    sort(ans.begin(),ans.end());
    rep(i,ans.size())cout << ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 27292
# soundhound2018-summer-qualC - Ordinary Beauty
def main():
    N, M, D = list(map(int, input().rstrip().split()))
    x = 2 if D else 1
    ans = x * (N - D) * (M - 1) / N ** 2
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
import collections
n,k,s = input().split()



dq = collections.deque()
max_value = str(10**9)
if int(s) !=10**9:
    for i in range(int(k)):
        dq.append(s)
    for i in range(int(n)-int(k)):
        dq.append(max_value)
    ans = " ".join(list(dq))
    print(ans)
else:
    for i in range(int(k)):
        dq.append(s)
    for i in range(int(n)-int(k)):
        dq.append("1")
    ans = " ".join(list(dq))
    print(ans)
        

Measured memory_bytes: 7396
#include<bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl


int main()
{
	int n,m;
	cin>>n>>m;
	int min = 1,max = n;
	for(int i =0;i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		if(a>min)
			min =a;
		if(b<max)
			max = b;

	}
	if(max-min+1<0)
		dump(0);
	else
	dump(max-min+1);
}

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

int main(){
  int N,K,d,i,j,a;
  cin >> N >> K;
  vector<int> A(N+1,0);
  for(i=0;i<K;i++){
    cin >> d;
    for(j=0;j<d;j++){
      cin >> a;
      A[a]++;
    }
  }
  int ct=0;
  for(i=1;i<=N;i++)
    if (A[i] == 0)
      ct++;
  
  cout << ct << endl;

  return 0;
}

Measured memory_bytes: 3600
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

  
def main():
    n = int(input())
    ans = 0 
    zs = []
    f = factorization(n) 
    for p, c in f:
        for i in range(1, c + 1):
            zs.append(p ** i)
    zs = sorted(zs, reverse=True)
    while n >1 and zs != []:
        a = zs.pop()
        if n  % a == 0:
            n = n / a
            ans += 1
    print(ans)
        
            
if __name__ == '__main__':
    main()

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> H(N);
    rep(i,N) cin >> H.at(i);
    sort(H.begin(), H.end());
    K = min(N, K);
    long long count = 0;
    rep(i,N-K) count += H.at(i);
    cout << count << endl;
}


Measured memory_bytes: 1024
n, m = map(int, input().split())
graph = [[] for i in range(n)]
height = [int(h) for h in input().split()]
for j in range(m):
    a, b = map(int, input().split())
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)
graph_ = [set(graph[i]) for i in range(n)] 
ans = 0
for i in range(n):
    h = height[i]
    flag = True
    if graph_[i] == {}:
        ans += 1
    else:
        for j in graph_[i]:
            if h <= height[j]:
                flag = False
                break
        if flag:
            ans += 1
print(ans)

Measured memory_bytes: 56156
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n;
    cin >> n;
    if(n % 2 == 0) cout << n << endl;
    else cout << 2*n << endl;

    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    char b; cin >> b;
    if(b == 'A') OUT('T');
    else if(b == 'T') OUT('A');
    else if(b == 'C') OUT('G');
    else OUT('C');

    return 0;
}

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

#define int long long
#define rep(i,a,b) for(int i = a; i < b; i++)
const int mod = 1e9 + 7;

vector<int> ad[100010];
int dp[100010][2];


void rec(int v=0, int pv=-1) {
    rep(i,0,ad[v].size()) {
        int cv = ad[v][i];
        if (cv == pv) continue;
        rec(cv, v);
        dp[v][0] *= dp[cv][0] + dp[cv][1];
        dp[v][0] %= mod;
        dp[v][1] *= dp[cv][0];
        dp[v][1] %= mod;
    }
}

signed main() {
    int N;
    cin >> N;
    rep(i,0,N-1) {
        int x,y;
        cin >> x >> y;
        x -= 1;
        y -= 1;
        ad[x].push_back(y);
        ad[y].push_back(x);
    }

    rep(i,0,N) {
        dp[i][0] = 1;
        dp[i][1] = 1;
    }

    rec();
    int ans = (dp[0][0] + dp[0][1]) % mod;
    cout << ans << endl;
}

Measured memory_bytes: 14208
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

n = int(input())

ans = num2alpha(n)

print(ans.lower())

Measured memory_bytes: 9048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%lld",&x)
int main(){
    ll n, neg = 0, zero = 0, ans = 0; sc(n);
    vector<ll> a(n), b;
    for (int i = 0; i < n; i++) sc(a[i]);
    for (int i = 0; i < n; i++){
        if (a[i] < 0) neg++;
        if (a[i] == 0) zero++;
        b.push_back(abs(a[i]));
    }
    sort(b.begin(), b.end());
    if (neg % 2 && zero==0) ans = -2 * b[0];
    for (int i = 0; i < n; i++) ans += b[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2296
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll MOD = 1000000007;

int main(){
  ll H,N,sum=0;
  cin >> H >> N;
  for(int i=0;i<N;i++){
    ll x;cin >> x;
    sum += x;
  }
  if(sum<H){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    string s;cin>>s;
    int a,b;
    int c[4];
    rep(i,0,4)c[i]=s[i]-'0';
    a=c[0]*10+c[1];
    b=c[2]*10+c[3];
    if(a>12){
        if(b<=12&&b>0)cout<<"YYMM"<<endl;
        else cout<<"NA"<<endl;
    }
    else if(a>0){
        if(b<=12&&b>0)cout<<"AMBIGUOUS"<<endl;
        else cout<<"MMYY"<<endl;
    }
    else{
      if(b<=12&&b>0)cout<<"YYMM"<<endl;
      else  cout<<"NA"<<endl;
    }
    
}


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

ans = [0 for _ in range(10001)]

for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            s = x*x + y*y + z*z + x*y + y*z + z*x
            if s <= 10000:
                ans[s] += 1

for i in range(1, n+1):
    print(ans[i])

    

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

#define MAX_V 10

int d[MAX_V][MAX_V];    //d[u][v] is cost of e(u, v)
int V;      //num of v


void warshall_floyd(){
    for(int k = 0; k < V; k++)
        for(int i = 0; i < V; i++)
            for(int j = 0; j < V; j++)
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

int main(){
    int H, W;
    cin >> H >> W;
    V = 10;
    for(int i = 0; i < V; i++){
        for(int j = 0; j < V; j++){
            int c;
            cin >> c;
            d[i][j] = c;
        }
    }

    warshall_floyd();

    ll ans = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            int a;
            cin >> a;
            if(a == -1) continue;
            ans += d[a][1];
        }
    }

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


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	char s[101];
	scanf("%s",s);
	int i;
	int l=strlen(s);
	char a=s[0];
	char b=s[l-1];
	int c=l-2;
	printf("%c%d%c\n",a,c,b);
}

Measured memory_bytes: 128
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    String[] S = sc.nextLine().split(" ");
    
    int[] nums = new int[N];
    int sum = 0;
    for(int i = 0; i < N; i++){
      nums[i] = Integer.parseInt(S[i]);
      sum += nums[i];
    }
    
    double a = (double)sum / N;
    int n = (int)Math.round(a);
    
    int ans = 0;
    for(int i = 0; i < N; i++){
      ans += ((nums[i] - n) * (nums[i] - n));
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int MOD = 1e9 + 7;

struct Combination{
  const int MOD = 1e9+7;

  vector<int> fact; //　fact[i] = iの階乗
  void init(int n){
    fact.resize(n+1);
    fact[0] = fact[1] = 1;
    for(int i = 2; i <= n; i++){
      fact[i] = i * fact[i-1] % MOD;
    }
  }

  int nCr(int n, int r){ // nCr = n!/r!(n-r)!
    if(n < r) return 0;
    return fact[n] * mod_pow(fact[r]*fact[n-r]%MOD, MOD-2) % MOD;
  }

  int inv(int n){
    return mod_pow(n, MOD-2);
  }

  int mod_pow(int n, int p){ // a/n ≡ a*n^(p-2) nとpは互いに素
    int r = 1;
    for(; p > 0; p >>= 1){
      if(p & 1LL) r = (r * n) % MOD;
      n = (n * n) % MOD;
    }
    return r; // r = n^p % MOD
  }

}c;

signed main(){

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

  c.init(2e6);
  vector<int> num(n, 0), dp(n, 1);
  auto dfs1 = [&](auto&& dfs1, int u, int p)->void{
    for(int v : G[u]){
      if(v == p) continue;
      dfs1(dfs1, v, u);
      num[u] += num[v];
      dp[u] = dp[u] * dp[v]%MOD * c.nCr(num[u], num[v]) % MOD;
    }
    num[u]++;
  };
  dfs1(dfs1, 0, -1);

  vector<int> ans(n);
  auto dfs2 = [&](auto&& dfs2, int u, int p, int res)->void{
    ans[u] = dp[u] * res%MOD * c.nCr(n-1, n-num[u]) % MOD;
    for(int v : G[u]){
      if(v == p) continue;
      res = ans[u] * c.inv(dp[v])%MOD * c.inv(c.nCr(n-1, num[v])) % MOD;
      dfs2(dfs2, v, u, res);
    }
  };
  dfs2(dfs2, 0, -1, 1);

  for(int p : ans){
    cout << p << endl;
  }

  return 0;
}


Measured memory_bytes: 35056
def main():
    N = int(input())
    A = list(map(int, input().split(' ')))
    ng = 0
    cum_xor = 0
    # しゃくとり法でngケースをカウントしていく
    right = 0
    for left in range(N):
        if left > 0:
            # 1つ前由来の立っているbitを消す
            cum_xor ^= A[left - 1]
        # 同時に立っているbitが無い限りxorをとり続ける
        while right < N and cum_xor & A[right] == 0:
            cum_xor ^= A[right]
            right += 1
        # 左端がleftとなるngケースの数を加算
        ng += N - right
    print(N * (N + 1) // 2 - ng)


if __name__ == '__main__':
    main()

Measured memory_bytes: 32056