akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        String planes = "";
        int row = 0;
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext()){
            String str = scan.next();
            planes += str;
            if(row++ > 6){
                row = 0;
                if(planes.matches(".*1111.*"))System.out.println("C");
                else if(planes.matches(".*110000011.*"))System.out.println("G");
                else if(planes.matches(".*1100000011.*"))System.out.println("A");
                else if(planes.matches(".*11000000011.*"))System.out.println("E");
                else if(planes.matches(".*1000000110000001.*"))System.out.println("D");
                else if(planes.matches(".*100000001100000001.*"))System.out.println("F");
                else if(planes.matches(".*1000000010000000100000001.*"))System.out.println("B");
                planes = "";
            }
        }
    }
}



Measured memory_bytes: 29632
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define rep(i, o) for (int i = 0; i < (o); ++i)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
#define NUM 1e5

typedef long long ll;
typedef unsigned long long ull;

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

int main() {
  ll n; 
  cin >> n;

  n = n%100;
  n = n%10;
  string ans;
  if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9)
  {
      /* code */
      ans = "hon";
  }
  if (n == 0 || n == 1 || n == 6 || n == 8)
  {
      /* code */
      ans = "pon";
  }
  if (n == 3)
  {
      /* code */
      ans = "bon";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int n,cnt[100003],cntt[16],ans;
int dp[65536];
int main(){
	cin>>n;
	for(int i=1;i<n;i++){int x,y,a;cin>>x>>y>>a;cnt[x]^=a;cnt[y]^=a;}
	for(int i=0;i<n;i++)cntt[cnt[i]]++;
	for(int i=1;i<16;i++)ans+=cntt[i]/2,cntt[i]%=2;
	int tmp=0;for(int i=1;i<16;i++)tmp=tmp+cntt[i]*(1<<i);
	memset(dp,31,sizeof(dp));
	dp[tmp]=0; 
	for(int i=tmp;i>0;i-=2)
		if(dp[i]<20000000)
			for(int j=1;j<16;j++)
				for(int k=j+1;k<16;k++)
					if((i|(1<<j))==i&&(i|(1<<k))==i)
						for(int l=1;l<=j;l++)
							if(((j|k)|l)==(j|k))
								dp[(((i-(1<<j)-(1<<k))^(1<<(j^l)))^(1<<(k^l)))/2*2]=min(dp[i]+1+bool((i&(1<<(j^l)))!=0)+
								bool((i&(1<<(k^l)))!=0),dp[(((i-(1<<j)-(1<<k))^(1<<(j^l)))^(1<<(k^l)))/2*2]);
	cout<<ans+dp[0];
}

Measured memory_bytes: 896
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BEcho solver = new BEcho();
        solver.solve(1, in, out);
        out.close();
    }

    static class BEcho {
        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            int n = sc.nextInt();
            if ((n & 1) != 0) {
                pw.println("No");
                return;
            }
            char[] arr = sc.next().toCharArray();
            for (int i = 0; i < n / 2; i++)
                if (arr[i] != arr[i + n / 2]) {
                    pw.println("No");
                    return;
                }
            pw.println("Yes");
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21588
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

long long int solve(long long int n){
	if(n==2){return 3;}
	else if(n==4||n==6||n==9||n==11){return 2;}
	else{return 1;}
}

int main() {
	long long int n=0,m,a,b,c,d,e;
	long double z,w;
	string str,str2,str3;
	char ch;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>str;
	str[5]=' ';
	str[13]=' ';
	cout<<str;




	cout<<endl;
} 


Measured memory_bytes: 256
def solve(nums)
  counts = nums.map{ |num| count_two(num) }

  answer = counts.min

  answer
end

def count_two(num)
  count = 0

  while num%2 == 0
    num = num / 2
    count += 1
  end

  count
end

n = gets.to_i
nums = gets.chomp.split(' ').map(&:to_i)

answer = solve(nums)
puts "#{answer}"

Measured memory_bytes: 1788
//
// author  : Abhishek
//
#include <bits/stdc++.h>

#define ll long long
#define db double
#define deb(x) cout<<#x<<": "<<x<<"\n"
#define all(x) x.begin(),x.end()
#define fo(i, n) for(i=0 ; i<n ; i++)
#define Fo(i, k, n) for(i=k ; i<n ; i++)

using namespace std;

const ll mod = 1000000007;
const ll N = 12801;  // array size
const ll inf = 10000000000000000;


void print(vector<ll> v) {
    ll i;
    fo(i, v.size())cout << v[i] << " ";
    cout << "\n";
}

vector<ll> read(ll n) {
    ll i;
    vector<ll> arr(n, 0);
    fo(i, n)cin >> arr[i];
    return arr;
}

vector<ll> read(ll n, ll k) {
    ll i;
    vector<ll> arr(n + k, 0);
    Fo(i, k, n + k)cin >> arr[i];
    return arr;
}

bool isEven(ll n) {
    return n % 2 == 0;
}

bool isOdd(ll n) {
    return n % 2 != 0;
}


void solve() {
    ll t;
    cin >> (t);
    while (t--) {

        ll i, j, k, n, m, p, q, x, y, a, b, l, r;


    }
}

class Cell {
public:
    ll a;
    ll b;
};

int main() {

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll i, j, k, n, m, p, q, x, y, a, b, l, r;

    cin >> n >> m;
    Cell mat[n + 1][m + 1];

    Fo(i, 1, n + 1) {
        Fo(j, 1, m + 1) {
            cin >> mat[i][j].a;
        }
    }

    Fo(i, 1, n + 1) {
        Fo(j, 1, m + 1) {
            cin >> mat[i][j].b;
        }
    }


    bool dp[n + 1][m + 1][N];

    fo(i, n + 1) {
        fo(j, m + 1) {
            fo(k, N) {
                dp[i][j][k] = false;
            }
        }
    }

    dp[1][1][abs(mat[1][1].a - mat[1][1].b)] = 1;

//    deb(abs(mat[1][1].a - mat[1][1].b));
//    deb(  dp[1][1][abs(mat[1][1].a - mat[1][1].b)] );

    i = 1;
    for (j = 2; j <= m; j++) {
        fo(k, N) {
            if (dp[i][j - 1][k]) {
                dp[i][j][abs(k + abs(mat[i][j].a - mat[i][j].b))] = true;
                dp[i][j][abs(k - abs(mat[i][j].a - mat[i][j].b))] = true;
            }
        }
    }

    j = 1;
    for (i = 2; i <= n; i++) {
        fo(k, N) {
            if (dp[i - 1][j][k]) {
                dp[i][j][abs(k + abs(mat[i][j].a - mat[i][j].b))] = true;
                dp[i][j][abs(k - abs(mat[i][j].a - mat[i][j].b))] = true;
            }
        }
    }

    for (i = 2; i <= n; i++) {
        for (j = 2; j <= m; j++) {
            fo(k, N) {
                if (dp[i][j - 1][k]) {
                    dp[i][j][abs(k + abs(mat[i][j].a - mat[i][j].b))] = true;
                    dp[i][j][abs(k - abs(mat[i][j].a - mat[i][j].b))] = true;
                }

                if (dp[i - 1][j][k]) {
                    dp[i][j][abs(k + abs(mat[i][j].a - mat[i][j].b))] = true;
                    dp[i][j][abs(k - abs(mat[i][j].a - mat[i][j].b))] = true;
                }
            }
        }
    }


    ll ans = inf;


    fo(i, N) {
        if (dp[n][m][i]) {
            ans = min(ans, i);
        }
    }

    cout << ans;


    return 0;
}




Measured memory_bytes: 85764
a, b=[int(i) for i in input().split()]
s=input()
#print(a, b, s)

flag=0

if s.count('-') == 1:
  s1, s2=[i for i in s.split('-')]
  if len(s1) == a and len(s2) == b :
    flag = 1

print('Yes' if flag==1 else 'No') 

Measured memory_bytes: 3060
package main

import(
"fmt"
)

func main() {
  var s string
  var t string
  fmt.Scan(&s,&t)
  
  length := len(s)
  if s[0:length] == t[0:len(t)-1] {
    fmt.Println("Yes")
 }else{
    fmt.Println("No")
 }
}


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

using namespace std;

#define LL long long
#define N 300
#define INF 0x3f3f3f3f3f3f3f3fLL
#define B 233

const LL mod=1000000007;
LL n,p,mx,ans,a[N],c[N];
map<LL,vector< pair<LL,LL> > > mp;
struct node{LL b,c,i;}b[N];

bool cmp(node x,node y){return x.b<y.b;}

LL popcount(LL x,LL y){
	if (x>=y) return INF;
	LL ret=0;
	for (LL i=60;i>=0;i--)
		if (((x>>i)&1)!=((y>>i)&1)){
			ret++;
			return ret;
		}
		else ret+=(x>>i)&1;
	return INF;
}

int main(){
	scanf("%lld%lld",&n,&p);
	for (LL i=1;i<=n;i++) scanf("%lld",&a[i]);
	for (LL i=0;i<=60;i++){
		memset(b,0,sizeof b);
		for (LL j=1;j<=n;j++) b[j].b=a[j]%(1LL<<i),b[j].c=a[j]/(1LL<<i),b[j].i=j;
		sort(b+1,b+n+1,cmp);
		for (LL j=0;j<=n;j++){
			LL k=((j==0)?0:popcount(b[j].b,b[j+1].b)),hsh=0;
			LL mn=p-k-i; bool fl=0;
			b[j].c--;
			for (LL k=1;k<=n;k++){
				if (b[k].c<0){fl=1; break;}
				mn=min(mn,b[k].c);
			}
			if (mn<0 || fl) continue;
			for (LL k=1;k<=n;k++) c[b[k].i]=b[k].c;
			for (LL k=2;k<=n;k++) hsh=((hsh*B+(c[k]-c[k-1]))%mod+mod)%mod;
			mp[hsh].push_back(make_pair(c[1]-mn,c[1]));
		}
	}
	for (map<LL,vector< pair<LL,LL> > >::iterator i=mp.begin();i!=mp.end();i++){
		vector< pair<LL,LL> > &vec=i->second;// puts("-----");
		sort(vec.begin(),vec.end()); mx=0;
		for (LL j=0;j<(LL)vec.size();j++){
			//cout<<vec[j].first<<' '<<vec[j].second<<endl;
			if (mx<=vec[j].second){ans=(ans+vec[j].second-max(vec[j].first,mx)+1)%mod; mx=vec[j].second+1;}
		}
	}
	printf("%lld\n",ans);
	
	return 0;
}
			

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


 long long int a,b;

int main (){
	cin >> a;
	b=0;
  for(long long int i=1;i*i<=a;i++){
    
    if(a%i == 0){
      b =i;
    }
  }
  
  cout << a/b +b -2 << endl;
}
      


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

const ll INF = ll(1e9)+1;

int main() {
  int n, k;
  cin >> n >> k;
  vector<ll> h(n);
  rep(i, n) cin >> h[i];
  sort(h.begin(), h.end());
  ll ans = INF;
  rep(i, n-k+1){
    ans = min(ans, (h[i+k-1] - h[i]));
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
colors = [?r, ?g, ?b]

loop do
	s = gets.chomp	
	break if s == ?0
	a = s.scan(/./)
	queue = [a]
	d = 0
	
	if a.uniq.size == 1
		puts 0
		next
	end

	reached = {a => 0}
	found = false
	loop do
		next_queue = []
		until queue.empty?
			a = queue.pop
			if a.uniq.size == 1
				next_queue = []
				found = true
				break
			end
			a.each_cons(2).with_index do |(x, y), i|
				if x != y
					c = a.dup
					z = (colors - [x, y])[0]
					c[i] = c[i+1] = z
					next if reached[c]
					reached[c] = 0
					next_queue << c
				end
			end
		end

		if next_queue.empty?
			puts found ? d : 'NA'
			break
		end
		d += 1
		queue = next_queue
	end
end

Measured memory_bytes: 12792
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <iostream>
using namespace std;

class Mystack {
public:
  int top;
  int s[1000];

  void push(int x) {
    s[++top] = x;
  }

  int pop() {
    top--;
    return s[top + 1];
  }
};

int main(void) {
  Mystack stack;
  stack.top = 0;
  char input[100];
  while (scanf("%s", input) != EOF) {
    if (input[0] == '+') {
      int a = stack.pop();
      int b = stack.pop();
      stack.push(a + b);
    }
    else if (input[0] == '-') {
      int a = stack.pop();
      int b = stack.pop();
      stack.push(b - a);
    }
    else if (input[0] == '*') {
      int a = stack.pop();
      int b = stack.pop();
      stack.push(a * b);
    }
    else {
      stack.push(atoi(input));
    }
  }
  printf("%d\n", stack.pop());
  return 0;
}

Measured memory_bytes: 1148
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
const int N=10000;
int prime[10010],tot;
bool vis[10010];
long long a[510][510];
long long gcd(long long a,long long b)
{
	return b==0?a:gcd(b,a%b);
}
long long lcm(long long a,long long b)
{
	return a/gcd(a,b)*b;
}
void init()
{
	vis[1]=true;
	for(int i=2;i<=N;i++)
	{
		if(!vis[i])prime[++tot]=i;
		for(int j=1;j<=tot&&i*prime[j]<=N;j++)
		{
			vis[i*prime[j]]=true;
			if(i%prime[j]==0)break;
		}
	}
	return ;
}
int main()
{
	init();
	int n;
	scanf("%d",&n);
	for(int i=0;i<=n+1;i++)
		for(int j=0;j<=n+1;j++)
			a[i][j]=1;
	for(int i=0;i<=n+1;i++)
		for(int j=0;j<=n+1;j++)
			if((i+j)%2==0)
				a[i][j]*=prime[1+(i+j)/2];
	for(int i=0;i<=n+1;i++)
		for(int j=0;j<=n+1;j++)
			if((i-j)%2==0)
				a[i][j]*=prime[2*n+10-(i-j+n+1)/2];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if((i+j)%2==1)
			{
				a[i][j]=lcm(a[i][j],a[i-1][j]);
				a[i][j]=lcm(a[i][j],a[i][j-1]);
				a[i][j]=lcm(a[i][j],a[i+1][j]);
				a[i][j]=lcm(a[i][j],a[i][j+1]);
				a[i][j]++;
			}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			printf("%lld%c",a[i][j],j==n?'\n':' ');
	return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    string s; cin>>s;
    int N=s.size();

    int ans=0;
    REP(S,1<<(N-1)){
        int sum=0,cur=0;
        REP(i,N){
            cur=cur*10+(s[i]-'0');
            if(i==N-1 or S>>i&1){
                sum+=cur; cur=0;
            }
        }
        ans+=sum;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
    int n;  cin >> n;
    vector<ll> a(n);
    ll res=0;
    REP(i, n){
        cin >> a[i];
        res ^= a[i];
    }
    vector<ll> bor(n+1, 0), fror(n+1, 0);
    REPD(i, n){
        bor[i] = bor[i+1]^a[i];
    }
    REP(i, n){
        fror[i+1] = fror[i]^a[i];
    }
    REP(i, n){
        res = fror[i]^bor[i+1];
        cout << res << ' ';
    }
    cout << endl;
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;

typedef struct Node_t
{
  Node_t() {}
  Node_t(int id, int deg, int parent, int depth) : id_(id), deg_(deg),
                                                             parent_(parent), depth_(depth),
                                                             type_(-1) {
    children_ = vector<int>(deg_, -1);
  }
  int id_, deg_, parent_, depth_;
  // 0: root, 1: internal, 2: leaf
  int type_;
  // identifiers of children
  vector<int> children_;
} Node;

void debug_print_node(Node& node)
{
  fprintf(stderr, "DEBUG: id=%d, deg=%d, parent=%d, depth=%d, type=%d\n",
          node.id_, node.deg_, node.parent_, node.depth_, node.type_);
  fprintf(stderr, "DEBUG: children=");
  for (int i = 0; i < node.deg_; ++i) {
    fprintf(stderr, "%d, ", node.children_[i]);
  }
  fprintf(stderr, "\n");
}

void print_node(Node& node)
{
  string type = "root";
  if (node.type_ == 1) { type = "internal node"; }
  else if (node.type_ == 2) { type = "leaf"; }
  fprintf(stdout, "node %d: parent = %d, depth = %d, %s, [",
          node.id_, node.parent_, node.depth_, type.c_str());
  for (int i = 0; i < node.deg_; ++i) {
    if (i) { fprintf(stdout, ", "); }
    fprintf(stdout, "%d", node.children_[i]);
  }
  fprintf(stdout, "]\n");
}

int main()
{
  int n = 0;
  fscanf(stdin, "%d", &n);
  vector<Node> nodes(n);
  for (int i = 0; i < n; ++i) {
    int id, deg;
    fscanf(stdin, "%d %d", &id, &deg);
    vector<int> v(deg, -1);
    Node node(id, deg, -1, -1);
    for (int j = 0; j < deg; ++j) {
      fscanf(stdin, "%d", &node.children_[j]);
    }
    nodes[node.id_] = node;
  }
  // find the root
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < nodes[i].deg_; ++j) {
      nodes[nodes[i].children_[j]].parent_ = nodes[i].id_;
    }
  }
  Node* root = 0;
  for (int i = 0; i < n; ++i) {
    if (nodes[i].parent_ == -1) {
      root = &nodes[i];
      break;
    }
  }
  // this is the root
  root->depth_ = 0;
  root->type_ = 0;
  queue<int> que;
  que.push(root->id_);
  while (!que.empty()) {
    int id = que.front(); que.pop();
    Node& node = nodes[id];
    if (node.type_ != 0 && node.deg_ == 0) {
      // if this is not a root node, neither an internal one,
      // this is a leaf node
      node.type_ = 2;
    }
    else if (node.type_ != 0 && node.deg_ > 0) {
      // not a root node but have children, then this is an internal node
      node.type_ = 1;
    }
    for (int i = 0; i < node.deg_; ++i) {
      // fprintf(stderr, "DEBUG: child of node\n");
      // print_node(nodes[node.children_[i]]);
      nodes[node.children_[i]].depth_ = node.depth_ + 1;
      que.push(node.children_[i]);
    }
  }

  for (int i = 0; i < n; ++i) {
    print_node(nodes[i]);
  }

  return 0;
}

Measured memory_bytes: 7004
#include <iostream>
#include <string>
#include <numeric>
#include <vector>

using namespace std;


class A {
	int A, B, X;

public:
	void solve()
	{
		cin >> A >> B >> X;

		if (X >= A && X <= (A + B)) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
};



class B {
	int N, M, X;
	vector<int> vec;

public:
	void solve()
	{
		cin >> N >> M >> X;
		vec.resize(N + 1);

		int a;
		for (int i{ 0 }; i < M; i++)
		{
			cin >> a;
			vec[a] = 1;
		}

		int costLeft{ accumulate(vec.begin(), vec.begin() + X, 0) };
		int costRight{ accumulate(vec.begin() + X, vec.end(), 0) };

		cout << ((costLeft < costRight) ? costLeft : costRight) << endl;
	}
};


int main()
{
	A solution;
	solution.solve();

	return 0;
}

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

using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    vector<vector<int> > a(2, vector<int>());
    int in;
    for (int i = 0; i < 2; i++)
    {
        for (int j = 0; j < N; j++)
        {
            cin >> in;
            a[i].emplace_back(in);
        }
        
    }

    
    int max = 0;
    for (int i = 0; i < N; i++)
    {
        int sum = 0;
        for (int j = 0; j <= i; j++)
        {
            sum += a[0][j];
        }
        for (int j = i; j < N; j++)
        {
            sum += a[1][j];
        }
        if (sum > max) max = sum;
    }
    
    cout << max << endl;
    
    return 0;
}

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

int main() {
	int n, k, min;
	cin >> n >> k;
	vector<int> h(n);
	for (int& x : h)
		cin >> x;
	sort(h.begin(), h.end());
	min = h.at(k - 1) - h.at(0);
	for (int i = 1; i <= n - k; i++)
		if (h.at(i + k - 1) - h.at(i) < min)
			min = h.at(i + k - 1) - h.at(i);
	cout << min << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
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(){
    ll n,k;
    cin>>n>>k;
    vector<pair<ll,pair<ll,ll>>>ans;
    vector<ll>a(n),b(n);
    vector<vector<ll>>v(n);
    rep(i,n)a[i]=k+i;
    rep(i,n)b[i]=k+n+i;
    int start=-1;
    rep(i,n){
        if(a.front()+b[i]==k+2*n){
            start=i;
            ans.eb(a[0]+b[i],make_pair(a[0],b[i]));
            break;
        }
    }
    if(start==-1){
        cout<<-1<<"\n";
        return;
    }
    for(int i=1;i<n;++i){
        ans.eb(a[i]+b[(start+i)%n],make_pair(a[i],b[(start+i)%n]));
    }
    sort(ans.begin(),ans.end());
    rep(i,n){
        v[i].pb(ans[i].second.first);
        v[i].pb(ans[i].second.second);
        v[i].pb(k+2*n+i);
    }
    rep(i,n){
        if(v[i][0]+v[i][1]>v[i][2]){
            cout<<-1<<"\n";
            return;
        }
    }
    rep(i,n){
        rep(j,3)cout<<v[i][j]<<" ";
        cout<<"\n";
    }
}
 
signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 13424
import java.util.Scanner;;

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

        Scanner sc = new Scanner(System.in);

        String num = sc.next();

        while (!num.equals("0")) {

            String[] strNum = new String[num.length()];
            int[] sepaNum = new int[num.length()];
            ;

            for (int i = 0; i < num.length(); i++) {
                strNum[i] = String.valueOf(num.charAt(i));
                sepaNum[i] = Integer.parseInt(strNum[i]);
            }

            int sum = 0;

            for (int i = 0; i < sepaNum.length; i++) {
                sum += sepaNum[i];
            }

            System.out.println(sum);

            num = sc.next();
        }

        sc.close();
    }
}



Measured memory_bytes: 26648
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
const int dx[4]={-1,1,0,0};
const int dy[4]={0,0,-1,1};
signed main()
{
	char c;
	cin>>c;
	if (islower(c))  cout<<'a';
	else  cout<<'A';
	re 0;
}

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

long long greedy(vector<long long> a, long long x){
    long long cum = 0LL;
    cum += max(0LL, a[0] - x);
    a[0] = min(x, a[0]);
    for (int i = 1; i < a.size(); ++i){
        auto dif = a[i] + a[i - 1] - x;
        if (dif > 0LL){
            a[i] -= dif;
            cum += dif;
        }
    }
    return cum;
}

int main() {
    long long N, x;
    cin >> N >> x;
    vector<long long> a(N, 0);
    for (auto &ai : a) cin >> ai;

    auto ans0 = greedy(a, x);
    reverse(a.begin(), a.end());
    auto ans1 = greedy(a, x);
    cout << min(ans0, ans1) << endl;
    return 0;
}

Measured memory_bytes: 1920
#include<iostream>
using namespace std;
int x[3] = { 0,1,2 }, p, q, d, e; char a, b, c;
int main() {
	while (cin >> a >> c >> b) {
		if (a == 'A') {
			p = 0;
		}
		if (a == 'B') {
			p = 1;
		}
		if (a == 'C') {
			p = 2;
		}
		if (b == 'A') {
			q = 0;
		}
		if (b == 'B') {
			q = 1;
		}
		if (b == 'C') {
			q = 2;
		}
		d = x[p];
		e = x[q];
		x[p] = e;
		x[q] = d;
	}
	for (int i = 0; i < 3; i++) {
		if (x[i] == 0) {
			p = i;
		}
	}
	if (p == 0) {
		cout << 'A' << endl;
	}
	if (p == 1) {
		cout << 'B' << endl;
	}
	if (p == 2) {
		cout << 'C' << endl;
	}
	return 0;
}

Measured memory_bytes: 1132
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  ll n,a,b;
  cin>>n>>a>>b;
  
  ll x=n-(a+b-1);
  if(x<0||x>(a-1)*(b-1)){
      cout<<-1<<endl;
      return 0;
  }

  if(a==1){
      if(b==n){
          for(int i=n;i>=1;i--) cout<<i<<" ";
          cout<<endl;
      }else cout<<-1<<endl;
      return 0;
  }else if(b==1){
      if(a==n){
          for(int i=1;i<=n;i++) cout<<i<<" ";
          cout<<endl;
      }else cout<<-1<<endl;
      return 0;
  }

  vector<int> ans;
  bool used[n+1]={};
  for(int i=b;i>=1;i--){
      ans.push_back(i);
      used[i]=true;
  }
  for(int i=n-(a-1)+1;i<=n;i++){
      ans.push_back(i);
      used[i]=true;
  }

  for(int k=1;;k++){
      int ma=n-(a-1)*k;
      if(ma<=0) break; 
      for(int i=ma-(a-1)+1;i<=ma;i++){
          if(i<=0) continue;
          if(used[i]) continue;
          ans.push_back(i);
          used[i]=true;
      }
  } 

  for(int i=0;i<ans.size();i++) cout<<ans[i]<<" ";
  cout<<endl;

  return 0;
}


Measured memory_bytes: 3824
#include<bits/stdc++.h>
using namespace std;
#define M 1000005
int n,A[M],tot,X[M],k;
vector<int>B;
bool check(int ans){
	int sum=0,tot=0;
	for(int i=1;i<=n;++i)X[i]=A[i]%ans,tot+=X[i];
	sort(X+1,X+n+1);
	for(int i=1;i<=n;++i){
		sum+=X[i];
		if(sum==(n-i)*ans-(tot-sum)&&sum<=k)return 1;
	}
	return 0;
}
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;++i)scanf("%d",&A[i]),tot+=A[i];
	for(int i=1;i<=tot;++i){
		if(tot%i!=0)continue;
		B.push_back(-i);
		if(i*i!=tot)B.push_back(-tot/i);
	}
	sort(B.begin(),B.end());
	for(int i=0;i<B.size();++i){
		int p=-B[i];
		if(check(p)){
			printf("%d",p);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 2432
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var one = nextIntArray();
	var r = one[0];
	var D = one[1];
	var x = one[2];
	var output = new Array(11);
	output[0] = x;
	for(var i = 1; i < 11; i++){
		output[i] = r * output[i - 1] - D;
	}
	output.shift();
	myout(myconv(output,9));
}


Measured memory_bytes: 30280
def insertionSort(A,N):
    for i,v in enumerate(A):
        j = i-1
        while j>=0 and A[j] > v:
            A[j+1] = A[j]
            j-=1
        A[j+1] = v
        print(' '.join(map(str, A)))

N = int(input())
A = list(map(int, input().split()))
insertionSort(A,N)

Measured memory_bytes: 7636
/*

 Remember, Hope is a good thing... May be the best of things... And No Good thing ever Dies !!!

*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios::sync_with_stdio(0); cout.tie(0);
#define endl "\n"
#define MOD 1000000007
const ll inf=(1LL<<60)-1;
int dx[]= {-1,1,0,0};
int dy[]= {0,0,-1,1};
void solve()
{
    ll n,c=0;
    string s;
    cin>>n>>s;
    for(ll i=0;i<s.size();i++)
    {
        ll x=s[i]-'A';
        x=(x+n)%26;
        printf("%c",'A'+x);
    }

}
int main()
{
    IOS;
    //ll t;
    //cin>>t;
    //while(t--)
    solve();
    return 0;
}


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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define m_p make_pair

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

    ll x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    ll x = x2,y = y2;
    ll dx = x2 - x1,dy = y2 - y1;
    rep(i,2){
        swap(dx,dy);
        dx *= -1;
        x += dx;
        y += dy;
        cout << x << ' ' << y << ' ';
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define maxn 3005
using namespace std;
int dp[maxn][maxn], tc[maxn][maxn];
int main() {
	ios::sync_with_stdio(false);
	//   sync_with_YinHsuan(true);
	cin.tie(0);
	string s, t;
	cin >> s >> t;
	int ls = s.size(), lt = t.size();
	for ( int i=1; i<=ls; ++i )
		for ( int j=1; j<=lt; ++j ) {
			if ( dp[i-1][j] > dp[i][j-1] ) {
				dp[i][j] = dp[i-1][j];
				tc[i][j] = 1;
			} else {
				dp[i][j] = dp[i][j-1];
				tc[i][j] = 3;
			}
			if ( s[i-1] == t[j-1] && dp[i-1][j-1]+1 > dp[i][j] ) {
				dp[i][j] = dp[i-1][j-1]+1;
				tc[i][j] = 2;
			}
		}
	int i = ls, j = lt;
	string ans = "";
	while ( i > 0 && j > 0 ) {
		if ( tc[i][j] == 1 ) {
			i--;
		} else if ( tc[i][j] == 2 ) {
			i--;
			j--;
			ans += s[i];
		} else {
			j--;
		}
	}
	for ( int i=0; i<ans.size(); ++i )	cout << ans[ans.size()-1-i];
	cout << '\n';
	return 0;
}


Measured memory_bytes: 70784
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N = ii()
A = li()

yen = 1000
kabu = 0

for i in range(1, N):
    if A[i] > A[i-1]:
        kabu = (yen//A[i-1])
        yen = kabu * A[i] + (yen - kabu * A[i-1])

print(yen)

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

#define allof(a) (a).begin(),(a).end()

using lint = long long;
using pii = pair< int, int >;
template< typename T > using Vec = vector< T >;

template< typename T > bool in_range(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool in_range(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }

template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }

int bitCount(int x) { return __builtin_popcount(x); }
int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double EPS = 1e-9;
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//

int N;
string S;
lint MOD = (lint)1e9 + 7;

int main() {
	cin >> N;
	cin >> S;
	
	Vec< lint > cnt(26, 0);
	for (int i=0; i<N; ++i) cnt[S[i] - 'a']++;
	
	lint ans = 1;
	for (int i=0; i<26; ++i) modMul(ans, cnt[i] + 1, MOD);
	cout << ans - 1 << endl;
}
//--------------8---------------->> coding space <<-----------------8-------------//


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

int main() {
	int N, a;
	cin >> N;
	int sum = 2 * N;
	for (int i = 0;i < N;++ i) {
		cin >> a;
		if (a % 2 > 0) { // 奇数があったので勝ち
			cout << "first";
			return 0;
		}
	}
	cout << "second";
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

全てのaが偶数だと、どれか一つ以上は奇数にする必要がある
逆に奇数があるなら、そのすべての奇数に操作すれば偶数になる
結論: 奇数があれば勝ち
*/

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

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

	int N;
	cin >> N;
	int l[100009], r[100009];
	int sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> l[i] >> r[i];
		sum += r[i] - l[i] + 1;
	}
	cout << sum;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
  int N,M,a,b;
  cin>>N>>M;
  vector<pair<int,int>> pairs(M);
  
  for(int i=0;i<M;i++){
    cin>>a>>b;
    pairs[i]=make_pair(b,a);
  }
  sort(pairs.begin(),pairs.end());
  int ans=0;
  int prev=-1;
  //壊した橋の左端を記憶
  for(int i=0;i<M;i++){
    a=pairs[i].second;
    b=pairs[i].first;
    if(prev<=a){
      //右ギリギリでこわす
      prev=b;
      ans+=1;
    }
  }
  cout<<ans<<"\n";
return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=3e5+10;
int32_t main()
{
	int n,k;
	cin>>n>>k;
	while(true)
	{
		int p=n%k;
		if(p==0)
		{
			n=p;
			break;
		}
		int x=(abs(k-p));
		if(x>=n)
			break;
		n=x;
	}
	cout<<n<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < (int) n; i++)
#define forin(i, a, b) for(int i = a; i < (int) b; i++) 
#define rofin(i, a, b) for(int i = a; i > b; i--)
#define v vector
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define debug(i) cout << #i << ": " << i << endl
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;


int N, W;
int main() {
    crap;
    cin >> N >> W;
    vector<ll> dp(W+1);
    forn(i,N) {
        int weight, value;
        cin >> weight >> value;
        rofin(w, W - weight, -1) {
            dp[w+weight] = max(dp[w+weight],dp[w]+value);
        }
    }
    cout << *max_element(dp.begin(), dp.end()) << endl;


}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main(){

	int n, flag;
	long long int ans=0, tmp=1;
	vector<string> v;

	cin>> n;
	v.resize(n);
	for(int i=0;i<n;i++){
		cin>> v[i];
		sort(v[i].begin(), v[i].end());
	}

	sort(v.begin(), v.end());

	for(int i=1;i<n;i++){
		flag=0;
		for(int j=0;j<10;j++){
			if(v[i][j]!=v[i-1][j]){
				flag=1;
				break;
			}
		}
		if(flag==0) tmp++;
		if(flag==1 || i==n-1){
			ans+=(tmp*(tmp-1))/2;
			tmp=1;
		}
	}

	cout<< ans << endl;

}

Measured memory_bytes: 7296
import sys
import math

f = sys.stdin
n = int(f.readline().split()[0])
A = list(map(int, f.readline().split()[:n]))

COUNT = 0

def Merge(A, left, mid, right):
    global COUNT
    if left == right:
        return
    n1 = mid - left
    n2 = right - mid
    L = A[left:mid]
    R = A[mid:right]

    L.append(10**9 + 1)
    R.append(10**9 + 1)
    i = 0
    j = 0
    for k in range(left, right):
        COUNT += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1


def Merge_Sort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        Merge_Sort(A, left, mid)
        Merge_Sort(A, mid, right)
        Merge(A, left, mid, right)

Merge_Sort(A, 0, len(A))
print(" ".join(map(str, A)))
print(COUNT)



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

int main() {
 int N;
 bool P = 0;
 bool W = 0;
 bool G = 0;
 bool Y = 0;
 cin >> N;

 for (int i = 0; i < N; i++) {
  string color;
  cin >> color;
  if (color == "P")
    P = 1;
  else if (color == "W")
    W = 1;
  else if (color == "G")
    G = 1;
  else if (color == "Y")
    Y = 1;
 }
 if (P + W + G + Y == 4)
   cout << "Four";
 else if (P + W + G + Y == 3)
   cout << "Three";
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long n;
    cin>>n;
    vector<long long> v(n);
    unordered_map<long long, long long> map;
    long long sum = 0;
    for (int i = 0; i < n; i++)
    {
        cin>>v[i];
        map[v[i]]++;
        sum += v[i];
    }
    int q;
    cin>>q;
    while(q--)
    {
        long long x, y;
        cin>>x>>y;
        sum = sum - map[x]*x + map[x]*y;
        map[y] += map[x];
        map[x] = 0;
        cout<<sum<<"\n";
    }
}

Measured memory_bytes: 7760
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int a,b;
    cin>>a>>b;
    cout << (a+b)%24 << endl;
    return 0;
}

Measured memory_bytes: 256
h1, h2 = map(int, input().split())
k1, k2 = map(int, input().split())
a, b, c, d = map(int, input().split())
H = h1 * a + h2 * b + h1 // 10 * c + h2 // 20 * d
K = k1 * a + k2 * b + k1 // 10 * c + k2 // 20 * d
print('hiroshi' if H>K else 'even' if H==K else 'kenjiro')


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

typedef long long ll;

const int N = 1e5+10;

ll a[N];
ll freq[N];

int main()	
{
	int x,y,n,m;
	ll sum = 0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum += a[i];
		freq[a[i]]++;
	}
	cin>>m;
	while(m--){
		cin>>x>>y;
		sum -= 1ll*x*freq[x];
		sum += 1ll*y*freq[x];
		freq[y] += freq[x];
		freq[x] = 0;
		cout<<sum<<'\n';
	}

}

Measured memory_bytes: 5096
#include<bits/stdc++.h>
typedef  long long int ll;
typedef  long double ld;
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define mod 1000000007
#define F first
#define S second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
//recursions\
#pragma comment(linker, "/stack:200000000")
//loops\
#pragma GCC optimize("unroll-loops")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
int main()
{
	sync;
	//to be the king
	ll n,m;
	cin>>n>>m;
	ll arr[n+1]={0},mark[n+1]={0};
	for(ll i=1;i<=m;i++)
	{
		ll p;string v;
		cin>>p>>v;
		if(v=="AC"&&!mark[p])
			mark[p]=1;
		if(v=="WA"&&!mark[p])
			arr[p]++;
	}
	ll s=0,p=0;
	for(ll i=1;i<=n;i++)
	{
		if(mark[i])
		s++,p+=arr[i];
	}
	cout<<s<<" "<<p;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(void) {
        int W,H,x,y,r;
        scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);
        if(r <= x && r <= y && (x+r) <= W && (y+r) <= H) {
                printf("Yes\n");
        } else {
                printf("No\n");
        }
        return 0;
}

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

using namespace std;

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

int in() { int x; scanf("%d", &x); return x; }
template<typename T> void pv(T a, T b) { for (T i = a; i < b; i++) cout << *i << ' '; cout << endl; }
template<typename T, typename U> void chmin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> void chmax(T &x, U y) { if (x < y) x = y; }

typedef long long ll;

const int MAX_N = 100010;
int N, Q, K;
ll dist[MAX_N];
bool visited[MAX_N];
vector<pair<int, int>> edge[MAX_N];

void calc(int x, ll d) {
  if (visited[x]) return;

  visited[x] = true;
  dist[x] = d;

  REP(i, edge[x].size()) {
    int to = edge[x][i].first;
    ll dd = (ll)edge[x][i].second;
    calc(to, d + dd);
  }
}

int main() {
  N = in();
  REP(i,N-1) {
    int a = in(), b = in(), c = in();
    edge[a].push_back(make_pair(b, c));
    edge[b].push_back(make_pair(a, c));
  }

  Q = in();
  K = in();
  calc(K, 0L);

  // pv(dist, dist + N);

  REP(i,Q) {
    int from = in(), to = in();
    cout << dist[from] + dist[to] << endl;
  }

  return 0;
}



Measured memory_bytes: 12800
/* ~/lib/template.cを引用 */
#include<stdio.h>
#include<stdlib.h>
// #inclide<math.h>

int main(int argc, char *argv[]){

  int n;

  scanf("%d", &n);

  if(n < 1 || 100 < n) {
    exit(0);
  }
  printf("%d\n", n*n*n);

  return 0;
}



Measured memory_bytes: 2108
fun main(args:Array<String>) {
    val S = readLine()!!
    var flag = false
    var acc = ' '
    for(c in S) {
        if(acc == c) {
            flag = true
            break
        } 
        acc = c
    }
    if(flag) {"Bad"} else {"Good"}.run(::println)
}



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



int main(){
	string s;
	cin>>s;
	bool flag=true;
	for(int i=0;i<s.length();i++){
		if(i%2==0 ){
			if(!(s[i]=='R'||s[i]=='U'||s[i]=='D')){
				cout<<"No"<<endl;
				flag=false;
				break;
			}
		}
		else{
			if(!(s[i]=='L'||s[i]=='U'||s[i]=='D')){
				cout<<"No"<<endl;
				flag=false;
				break;
			}
		}
	}
	if(flag){
		cout<<"Yes"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#define lli long long int
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 57;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;

lli dp[N];

void solve()
{
    string s[3] = {"Sunny", "Cloudy", "Rainy"};
    map<string, lli> ma;
    ma["Sunny"] = 0;
    ma["Cloudy"] = 1;
    ma["Rainy"] = 2;
    string x;
    cin>>x;
    lli idx = ma[x];
    cout<<s[(idx + 1) % 3];
    return ;
}
/*
7
6 7 4 1 2 11 6
5
1 2 10 4 5
*/

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

    lli t;
    t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


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

int main(){
  stack<int> S;
  int a,b;
  string s;

  while(cin >> s){
    if(s[0] == '+'){
      b = S.top(); S.pop();
      a = S.top(); S.pop();
      S.push(a + b);
    } else if(s[0] == '-'){
      b = S.top(); S.pop();
      a = S.top(); S.pop();
      S.push(a - b);
    } else if(s[0] == '*'){
      b = S.top(); S.pop();
      a = S.top(); S.pop();
      S.push(a * b);
    } else S.push(atoi(s.c_str()));
  }
  cout << S.top() << endl;
}


Measured memory_bytes: 3220
import sys
input = sys.stdin.readlines
ans = {chr(i):0 for i in range(ord("a"), ord("z")+1)}

for l in input():
    for _s in l:
        _s = _s.lower()
        if ord("a") <= ord(_s) <= ord("z"):
            ans[_s] += 1

for i in range(ord("a"), ord("z")+1):
    k = chr(i)
    print(k + " : " + str(ans[k]))


Measured memory_bytes: 5568
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
    for (T& x: vec) { is >> x; }
    return is;
}

int main() {
	string ans = "";
	ll tmp;
	ll n; cin >> n;
	while(n > 0){
		n--;
		ans = (char)('a'+ n%26) + ans;
		n /= 26;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3608
#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> ps(N);
  int total = 0;
  for(int i = 0; i < N; ++i) {
    cin >> ps[i];
    total += ps[i];
  }
  sort(ps.begin(), ps.end(), greater<int>());
  cout << total - ps[0] / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<map>
 
using namespace std;
#define mod 1000000007
#define ll long long 
 
 
ll n,w, a[100009], b[100009];
ll dp[109][100009];
 
// map<int, map<ll, ll> > dp;
 
ll solve(int r, int idx) {
    if(idx == n)
        return r == 0 ? 0 : INT_MAX;
 
    if(dp[idx][r] != -1)
    	return dp[idx][r];
 
    ll ans = solve(r, idx + 1);
    if(b[idx] <= r)
    	ans = min(ans, a[idx] + solve(r - b[idx], idx + 1));
 
    return dp[idx][r] = ans;
}
 
int s(int v_max) {
 
	for(int i = v_max; i >= 0; i--) {
		if(solve(i, 0) <= w)
			return i;
	}
	return 0;
}
 
int main() {
 
    // int t;
    // cin>>t;
    // while(t--) {
        cin>>n>>w;
        memset(dp, -1, sizeof(dp));
 
        int v_max = 0;
 
        for(int i = 0; i < n; i++) {
            cin>>a[i]>>b[i];
            v_max += b[i];
        }
 
        cout<<s(v_max)<<endl;
 
}

Measured memory_bytes: 88764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;
using P = pair<int, int>;
const int MOD = 1e9+7;
const double EPS = 1e-9;

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

  map<string, vl> AGC;
  string s = "ACGT";
  vector<string> t;
  string u;
  rep(i,4) {
    rep(j,4) {
      u = {s[i], s[j]};
      t.push_back(u);
    }
  }
  t.insert(t.end(), {"AGG", "AGT", "ATG"});
  rep(i,19) {
    AGC[t[i]].assign(n, 0);
    if (i<16) AGC[t[i]][1] = 1;
  }

  for (int i=2; i<n; ++i) {
    rep(j,16) {
      rep(k,4) {
        u = {t[j][1], s[k]};
        AGC[u][i] += AGC[t[j]][i-1];
      }
    }
    rep(j,3) {
      u = t[j+16]; u.pop_back();
      AGC[t[j+16]][i] = AGC[u][i-1];
    }
    // remove "AGC"s
    AGC["GC"][i] -= AGC["AG"][i-1] + AGC["AGG"][i-1] + AGC["ATG"][i-1];
    AGC["CG"][i] -= AGC["AC"][i-1];
    AGC["AC"][i] -= AGC["GA"][i-1];
    AGC["TC"][i] -= AGC["AGT"][i-1];

    rep(j,16) AGC[t[j]][i] %= MOD;
  }

  ll ans = 0;
  rep(i,16) ans += AGC[t[i]][n-1];
  cout << ans % MOD << endl;
  return 0;
}


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

int main()
{
	int x, y, gx, gy;
	int a1[4] = {4, 6, 9, 11};
	int a2 = 2;

	scanf("%d %d", &x, &y);

	gx = 0;
	gy = 0;
	for (int i = 0; i < 4; i++) {
		if (x == a1[i]) {
			gx = 1;
		}
		if (y == a1[i]) {
			gy = 1;
		}

	}
	if (x == a2) {
		gx = 2;
	}
	if (y == a2) {
		gy = 2;
	}

	if (gx == gy) {
		printf("Yes");
	}
	else {
		printf("No");
	}

    return 0;
}



Measured memory_bytes: 128