akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
using namespace std; 
#define int long long
# define pii pair<int,int>
const int maxn=10000007;
int prime[maxn];
signed main() { 
    #ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	char ch;
	cin>>ch;
	if(isupper(ch))cout<<"A";
	else cout<<"a";
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define ll long long int
#define tc int t; cin>>t; while(t--)
#define inn ll arr[n]; for(int i=0;i<n;i++) cin>>arr[i];
#define fora(i,n); for(ll i=0;i<n;i++)
#define forb(i,a,n); for(int i=a;i<n;i++)
#define mod 1000000007

int main()
{

//THIS CODE IS CREATED BY ANSHJAIN18

ll h,w,n;
cin>>h>>w>>n;
ll a=max(h,w);
cout<<(n/a+(n%a!=0));


return 0; }

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;
 
Node treeMinimum(Node x){
  while(x->left!=NIL)x=x->left;
  return x;
 
}
 
Node treeSearch(Node u, int k){
  /*while(u!=NIL && k!=u->key){
    if(k<u->key)u=u->left;
    else u=u->right;
  }
  return u;*/

 
  if(u==NIL || k==u->key)return u;
  if(k<u->key)return treeSearch(u->left,k);
  else return treeSearch(u->right,k);
  
 
}
 
Node treeSuccessor(Node x){
  Node y;
  if(x->right!=NIL)return treeMinimum(x->right);
  y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}
 
void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL || z->right==NIL)y=z;
  else y=treeSuccessor(z);
 
  if(y->left!=NIL)x=y->left;
  else x=y->right;
 
  if(x!=NIL)x->parent=y->parent;
 
  if(y->parent==NIL)root=x;
  else if(y==y->parent->left)y->parent->left=x;
  else y->parent->right=x;
 
  if(y!=z){
    z->key=y->key;
    z->left=y->left;
    z->right=y->right;
    z->parent=y->parent;
  }
  //return y;
}
 
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  while(x!=NIL){
    y=x;
    if(z->key<x->key)x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL)root=z;
  else if(z->key<y->key)y->left=z;
  else y->right=z;
}
 
void inorder(Node u){
  if(u!=NIL){
    inorder(u->left);
	printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  if(u!=NIL){
	printf(" %d",u->key);
	if(u->left!=NIL)preorder(u->left);
	if(u->right!=NIL)preorder(u->right);
  }
}
 
 
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
 
  return 0;
}

Measured memory_bytes: 19364
import java.util.Scanner;


public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
    
        int x, y;
Scanner sc = new Scanner(System.in);
x  = sc.nextInt();
y = x* x* x;
System.out.println(y);

    }
    
}


Measured memory_bytes: 26204
fun main(args: Array<String>) {
    val (a,b,c,d) = readLine()!!.split(' ').map { s -> s.toLong() }
    //val (n,x) = readLine()!!.split(" ").map { s -> s.toLong() }
    //val L = readLine()!!.split(" ").map { s -> s.toLong() }
    val result = countNumber(b,c,d) - countNumber(a-1L,c,d)
    println(result)
}

fun countNumber(x: Long, c: Long, d: Long): Long {
    var c_cnt = (x / c).toLong()
    var d_cnt = (x / d).toLong()
    var cd_cnt = (x / lcm(c,d)).toLong()
    return(x - c_cnt - d_cnt + cd_cnt)
}

fun gcd(a: Long, b: Long): Long = if(a < b) gcd(b, a) else if(b == 0L) a else gcd(b, a % b)
fun lcm(a: Long, b: Long): Long = (a * b) / gcd(a, b)

Measured memory_bytes: 37868
n,a,b=map(int,input().split())
c=max(a,b)
b=min(a,b)
a=c
MOD = pow(10,9) + 7

X=1
Y=1

for i in range(1,a+1):
    X=X*(n+1-i)%MOD
    Y=Y*i%MOD
    if i==b:
        b_X=X
        b_Y=Y
a_X=X
a_Y=Y
def calc(X,Y,MOD):
    return X*pow(Y,MOD-2,MOD)

ans=pow(2,n,MOD)%MOD-1-calc(a_X,a_Y,MOD)-calc(b_X,b_Y,MOD)

print(ans%MOD)


Measured memory_bytes: 64408
#include <stdio.h>

#define N 64

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i;

  for ( ; ; )
  {
    int d[ N ];
    int n, r;

    scanf ( "%d%d", &n, &r );
    if ( !( n | r ) ) break ;

    for ( i = 0; i < n; ++i )
    {
      d[ i ] = n - i;
    }

    while ( r-- )
    {
      int t[ N ];
      int p, c;

      scanf ( "%d%d", &p, &c );

      for ( i = 0; i < p - 1; ++i )
      {
        t[ i ] = d[ i ];
      }
      for ( i = 0; i < c; ++i )
      {
        d[ i ] = d[ p - 1 + i ];
      }
      for ( i = 0; i < p - 1; ++i )
      {
        d[ c + i ] = t[ i ];
      }
    }

    printf ( "%d\n", d[ 0 ] );
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main(){
	int a1,b1,i,j,c=0,max=0;
	cin>>a1>>b1;
	int a[a1],b[b1];
	for(i=0;i<a1;i++)cin>>a[i];
	for(i=0;i<b1;i++)cin>>b[i];
	for(i=0;i<b1;i++){
		c=0;
		for(j=0;j<a1;j++){
			if(b[i+c]==a[j])c++;
		}
		if(max<c)max=c;
	}
	cout<<max<<endl;
	return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int inf=1e9+7;
signed main(){
    int w,h,n,px,py,x,y;
    cin>>w>>h>>n>>px>>py;
    int ans=0;
    while(cin>>x>>y){
        if(px<=x&&py<=y)
            ans+=max(x-px,y-py);
        if(px<=x&&py>y)
            ans+=x-px+py-y;
        if(px>x&&py<=y)
            ans+=px-x+y-py;
        if(px>x&&py>y)
            ans+=max(px-x,py-y);
        px=x,py=y;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3112
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
int n;
ll ans;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;i++){
        ll y=n/i;
        ans+=(y*(y+1)*i)/2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
vector<vector<char> >arr(1005,vector<char>(1005));
ll dip(ll n,ll m)
{     
	ll i,j,dp[n][m]={0};
	for(i=0;i<n;i++){for(j=0;j<m;j++)dp[i][j]=0;
	}
	dp[0][0]=1;
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{    if((i-1)>=0&&arr[i][j]!='#')
		    dp[i][j] =(dp[i][j]+dp[i-1][j])%mod;
			if((j-1)>=0&&arr[i][j]!='#')
			dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
		}
	}
//	for(i=0;i<n;i++)
//	{
//		for(j=0;j<m;j++)
//		{ cout<<dp[i][j]<<" ";}cout<<endl;}
	
	return dp[n-1][m-1];
}
int main()
{
	ll n,m,i,j,k;
	cin>>n>>m;
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		cin>>arr[i][j];
	}
//		for(i=0;i<n;i++)
//	{
//		for(j=0;j<m;j++)
//		cout<<arr[i][j]<<" ";
//		cout<<endl;
//	}
	cout<<dip(n,m);
	return 0;
	
}

Measured memory_bytes: 9088
import java.util.Scanner;

public class Main {
	public static void main(String[] wjy) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int k=0;
		//ArrayList<Integer> tar = new ArrayList<Integer>();
		for (int i= 0;i<num;i++) {
			int aim = sc.nextInt();
			if (Pri(aim)) {
				//tar.add(aim);
				k++;
			}
		}
		//System.out.println(tar);
		System.out.println(k);
	}
	public static boolean Pri(int a) {
		if (a<=3) {
			return a>1;
		}
		else {
			if (a%2==0) {
				return false;
			}
		    if (a%3==0) {
		    	return false;
		    }
		    int k =5;
		    while ((k*k)<=a) {
		    	if (a% k == 0) {
		    		return false;
		    	}
		    	else if (a%(k+2)==0) {
		    		return false;
		    	}
		    	k=k+6;
		    }
		    return true;
		}
	}
}



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

int n;
int i, j, k;
int ans = 0;
int l[2000];

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

    cin >> n;

    for(i = 0 ; i < n ; ++i){
        cin >> l[i];
    }

    sort(l, l + n);

    for(i = 0 ; i < n-2 ; ++i){
        for(j = i+1 ; j < n-1 ; ++j){
            for(k = j+1 ; k < n ; ++k){
                if(l[i]+l[j] <= l[k]){
                    break;
                }
                ++ans;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

const int INF  = 1e9;
const long long INFLL = 1e18;
const int NMAX = 100005;
const int MMAX = 100005;
const int KMAX = 1005;
const int MOD  = 1e9 + 7;
using namespace std;

// comment to disable debug functions
#define DEBUG

// frequently used macros

#if __cplusplus >= 201103L
#define ALL(v) begin(v),end(v)
#define SORT(v) sort(begin(v), end(v))
#define FIND(v,x) find(begin(v), end(v), (x))
#else
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(v.begin(), v.end())
#define FIND(v,x) find(v.begin(), v.end(), (x))
#endif

#define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \
memset((from), 0, sizeof(from)); } while(0)
#ifdef DEBUG
#define DUMP(x) do{ std::cerr << (#x) << ": " << x << std::endl; }while(0)
#else
#define DUMP(x) do{}while(0)
#endif

// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> lp;
typedef pair<ll, ll> llp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<vec> mat;
typedef vector<vecll> matll;

// frequently used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// frequently used structs
struct edge{
  int to,cost;
};

// printf for debug
#ifndef DEBUG
void debug(const char* format, ...){}
#else
void debug(const char* format, ...){
  va_list arg;
  va_start(arg, format);
  vprintf(format, arg);
  va_end(arg);
}
#endif

// dump vector
#ifdef DEBUG
#define DUMPV(v, c) do{       \
  printf("%s: ", #v);         \
  for (int i = 0; i < (c); ++i) \
  {                           \
  cout << (v)[i] << " ";      \
  }                           \
  cout << endl;               \
} while(0)
#else
#define DUMPV(v,c)
#endif

// std::fill of multi dimensions
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
  std::fill( (T*)array, (T*)(array+N), val );
}

// binary search
ll BSearch(ll _begin, ll _end, bool (*f)(int)){
  ll mid;
  while(_end - _begin > 1LL) {
  mid = (_begin + _end) / 2LL;
  if(f(mid)) {
    debug("BSearch: f(%d) == true\n", mid);
    _end = mid;
  }
  else
  {
    debug("BSearch: f(%d) == false\n", mid);
    _begin = mid;
  }
  }
  return _end;
}


ll N,M,K,A,B,C,D,E;
int dp[NMAX] = {};

string S;
vec v;

ll ans = 0;

void solve(){
  // main algorithm

}
void debug(){
  // output debug information

}
void answer(){
  // output answer
  if((N * 10 + M) % 4) {
    cout << "NO\n";
  }
  else {
    cout << "YES\n";
  }
}
int main(int argc, char const *argv[])
{
  // operate inputs

  // Fill(dp, -1);
  cin >> N >> N >> M;
  solve();
  #ifdef DEBUG
  debug();
  #endif
  answer();

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for(int i = a; i < b; i++)
int a, b, c, d, e, k;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> a >> b >> c >> d >> e >> k;
    bool flg = true;
    if(e - a > k) {
        flg = false;
    }

    if(flg) {
        cout << "Yay!" << endl;
    } else {
        cout << ":(" << endl;
    }
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;

using namespace std;
using Graph = vector<vector<int>>;
Graph G;

/*int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}

int n;
vll a;

ll solve(bool isp)
{
	ll sum = 0ll;
	ll ret = 0ll;

	for (int i = 0; i < n; i++)
	{
		sum += a[i];
		if (isp and sum <= 0)
		{
			ret += -sum + 1;
			sum = 1ll;
		}
		if (not isp and sum >= 0)
		{
			ret += sum + 1;
			sum = -1ll;
		}
		isp ^= 1;
	}
	return ret;
}

*/
int main()
{
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	
	
	/*ll N, K;
	cin >> N >> K;
	ll t1 = N%K;
	ll t2 = abs(t1 - K);

	ll ans = min(t1, t2);
	

	cout << ans << endl;*/
	int N, M;
	cin >> N >> M;
	vector<ll> data(N);
	double sum = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> data[i];
		sum += data[i];
	}
	ll cnt = 0;
	for (auto& i : data)
	{
		if (i >= sum / (4 * M)) cnt++;
	}
	
	if (cnt>=M)
	{
		cout << "Yes" << endl;

	}
	else
	{
		cout << "No" << endl;
	}
	
	return 0;

}

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

#define mod 1000000007

int main() {
	int n, k;
	long long a[200002];
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	sort(a, a + n);
	int l = 0, r = n - 1, w = 1;
	long long ans = 1;
	if (k & 1) {
		ans = a[r--];
		k--;
		w = (ans < 0 ? -1 : 1);
	}
	while (k) {
		long long x = a[l] * a[l + 1], y = a[r] * a[r - 1];
		if (x * w > y* w)
			ans = (ans * (x % mod)) % mod, l += 2;
		else
			ans = (ans * (y % mod)) % mod, r -= 2;
		k -= 2;
	}
	printf("%lld\n", (ans % mod + mod) % mod);
}


Measured memory_bytes: 5284
package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	if err := io.writer.Flush(); err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func intMin(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func intMax(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	io := NewIo()
	defer io.Flush()
	A := io.NextInt()
	B := io.Next()
	B = strings.Replace(B, ".", "", 1)
	BB, _ := strconv.Atoi(B)
	io.Printf("%d", uint64(A)*uint64(BB)/100)
}


Measured memory_bytes: 1748
#include <bits/stdc++.h>
//using
using intl = long long;
using itnl = long long;//typo用
using uintl = unsigned long long;
using itn = int;//typo用
using ld = long double;
using namespace std;

//関数マクロ
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl

//定数マクロ
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);

//テンプレート関数
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; }
//intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); } //c++17からある
//intl lcm(intl a,intl b){ return a / gcd(a, b) * b; } //c++17からある

//自作テンプレート関数
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}//Yes,Noの出力を楽にするよう
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}//上の関数のYes,Noを任意の文字列でできるようにしたもの
intl kai(intl k){ intl a = 1; for(int i = 2; i <= k; i++){ a *= i; } return a; }//k!を求める関数,O(N)
intl digit10(intl a){ intl b = 0; do{ a /= 10; b++; }while(a); return b; }//aを10進数で表したときの桁数を求める関数,桁数回の演算だからだいたいO(logN)くらい?



signed main(){
    cout << fixed << setprecision(10);
    int d;
    cin >> d;
    int c[26];
    rep(i,26)cin >> c[i];
    int s[d][26];
    rep(i,d){
        rep(j,26)cin >> s[i][j];
    }
    int t[d];
    rep(i,d){
        cin >> t[i];
        t[i]--;
    }
    int M;
    cin >> M;
    int day[M],q[M];
    rep(i,M){
        cin >> day[i] >> q[i];
        day[i]--;
        q[i]--;
    }
    
    rep(k,M){
        intl ans = 0;
        int last_day[26];
        m0(last_day);
        t[day[k]] = q[k];
        rep(i,d){
            ans += s[i][t[i]];
            last_day[t[i]] = i + 1;
            //debug(ans);
            rep(j,26){
                ans -= (c[j] * ((i + 1) - last_day[j])); 
            }
            
        }
        cout << ans << endl;    
    }
    return 0;
}


Measured memory_bytes: 4260
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
 
using namespace std;
using namespace __gnu_pbds;
 	// find_by_order()  // order_of_key
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inff (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define primeDEN 727999983
#define SPEED ios_base::sync_with_stdio(false) ;cin.tie(NULL) ;cout.tie(NULL) ;
#define fp(i,a,n) for(ll i=n-1; i>a ;i--)
#define deb(x) cout << #x << " ---> " << x << endl;
#define X first
#define Y second
#define pia 3.1415926536
#define mod 1000000007
#define N 100005
#define ml map<ll,ll>
#define mll map<pll,ll>
#define letsh(a,b) (a<<b)
#define rigsh(a,b) (a>>b)
 #define vvl vector<vl>
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count()) ;
		ll lcm(ll a, ll b){
               return a / __gcd(a, b) * b;
       }
	   bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 	   

       ll power(ll a,ll n)
	   {
        ll ans=1;
        while(n)
		{
        if(n&1) ans=(ans*a)%mod;
        a=(a*a)%mod ;
        n=n>>1;
   		 }
   		 return ans;
      }
      ll power2(ll a,ll n)
      {
      	ll ans =1 ;
      	while(n)
      	{
      		if(n&1) ans =(ans*a) ;
      		a = (a*a) ;
      		n =n>>1 ;
		  }
		  return ans ;
	  } 
	  void p1(ll x,ll y)
	  {
	  cout<<x<<" "<<y<<endl ; 	
	  }
	  void p2(ll x,ll y)
	  {
	  	cout<<x<<" "<<y<<" " ;
	  }
  vvl dir({{1, 0}, {-1, 0}, {0, 1}, {0, -1}});
  
  void solve()
  {
    string s ;cin>>s ;
    ll ans =0 ,cur =0 ;
  //  cout<<"kdkkd" ;
    f(i,0,3) if(s[i] == 'R') cur++ ;
    else ans = max(ans,cur) ,cur =0 ;
    ans = max(ans,cur) ;
    cout<<ans<<endl ;
  }
  int main() 
  	{
  		SPEED
  		ll t =1 ;
  		while(t--) solve() ;  
   	}
   	

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

int main(){
  int v, ans = 0;
  std::cin >> v;
  string s = std::to_string(v);
  for (int i = 0; i < s.length(); i++) {
    if(s[i] == '2')ans++;
  }
  std::cout << ans << std::endl;
  return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

#define INF 2e9

#define REP(i,n) for(int i = 0; i < n;++i)
#define REPA(i,a,n) for(int i = a; i < n; ++i)
#define ALL(a) a.begin, a.end()

using namespace std;

int main(void) {

	int a;
	string s;

	cin >> a >> s;

	if (a >= 3200) cout << s << '\n';
	else cout << "red\n";

	return 0;
}

Measured memory_bytes: 256
def compression(init, matrix):
	
	mir = []
	
	for row in matrix:
		if "#"in row:
			mir.append(row)
	matrix = []
	
	mir = list(map(list, zip(*mir)))
	
	for row in mir:
		if "#"in row:
			matrix.append(row)
		
	matrix = list(map(list, zip(*matrix)))	
			
	
	return matrix


init = input().split(" ")
init = [int(c) for c in init]

matrix = [[] for j in range(init[0])]

for j in range(init[0]):
	matrix[j] = input()

result = compression(init, matrix)
for row in result:
	print("".join(row))

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

int main()
{
	int N;
	cin >> N;
	vector<tuple<int, int, string>> vs;
	for (int i = 0; i < N; i++) {
		string C;
		int D;
		cin >> C >> D;
		vs.emplace_back(D, i, C);
	}
	sort(vs.begin(), vs.end());
	vector<string> tt(N);
	for (int i = 0; i < N; i++) {
		tt[i] = get<2>(vs[i]);
	}
	int M;
	cin >> M;
	vector<string> ss(M);
	for (int i = 0; i < M; i++) {
		cin >> ss[i];
	}
	int j = 0;
	bool ok = true;
	for (int i = 0; i < M; i++) {
		while (j < N && ss[i] != tt[j]) {
			++j;
		}
		if (j == N) {
			ok = false;
			break;
		}
		int c = get<0>(vs[j]);
		while (j < N && get<0>(vs[j]) == c) ++j;
	}
	puts(ok ? "Yes" : "No");
	return 0;
}



Measured memory_bytes: 21600
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    ll N;
    cin >> N;
    vector<string> s(N);
    rep(i, N){
        cin >> s[i];
        sort(all(s[i]));
    }
    sort(all(s));
    ll ans = 0;
    ll cnt = 1;
    rep(i, N-1){
        if(s[i] != s[i+1]){
            ans += cnt * (cnt-1) / 2;
            cnt = 1;
        }else{
            cnt++;
        }
        if(i+1 == N-1){
            ans += cnt * (cnt-1) / 2;
        }
    }
    cout << ans;
}

Measured memory_bytes: 7296
H, W = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))
C = [[0] * W for _ in range(H)]
x = -1
for c, i in enumerate(A, 1):
  for _ in range(i):
    x += 1
    row = x // W
    column = x % W
    C[row][column] = c
for i in range(H):
  if i%2 == 0:
    print(*C[i])
  else:
    print(*C[i][::-1])

Measured memory_bytes: 9652
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector <int> a(n);
    cin >> a;
    vector <int> dp(k + 1); // 0 = lose
    forn (i, 0, k + 1) {
        int sum = 0, loses = 0;
        forn (j, 0, n)
            if (i - a[j] >= 0) {
                sum++;
                loses += dp[i - a[j]];
            }
        if (sum == loses)
            dp[i] = 0;
        else
            dp[i] = 1;
    }
    if (dp[k] == 1)
        cout << "First";
    else
        cout << "Second";
    return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		var h=new int[206];
		h[1]=300000;
		h[2]=200000;
		h[3]=100000;
		Console.WriteLine("{0}",h[s[0]]+h[s[1]]+((s[0]==1&&s[1]==1)?400000:0));
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define SIZE 7368800

int main(){
	int n, m, i, j, k, f;// sosu[SIZE] = {};
	
	while(1){
		int count = 0, a[SIZE] = {}, temp = 0;
		cin>>m>>n;
		
		if(m == 0 && n == 0) break;
		
		for(i = m; count <= n; i++){
			if(a[i] == 0){
				count++;
				for(j = i; j < SIZE; j+=i){
					a[j] = 1;
				}
			}
		}

		cout<<i-1<<endl;
		
		
	}
	
	return 0;
}


Measured memory_bytes: 31864
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, fractions
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

n,k=map(int,input().split())
D=set(input().split())
while True:
    ns=str(n)
    for ni in ns:
        if ni in D:
            break
    else:
        print(n)
        exit()
    n+=1
    continue

    

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

int main() {
  int N,A,B;
  cin >> N >> A >> B;
  int taxi,train;
  taxi = N*A;
  train = B;
  if(taxi < train){
    cout << taxi << endl;
  }else{
    cout << train << endl;
  }
}

Measured memory_bytes: 256
// Why I am so dumb? :c
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

int arr[200005];

map<ll, int> m;

ll ans;

int n;

void solve() {                   
	scanf("%d", &n);

    for (int i = 1; i <= n; ++i) {
    	scanf("%d", &arr[i]);
    }

    ll sum = 0;
    ++m[sum];

    for (int i = 1; i <= n; ++i) {
    	sum += arr[i];
    	ans += m[sum]++;
    }

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

int main() {    
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 13568
#include <iostream>
#include <cassert>
#include <algorithm>
#include <cmath>
using namespace std;

class G {
public:
  double b, r, t;
  int y;
  double gn;

  double power(double a, int p) {
    if(p==0) return 1;
    return a*power(a, p-1);
  }
  
  void setGn() {
    if(t==1) {
      gn = 10000 * (1 + y * r/100);
    } else if(t==2) {
      gn = 10000 * power((1 + r/100), y);
    } else assert(0);
  }
  
  bool operator< (const G &t) const {
    return gn != t.gn ? gn < t.gn : b < t.b;
  }
};

int main() {
  G Ginko[52];
  int n, y;
  
  while(cin >> n >> y, n) {
    for(int i=0; i<n; i++) {
      cin >> Ginko[i].b >> Ginko[i].r >> Ginko[i].t;
      Ginko[i].y = y;
      Ginko[i].setGn();
    }
    
    sort(Ginko, Ginko + n);
    
    cout << Ginko[n-1].b << endl;
  }
  return 0;
}

Measured memory_bytes: 1312
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define rrep(i, a, b) for(int i=(a); i>=(b); i--)
typedef long long ll;
const string yes = "YES";
const string no = "NO";

int main()
{
  int N; cin >> N;
  set<int> st;
  for (int i=0; i<N; i++){
    int a; cin >> a;
    st.insert(a);
  }
  if ((int)(st.size())==N) cout << yes << endl;
  else cout << no << endl;

  return 0;
}


Measured memory_bytes: 9600
#include <stdio.h>
#include <stdlib.h>
int gcd(int a, int b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
int main() {
  int a,b,k;
  scanf("%d%d%d", &a, &b, &k);
  int x = gcd(a, b);
  int i;
  int cnt = 0;
  int *div = (int*)malloc(sizeof(int)*x);
  for (i = 1; i <= x; i++) {
    if (x % i == 0) {
      div[cnt++] = i;
    }
  }
  printf("%d\n", div[cnt - k]);
  return 0;
}

Measured memory_bytes: 128
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cctype>
#include <string>

using namespace std;

typedef long long ll;

#define rep(i,n)  for(int i=0;i<(n);++i)
#define all(x) (x).begin(),(x).end()

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

const int mod = 1000000007;
const int INF = 1001001001;

char m[1010][1010];

int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

int main() {
    int h, w;
    cin >> h >> w;
    rep(i, h) cin >> m[i];
    vector<pair<int, int>> st;
    queue<pair<int, int>> q;
    queue<pair<int, int>> nq;
    bool isStart = false;
    rep(i, h) rep(j, w) if (m[i][j] == '#') q.emplace(i, j);

    int ans = -1;

    while(!q.empty()) {
        int startNums = q.size();
        rep(i, startNums) {
            int y = q.front().first;
            int x = q.front().second;
            q.pop();
            rep(j, 4) {
                int ny = y + dy[j];
                int nx = x + dx[j];
                if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
                if(m[ny][nx] == '#') continue;
                m[ny][nx] = '#';
                q.emplace(ny, nx);
            }
        }
        ans += 1;
    }

    cout << ans << endl;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

bool isPrime(int n) {
  if (n <= 1) return false;
  if (n == 2) return true;
  if (n % 2 == 0) return false;
  for (int d = 3; d * d <= n; d+=2) {
    if (n % d == 0) return false;
  }
  return true;
}

int main2() {
  int X = nextInt();
  for (;;) {
    if (isPrime(X)) {
      break;
    }
    X++;
  }
  cout << X << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 256
/*
ID: espr1t
TASK: 
KEYWORDS: 
*/

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
FILE* in = stdin; FILE* out = stdout;

const int MAX = 1024;

int main(void) {
//	in = fopen("B.in", "rt");
	
	int R, G, B, N;
	fscanf(in, "%d %d %d %d", &R, &G, &B, &N);
	
	int ans = 0;
	for (int r = 0; r * R <= N; r++) {
	    for (int g = 0; r * R + g * G <= N; g++) {
	        if ((N - r * R - g * G) % B == 0)
	           ans++;
        }
    }
    fprintf(out, "%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 128
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *
from fractions import *

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

def f(arr):
    m = min(arr)
    for i in range(len(arr)):
        arr[i] -= m
    buf = []
    ret = m
    for i in arr:
        if i == 0:
            if len(buf) > 0:
                ret += f(buf)
                buf = []
        else:
            buf.append(i)
    if len(buf) > 0:
        ret += f(buf)
    return ret

def main():
    N = int(input())
    h = list(map(int, input().split()))
    print(f(h))

main()


Measured memory_bytes: 64364
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var answer = (long)1e18;
            var t = 1;
            for (var k = 0; k < 2; k++)
            {
                t ^= 1;
                var step = 0L;
                var sum = 0L;
                for (var i = 0; i < N; i++)
                {
                    sum += A[i];

                    if (i % 2 == t)
                    {
                        if (sum <= 0)
                        {
                            step += 1 - sum;
                            sum = 1;
                        }
                    }
                    else
                    {
                        if (sum >= 0)
                        {
                            step += 1 + sum;
                            sum = -1;
                        }
                    }
                }
                answer = Math.Min(answer, step);
            }

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 39248
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

alias C = Tuple!(int, int);
immutable C[] dirs = [
  tuple (1, 0),
  tuple (-1, 0),
  tuple (0, 1),
  tuple (0, -1)
];

enum inf = int.max; 

void main() {
  auto s = readln.strip.splitter;
  immutable int h = s.front.to!int;s.popFront;
  immutable int w = s.front.to!int;
  auto a = new char[][h];
  foreach (j; 0 .. h) {
    auto z = readln;
    a[j] = z[0 .. w].dup;
  }
  auto d = new int[][](h, w);
  void clear () {
    foreach (j; 0 .. h) foreach (i; 0 .. w) d[j][i] = inf;
  }
  C[] bfs (in int sy, in int sx, out int dy, out int dx, out int dist) {
    d[sy][sx] = 0;
    C[] q;
    q ~= C (sy, sx);
    int left = 0;
    while (left < q.length) {
      auto t = q[left++];
      immutable int y = t[0], x = t[1];
      dy = y;
      dx = x;
      foreach (const ref p; dirs) {
        immutable j = y + p[0];
        if (j < 0 || j >= h) continue;
        immutable i = x + p[1];
        if (i < 0 || i >= w) continue;
        if (d[j][i] < inf || a[j][i] == '#') continue;
        q ~= C (j, i);
        d[j][i] = d[y][x] + 1;
      }
    }
    dist = d[dy][dx];
    return q;
  }
  int res;
  foreach (j; 0 .. h) foreach (i; 0 .. w) if (a[j][i] != '#') {
    int y, x, dd;
    clear ();
    bfs (j, i, y, x, dd); 
    res = max (res, dd);
  }
  /*
  C[] u;
  clear ();
  foreach (j; 0 .. h) foreach (i; 0 .. w) if (a[j][i] != '#' && d[j][i] == inf) {
    int y, x, dd;
    bfs (j, i, y, x, dd); 
    u ~= tuple (y, x);
  }
  clear ();
  int res;
  foreach (p; u) {
    int y, x, dd;
    res = max (res, dd);
  }
  */
  writeln (res);
}



Measured memory_bytes: 2300
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;

int n;
vector<int>graph[123456];
int k;
struct spread
{
	int left;
	int size;
	bool active;
	spread()
	{
		left = -12345678; size = 123456789;
		active = true;
	}
	spread(int le, int sz, bool ac = true)
	{
		left = le; size = sz;
		active = ac;
	}
	spread operator++()
	{
		--left;
		++size;
		return *this;
	}
	spread operator*(const spread& other)
	{
		if (abs(left % 2) != abs(other.left % 2) && left != -12345678 && other.left != -12345678)
		{
			return spread(0, 0, false);
		}
		int top = min((size - 1) * 2 + left, (other.size - 1) * 2 + other.left);
		int btm = max(left, other.left);
		if (top < btm)return spread(0, 0, false);
		return spread(btm, (top - btm) / 2 + 1);
	}
};

spread s[123456];
queue<pair<int, spread>>que;

int main(void)
{
	scanf("%d", &n);
	for (int i = 0; i < n - 1; ++i)
	{
		int a, b;
		scanf("%d %d", &a, &b);
		--a; --b;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	scanf("%d", &k);
	for (int j = 0; j < k; ++j)
	{
		int v, p;
		scanf("%d %d", &v, &p);
		--v;
		s[v] = spread(p, 1);
		que.push({ v,s[v] });
	}
	while (!que.empty())
	{
		auto q = que.front(); que.pop();
		auto next = ++q.second;
		for (int vert : graph[q.first])
		{
			auto nsp = next * s[vert];
			if (!nsp.active)
			{
				return 0 * printf("No\n");
			}
			if (!(nsp.left == s[vert].left && nsp.size == s[vert].size))
			{
				s[vert] = nsp;
				que.push({ vert,s[vert] });
			}
		}
	}
	printf("Yes\n");
	for (int i = 0; i < n; ++i)
	{
		printf("%d\n", s[i].left);
	}
	return 0;
}

Measured memory_bytes: 10488
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //切り出しする文字列
        int A = sc.nextInt();
        int B = sc.nextInt();
        int H = sc.nextInt();
        int M = sc.nextInt();

        double e = (60 * H + M) * 0.5 - M * 6;
        double r=Math.sqrt(Math.pow(A,2) + Math.pow(B,2) - 2*A*B*Math.cos(Math.toRadians(e)));
        System.out.println(r);
    }
}


Measured memory_bytes: 36032
#include <stdio.h>

int begin[1010], end[1010];
char name[1010][20];

int main(void)
{
    int n, q;
    while (scanf("%d%d", &n, &q), n) {
        int i;
        for(i=0;i<n;++i) {
            scanf("%s%d%d", name[i], begin+i, end+i);
            begin[i]=end[i]-begin[i]+1;
        }
        while (q--) {
            int y;
            scanf("%d", &y);
            for(i=0;i<n;++i) if (begin[i]<=y && y<=end[i]) break;
            if (i<n)
                printf("%s %d\n", name[i], y-begin[i]+1);
            else
                puts("Unknown");
        }
    }
    return 0;
}

Measured memory_bytes: 644
# https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/6/ALDS1_6_D
# 本の解説がわかりやすい
# ここでは本には書いてないことの補足を意識しながらコメントを付けていく
WMAX = 10**4 + 1
n = int(input())
A = list(map(int, input().split()))
B = sorted(A)
is_visited = [False] * n  # 巡回管理用
next_idxs = {}  # Aの要素について、これのkeyを見れば、その数字がsort後にどの位置にあるのかわかるように対応させる
for i, b in enumerate(B):
    next_idxs[b] = i

m_A = min(A)  # globalで一番小さい要素

# ソート後の並び順から巡回可能なグループから答えを計算する
# グループ内の最小の要素をm, グループの和をS, グループ内の要素数をn2とする。
# 具体的には,m*(n2-2) + S もしくは m + S + (1+n2)*m_Aのうち小さい方
ans = 0
for i in range(n):
    if is_visited[i]:
        continue  # 巡回済みならば次へ
    cur = i  # 巡回制御用のidx #探索済みでないiが入るはず
    S = 0  # 合計管理用
    n2 = 0
    m = WMAX  # グループ内の最小値探索用
    while True:
        # まずはもろもろの値を更新
        is_visited[cur] = True
        S += A[cur]
        m = min(m, A[cur])
        n2 += 1
        # ここで次のidxを取得する
        cur = next_idxs[A[cur]]
        if is_visited[cur]:
            break  # もし一周したらおわり
    # ループ内で完結したほうがいいのか外から要素を変えいてきたほうがいいのか
    # 小さい方を採用して答えに足し込む
    ans += min(m*(n2-2)+S, m+S+(1+n2)*m_A)

print(ans)



Measured memory_bytes: 5716
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int f(int r[],int t[],int s[],int d[],int n,int c,int m){
  int i;
  int l=m;
  if(d[c]<m){
    d[c]=m;
    for(i=c+1;i<n;i++){
      if(r[i]<r[c]&&t[i]<t[c])
	l=max(l,f(r,t,s,d,n,i,m+1));
    }
    return l;
  }else
    return 0;
}  
int main(){
  int h,i;
  int m,n,o,r[200],t[200],s[200],d[200];
  for(;;){
    cin>>m;
    if(m==0)
      break;
    for(i=0;i<m;i++){
      cin>>t[i]>>r[i];
      s[i]=r[i]*r[i]*t[i];
    }
    cin>>n;
    for(;i<m+n;i++){
      cin>>t[i]>>r[i];
      s[i]=r[i]*r[i]*t[i];
    }
    do{
      h=0;
      for(i=1;i<m+n;i++){
	if(s[i-1]<s[i]){
	  swap(s[i-1],s[i]);
	  swap(t[i-1],t[i]);
	  swap(r[i-1],r[i]);
	  h=1;
	}
      }
    }while(h);
    o=0;
    memset(d,0,sizeof(d));
    for(i=0;i<m+n;i++)
      o=max(o,f(r,t,s,d,m+n,i,1));
    cout<<o<<endl;
  }
  return 0;
}
    
      

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

int main(){
  int N,M;cin>>N>>M;
  vector<pair<long int,long int>> pairs(N);
  for(int i=0;i<N;i++){
    long int a,b;cin>>a>>b;
    pairs[i]=make_pair(a,b);
  }

  sort(pairs.begin(),pairs.end());
  int sum=0;
  long long int en=0;

  for(int i=0;sum<M;i++){
    if((M-sum)>=pairs[i].second){
      sum+=pairs[i].second;
      en+=(pairs[i].first*pairs[i].second);
    }else if((M-sum)<pairs[i].second){
      en+=((M-sum)*pairs[i].first);
      sum=M;
    }

  }
  cout<<en<<endl;
}


Measured memory_bytes: 1792
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    H,W = LI()
    ch, cw = _LI()
    dh, dw = _LI()
    m = [[0] * W for _ in range(H)]
    for i in range(H):
        s = SI()
        for j in range(W):
            if s[j] == "#":
                m[i][j] = -1

    z = collections.deque()
    z.append((ch,cw,1))
    while z:
        x,y,c = z.popleft()
        if m[x][y]: continue
        q = collections.deque()
        q.append((x,y))
        m[x][y] = c
        r = [(x,y)]
        while q:
            x,y = q.popleft()
            if x == dh and y == dw:
                print(c-1)
                return
            for dx,dy in ((0,1),(1,0),(-1,0),(0,-1)):
                nx = x + dx
                ny = y + dy
                if not(0<= nx < H and 0<= ny < W): continue
                if m[nx][ny]: continue
                m[nx][ny] = c
                q.append((nx,ny))
                r.append((nx,ny))
        for x,y in r:
            for dx in range(-2,3):
                nx = x + dx
                if not(0<= nx < H): continue
                for dy in range(-2,3):
                    ny = y + dy
                    if not(0<= ny < W): continue
                    if m[nx][ny]: continue
                    z.append((nx,ny,c+1))
    print(-1)
if __name__ == '__main__':
    main()

Measured memory_bytes: 151212
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int n,a,b; cin >>n;
    if(n == 1){cout << "Hello World" << endl; return 0;}
    cin >> a >> b;
    cout << a+b << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
        int n;
        cin >> n;
        if (n <= 1) {
                cout << 1 << endl;
                return 0;
        }

        int *fib = new int[n + 1];
        fib[0] = fib[1] = 1;
        for (int i = 2; i <= n; i++) {
                fib[i] = fib[i - 1] + fib[i - 2];
        }
        cout << fib[n] << endl;
        delete [] fib;

        return 0;
}

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

int main(){
    ll N; cin >> N;
    vector<ll> A(N+1), S(N+1);
    rep(i, 1, N+1) cin >> A[i];
    rep(i , 1, N + 1) S[i] = S[i-1] + A[i];
    ll ans = 1e18;

    rep(div, 3, N){
        double diff1 = (double)S[div-1] / 2.0;
        double diff2 = (double)(S[N] + S[div-1]) / 2.0;
        auto it1 = upper_bound(S.begin() + 1, S.begin() + div - 1, diff1);
        auto it2 = upper_bound(S.begin() + div, S.begin() + N, diff2);
        ll p1 = *it1;
        ll q1 = S[div-1] - *it1;
        it1--;
        ll p2 = *it1;
        ll q2 = S[div-1] - *it1;
        ll p, q;
        if(llabs(p1 - q1) < llabs(p2 - q2)) p = p1, q = q1;
        else p = p2, q = q2;
        ll r1 = *it2 - S[div-1];
        ll s1 = S[N] - *it2;
        it2--;
        ll r2 = *it2 - S[div-1];
        ll s2 = S[N] - *it2;
        ll r, s;
        if(llabs(r1 - s1) < llabs(r2 - s2)) r = r1, s = s1;
        else r = r2, s = s2;
        ll m1 = min(p, min(q, min(r,s)));
        ll M1 = max(p, max(q, max(r,s)));
        cerr << p << " " << q << " " << r << " " << s << endl;
        ans = min(ans, llabs(M1 - m1));
    }
    cout << ans << endl;

}

Measured memory_bytes: 3328