akhauriyash/Code-Regression huggingface dataset:
/*s1190073  Rina Sato
  File name: prog9b.c
  This is a max heap program.
*/

#include <stdio.h>
#include <stdlib.h>

#define MAX 500001

int heap_size;

int Parent(int i){
  return i/2;
}
int Left(int i){
  return 2*i;
}
int Right(int i){
  return 2*i+1;
}

void maxHeapify(int A[],int i){
  int l,r,largest;
  int temp;
  
  l = Left(i);
  r = Right(i);
  

  if((l <= heap_size) && (A[l] > A[i])){
    largest = l;
  }
  else {
    largest = i;
  }
  
  if((r <= heap_size) && (A[r] > A[largest])){
    largest = r;
  } 
  
  if(largest != i){
    temp = A[i];
    A[i] = A[largest];
    A[largest] = temp;
    
    maxHeapify(A,largest);
  } 
}

void buildMaxHeap(int A[]){
  int i;

  for(i = heap_size/2 ; i >= 1 ; i--){
    maxHeapify(A,i);
  }
}

int main(void){
  int i,key[MAX];
  
  scanf("%d",&heap_size);
  
  for(i = 1 ; i <= heap_size ; i++){
    scanf("%d",&key[i]);  
  }
  
  buildMaxHeap(key);
  
  for(i = 1 ; i <= heap_size ; i++){
    printf(" %d",key[i]);
  }
  printf("\n");
  
  return 0;
}

Measured memory_bytes: 2356
import java.util.*;
import java.io.*;

public class Main {
    static char[] stones;
    static int[][] dp;
	public static void main (String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		stones = br.readLine().toCharArray();
		dp = new int[2][n];
		for (int[] arr : dp) {
		    Arrays.fill(arr, -1);
		}
		System.out.println(Math.min(dfw(0, n - 1), dfw(1, n - 1)));
	}
	
	static int dfw(int isBlack, int idx) {
	    if (idx < 0) {
	        return 0;
	    }
	    if (dp[isBlack][idx] >= 0) {
	        return dp[isBlack][idx];
	    }
	    int ans;
	    if (isBlack == 0) {
	        ans = dfw(isBlack, idx - 1);
	        if (stones[idx] == '#') {
	             ans++;
	        }
	    } else {
	        if (stones[idx] == '#') {
	            ans = dfw(isBlack, idx - 1);
	        } else {
	            ans = Math.min(dfw(isBlack, idx - 1) + 1, dfw(0, idx - 1));
	        }
	    }
	    return dp[isBlack][idx] = ans;
	}
}


Measured memory_bytes: 46460
# coding: utf-8

n, k = map(int, input().rstrip().split())
w = [0 for _ in range(n)]
for i in range(n):
    w[i] = int(input())
    
# from random import randint
# n = 100000
# k = 10000
# w = [0 for _ in range(n)]
# for i in range(n):
#     w[i] = randint(1, 10000)
# print(w)
count = 0

def check(P):
    m = 0
    ik = 1
    for i in range(n):
        global count
        count += 1
        new = m + w[i]
        if new > P:
            m = w[i]
            ik += 1
            if ik > k:
                return False
        else:
            m = new
    return True

s = max(sum(w)//k, max(w))
e = sum(w)

while True:
    P = (s + e)//2
    # print("s:{}, e:{}, P:{}".format(s, e, P))
    if s == e:
        break
    if check(P):
        e = P
    else:
        s = P + 1
            
        
print(P)
# print(count)

Measured memory_bytes: 11628
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
int main()
{
    int n, m; cin>>n>>m;
    bool dame[100010]={};
    for(int i=0; i<m; i++){
        int a; cin>>a; dame[a]=1;
    }
    ll dp[100010]={};
    dp[0]=1;
    for(int i=1; i<=n; i++){
        if(dame[i]) continue;
        dp[i]=dp[i-1];
        if(i>=2) dp[i]+=dp[i-2];
        dp[i]%=MOD;
    }
    cout<<dp[n]<<endl;
    return 0;
}

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

using namespace std;
//using namespace __gnu_pbds;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define F0R(i, a) for (int i=0; i<a; i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

const int MOD = 1000000007;
double PI = 4*atan(1);

pii s1[100001], s2[100001];
string S, j2;

int main() {
	cin >> S >> j2;
	F0R(i,S.length()) {
		s1[i+1] = s1[i];
		if (S[i] == 'A') s1[i+1].f ++;
		else s1[i+1].s ++;
	}
	F0R(i,j2.length()) {
		s2[i+1] = s2[i];
		if (j2[i] == 'A') s2[i+1].f ++;
		else s2[i+1].s ++;
	}
	int q; cin >> q;
	F0R(i,q) {
		int a,b,c,d; cin >> a >> b >> c >> d;
		pii x1 = {s1[b].f-s1[a-1].f,s1[b].s-s1[a-1].s};
		pii x2 = {s2[d].f-s2[c-1].f,s2[d].s-s2[c-1].s};
		x1.f -= x2.f, x1.s -= x2.s;
		if ((x1.f-x1.s) % 3 == 0) cout << "YES\n";
		else cout << "NO\n";
	}
}

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

#define MAX_N 101000

int isPrime[ MAX_N + 1 ] = { 0, 0, 1 };

void quickSort( int *, int, int );
int median( int, int, int );
void insertionSort( int *, int );

int main( void ) {
	int i, j, N, P, cnt, p[ 22 ], sum[ 253 ];

	for ( i = 3; i <= MAX_N; i += 2 )
		isPrime[ i ] = 1;

	for ( i = 3; i * i <= MAX_N; i += 2 )
		if ( isPrime[ i ] )
			for ( j = i * 2; j <= MAX_N; j += i )
				isPrime[ j ] = 0;

	for ( ; scanf( "%d %d", &N, &P ), N != -1; printf( "%d\n", sum[ P - 1 ] ) ) {
		cnt = 0;
		for ( i = N + 1; cnt < 22; i++ )
			if ( isPrime[ i ] )
				p[ cnt++ ] = i;

		cnt = 0;
		for ( i = 0; i < 22; i++ )
			for ( j = i; j < 22; j++ )
				sum[ cnt++ ] = p[ i ] + p[ j ];

		quickSort( sum, 0, 176 );
	}

	return 0;
}

void quickSort( int *data, int l, int r ) {
	if ( l < r ) {
		int i = l, j = r, pivot = median( data[ i ], data[ ( i + j ) / 2 ], data[ j ] ), tmp;

		while ( 1 ) {
			for ( ; data[ i ] < pivot; i++ ) ;
			for ( ; pivot < data [ j ]; j-- ) ;
			if ( i >= j )
				break;

			tmp = data[ i ];
			data[ i ] = data[ j ];
			data[ j ] = tmp;

			i++;
			j--;
		}

		if ( i - l < 20 )
			insertionSort( data + l, i - l );
		else
			quickSort( data, l, i - 1 );

		if ( r - j < 20 )
			insertionSort( data + j + 1, r - j );
		else
			quickSort( data, j + 1, r );
	}
}

int median( int x, int y, int z ) {
	if ( x < y )
		if ( y < z )
			return y;
		else if ( z < x )
			return x;
		else
			return z;
	else if ( z < y )
		return y;
	else if ( x < z )
		return x;
	else
		return z;
}

void insertionSort( int *data, int n ) {
	int i, j, tmp;

	for ( i = 1; i < n; i++ ) {
		tmp = data[ i ];

		for ( j = i; j && data[ j - 1 ] > tmp; j-- )
			data[ j ] = data[ j - 1 ];

		data[ j ] = tmp;
	}
}

Measured memory_bytes: 988
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
    
int main(){
    ll n;
    cin >> n;
    vector<ll> xs(n), ys(n);
    rep(i,n){
        ll x, y;
        cin >> x >> y;
        xs[i] = x + y;
        ys[i] = x - y;
    }
    ll ans = 0;
    ll maxx, maxy;
    maxx = *max_element(xs.begin(),xs.end()) - *min_element(xs.begin(),xs.end());
    maxy = *max_element(ys.begin(),ys.end()) - *min_element(ys.begin(),ys.end());
    if(maxx>=maxy) ans = maxx;
    else ans = maxy;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6408
class Dice
  def initialize(line)
    @dice = line.split(" ").map(&:to_i)
  end
  def rot(command)
    if(command == "E") 
      @dice[0], @dice[3], @dice[5], @dice[2] = @dice[3], @dice[5], @dice[2], @dice[0]
    elsif(command == "N") 
      @dice[0], @dice[1], @dice[5], @dice[4] = @dice[1], @dice[5], @dice[4], @dice[0]
    elsif(command == "S") 
      @dice[0], @dice[1], @dice[5], @dice[4] = @dice[4], @dice[0], @dice[1], @dice[5]
    elsif(command == "W") 
      @dice[0], @dice[3], @dice[5], @dice[2] = @dice[2], @dice[0], @dice[3], @dice[5]
    end
  end

  def getRight(line)
    u, f = line.split(" ").map(&:to_i)
    4.times{
      rot("N")
      4.times{
        rot("E")
        if(@dice[0] == u && @dice[1] == f) 
         return @dice[2]
        end
      }
    }
    rot("E")
    4.times{
      rot("N")
      4.times{
        rot("E")
        if(@dice[0] == u && @dice[1] == f) 
          return @dice[2]
        end
      }
    }
  end
end
 
dice = Dice.new(gets.chomp)
n = gets.to_i

n.times {
  printf "%d\n", dice.getRight(gets.chomp)
}


Measured memory_bytes: 6896
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

// 根付き木の構成
 
void dfs (Graph &G, vector<int> &count, int x, int px) {
  
  for (int nx : G[x]) {
    if (nx != px) {
      count[nx] += count[x];
      dfs(G, count, nx, x);
    }
  }
  
}

int main () {
  
  int N, Q;
  cin >> N >> Q;
  
  Graph G(N);
  
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    G[a - 1].push_back(b - 1);
    G[b - 1].push_back(a - 1);
  }
  
  vector<int> count(N, 0);
  
  for (int i = 0; i < Q; i++) {
    int p, x;
    cin >> p >> x;
    count[p - 1] += x;
  }
  
  vector<int> ans(N, 0);
  dfs(G, count, 0, -1);
  
  for (int i = 0; i < N; i++) {
    cout << count[i] << " ";
  }
  
}

Measured memory_bytes: 30464
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

int main() {
    int r, D;
    vector<int> x(2100, 0);
    cin >> r >> D >> x.at(2000);

    for (int i = 2000; i <= 2010; i++) {
        x.at(i + 1) = r * x.at(i) - D;
    }

    for (int i = 2001; i <= 2010; i++) {
        cout << x.at(i) << endl;
    }

    return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    double divisor = 0;
    for(int i = 0; i < n; i++) {
        divisor += 1.0 / a[i];
    }

    double ans = 1.0 / divisor;

    cout << setprecision(10) << ans << endl;
    return 0;
}


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

public class Main {
	public static void main(String[] args) {
		InputReader in = new InputReader(System.in);
		int n = in.readInt();
		int t = in.readInt();
		int arr[] = new int[n]; 
		for(int i = 0; i<n; i++) {
			arr[i] = in.readInt();
		}
	    int sum = 0; 
	    for(int i =1; i<n; i++) {
	    	sum += Math.min( arr[i]-arr[i-1] , t);
	    }
	    System.out.println(sum + t); 
	}
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


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

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

  int ans = 0;

  for (int i = 1; i <= N; i += 2) {
    int cnt = 0;
    for (int j = 1; j <= N; j++) {
      if (i % j == 0) cnt++;
    }
    if (cnt == 8) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
object Main extends App {

  val Array(n, a, b) = io.StdIn.readLine.split(" ").map(_.toInt)

  val ans = (1 to n).foldLeft(0)( (acc,i) => {

    val sum = {
      var m = i
      var t = 0
      for(j <- 1 to 5 if m > 0 ) {
        t += m % 10
        m /= 10
      }
      t
    }

    if(a <= sum && sum <= b ) acc + i else acc
  })

  println(ans)
}

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

int main(void){
  string s;
  cin >> s;
  int ans = 0;
  for(int i = 0; i < s.size()/2; i++){
    if(s[i] != s[s.size()-i-1]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include"bits/stdc++.h"

using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	vector<int>cnt(M);
	int ans = 0;

	for (int i = 0; i < N; i++) {
		int K;
		cin >> K;
		for (int j = 0; j < K; j++) {
			int A;
			cin >> A;
			A--;
			cnt[A]++;
		}
	}

	for (int i = 0; i < M; i++) {
		if (cnt[i] == N) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
p=[1,-1]
j=[-1,1]
c=0
l=0
d=0
e=0
for i in range(n):
    s=i%2
    c+=a[i]
    l+=a[i]
    if p[s]*c<=0:
        d+=abs(c-p[s])
        c=p[s]
    if j[s]*l<=0:
        e+=abs(l-j[s])
        l=j[s] 
print(min(e,d))
#####################################################

Measured memory_bytes: 14468
#include <iostream>
#include <stack>
#include <string>
#include <cstring>
#include <cstdlib>
 
using namespace std;
stack<long> s;
int main(){
    string str;
    while (cin >> str){
        if (str[0] == '+' || str[0] == '-' || str[0] == '*'){
            char ch; ch = str[0];
            long b = s.top(); s.pop();
            long a = s.top(); s.pop();
            if (ch == '+') s.push(a + b);
            else if (ch == '-') s.push(a - b);
            else if (ch == '*') s.push(a*b);
        }
        else {
            long tmp = atoi(str.c_str());
            s.push(tmp);
        }
    }
    cout << s.top() << '\n';
}

Measured memory_bytes: 1200
#include <iostream>
#include <vector>
#include <string>

using namespace std;


int a,b,c,d;
int res;
string s;


int cal(int x, int y, bool type){
    if (type==true){
        return x+y;
    }
    else{
        return x-y;
    }
}

int main(){
    cin>>s;
    //size_t size=s.length();
    int N[4];
    for (int i=0; i<4; ++i){
        N[i]=(int)(s[i]-'0');
    }
    a=N[0];
    b=N[1];
    c=N[2];
    d=N[3];

    bool isTop1, isTop2, isTop3;
    char T1, T2, T3;
    for (int t1=0;t1<=1; ++t1){
        for (int t2=0;t2<=1;++t2){
            for(int t3=0;t3<=1; ++t3){
                isTop1 = (t1 == 0) ? true : false; 
                isTop2 = (t2 == 0) ? true : false; 
                isTop3 = (t3 == 0) ? true : false; 

                res=cal(cal(a,b,isTop1),c, isTop2);
                res=cal(res,d, isTop3);
                if (res==7){
                    T1= (t1 == 0) ? '+' : '-'; 
                    T2 = (t2 == 0) ? '+' : '-';
                    T3 = (t3 == 0) ? '+' : '-';
                    cout<<a<<T1<<b<<T2<<c<<T3<<d<<'='<<7<<endl;
                    break;
                }

            }
            if(res==7){
                break;
            }
        }
        if (res==7){
            break;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define popb pop_back
#define all(A) A.begin(),A.end()
#define dic unordered_map //Diccionario
#define bpc __builtin_popcountll //numero de bits para long long
#define bclz __builtin_clzll //leading zeros
 
using namespace std;
 
//Funtions here
int main () {
	int n,k;
	cin>>n>>k;
	vector<int> a(n);
	vector<int> dp(n,INT_MAX);
	for(int i=0;i<n;i++) cin>>a[i];
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int j=1;j<=k;j++){
			if(i+j<n) dp[i+j]=min(dp[i+j],dp[i]+abs(a[i+j]-a[i]));
		}
	}
	cout<<dp[n-1]<<"\n";
	//Your Code goes here
	return 0;
}

Measured memory_bytes: 3976
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

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;
}
int main() {
    int n, W;
    int v[110], w[110];
    ll dp[110][100010];
    cin >> n >> W;

    rep(i, 0, n) {
        cin >> w[i] >> v[i];
    }

    rep(i, 0, n) {
        rep(j, 0, W+1) {
            if (w[i] <= j) {
                dp[i+1][j] = dp[i][j-w[i]] + v[i];
            }
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
        }
    }
    cout << dp[n][W] << endl;
    return 0;
}

Measured memory_bytes: 80128
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 50000
#define M 100000
using namespace std;
int n,m,op,a[M+5],b[M+5];char ans[M+5];
class UniformingSolver
{
	private:
		int p[N+5];bitset<N+5> S[N+5];
	public:
		I void Solve()
		{
			RI i,j;for(i=1;i<=n;++i) S[i].set(i);
			for(i=1;i<=m;++i) S[a[i]]=S[b[i]]=S[a[i]]|S[b[i]];
			for(i=1;i<=n;++i) if(S[i].count()==n)
			{
				for(p[i]=1,j=m;j;--j) p[a[j]]?
					(p[b[j]]=1,ans[j]='^'):(p[a[j]]=p[b[j]],ans[j]='v');
				puts(ans+1);return;
			}puts("-1");
		}
}S1;
class NonUniformingSolver
{
	private:
		int t[N+5],k[N+5];
	public:
		I void Solve()
		{
			RI i;if(n<=2) return (void)(puts("-1"));for(i=1;i<=n;++i) k[t[i]=i]=1;
			#define U(x,y) (--k[t[x]],++k[t[x]=t[y]])
			for(i=m;i;--i) k[t[a[i]]]<=k[t[b[i]]]?
				(ans[i]='^',U(b[i],a[i])):(ans[i]='v',U(a[i],b[i]));
			puts(ans+1);
		}
}S2;
int main()
{
	RI i;for(scanf("%d%d%d",&n,&m,&op),i=1;i<=m;++i) scanf("%d%d",a+i,b+i);
	return op==1?S1.Solve():S2.Solve(),0;
}

Measured memory_bytes: 307072
n,m = map(int,input().split())
x = [[int(i) for i in input().split()] for i in range(n)]
total = 0
x = sorted(x)
for i in range(0,n):
    if x[i][1] < m:
        total += x[i][0] * x[i][1]
        m -= x[i][1]
    else:
        total += x[i][0] * m
        break
print(total)


Measured memory_bytes: 22376
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int A=in(),B=in(),C=in();

	out(C,A,B);
	return 0;
}


Measured memory_bytes: 256
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

template <std::int_fast64_t Modulus> class modint {
	using u64 = std::int_fast64_t;
public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept {
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) {
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept {
		if (a < rhs.a) {
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept {
		u64 exp = Modulus - 2;
		while (exp) {
			if (exp % 2) {
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};
#pragma endregion

char c;
int app_count[26]{ 0 };

int main() {
	cin >> H >> W;
	rep(i, H) {
		rep(j, W) {
			cin >> c;
			app_count[c - 'a']++;
		}
	}

	int g1 = 1, g2 = (H % 2 == 0 ? 0 : W / 2) + (W % 2 == 0 ? 0 : H / 2), g3 = H *W / 4;
	rep(i, g1) {
		rep(j, 26) {
			if (app_count[j] % 4 == 1 || app_count[j] % 4 == 3) {
				app_count[j] -= 1;
				break;
			}
		}
	}
	rep(i, g2) {
		rep(j, 26) {
			if (app_count[j] % 4 == 2) {
				app_count[j] -= 2;
				break;
			}
		}
	}
	rep(i, g3) {
		rep(j, 26) {
			if (app_count[j] != 0 && app_count[j] % 4 == 0) {
				app_count[j] -= 4;
				break;
			}
		}
	}
	rep(i, 26) {
		if (app_count[i] != 0) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1e+9 + 7;
// constexpr int mod = 998244353;

constexpr int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int k;
    cin >> k;
    cout << a[k - 1] << endl;
}

Measured memory_bytes: 256
/**
    __author__ : p4mf
    problems_ID:
*/

#include <cstdio>
#include <map>
#include <vector>
#include <cmath>

using namespace std;
#define sz(x)          (int)((x).size(x))
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define REP(i, y)  for (__typeof(x) i = 0; i < y; i++)
#define REPI(i, y)  for (__typeof(x) i = y; i > 0; i--)
typedef long long      ll;
typedef pair<int, int> P;
typedef pair<P, int>   PP;
typedef vector<int>    VV;
typedef vector<P>      VVP;
typedef vector<PP>     VVPP;
const   int            INF = 2<<20;
const   double         EPS = 1E-8;

int main() {
    const long long K = (int)pow(10., 9.)+7;
    sci(N);
    long long power=1;
    for (int i=1; i<=N; i++) {
        power = power * i;
        if (power > K)
            power = power % K;
    }
    printf("%llu", power);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++) 
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    int Q; cin >> Q;
    rep(i,Q){
        int v,w;
        cin >> v >> w;
      	if(N==1)cout << min(v,w) << endl; 
        else{
          	while(v!=w){
            	w=(w+N-2)/N;
            	if(v>w){
                	int num=v;
                	v=w;
                	w=num;
            	}
        	}
        	cout << v << endl;
        }
    }


}

/*



 */



Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main() {
	queue<int> s[5];
	char winner;
	for(int i=0;i<3;i++) {
		string st;
		cin>>st;
		for(int j=0;j<(int)st.size();j++) s[i].push(st[j]-'a');
	}
	int now=0;
	while(1) {
		if(s[now].empty()) {winner=now+65;break;}
		int t=s[now].front();
		s[now].pop();
		now=t;
	}
	cout<<winner<<endl;
	return 0;
}

Measured memory_bytes: 3616
a, b, k = map(int, input().split())

if 2 * k > (b - a + 1):
    for i in range(a, b + 1):
        print(i)
    exit()

for i in range(a, a + k):
    print(i)
    
for i in range(b - k + 1, b + 1):
    print(i)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define repm(i, a, n) for (ll i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vs vector<string>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define vd vector<double>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define reverse_v(a) reverse(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    (c) ? (cout << "Yes" << endl) : (cout << "No" << endl);
}

void Print(bool c)
{
    (c) ? (cout << "YES" << endl) : (cout << "NO" << endl);
}

//最小公倍数
template <typename T>
T gcd(T a, T b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

//最大公約数
template <typename T>
T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}
//セカンドキー->ファーストキーの順ソート
bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

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

int eve(int x)
{
    if (x % 400 == 0)
        return 1;
    if (x % 100 == 0)
        return 0;
    if (x % 4 == 0)
        return 1;
    return 0;
}

int main(void)
{
    ll n;
    cin >> n;
    vll a(n), sum(n + 1);
    map<ll, ll> mp;
    mp[0]++;
    rep(i, 0, n)
    {
        cin >> a[i];
        sum[i + 1] = sum[i] + a[i];
        mp[sum[i + 1]]++;
    }
    ll ans = 0;
    for (auto x : mp)
        ans += x.second * (x.second - 1) / 2;
    cout << ans << endl;
}

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

using namespace std;

using ll = long long int;
using vi = vector<int>;
#define f(n) for(int i = 0; i < n; i++)
#define fj(n) for(int j = 0; j < n; j++)
#define fk(n) for(int k = 0; k < n; k++)
#define ci(n) cin >> n;
#define ic(n) int n; cin >> n;
#define lc(n) int n; cin >> n;
#define all(a) a.begin(), a.end()
#define pri(a, n) for(int i = 0; i < n; i++) cout << a[i] << " "; cout << "\n";
#define sc(a, n) int a[n] = {0}; for(int i = 0; i < n; i++) cin >> a[i];
#define scl(a, n) ll a[n] = {0}; for(int i = 0; i < n; i++) cin >> a[i];
#define pb push_back
#define eb emplace_back
#define int long long
const int inf = 2e18, maxn = 200000;

int g2(int n, int a, int b, int c, int d)
{
    if(n == 0) return 0;
    if(n == 1) return d;
    if(((n + 1) / 2) < (a + d - 1) / d && ((n + 2) / 3) * 2 >= (b + d - 1) / d && ((n + 4) / 5) * 4 < (c + d - 1) / d) return n * d;
    int res = 0;
    while(n % 2 == 0 && (n / 2) >= (a + d - 1) / d) n /= 2, res += a;
    while(n % 3 == 0 && (n / 3) * 2 >= (b + d - 1) / d) n /= 3, res += b;
    while(n % 5 == 0 && (n / 5) * 4 >= (c + d - 1) / d) n /= 5, res += c;
    return min(g2(n - 1, a, b, c, d), g2(n + 1, a, b, c, d));
}
int get(int n, int p, int c1, int c2)
{
    if(n == 0) return 0;
    int res = inf;
    if (n <= inf / c1) res = n * c1;
    if(n % p == 0) res = min(res, get(n / p, p, c1, c2) + c2);
    else res = min(res, get(n - 1, p, c1, c2) + c1);
    return res;
}

void solve(int ci)
{
   int h1, m1, h2, m2, k;
   cin >> h1 >> m1 >> h2 >> m2 >> k;
   cout << h2 * 60 - h1 * 60 + m2 - m1 - k << '\n';
}


main()
{
    //cout << atan2(0, -1);
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t = 1;
    //cin >> t;
    f(t) solve(i + 1);
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
const long long INF = (1e18)+1;

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

    vector<long long> a(n);
    for(int i=0; i<n; ++i){
        cin >> a[i];
    }

    sort(a.begin(), a.end());
    //答えを求めるための2分探索
    long long l = -INF, r = INF;

    while(l + 1 < r){
        long long x = (l+r)/2;
        bool ok = [&]{
            //tot(total):x未満の数が何個あるのか
            long long tot = 0;

            for(int i=0; i<n; ++i){
                //負の値の場合は右側からかけていく
                if(a[i] < 0){
                    //r がok , lがng
                    int l = -1, r = n;
                    while(l+1 <r){
                        int c = (l+r)/2;
                        if(a[c] * a[i] < x){
                            r = c;
                        }else{
                            l =c;
                        }
                    }
                    tot += n-r;
                }else{
                    //正の場合は左からかけていく
                    // rがngでlがok
                    int l = -1, r = n;
                    while(l+1 < r){
                        int c = (l+r)/2;
                        if(a[c] * a[i] < x){
                            l = c;
                        }else{
                            r = c;
                        }
                    }
                    tot += r;
                }
                //同じ数は選べないのでその場合を削除
                if(a[i] * a[i] < x) tot--;
            }

            //全体で２回同じものを選んでいるので、半分にする
            tot /= 2;
            return tot < k;
        }();
        if(ok){
            l = x;
        }else{
            r = x;
        }
    }
    cout << l << endl;
    return 0;
}


Measured memory_bytes: 4804
#include<cstdio>
#include<set>
#include<stack>
#include<queue>
int main()
{
int al=1000000007;
long long int n,x,y,z,ans;
x=y=z=1;
scanf("%lld",&n);
for(int i=0;i<n;i++)
{
x=x*10;
y=y*9;
z=z*8;
x=(x+al)%al;
y=(y+al)%al;
z=(z+al)%al;
}
ans=x-y-y+z;
ans=(ans+al+al)%al;
printf("%lld",ans);
}

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

int main() {
  string s;
  cin >> s;
  int ans=0;
  for(int i=0; i<s.length()-1; i++) {
    if(s[i]!=s[i+1]) {
      ans++;
    }
  }
    cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allg(v) v.begin(), v.end(), greater<int>()



signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  int x;
  cin >> x;
  
  //vector<int> a(n);  rep(i, 0, n) cin >> a[i];
  
  cout << (x/500)*1000 +((x%500)/5)*5 << "\n";
  
  //cout << (  ?"Yes" :"No") << "\n";
  
  //cout << fixed << setprecision(15) << n << "\n";

}

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

int main(void){
    char c;
    cin >>c;
    if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o'){
        cout << "vowel";
        return 0;
    }
    else{
        cout << "consonant";
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N,i,x=0,t=0;
    cin>>N;
    char c[N+1];
    cin>>c;
    for(i=0;i<N;i++)
    { 
        if(c[i]=='I')
            ++x;
        else
            --x;
        if(x>t)
            t=x;
    }
    cout<<t;
return 0;
}

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

using namespace std;

typedef long long LL;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MAX_COMB = 1e5 + 3;
const LL mod = 998244353;
LL fct[MAX_COMB+1];
LL invfct[MAX_COMB+1];

void build(){
	fct[0] = fct[1] = 1;
	repp(i,2,MAX_COMB+1){
		fct[i] = fct[i-1] * i % mod;
	}
	LL x = fct[MAX_COMB];
	invfct[MAX_COMB] = 1;
	for(int i = mod - 2 ; i > 0 ; i >>= 1){
		if(i % 2 == 1) (invfct[MAX_COMB] *= x) %= mod;
		(x *= x) %= mod;
	}
	repm(i,MAX_COMB,0){
		invfct[i-1] = invfct[i] * i % mod;
	}
}

LL comb(int x, int y){
	if(x < 0 || y < 0 || x < y) return 0;
	return fct[x] * invfct[y] % mod * invfct[x-y] % mod;
}

LL rep_comb(int x, int y){
	return y==0?1:comb(x+y-1,y);
}

int main(){
	build();
	string S; cin >> S;
	int N = S.size();
	vector<LL> dp(2*N+1,0);
	dp[0] = 1;
	repp(i,0,N){
		vector<LL> nx(N*2+1,0);
		int a = S[i]-'0';
		repp(k,a,2*N+1) nx[k] = dp[k-a];
		fill(dp.begin(),dp.end(),0);
		repp(k,0,i+2) dp[k] = (nx[k]+nx[k+1])%mod;
	}
	LL ans = 0;
	repp(i,0,N+1) (ans += dp[i]*comb(N,i)) %= mod;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.rbegin(), t.rend());
  if(s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
I=lambda:map(int,input().split());F=1e21;r=range;n,m=I();f=[-F,F];X=[0]+f;Y=X[:];R=(f,F),(f,-F),;H=(F,f),(-F,f),
for i in r(n):*a,c=I();R+=(a,c),;Y+=c,;X+=a
for i in r(m):a,*b=I();H+=(a,b),;X+=a,;Y+=b
def g(X):s=dict(enumerate(sorted(set(X))));return{s[i]:i for i in s},s,len(s)
h,s,K=g(X);w,t,L=g(Y);j=lambda:[[0]*-~K for i in r(L+1)];V=j();U=j();v=j()
for(a,b),c in R:U[w[c]][h[a]]+=1;U[w[c]][h[b]]-=1
for d,(e,f)in H:V[w[e]][h[d]]+=1;V[w[f]][h[d]]-=1
for i in r(L):
 for j in r(K):U[i][j+1]+=U[i][j];V[i+1][j]+=V[i][j]
q=[(h[0],w[0])];v[w[0]][h[0]]=1;a=0
while q:
 x,y=q.pop();a+=(s[x]-s[x+1])*(t[y]-t[y+1])
 for e,f in(-1,0),(1,0),(0,1),(0,-1),:
  c=x+e;d=y+f
  if 1-v[d][c]and(U[(f>0)+y][x]|e==0)|(V[y][(e>0)+x]|f==0):q+=[(c,d)];v[d][c]=1
print([a,'INF'][a>F])

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

int main() {
 
  int a, b, c;
  cin >> a >> b >> c;
  
  if (a + b == c) {
    cout << "Yes" << endl;
  } else if (a + c == b) {
    cout << "Yes" << endl;
  } else if (b + c == a) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#define INF 2e9
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

int main()
{
	long long int h, w;
	long long int ans;
	cin >> h >> w;
	if (h % 2 == 1 && w % 2 == 1)ans = (h * w)/2 + 1;
	else ans = (h * w)/2;
	if (h == 1 || w == 1)ans = 1;
	cout << ans << endl;
}


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

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

    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];

    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());

    cout << a.size() << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdlib>

using namespace std;

int main() {
  while( 1 ) {
    int ss[ 5 ];
    int a, b;
    int maxidx = 0;
    cin >> a >> b;
    if( !a && !b ) {
      return EXIT_SUCCESS;
    }
    ss[ 0 ] = a + b;
    for( int i = 1; i < 5; i++ ) {
      cin >> a >> b;
      ss[ i ] = a + b;
      if( ss[ i ] > ss[ maxidx ] ) {
        maxidx = i;
      }
    }
    cout << ( char )( 'A' + maxidx ) << " " << ss[ maxidx ] << endl;
  }
};

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

int is_double(char str[100][11], int N, int x)
{
	int i = 0;
	while (i < N)
	{
		if (i != x && strcmp(str[i], str[x]) == 0)
			return 1;
		i++;
	}
	return 0;
}

int main()
{
	int N;
	scanf("%d", &N);
	char s[N][11];
	int len[N];
	int i = 0;
	while (i < N)
	{
		scanf("%s", s[i]);
		len[i] = strlen(s[i]);
		i++;
	}
	i = 0;
	int j;
	while (i < N)
	{
		j = 0;
		while (j < N)
		{
			if (i != j && strcmp(s[i], s[j]) == 0)
			{
				printf("No\n");
				return 0;
			}
			j++;
		}
		if (i != N-1 && s[i][len[i] - 1] != s[i+1][0])
		{
			printf("No\n");
			return 0;
		}
		// printf("%d\n", len[i]);
		i++;
	}
	printf("Yes\n");
	return (0);
}


Measured memory_bytes: 128
#include <iostream>
#include <deque>

#define rep(i,s,t) for(int i=s;i<t;i++)
using namespace std;

int main(void){
	int t;
	cin >> t;
	rep(i,0,t){
		int n;
		cin >> n;

		int maxUp=0;
		int minDn=0;
		int pre;
		cin >> pre;
		rep(j,0,n-1){
			int in;
			cin >> in;
			int diff=in-pre;
			if(diff>0)	maxUp=diff>maxUp?diff:maxUp;
			else		minDn=(-diff)>minDn?(-diff):minDn;
			pre=in;
		}
		cout << maxUp << " " << minDn << endl;
	}
	return 0;
}

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

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

	int a[4], b[4];
	
	while(cin >> a[0]){
		for(int i = 1; i < 4; ++i){
			cin >> a[i];
		}

		for(int i = 0; i < 4; ++i){
			cin >> b[i];
		}

		int hit = 0;
		for(int i = 0; i < 4; ++i){
			if(a[i] == b[i]){
				hit++;
			}
		}

		int blow = 0;
		for(int i = 0; i < 4; ++i){
			for(int j = 0; j < 4; ++j){
				if(i != j && a[i] == b[j]){
					blow++;
				}
			}
		}

		cout << hit << " " << blow << endl;
	}

	return 0;
}

Measured memory_bytes: 1192
n,k=map(int,input().split())

l=[]
for i in range(n):
    p=[int(i) for i in input().split()]
    l.append(p)

from operator import itemgetter
l.sort(key=itemgetter(0)) 

s=0
ans=0
for i in range(n):
    s+=l[i][1]
    if s>=k:
        ans=l[i][0]
        break
print(ans)




Measured memory_bytes: 23000
import math

n, k = map(int, input().split())
a = list(map(int, input().split()))
b = [0] * (n + 1)
for i in range(n):
    b[i + 1] = b[i] + a[i]
m = int(math.log2(b[n]))
x = pow(2, m)
s = [[] for _ in range(m + 2)]
for i in range(n):
    for j in range(i + 1, n + 1):
        s[0].append(b[j] - b[i])
c = 0
ans = 0
for i in range(1, m + 2):
    for j in range(len(s[c])):
        if s[c][j] >= x:
            s[i].append(s[c][j] - x)
            s[c][j] -= x
    if len(s[i]) >= k:
        c = i
        ans += x
    x //= 2
print(ans)

Measured memory_bytes: 134208
import java.util.Scanner;

class Main{

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if(a<b){
			System.out.println("a < b");
		}else if(a>b){
			System.out.println("a > b");
		}else{
			System.out.println("a == b");
		}
	}
}


Measured memory_bytes: 26324
package main
import (
	"fmt"
)

func main() {
  solve()
}

func solve() {
  var s string
  var re string
  fmt.Scan(&s)
  for _, v := range s {
    switch string(v) {
      case "0":
    	 re += "0"
      case "1":
    	 re += "1"
      case "B":
         if len(re) == 0 {
           continue
         }
         re = re[:len(re)-1]
    }
  }
  fmt.Println(re)
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
const int M = 1000000007;

int n, m;
vector<vector<int>> edge;
vector<long long> ans, parc, rem, memo;

long long dfs(int p, int par) {
    int c = edge[p].size();
    vector<long long> a(c), mull(c + 1), mulr(c + 1);
    for (int i = 0; i < c; ++i) {
        if (edge[p][i] == par) continue;
        a[i] = dfs(edge[p][i], p);
        memo[edge[p][i]] = a[i];
    }
    mull[0] = 1;
    mulr[c] = 1;
    for (int i = 0; i < c; ++i) {
        mull[i + 1] = mull[i] * (a[i] + 1) % m;
        mulr[c - i - 1] = mulr[c - i] * (a[c - i - 1] + 1) % m;
    }
    for (int i = 0; i < c; ++i) {
        if (edge[p][i] == par) continue;
        rem[edge[p][i]] = mull[i] * mulr[i + 1] % m;
    }
    return mull[c];
}
void dfs2(int p, int par) {
    for (int i : edge[p]) {
        if (i == par) continue;
        parc[i] = (parc[p] + 1) * rem[i] % m;
        ans[i] = memo[i] * (1 + parc[i]) % m;
        dfs2(i, p);
    }
}

int main() {
    cin >> n >> m;
    edge = vector<vector<int>>(n);
    ans = vector<long long>(n);
    parc = vector<long long>(n);
    rem = vector<long long>(n);
    memo = vector<long long>(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    ans[0] = dfs(0, -1);
    dfs2(0, -1);
    for (int i = 0; i < n; i++)
        cout << ans[i] << "\n";

    return 0;
}


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

int main() {
    int A,B;
    cin >> A >> B;
    int s = 0;
    if (A < 10 && B < 10) {
        s = A * B;
    }
    else {
        s = -1;
    }

    cout << s << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
const int inf = INT_MAX;
const double eps = 0.0000001;
const double PI = acos(-1.0);
const int MOD = 1e9+7;
const int N  = 1e5+5;

int a[N], dp[N];

int solve (int i) {
	int ans = inf;
	for (auto j: {i+1, i+2}) {
		if (dp[j]) ans = min(ans, dp[j] + abs(a[j] - a[i]));
		else ans = min(ans, solve(j) + abs(a[j] - a[i]));
	}
	dp[i] = ans;
}

signed main(){
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif  
    IOS;

    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    	cin >> a[i];
    dp[n-1] = abs(a[n] - a[n-1]);
    for (int i = n-2; i >= 1; i--) {
    	dp[i] = min(dp[i+1] + abs(a[i+1] - a[i]), dp[i+2] + abs(a[i+2]-a[i]));
    }
    cout << dp[1];
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

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

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	string s;
	cin >> s;
	int n = s.length();

	string t;
	for(int i = 0; i < n; i++){
		if(s[i] != 'x') t += s[i];
	}
	int m = t.size();

	if(m == 0){
		cout << 0 << endl;
		return 0;
	}

	for(int i = 0; i < m/2; i++){
		if(t[i] != t[m-1-i]){
			cout << -1 << endl;
			return 0;
		}
	}

	int left = 0, right = n-1,ans = 0;
	while(1){
		if(left > right) break;
		if(s[left] != s[right]){
			ans++;
			if(s[left] == 'x') left++;
			else right--;
		}else{
			left++;
			right--;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
n, k = map(int, input().split())

if k % 2 == 1:
	print((n // k) ** 3)
else:
	if n % k < k // 2:
		print((n // k) ** 3 * 2)
	else:
		print((n // k) ** 3 + (n // k + 1) ** 3)


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

int main(){

    string s;
    cin >> s;

    ll t=0;
    ll ans=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='W'){
            ans+=i-t;
            t++;
        }else{
            continue;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
N = int(input())

x = list(map(int,input().split()))

mod = 10 ** 9 + 7


ans = 0
t = [1]
u = [1]

for i in range(N):

    i += 1
    t.append(t[-1] * i % mod)

for i in range(N-1):
    u.append(u[-1] * (N-1-i) % mod)
    
#print (t)
#print (u)
u.reverse()


now = 0
for i in range(N-1):

    now += u[i+1] * t[i]
    now %= mod
    ans += now * (x[i+1] - x[i])
    ans %= mod
    #print (i,ans/6)

print (ans)




Measured memory_bytes: 65688
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<vector>
using namespace std;
#define rep(i, n) for ( int i = 0; i < n; i++)
static const int MAX = 500;
static const int L = 30;

bool overlap(int a, int b){
  if ( a > b ) swap(a, b);
  return a + 30 > b;
}

int getProgram(vector<int> v){
  sort(v.begin(), v.end());
  int dp[MAX];
  int maxv = v.size()>0?1:0;
  for ( int i = 0; i < v.size(); i++ ) dp[i] = 1;
  for ( int i = 1; i < v.size(); i++ ){
    for ( int j = i-1; j >= 0; j-- ){
      if ( !overlap(v[j], v[i]) ){
	dp[i] = dp[j]+1;
	maxv = max(maxv, dp[i]);
	break;
      }
    }
  }
  return maxv;
}

int solve(int N){
  int in[MAX], w, s, P;
  map<string, int> M;
  string name;
  vector<int> F, T;
  rep(i, N){
    cin >> name >> w >> s;
    M[name] = i;
    in[i] = w*1440 + (s/100)*60 + s%100;
  }
  cin >> P;
  rep(i, P){
    cin >> name;
    F.push_back(in[M[name]]);
  }

  int ans = getProgram(F);
  if ( ans != P ) return -1;

  rep(i, N){
    bool f = true;
    for ( int j = 0; j < F.size(); j++ ){
      if ( overlap(F[j], in[i]) ) { f = false; break; }
    }
    if ( f ) T.push_back(in[i]);
  }
  return ans + getProgram(T);
}

main(){
  int N;
  while(1){
    cin >> N;
    if ( N == 0 ) break;
    cout << solve(N) << endl;
  }
}

Measured memory_bytes: 1312
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		String yomi ="";
		Scanner scan = new Scanner(System.in);

		int num  = scan.nextInt();
		int amari = num%10;

		if(amari ==3) {
			yomi ="bon";
		}else if(amari == 0 || amari == 1 ||amari == 6 ||amari == 8 ) {
			yomi = "pon";
		}else {
			yomi = "hon";
		}

		System.out.println( yomi);
	}
}

Measured memory_bytes: 35700