akhauriyash/Code-Regression huggingface dataset:
def items(p,q):
    print(p)
    print(q)
    
list_H=[]
list_W=[]
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    else:
        list_H.append(H)
        list_W.append(W)
for i in range(len(list_H)):
    h=list_H[i]
    w=list_W[i]
    A=h//2
    B=w//2
    a=h%2
    b=w%2
    X="#."
    Y=".#"
    x="#"
    y="."

    if h==0 or w==0:
        pass
    elif b==0:
        s=X*B
        t=Y*B
        if h==1:
            print(s)
            print()
        else:
            for i in range(A):
                items(s,t)
            if a==1:
                print(s)
            print()
    else:
        s=X*B+x
        t=Y*B+y
        if w==1 and h==1:
            print(x)
            print()
        elif w==1:
            for j in range(A):
                items(x,y)
            if a==1:
                print(x)
            else:
                pass
            print()
        elif h==1:
            print(s)   
            print() 
        else:
            for j in range(A):
                items(s,t)
            if a==1:
                print(s)
            else:
                pass
            print()


Measured memory_bytes: 5636
import java.util.*;

public class Main {
    static Scanner in = new Scanner(System.in);

    public static void main(String[] args) {
        int N = in.nextInt();
        Pair[] pairs = new Pair[N];
        for (int i = 0; i < N; i++) {
            pairs[i] = new Pair(i + 1, in.nextInt());
        }
        Arrays.sort(pairs);
        StringBuilder sb = new StringBuilder();
        sb.append(pairs[0].i);
        for (int i = 1; i < pairs.length; i++) {
            sb.append(" " + pairs[i].i);
        }

        System.out.println(sb.toString());
    }

    static class Pair implements Comparable<Pair> {
        int i;
        int a;

        Pair(int i, int a) {
            this.i = i;
            this.a = a;
        }

        @Override
        public int compareTo(Pair o) {
            return Integer.compare(a, o.a);
        }
    }
}


Measured memory_bytes: 65856
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		while (true) {
			int h = Integer.parseInt(in.next());
			int w = Integer.parseInt(in.next());
			if (h == 0 && w == 0) {
				break;
			}
			for (int i = 0; i < w; i++) {
				System.out.print("#");
			}
			System.out.println("");
			for (int i = 1; i < h - 1; i++) {
				System.out.print("#");
				for (int j = 1; j < w - 1; j++) {
					System.out.print(".");
				}
				System.out.print("#");
				System.out.println("");
			}
			for (int i = 0; i < w; i++) {
				System.out.print("#");
			}
			System.out.println("\n");
		}
	}
}	


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

int get_cnt(string s, char c){
	string s1, s2 = s;
	int fl = 0;
	REP(i, 0, (int)s.length()){
		if (s[i] == c){
			fl = 1;
			break;
		}
	}
	if (!fl){
		return INF;
	}
	fl = 1;
	REP(i, 0, (int)s.length()){
		if (s[i] != c){
			fl = 0;
			break;
		}
	}
	if (fl){
		return 0;
	}
	while(1){
		s1 = s2;
		int n = s2.length();
		s2 = s2.substr(0, n - 1);
		fl = 1;
		REP(i, 0, n - 1){
			if (s1[i] == c || s1[i + 1] == c){
				s2[i] = c;
			}
			if (s2[i] != c){
				fl = 0;
			}
		}
		if (fl){
			return s.length() - s2.length();
		}
		
	}
}

void solve(){
	string s;
	cin >> s;
	int ans = INF;
	REPN(i, 'a', 'z'){
		ans = min(ans, get_cnt(s, (char)i));
	}
	printf("%d\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL); \
    cout.tie(NULL)
#define inc(x, y, i) for (int i = x; i <= y; i++)
#define dec(x, y, i) for (int i = x; i >= y; i--)
#define repeat(n) for (int i = 0; i<n;i++)

#define ll long long
#define ld long double
#define ull unsigned long long
#define infl LONG_MAX
#define infi INT_MAX
#define nl cout<<'\n'

#define all(v) v.begin(),v.end()
#define vi vector<int>
#define pb push_back
#define pii pair<int,int>
#define mkpr make_pair
#define pq priority_queue


void printAr(int a[],int n)  // print the array
{
    for(int *i = a; i!=a+n; ++i)cout << *i << " ";
    cout << endl;
}

const int N = 2e5+2;
//int a[N],cum[N];
int n,k,m;
int a[N] = {};
bool is_one(int n,int p)
{
    return n & (1 << p);
}
int main()
{
    fastio;
    cin >> n;
    repeat(n){cin >> a[i];}
    sort(a,a+n);
    long long ans = 0;
    if(n==1){cout << 0 << endl;}
    else if(n==2){cout << a[1] << endl;}
    else{
        long long ans = a[n-1];
        int i = n-2;
        int f = 0;
        int cnt = 2;
        while(cnt < n){
            ans = ans + a[i];
            f++;
            if(f==2){f = 0;i--;}
            cnt++;
        }
        cout << ans << endl;
    }

}


Measured memory_bytes: 4444
target_str = "AC"

N, Q = map(int, input().split()) 
S = input().strip()

cumsum_list = [0 for i in range(N)]

cnt = 0
for i in range(N - 1):
  if S[i: i + 2] == target_str:
    cnt += 1
  cumsum_list[i] = cnt
cumsum_list.insert(0, 0)
cumsum_list.insert(0, 0)


for i in range(Q):
  l, r = map(int, input().split()) 
  print(cumsum_list[r] - cumsum_list[l])

Measured memory_bytes: 6104
#include<iostream>
using namespace std;
int dx[12]={-2,-2,-2,-1,-1, 0, 0, 1, 1, 2, 2, 2};
int dy[12]={ 1, 0,-1,-2, 2,-2, 2,-2, 2, 1, 0,-1};
int fy[9]={ 1, 0,-1, 1, 0,-1, 1, 0,-1};
int fx[9]={ 1, 1, 1, 0, 0, 0,-1,-1,-1};


int n,x,y,flg;
int sx,sy;
int t[10][10][10];

void init();
void dfs(int,int,int);

int main(){
 

  while(cin>>x>>y){
    if(x==0&&y==0)break;
    init();
    cin>>n;
    for(int i=0;i<n;i++){
      cin>>sx>>sy;

      for(int j=0;j<9;j++){
	int nx,ny;
	nx=sx+fx[j];
	ny=sy+fy[j];
	if(nx<0||ny<0||nx>=10||ny>=10)continue;
	t[i][nx][ny]=1;
      }
      /*
      cout<<endl;
      for(int j=0;j<9;j++){
	for(int k=0;k<9;k++){
	  if(k==sy&&j==sx)cout<<'x';
	  else cout<<t[i][j][k];
	}
	cout<<endl;
      }
      */
    }
    flg=0;
    dfs(x,y,-1);
    if(flg)cout<<"OK"<<endl;
    else cout<<"NA"<<endl;
  }
  
  return 0;
}

void init(){
  for(int i=0;i<10;i++)
    for(int j=0;j<10;j++)
      for(int k=0;k<10;k++)
	t[i][j][k]=0;
}

void dfs(int y,int x,int c){
  if(c==n-1){flg=1;return;}



  int nx,ny;  
  for(int i=0;i<12;i++){
    nx=x+dx[i];
    ny=y+dy[i];
    if(nx<0||ny<0||nx>=10||ny>=10)continue;
    if(t[c+1][ny][nx]==0)continue;
    dfs(ny,nx,c+1);
  }
}

Measured memory_bytes: 1156
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

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

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    ll t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    a1 *= t1;
    a2 *= t2;
    b1 *= t1;
    b2 *= t2;
    if (a1 < b1) {
        swap(a1,b1);
        swap(a2,b2);
    }
    ll d1 = a1 - b1;
    ll d2 = b1+b2-a1-a2;

    if (a1+a2>(b1+b2)) {
        cout << 0 << endl;
        return 0;
    }
    if (d2>d1) {
        cout << 1 << endl;
        return 0;
    }
    if (a1+a2==b1+b2) {
        cout << "infinity" << endl;
        return 0;
    }

    ll num = (d1 +(d2-1)) / d2;
    num *= 2;
    --num;
    if (d1%d2==0) num += 1;
    //num += 1;
    //cout << "d1: " << d1 << " d2: " << d2 << endl;
    cout << num << endl;
    return 0;
}


Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N, K, R, S, P := nextInt(), nextInt(), nextInt(), nextInt(), nextInt()
	T := nextLine()
	// Tn := strings.Split(T, "")
	W := make([]bool, N)
	ans := 0
	v := map[byte]int{
		'r': P,
		'p': S,
		's': R,
	}

	// for i := 0; i < N; i++ {
	// 	if i < K {
	// 		W[i] = true
	// 	} else if T[i] != T[i-K] {
	// 		W[i] = true
	// 	}
	// }

	for i := 0; i < N; i++ {
		if i < K {
			ans += v[T[i]]
		} else if T[i] == T[i-K] {
			if W[i-K] {
				ans += v[T[i]]
			} else {
				W[i] = true
			}
		} else {
			ans += v[T[i]]
		}
	}

	// for i := 0; i < N; i++ {
	// 	if i < K {
	// 		switch Tn[i] {
	// 		case "r":
	// 			W[i] = "p"
	// 		case "p":
	// 			W[i] = "s"
	// 		case "s":
	// 			W[i] = "r"
	// 		}
	// 	} else {
	// 		switch Tn[i] {
	// 		case "r":
	// 			if W[i-K][0] != 'p' {
	// 				W[i] = "p"
	// 			} else if i+K < N && W[i+K][0] != 's' {
	// 				W[i] = "sl"
	// 			} else {
	// 				W[i] = "rl"
	// 			}
	// 		case "p":
	// 			if W[i-K][0] != 's' {
	// 				W[i] = "s"
	// 			} else if i+K < N && W[i+K][0] != 'p' {
	// 				W[i] = "rl"
	// 			} else {
	// 				W[i] = "pl"
	// 			}
	// 		case "s":
	// 			if W[i-K][0] != 'r' {
	// 				W[i] = "r"
	// 			} else if i+K < N && Tn[i+K][0] != 'r' {
	// 				W[i] = "pl"
	// 			} else {
	// 				W[i] = "sl"
	// 			}
	// 		}
	// 	}
	// 	if len(W[i]) == 1 {
	// 		switch W[i] {
	// 		case "r":
	// 			ans += R
	// 		case "p":
	// 			ans += P
	// 		case "s":
	// 			ans += S
	// 		}
	// 	}
	// 	fmt.Println(ans)
	// }
	// fmt.Println(ans, Tn, W)
	fmt.Println(ans)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 896
def InputToInt():
    A = input().split()
    for i in range(len(A)):
        A[i] = int(A[i])
    return A
    
if __name__ == '__main__':
    N = int(input())
    A = InputToInt()
    B = InputToInt()
    C = InputToInt()

    c = sum(B)
    for i in range(N-1):
        if A[i+1] == A[i]+1:
            c += C[A[i]-1]
    print(c)




Measured memory_bytes: 3060
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
#define REP(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;
using ll = long long;

/**
 * main
 */
int main () {
  ll N, Q;
  string S;

  cin >> N >> S >> Q;

  set<ll> M[26];

  REP(i, 0, N) {
    char c = S[i];
    ll c_i = c - 'a';
    M[c_i].insert(i);
  }

  REP(j, 0, Q) {
    ll type;
    scanf("%lld", &type);

    if (type == 1) {
      ll i;
      char c;

      scanf("%lld %c", &i, &c);

      if (S[i - 1] == c) continue;

      M[S[i - 1] - 'a'].erase(i - 1);
      M[c - 'a'].insert(i - 1);
      S[i - 1] = c;
    } else {
      ll l, r;
      scanf("%lld %lld", &l, &r);
      ll cnt = 0;

      REP(c, 0, 26) {
        auto it = M[c].lower_bound(l - 1);
        if (it == M[c].end()) continue;
        if (*it <= r - 1) cnt++;
      }

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


Measured memory_bytes: 24196
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    ll N, M, K;
    cin >> N >> M >> K;

    vec<ll> A(N + 1,0);
    rep(i, N) cin >> A[i+1];
    rep(i, N+1) A[i + 1] += A[i];

    vec<ll> B(M + 1,0);
    rep(i, M) cin >> B[i+1];
    rep(i, M+1) B[i + 1] += B[i];

    ll ans = 0;
    int b_i = M;
    rep(i, N+1) {
        if (A[i] > K) break;
        int idx = upper_bound(all(B),K-A[i]) - B.begin();
        ans = max(ans,i+idx-1);
        
    }

    cout << ans << endl;
}


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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

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

// constant
// -----------------------------------------------------------------------------
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    int N; cin >> N;
    ll ans = 1;
    for(int i = 1; i <= N; i++) {
        ans = ans * i % MOD;
    }
    cout << ans << "\n";
}

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

#define MAX_PROCESSES 100000

typedef struct {
  char name[16];
  int time;
} Process;

Process *queue[MAX_PROCESSES];
int p = 0, q = 0;

void push(Process *proc) {
  queue[p++] = proc;
  if (p >= MAX_PROCESSES) p = 0;
}

Process *unshift() {
  Process *proc = queue[q++];
  if (q >= MAX_PROCESSES) q = 0;
  return proc;
}

int main(int argc, char *argv[]) {
  int n, qu;
  int time = 0;
  scanf("%d %d", &n, &qu);
  for (int i = 0; i < n; i++) {
    Process *proc = malloc(sizeof(Process));
    scanf("%s %d", proc->name, &proc->time);
    push(proc);
  }
  while (p != q) {
    Process *proc = unshift();
    if (proc->time <= qu) {
      time += proc->time;
      printf("%s %d\n", proc->name, time);
      free(proc);
      continue;
    }
    proc->time -= qu;
    time += qu;
    push(proc);
  }
}

Measured memory_bytes: 4164
L, R = [int(i) for i in input().split()]

l, r = L + (3 - L % 3) % 3, R - R % 673

if l < r:
    print(0)
else:
    mi = 3000
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            mi = min(mi, (i * j) % 2019)
    print(mi)


Measured memory_bytes: 40176
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
int main (void)
{
  int s,a,b;
  bool af=0,bf=0;
  cin>>s;
  //cout<<s<<endl;
  a=s%100;
  b=s/100;
  if(a>0&&a<13){af=1;}
  if(b>0&&b<13){bf=1;}
  if(af==1&&bf==1){cout<<"AMBIGUOUS"<<endl;}
  else if(af==1){cout<<"YYMM"<<endl;}
  else if(bf==1){cout<<"MMYY"<<endl;}
  else{cout<<"NA"<<endl;}
}

Measured memory_bytes: 3636
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int dp[100010];
signed main() {
    int N; cin >> N;
    vector<int> cand;
    cand.push_back(1);
    for(int i=6; i<=N; i*=6) cand.push_back(i);
    for(int i=9; i<=N; i*=9) cand.push_back(i);

    fill(dp, dp + N + 1, INF);
    dp[0] = 0;
    for(int i=0; i<=N; i++) {
        for(auto x : cand) {
            if(i + x > N) continue;
            chmin(dp[i+x], dp[i] + 1);
        }
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

class Main { 
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            int N = in.nextInt();
            while (N != 0) {
                String X = in.next();
                String Y = in.next();
                int[][] map = new int[X.length() + 1][Y.length() + 1];
                System.out.println(lcs(X, Y, map));
                N--;
            }
        }
    }
    static int lcs(String X, String Y, int[][] map) {
        for (int i = 0; i < X.length(); i++) {
            for (int j = 0; j < Y.length(); j++) {
                if   (X.charAt(i) == Y.charAt(j)) map[i + 1][j + 1] = map[i][j] + 1;
                else                              map[i + 1][j + 1] = Math.max(map[i + 1][j], map[i][j + 1]);
            }
        }
        return map[X.length()][Y.length()];
    }
}

Measured memory_bytes: 61012
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

typedef long long ll;

int main() {
    int h, w, cnt = 0;
    cin >> h >> w;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            char c;
            cin >> c;
            if (c == '#') ++cnt;
        }
    }

    if (cnt == h + w - 1) {
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1000000007;

void solve() {
  int n;
  cin >> n;
  vector<vector<int>> tree(n);
  vector<vector<int>> cost(n);
  rep(i,n-1) {
    int u, v, w;
    cin >> u >> v >> w;
    u--, v--;
    tree[u].push_back(v);
    tree[v].push_back(u);
    cost[u].push_back(w);
    cost[v].push_back(w);
  }

  vector<int> ans(n, -1);
  queue<int> q;
  ans[0] = 0;
  q.push(0);
  while(!q.empty()) {
    int u = q.front();
    q.pop();
    for(int i = 0; i < tree[u].size(); i++) {
      int v = tree[u][i];
      if (ans[v] != -1) continue;
      else {
        if (cost[u][i] % 2 == 0) ans[v] = ans[u];
        else ans[v] = (ans[u] + 1) % 2;
        q.push(v);
      }
    }
  }
  rep(i,n) cout << ans[i] << endl;
}

int main() {
  solve();
  return 0;
}

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

template <typename T> inline T min(const T &x, const T &y) { return x < y ? x : y; }
template <typename T> inline T max(const T &x, const T &y) { return x > y ? x : y; }
template <typename T> inline bool cmin(T &x, const T &y) { if (x > y) { x = y; return 1; } return 0; }
template <typename T> inline bool cmax(T &x, const T &y) { if (x < y) { x = y; return 1; } return 0; }

int main() {
	std ::string a;
	std ::cin >> a;
	if (a[0] == 'S') puts("Cloudy");
	if (a[0] == 'C') puts("Rainy");
	if (a[0] == 'R') puts("Sunny");
	return 0;	
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,a,b,s;
    scanf("%d",&n);
    if(n==1)
    {
        printf("Hello World");
    }
    else if(n==2)
    {
        scanf("%d %d" ,&a,&b);
        s=a+b;
        printf("%d",s);
    }
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=25005;
const int K=405;
const int mod=1e9+7;
int n,k,m,a[N],ans,f[N][K],g[N][K],sum_f[K],sum_g[K];
int fastpow(int x,int y){
	int res=1;
	while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}
	return res;
}
bool check1(){
	static int lst[K],len=0;
	for(int i=1,j=0;i<=m;++i){
		j=max(j,lst[a[i]]);
		len=max(len,i-j);
		lst[a[i]]=i;
	}
	return len==k;
}
bool check2(){
	static int vis[K];
	for(int i=1;i<=m;++i){
		if(vis[a[i]])return false;
		vis[a[i]]=1;
	}
	return true;
}
int prelen(){
	static int vis[K];
	for(int i=1;i<=m;++i){
		if(vis[a[i]])return i-1;
		vis[a[i]]=1;
	}
}
int suflen(){
	static int vis[K];
	for(int i=m;i;--i){
		if(vis[a[i]])return m-i;
		vis[a[i]]=1;
	}
}
void solve(int s){
	memset(f,0,sizeof(f));
	memset(g,0,sizeof(g));
	f[0][s]=1;
	for(int i=0;i<n;++i){
		for(int j=1;j<k;++j){
			sum_f[j]=(sum_f[j-1]+f[i][j])%mod;
			sum_g[j]=(sum_g[j-1]+g[i][j])%mod;
		}
		for(int j=1;j<k;++j){
			f[i+1][j]=(1ll*f[i][j-1]*(k-j+1)+sum_f[k-1]-sum_f[j-1]+mod)%mod;
			g[i+1][j]=(1ll*g[i][j-1]*(k-j+1)+sum_g[k-1]-sum_g[j-1]+mod)%mod;
			if(j>=m)g[i+1][j]=(g[i+1][j]+f[i+1][j])%mod;
		}
	}
}
int main(){
	scanf("%d%d%d",&n,&k,&m);
	for(int i=1;i<=m;++i)scanf("%d",&a[i]);
	ans=1ll*(n-m+1)*fastpow(k,n-m)%mod;
	if(check1())return printf("%d\n",ans),0;
	if(check2()){
		solve(0);int res=0;
		for(int i=0;i<k;++i)res=(res+g[n][i])%mod;
		for(int i=1;i<=m;++i)res=1ll*res*fastpow(k-m+i,mod-2)%mod;
		ans=(ans+mod-res)%mod;
	}else{
		solve(prelen());static int tmp[N];
		for(int i=0;i<=n-m;++i)
			for(int j=0;j<=k;++j)
				tmp[i]=(tmp[i]+f[i][j])%mod;
		solve(suflen());int res=0;
		for(int i=0;i<=n-m;++i){
			int s=0;
			for(int j=0;j<=k;++j)s=(s+f[i][j])%mod;
			res=(res+1ll*tmp[n-m-i]*s)%mod;
		}
		ans=(ans+mod-res)%mod;
	}
	return printf("%d\n",ans),0;
}


Measured memory_bytes: 79360
m[4][65536],i,l,L,p,c;main(n){for(;~scanf("%d\n",&n);L=n&&!printf("%d\n",L))for(p=255;++p<256-~n*n;)for(c=getchar(i=4);i--;L=l>L?l:L)l=m[i][p]=c-49?0:m[i][p-(i?n+i-1:1)]+1;}

Measured memory_bytes: 0
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

// vectorの重複削除
// std::sort(test.begin(), test.end());
// test.erase(std::unique(test.begin(), test.end()), test.end());

using namespace std;
using ll = long long;
using P = pair<int, int>; // vector<P> ba(n); みたいな感じですぐ使える ba[i] = P(a, b); make_pairをしなくてもいい
// typedef vector<int> v;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}
#define rep(i, c) for(int i = 0; i < int(c); i++)
#define ALL(x) (x).begin(), (x).end() //sort(ALL(obj))みたいな
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値
#define pb push_back //
// const int MOD = 1000000007;
// string alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
// printf("%.20f\n", ans); あれ
// const double PI = 3.141592653589793238462643383;

int main() {
  ll a,b; cin>>a>>b;
  if (a%2 != b%2) {
    cout << "IMPOSSIBLE" << endl;
  } else {
    cout << abs(a+b)/2 << endl;
  }
}


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

ANS=0
i=0
while i<N:
    if i==0:
        ANS+=B[i]
        mae=B[i]
    elif i==N-1:
        ANS+=mae
    else:
        ANS+=min(B[i],mae)
        mae=B[i]
    i+=1
    
print(ANS)


Measured memory_bytes: 3060
# include<iostream>
using namespace std;
int gcd(int x, int y){
    while(y>0){
        int a = x%y; x = y; y = a;
    }
    return x;
}
int main(){
    int x,y;
    cin >> x >> y;
    int ans = gcd(x,y);
    cout << ans <<"\n";
    return 0;
}


Measured memory_bytes: 3116
#include<stdio.h>
#include<math.h>
#include<stack>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define inf 0X3f3f3f3f
#define ll long long
#define N 1011
int a[5];
int main()
{
    int n,m;
    while(~scanf("%d %d",&n,&m))
    {
        memset(a,0,sizeof a);
        int flag=0;
        while(m--)
        {
            int x,y;
            scanf("%d %d",&x,&y);
            if((a[x]!=0&&a[x]!=y)||(x==1&&y==0&&n!=1))
            {
                flag=1;
                continue;
            }
             a[x]=y;
        }
        if(n!=1&&a[1]==0)
            a[1]=1;
        if(flag)
            printf("-1\n");
        else
        {
            for(int i=1; i<=n; i++)
                    printf("%d",a[i]);
            printf("\n");
        }
    }
    return 0;
}


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

using namespace std;

inline int read(){
	char ch=getchar();int x=0,f=1;
    while(ch<'0' || ch>'9') {
       if(ch=='-') f=-1;
	  	  ch=getchar();
	}
    while(ch<='9' && ch>='0') {
	   x=x*10+ch-'0';
	   ch=getchar();
	}
    return x*f;
}

bitset<2010*2010> bt; 

int main(){
	int n=read();
	int sum=0;
	bt[0]=1;
	for(int i=1;i<=n;i++){
		int d=read();
		sum+=d;
		bt=bt | (bt<<d);
	} 
	int ans=(sum+1)/2;
	while(bt[ans]==0) ans++;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 2304
//is there any case of -1 or any special corner cases ?
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define zeros(arr) memset(arr,0,sizeof(arr));
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
#define nl cout<<"\n";
#define test int t;cin>>t;while(t--) 
const int maxx  = 3*1e5 , limit = 1e17 , MOD=1e9+7;
string binary(int n){bitset<32>b(n) ;string p =b.to_string();return p;}
#define boost  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int32_t main(){
    boost;
    
    
    int n , m ,x;
    cin>>n>>m>>x;
    vector< int > v[n+1];
    
    int cost[n+1];
    for(int i = 0 ;i  < n; i ++ ){
        cin>>cost[i];
        for(int  j =0  ;j  < m ; j++ ){
            int val;
            cin>>val;v[i].pb(val);
        }
    }
    int ans  = limit;
    int num = pow(2,12);
    for(int i =0 ; i < num ; i ++ ){
        
        string q = binary(i);
        
        reverse(all(q));
        
        int arr[m+1];
        zeros(arr);
        
        int co = 0;
        for(int j =0 ; j < n ; j ++ ){
            
                if(q[j] == '1'){
                co+=cost[j];
                    
                        for(int k = 0 ; k < m ; k ++ ){
                            arr[k] +=v[j][k];
                        }
                    
                    
                }
            
            
        }
        bool flag=true;
        for(int j = 0; j < m ; j++ ){
            if(arr[j] < x){
                flag=false;
            }
        }
        if(flag){
            ans = min(ans ,  co);
        }
        
        
        
        
    }
    if(ans == limit)ans=-1;
    
    
    cout<<ans<<endl;
    
    
}

Measured memory_bytes: 3656
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        int ans = 0;
        int a = 0;
        int b = 0;
        int ab = 0;
        for (int i = 0; i < n; i++) {
            String s = scanner.next();
            for (int j = 1; j < s.length(); j++) {
                if (s.charAt(j - 1) == 'A' && s.charAt(j) == 'B') {
                    ans++;
                }
            }
            if (s.charAt(s.length() - 1) == 'A') {
                if (s.charAt(0) == 'B') {
                    ab++;
                } else {
                    a++;
                }
            } else if (s.charAt(0) == 'B') {
                b++;
            }
        }

        if (a == 0 && ab > 0) {
            ab--;
            a++;
        }

        if (b == 0 && ab > 0) {
            ab--;
            b++;
        }

        System.out.println(ans + Math.min(a, b) + ab);
    }
}

Measured memory_bytes: 30596
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    H, W = map(int,input().split())
    h, w = map(int,input().split())

    print(H*W-W*h-H*w+h*w)
    
    
    
resolve()

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
inline int read(){int w=1,s=0;char ch=getchar();while(!isdigit(ch)){if(ch=='-')w=-1;ch=getchar();}while(isdigit(ch)){s=s*10+ch-'0';ch=getchar();}return  w*s;}
int n,a,b;
int calc(int t)
{
	int res=0;
	while(t)
	{
		res+=t%10;
		t/=10;
	}
	return res;
}
int main()
{
	n=read();
	int ans=1e9;
	for(a=1;a<n;++a)
	{
		b=n-a;
		ans=min(ans,calc(a)+calc(b));
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 764
// package com.company;

import java.util.*;
import java.io.*;

public class Main {
    static Scanner input = new Scanner(System.in);

    public static void main(String[] args) {
        List<Integer> ans = new ArrayList<>();
        int n = input.nextInt();

        for (int i = 0; i < n; i++) {
            int Y = input.nextInt();
            int M = input.nextInt();
            int D = input.nextInt();

            int years = 1000 - Y;

            int yearsBig = years / 3;
            if ( Y % 3 != 1) yearsBig ++;
            // System.out.println("Y = " + yearsBig);
            int yearsSmall = years - yearsBig;

            int days = yearsBig*200 + yearsSmall*195;
            // System.out.println("day = " + days);

            int monthDis = M - 1;
            int monthSmall = monthDis / 2;
            int monthBig = monthDis - monthSmall;
            if (Y %3 != 0) {
                days = days - monthSmall * 19 - monthBig * 20;
            } else {
                days = days - monthDis * 20;
            }
            // System.out.println("day = " + days);

            int dayDis = D - 1;

            days = days - dayDis;
            // if (M * D > 1)
            //     ans.add(days + 5);
            // else ans.add(days);

            ans.add(days);
        }

        for (int day : ans) {
            System.out.println(day);
        }
    }
}


Measured memory_bytes: 26912
import bisect
n=int(input())
A=sorted(list(map(int,input().split())))
B=sorted(list(map(int,input().split())))
C=sorted(list(map(int,input().split())))
print(sum(bisect.bisect_left(A,b)*(n-bisect.bisect_right(C,b)) for b in B))

Measured memory_bytes: 23336
/*input
15
35 45 42 19 49 30 42 16 22 44 48 31 17 42 39
27 44 31 13 30 8 35 8 29 32 19 29 30 2 42
3
3 4 3
3 2 3
*/
#ifdef UncleGrandpa
#include <prettyprint.hpp>
#endif
#include <bits/stdc++.h>
using namespace std;
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define loop(i,l,r) for(int i=(l); i<=(r); i++)
#define rloop(i,l,r) for(int i=(l); i>=(r); i--)
#define bit(x,y) ((x>>y)&1)
#define debug(x...) {cout << "[" << #x << "] ="; _co(x);}
void _co() {cout << endl;}
template<typename T, typename... Ts> void _co(const T& value, const Ts&... values) {cout << ' ' << value; _co(values...);}
template<typename T, typename... Ts> void co(const T& value, const Ts&... values) {cout << "deb: " << value; _co(values...);}
// const int N =;

int n;

const int INF = 1e9;

int solve(vector<pair<int, int> > &inp) {
	int ret = 0;
	loop(i, 1, inp.size() - 1) {
		int cur = i;
		while (cur > 0 && inp[cur - 1].fi > inp[cur].fi) {
			swap(inp[cur - 1], inp[cur]);
			inp[cur - 1].se ^= 1; inp[cur].se ^= 1;
			cur--;
			ret++;
		}
	}
	for (int i = 0; i < inp.size();) {
		int last = i;
		loop(j, i + 1, inp.size() - 1) {
			if (inp[j].fi != inp[j - 1].fi) break;
			last = j;
		}
		int tick = -1;
		loop(j, i, last) {
			if (inp[j].se == 0) continue;
			if (tick == -1) tick = j;
			else {
				if ((j - tick + 1) % 2 == 0) 
					ret += j - tick;
				else return INF;
				tick = -1;
			}
		}
		if (tick != -1) return INF;
		i = last + 1;
	}
	return ret;
}

vector<pair<int, int> > a;
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	loop(i, 1, n) {
		int t; cin >> t; a.push_back({t, 0});
	}
	for (auto &it : a) cin >> it.se;
	int ans = INF;
	loop(mask, 0, (1 << n) - 1) {
		vector<pair<int, int> > b;
		loop(i, 0, n - 1) {
			if (bit(mask, i)) b.push_back({a[i].se, 1});
			else b.push_back({a[i].fi, 0});
		}
		auto rec = solve(b);
		ans = min(ans, rec);
	}
	if (ans == INF) cout << -1 << endl;
	else cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main() {
   int a[6],k,ok=1;
   
   for(int i=1;i<=5;i++){
       cin>>a[i];
   }
   cin>>k;
   for(int i=1;i<=4;i++)
   for(int j=i+1;j<=5;j++){
       if(a[j]-a[i]>k){
           ok=0;
       }
   }
   if(ok==0){
       cout<<":(";
   }
   else{
       cout<<"Yay!";
   }

    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
points=[]
for i in range(m):
    a,b=map(int,input().split())
    points.append([a,b-1])
points = sorted(points)
arrow = float('-inf')
res = 0
#print(points)
for l,r in points:
    if l > arrow:
        res += 1
        arrow = r
    elif r < arrow:
        arrow = r
print(res)

Measured memory_bytes: 20972
using System;
using System.Collections;
using System.Collections.Generic;
using System.Dynamic;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Runtime.InteropServices;
using System.Text;
using static System.Console;
using static System.Math;

class Simple {    
    
    void Solve() {
        //input        
        var a = io.Double;
        var b = io.Double;
        //cal
        var ans = Math.Ceiling((a + b) / 2.0);
        //ret
        WriteLine(ans);
    }

    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Simple().Stream();
    private void Stream() {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        io.Flush();        
    }
}
class SimpleIO {
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] {' ', '"', ','};
    StreamWriter sw = new StreamWriter(OpenStandardOutput()) {
#if DEBUG
        AutoFlush = true
#else
        AutoFlush = false
#endif
    };
    public SimpleIO() {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        SetOut(sw);        
    }
    string Next() {
        if(_bufferCnt < _nextBuffer.Length)
            return _nextBuffer[_bufferCnt++];
        var st = ReadLine();
        while(st == "")
            st = ReadLine();
        _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() => Out.Flush();
}
static class Ex {
    public static void REP(this int n, Action <int> act) {
        for(var i = 0; i < n; ++i) 
            act(i);
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
#include<map>
#include<cmath>
#include<complex>
using namespace std;

typedef complex<double> P;

#define X real()
#define Y imag()
typedef int kz;

kz gcd(kz a,kz b) { if(b==0) return a; else gcd(b,a%b); }

int main(){
    int mod=1000000007;
    int w,n,a[1000],b[1000],Case=1;
    char s[260];
    for (;;) {
        scanf("%d",&w);
        if (w==0) break;
        int dp[w+1]={0};
        int ans[2]={0,0};
        scanf("%d",&n);
        for (int i=0;i<n;++i) {
            scanf("%d,%d",&a[i],&b[i]);
        }
        for (int i=0;i<n;++i) {
            for (int j=w-b[i];j>0;--j) {
                if (dp[j]!=0) {
                    dp[j+b[i]]=max(dp[j+b[i]],dp[j]+a[i]);
                }
            }
            dp[b[i]]=max(dp[b[i]],a[i]);
        }
        for (int i=0;i<w+1;++i) {
            if (ans[0]<dp[i]) {
                ans[0]=dp[i];
                ans[1]=i;
            }
        }
        printf("Case %d:\n%d\n%d\n",Case,ans[0],ans[1]);
        Case++;
    }
    return 0;
}

Measured memory_bytes: 3168
#include<iostream>

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

int p,q,a;

int solve(int n, int i, int prob, int sum){
	int cnt = 0;
	for(; i*prob <= a; i++){
		int left = i*prob*p;
		int right = i*sum+prob;
		if(left < right*q)continue;
		if(left == right*q){cnt++;continue;}
		if(n == 1)continue;
		cnt += solve(n-1,i,prob*i,right);
	}
	return cnt;
}

int main(){

	int n;

	while(std::cin >> p >> q >> a >> n,(p||q||a||n)){
		std::cout << solve(n,1,1,0) << std::endl;
	}
	return 0;
}

Measured memory_bytes: 864
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if (A+B>C+D){
    cout << "Left";
  } else if (A+B<C+D){
    cout << "Right";
  } else {
    cout << "Balanced";
  }
}

Measured memory_bytes: 256
stdin.ReadLine().Split(" ")
|> fun x ->
    let tail =
        x
        |> Array.take 2
        |> Array.map (fun x -> x.ToCharArray() |> Array.rev |> Array.head)

    let head =
        x
        |> Array.rev
        |> Array.take 2
        |> Array.rev
        |> Array.map (fun x -> x.ToCharArray() |> Array.head)

    Array.zip tail head
    |> Array.filter (fun (a, b) -> a = b)
    |> Array.length
    |> fun x -> if x = 2 then "YES" else "NO"
    |> printfn "%s"


Measured memory_bytes: 29588
#include <stdio.h>
int main(){

  int n,N,a,result2=0,i;

  while(1){

    result2=0;
    scanf("%d",&n);
    N=n*(n-1)/2;

    if(n != 0){

      for(i = 0; i < N; i++){

        scanf("%d",&a);

        result2 += a;

      }

      printf("%d\n",result2/(n-1));

    } else {

      break;

    }

  }

  return 0;

}

Measured memory_bytes: 600
import heapq
n,m=map(int,input().split())
a=list(map(int,input().split()))
q=[-a[i] for i in range(n)]
heapq.heapify(q)
for _ in range(m):
  x=heapq.heappop(q)
  x=(x+1)//2
  heapq.heappush(q,x)
ans=0
for _ in range(n):
  ans-=heapq.heappop(q)
print(ans)

Measured memory_bytes: 14180
using System;
using System.Linq;
using System.Collections.Generic;

public class Test
{
	public static void Main()
	{
        string[] line = Console.ReadLine().Split(' ');
        int n = int.Parse(line[0]);
        int m = int.Parse(line[1]);
        int cnt = 0;

        int[] brigde = new int[n];
        
        string[] youbou = new string[2];
        int[] a = new int[m];
        int[] b = new int[m];

        for(int i = 0 ; i < m ; i++){
            youbou = Console.ReadLine().Split(' ');
            a[i] = int.Parse(youbou[0]);
            b[i] = int.Parse(youbou[1]);
        }

        Array.Sort(b,a);
        int c = 0;        
        for(int i = 0 ; i < m ; i++){
            if(a[i] < c){
            } else {
                brigde[b[i]-1] = 1;
                c = b[i];
            }
        }

        cnt = brigde.Sum();
        Console.WriteLine(cnt);
    }                                                                                                                                   
}

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

#define endl "\n"
#define sc(a) scanf("%d ",&a);
#define ssc(a,b) scanf("%d %d ",&a,&b);
#define mp(a,b) make_pair(a,b)
#define pb(x) push_back(x)
#define all(a) a.begin(),a.end()
#define forn(i,n) for(int i=0;i<n;i++)
#define forq(i,q,n) for(int i=q;i<n;i++)
#define form(i,n) for(int i=n;i>=0;i--)
#define forp(i,q,n) for(int i=q;i>=n;i--)
#define fi first
#define se second
#define INF 1000000010
#define MOD 1000000007
#define MAXN
#define long long ll;


using namespace std;

string s;

void init(){
	//cin.ignore();
	getline(cin, s);
	//cout << s[0];
	s[5] = ' ';
	s[13] = ' ';
	cout << s << endl;
}

int main(){
	
	init();
	return 0;
}

Measured memory_bytes: 256
macro_rules! get {
    (Vec<$t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

use std::collections::BinaryHeap;

fn main() {
    let (N, M) = get!(usize, usize);
    let mut AB = get!(usize, i64; N);

    // 後ろから（M-1日後から）貪欲に詰める
    AB.sort_by_key(|&(a, b)| (a, -b));
    let (A, B): (Vec<usize>, Vec<i64>) = AB.into_iter().unzip();
    let mut i = 0;
    let mut q = BinaryHeap::new();
    let mut ans = 0;
    for k in 1..(M + 1) {
        while i < N && A[i] <= k {
            q.push(B[i]);
            i += 1;
        }
        ans += match q.pop() {
            Some(b) => b,
            _ => 0
        }
    }

    println!("{}", ans);
}



Measured memory_bytes: 10492
#include<bits/stdc++.h>
 using namespace std;
      int a,b,c,d; int main() {
               cin>>a>>b>>c>>d;
                       int p= min(b,d)- max(a,c);  
                          if(p>0)
                                cout<<p;
                          else 
                            cout<<0;
                          }

Measured memory_bytes: 256
/*********************************************JMD**********************************************/
//                                  |\  |     | |   |   /\                                   //
    //                              | \ |     | |---|  /--\                              //
        //                          |  \| |___| |   | /    \1999                     //
/*******************************************************************************************/
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define mem(x,val) memset(x,val,sizeof(x))
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define f(i,n) forr(i,0,n)
#define sz(x) ll((x).size())
#define all(x) ((x).begin(),(x).end())
#define asc(x) ((int)(x))
#define precision(x) cout<<fixed<<setprecision((x));

const ll mod=1e9 + 7;

/*******************************************************************************************/

void solve()
{
    char c;
    cin>>c;
    if(c=='A') cout<<"T\n";
    if(c=='T') cout<<"A\n";
    if(c=='G') cout<<"C\n";
    if(c=='C') cout<<"G\n";
    
    return;
}

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

    ll t=1;
    //cin>>t;
    clock_t launch=clock();

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

    clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
}

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

int main(){
    int  N, K, ans=0, tmp, tmp2;
    priority_queue<int, vector<int>, greater<int>> desc;
    cin >> N >> K;
    vector<int> V(N);
    for(int i=0; i<N; i++){
	cin >> V[i];
    }

    for(int i=0;i<=K;i++){
        for(int j=0;j<=K;j++){
	    tmp=0;
	    tmp2=i+j;
	    if(tmp2>K ||tmp2>N)
	    	continue;	    
	    for(int k=0; k<i; k++){
		desc.push(V[k]);
	    }
	    for(int k=0; k<j; k++){
		desc.push(V[N-1-k]);
	    }
	    while(!desc.empty()){
		
		if(desc.top()<0 && tmp2<K)
		    tmp2++;
		else
		    tmp+=desc.top();
		desc.pop();
	    }

	    ans = max(ans, tmp);
	}	
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long,long long> ii;

int main() {
    long long H, W, N;
    cin >> N;
    vector<ii> xi;
    long long xtemp, ltemp;
    for(long long i = 0; i<N; i++) {
        cin >>xtemp >> ltemp;
        xi.push_back(ii(xtemp-ltemp,xtemp+ltemp));
    }
    sort(xi.begin(),xi.end());
    long long farright = xi[N-1].first;
    long long c = 1;
    for(long long i = N-2; i>=0; i--) {
        if(xi[i].second <= farright) {
            c++;
            farright = xi[i].first;
        }
    }
    cout << c << endl;

    return 0;
}



Measured memory_bytes: 2420
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT false

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == 1)return;for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(std::vector<T>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}

void DFS(int V,int Depth,vector<vector<int> > & GRAPH,vector<int>& path)
{
  path[V] = Depth;
  for (int i = 0; i < GRAPH[V].size(); i++)
  {
    int P_N = GRAPH[V][i];
    DEBUG("call");
    if(path[P_N] == -1)
    {
      DFS(P_N,Depth+1,GRAPH,path);
    }
  }
  
}
 
void solve(void)
{

  int N;
  cin>>N;
  vector<vector<int> > GRAPH(N);
  for (int i = 0; i < N-1; i++)
  {
    int A,B;
    cin>>A>>B;
    A--;B--;
    GRAPH[A].push_back(B);
    GRAPH[B].push_back(A);
    DEBUG(GRAPH[A][0]);
  }
  
  vector<int> Path_S(N,-1);
  vector<int> Path_F(N,-1);
  DEBUG(Path_S);
  DFS(0,0,GRAPH,Path_S);
  DFS(N-1,0,GRAPH,Path_F);
  DEBUG(Path_S);
  
  int COUNT = 0;
  for (int i = 0; i < N; i++)
  {
    if(Path_S[i] <= Path_F[i]) COUNT++;
  }

  if(COUNT > N/2)
  {
    cout<<"Fennec"<<endl;;
  }
  else
  {
    cout<<"Snuke"<<endl;
  }
  
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 12032