akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        // System.out.println(n);
        int k = 100000;
        for (int i = 0; i < n; i++) {
            k = 1000 * (int)Math.ceil(((double) k) * 1.05 / 1000);
        }
        System.out.println(k);
    }
}

Measured memory_bytes: 26120
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#include <functional>
#include <string.h>

using namespace std;
typedef pair<long long, long long> P;


void solve()
{
	int N;
	cin >> N;
	vector<int> H(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> H[i];
	}
	int ans = 1;
	for (int i = 1; i < N; ++i)
	{
		bool flag = true;
		for (int j = 0; j < i; ++j)
		{
			if (H[j] > H[i])
			{
				flag = false;
			}
		}
		if (flag)
		{
			++ans;
		}
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 256
#include <stdio.h>

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

  for ( i = 0; i < 3; ++i )
  {
    int h1, m1, s1
      , h2, m2, s2;
    int rsec;

    scanf ( "%d%d%d%d%d%d"
          , &h1, &m1, &s1, &h2, &m2, &s2 );

    rsec = h2 * 60 * 60 + m2 * 60 + s2
         - h1 * 60 * 60 - m1 * 60 - s1;

    printf ( "%d %d %d\n", rsec / 60 / 60, ( rsec / 60 ) % 60, rsec % 60 );
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P pair<int,int>
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 (b<a) { a = b; return 1; } return 0; }

signed main(){
  int n;
  cin >> n;
  vint T(n);
  vint A(n);
  rep(i,0,n) cin >> T[i];
  rep(i,0,n) cin >> A[i];
  vbool Tjudge(n);
  vbool Ajudge(n);
  rep(i,1,n){
    if(T[i] == T[i-1]) Tjudge[i] = true;
  }
  rrep(i,n-2,0){
    if(A[i] == A[i+1]) Ajudge[i] = true;
  }
  int ans = 1;
  rep(i,0,n){
    if(Tjudge[i] && Ajudge[i]){
      ans *= min(T[i],A[i]);
      ans %= MOD;
    }
    if(!(Tjudge[i]) && Ajudge[i]){
      if(T[i] > A[i]){
        cout << 0 << endl;
        return 0;
      }
    }
    if(Tjudge[i] && !(Ajudge[i])){
      if(A[i] > T[i]){
        cout << 0 << endl;
        return 0;
      }
    }
    if(!(Tjudge[i]) && !(Ajudge[i])){
      if(T[i] != A[i]){
        cout << 0 << endl;
        return 0;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-12;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;


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

	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (i & 1) {
			if (s[i] != 'i') {
				cout << "No\n";
				return 0;
			}
		}
		else {
			if (s[i] != 'h') {
				cout << "No\n";
				return 0;
			}
		}
	}
	if (s.size() % 2 == 1) {
		cout << "No\n";
		return 0;
	}
	cout << "Yes\n";
}

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

#define PI 3.14159265358979323846264338327950

using namespace std;

int main()
{
	long double a,b,h,m;
	cin >> a >> b >> h >> m;
	long double rad=PI*2*(h/12.0+(m/60.0)/12.0-m/60);
	long double sidesqr=(a*a+b*b)-(2*a*b*cos(rad));
	long double side=sqrt(sidesqr);
	printf("%20.20Lf\n",side);
	return 0;
}

Measured memory_bytes: 4164
#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;

int main() {
    int A, B, C;
    cin >> A >> B >> C;

    bool isYes = false;
    rep(i, 1000) { // O(10^8)
        rep(j, 1000) {
            if ((A * i) - (B * j) == C)
                isYes = true;
        }
    }

    string ans = isYes ? "YES" : "NO";
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
//if(strcmp(s[i],"AC")==0)
//if(s[l]=='#')
/*小文字判定
if((moji>= 'a') && (moji<='z')){
    printf("a\n");
    return 0;
  }
  */

int W_Length(char *str){
	int length = 0;
	while(*str++ != '\0')
		length++;
	return length;
}

void swap(long long int *a, long long int *b){
  int temp;
  temp=*a;
  *a=*b;
  *b=temp;
}
//swap(&a, &b)

double deg(double theta){//deg to theta
return theta*(2*3.14159265359)/360;
}

long long int cmp( const void *p, const void *q ) {
    return *(long long int*)p - *(long long int*)q;
}//ちいさい順
//qsort(a,n,sizeof(long long int),cmp);


int cmp_s(const void * left, const void * right)
{
	char *left_char = (char *)left;
  char *right_char = (char *)right;
  return strcmp(left_char, right_char);
}
//qsort(s,n,sizeof(s[0]),cmp_s);
//char s[n][11]

long long int GCD(long long int a, long long int b){
  long long int L=a,S=b;
  while(1){
    if(S>L){
      L=S+L;
      S=L-S;
      L=L-S;
    }
    if(L%S==0){
      return S;
    }
    L=L%S;
  }
  
}

long long int LCM(long long int a, long long int b){
  return a*b/(GCD(a,b));
}

int main (void)
{
	long long int p[5005],b,c,n,i,m,k,h[210000],max,j=1,flag[210000]={0},count=0;
scanf("%lld%lld",&n,&m);
for(i=1;i<=n;i++){
  scanf("%lld",&h[i]);
}  
  for(i=1;i<=m;i++){
    scanf("%lld %lld",&b,&c);
    if(h[b]>=h[c]){
      flag[c]=1;
    }
    if(h[c]>=h[b]){
      flag[b]=1;
    }
  }
  for(i=1;i<=n;i++){
    if(flag[i]==0){
      count++;
    }
  }
  
  printf("%lld",count);
return 0;
}


Measured memory_bytes: 4160
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <map>
#define int long long

using namespace std;

typedef long double ld;
typedef pair<int, int> pa;
typedef long long ll;

const int mod = 1e9 + 7, N = 1e5;
const ld pi = 3.1415926535;

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

    cout.precision(6);
    cout << fixed;

    int n, k;
    cin >> n >> k;
    int ans = 0;
    for (int cnt = k; cnt <= n + 1; ++cnt) {
        int mn = (cnt) * (cnt - 1) / 2;
        int mx = cnt * (cnt + 1) / 2 + (n - cnt) * cnt;
        ans += (mx - mn + 1);
        ans %= mod;
    }
    cout << ans;
}

Measured memory_bytes: 3652
fun main(args:Array<String>):Unit {
    while (true) {
        val (n, h) = readLine()!!.trim().split(' ').map(String::toInt)
        if (n == 0 && h == 0) return
        val lines = Array(h){
            val (type, a, b) = readLine()!!.trim().split(' ')
            when(type){
                "xy" -> Line.Xy(a.toInt(), b.toInt())
                "xz" -> Line.Xz(a.toInt(), b.toInt())
                else -> Line.Yz(a.toInt(), b.toInt())
            }
        }
        val xy = lines.mapNotNull{it as? Line.Xy}
        val xz = lines.mapNotNull{it as? Line.Xz}
        val yz = lines.mapNotNull{it as? Line.Yz}
        val x = xy.sumBy{ay -> xz.count{az -> isCrossing(ay, az)}}
        val z = xz.sumBy{ax -> yz.count{ay -> isCrossing(ax, ay)}}
        val y = xy.sumBy{ax -> yz.count{az -> isCrossing(ax, az)}}
        val xyz = xy.sumBy{lxy ->
            xz.count{lxz ->
                yz.any{lyz -> isCrossing(lxy, lxz, lyz)}
            }
        }
        println(n * n * n - n * h + x + y + z - xyz)
    }
}
fun isCrossing(a:Line, b:Line):Boolean {
    return when(a){
        is Line.Xy -> when(b){
            is Line.Xy -> false
            is Line.Xz -> a.x == b.x
            is Line.Yz -> a.y == b.y
        }
        is Line.Xz -> when(b){
            is Line.Xy -> a.x == b.x
            is Line.Xz -> false
            is Line.Yz -> a.z == b.z
        }
        is Line.Yz -> when(b){
            is Line.Xy -> a.y == b.y
            is Line.Xz -> a.z == b.z
            is Line.Yz -> false
        }
    }
}
fun isCrossing(xy:Line.Xy, xz:Line.Xz, yz:Line.Yz):Boolean {
    return xy.x == xz.x && xy.y == yz.y && xz.z == yz.z
}
sealed class Line{
    data class Xy(val x:Int, val y:Int):Line()
    data class Xz(val x:Int, val z:Int):Line()
    data class Yz(val y:Int, val z:Int):Line()
}


Measured memory_bytes: 39996
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] result = new int[n];
		for(int i = 0; i < n; i++){
		    a[i] = sc.nextInt();
		}
		for(int i = 0; i < n; i++){
		    b[i] = sc.nextInt();
		    result[n-i-1] = b[i]; 
		}

		// 計算
		//int result = 0;
		int l  = 0;
		int r = n-1;
		for(int i = 0; i < n; i++){
		    if(a[i] == result[i]){
		        if(a[l] != result[l] && a[l] != result[i] && a[i] != result[l]){
		            int tmp = result[l];
		            result[l] = result[i];
		            result[i] = tmp;
		            l++;
		        }else if(a[r] != result[r] && a[r] != result[r] && a[i] != result[r]){
		            int tmp = result[r];
		            result[r] = result[i];
		            result[i] = tmp;
		            r--;
		        }else{
		            System.out.println("No");
		            return;
		        }
		    }
		    //for(int j = 0; j < n; j++){System.out.print(result[j] + " ");}System.out.println();
		}
		
		// 出力
		//System.out.println(result);
		System.out.println("Yes");
		for(int i = 0; i < n; i++){
		    System.out.print(result[i] + " ");
		}
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}

}


Measured memory_bytes: 63140
def BubbleSort(seq):
    count = 0

    for i in range(len(seq)):
        for j in reversed(range(i + 1, len(seq))):
            if seq[j] < seq[j - 1]:
                seq[j], seq[j - 1] = seq[j - 1], seq[j]
                count += 1

    print(*seq)
    print(count)

def main():
    n = input()
    seq = [int(a) for a in input().split()]
    BubbleSort(seq)

main()


Measured memory_bytes: 5612
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>

using namespace std;

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

#define reps(i,f,n) for(int i = int(f); i <= int(n); i++)
#define rep(i,n) reps(i,0,int(n)-1)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)

#define all(x) (x).begin(),(x).end()
#define X first
#define Y second

#define sz size()
#define eb emplace_back

int d[128];

int main(void){
  int n,q,m,t;
  while( cin >> n >> q,n+q){
    fill(d,d+128,0);
    rep(i,n){
      cin >> m;
      rep(j,m){
        cin >> t;
        d[t]++;
      }
    }
    m = *max_element(d,d+128);
    rep(i,128){
      if(d[i] >= m && d[i] >= q){
        cout << i << endl;
        goto A;
      }
    }
    cout << 0 << endl;
    A:;
  }
  return 0;
}

Measured memory_bytes: 3044
include Math

#素数の配列を返すメソッド
def fetch_prime_list(max)
  list = (2..max).to_a
  prime_list = Array.new(max,0)
  sqrt = Math.sqrt(max).floor

  while val = list.shift
    prime_list[val-1] = 1
    if val > sqrt
      break
    end
    list.delete_if{|num| num % val == 0}
  end
    list.each{|num| prime_list[num-1] = 1}
  return prime_list
end

Q = gets.chomp.to_i
query = []
Q.times do
  query.push gets.chomp.split.map(&:to_i)
end

prime_list = fetch_prime_list(100000)
cumsum_list = Array.new(100000,0)
3.step(100000,2) do |n|
  cumsum_list[n-1] = cumsum_list[n-3] + prime_list[n-1]*prime_list[n/2]
end

while q = query.shift
  p cumsum_list[q[1]-1]-(q[0]>3 ? cumsum_list[q[0]-3] : 0)
end

Measured memory_bytes: 16580
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
const int maxn = 100010;
const int INF = INT_MAX/2;


int n;
int AC,WA,TLE,RE;
int32_t main(){
	cin >> n;
	for (int i =0;i<n;i++) {
		string s; cin >> s;
		if (s == "AC") AC++;
		else if (s == "TLE") TLE++;
		else if (s == "WA") WA++;
		else RE++;
	}
	
	cout << "AC x " << AC << "\n";
	cout << "WA x " << WA << "\n";
	cout << "TLE x " << TLE << "\n";
	cout << "RE x " << RE << "\n";
	
	
}









Measured memory_bytes: 3624
/**
 *    author: apurba_debnath
**/
#include <bits/stdc++.h>


#define ll long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;


using namespace std;

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

    int n, flag = 0;
    cin >> n;
    while (n > 0) {
        if (n % 10 == 7) {
            flag = 1;
            break;
        }
        n /= 10;
    }
    if (flag) cout << "Yes";
    else cout << "No";

    return 0;
}


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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;

  int count = 0;
  for (int a = 0; a <= A; a++) {
    for (int b = 0; b <= B; b++) {
      for (int c = 0; c <= C; c++) {
        if (500 * a + 100 * b + 50 * c == X) count++;
      }
    }
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Iterator;
import java.util.Collections;
import java.util.Comparator;

class Main{
        public static void main(String args[]){
                Scanner sc = new Scanner(System.in);
                int[][] grid = new int[3][3];
                int i,j;
                for(i=0;i<3;i++){
                        for(j=0;j<3;j++){
                                grid[i][j] = sc.nextInt();
                        }
                }
                boolean check = true;
                boolean[] a,b;
                a = new boolean[3];
                b = new boolean[3];
                a[0] = (grid[0][0] - grid[1][0]) == (grid[0][1] - grid[1][1])
                        && (grid[0][1] - grid[1][1]) == (grid[0][2] - grid[1][2])
                        && (grid[0][0] - grid[1][0]) == (grid[0][2] - grid[1][2]);

                a[1] = (grid[1][0] - grid[2][0]) == (grid[1][1] - grid[2][1])
                        && (grid[1][1] - grid[2][1]) == (grid[1][2] - grid[2][2])
                        && (grid[1][0] - grid[2][0]) == (grid[1][2] - grid[2][2]);

                a[2] = (grid[2][0] - grid[0][0]) == (grid[2][1] - grid[0][1])
                        && (grid[2][1] - grid[0][1]) == (grid[2][2] - grid[0][2])
                        && (grid[2][0] - grid[0][0]) == (grid[2][2] - grid[0][2]);

                b[0] = (grid[0][0] - grid[0][1]) == (grid[1][0] - grid[1][1])
                        && (grid[1][0] - grid[1][1]) == (grid[2][0] - grid[2][1])
                        && (grid[0][0] - grid[0][1]) == (grid[2][0] - grid[2][1]);

                b[1] = (grid[0][1] - grid[0][2]) == (grid[1][1] - grid[1][2])
                        && (grid[1][1] - grid[1][2]) == (grid[2][1] - grid[2][2])
                        && (grid[0][1] - grid[0][2]) == (grid[2][1] - grid[2][2]);

                b[2] = (grid[0][2] - grid[0][0]) == (grid[1][2] - grid[1][0])
                        && (grid[1][2] - grid[1][0]) == (grid[2][2] - grid[2][0])
                        && (grid[0][2] - grid[0][0]) == (grid[2][2] - grid[2][0]);

                if(a[0] && a[1] && a[2] && b[0] && b[1] && b[2]){
                        System.out.print("Yes");
                }else{
                        System.out.print("No");
                }
        }
}

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

int calcDigits(int n){
	if(n < 10)
		return 1;
	return 1+ calcDigits(n/10);
}

int main(){
	int a, b;
	while(cin >> a >> b){
		cout << calcDigits(a+b) << endl;
	}
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int,int> pair2;
typedef std::pair<int,pair2> pair3;
const ll INF = 1LL<<60;

int main(){
string S,T,U;
  ll A,B;
  cin >>S>>T;
  cin >>A>>B;
  cin >>U;

  if(S==U){A=A-1;}
  if(T==U){B=B-1;}
  
  cout<<A<<" "<<B<<endl;
}


Measured memory_bytes: 256
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main (){
    int n;cin>>n;vector<int> a(n);
    rep(i,0,n)cin>>a[i];
    int m;cin>>m;vector<int> b(m);
    rep(i,0,m)cin>>b[i];
    cout<<includes(all(a),all(b))<<endl;
    
}



/*

*/



Measured memory_bytes: 4308
#include <iostream>

using namespace std;

struct player {
	int score[3];
	int ts;
};

int main() {


	int n;

	cin >> n;

	player *p = new player[n];

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++)
			cin >> p[i].score[j];
		p[i].ts = 0;
	}

	for (int i = 0; i < 3; i++) {

		for (int j = 0; j < n; j++) {

			int count = 0;
			for (int k = 0; k < n; k++) {

				if (p[j].score[i] == p[k].score[i] && j != k)
					count++;

			}

			if (count == 0)
				p[j].ts += p[j].score[i];
		}

	}

	for (int i = 0; i < n; i++)
		cout << p[i].ts << "\n";
	

	return 0;

}




Measured memory_bytes: 3096
#include <iostream>

using namespace std;

const int N = 100;

const long long INFTY = (1LL << 32);

int n;

long long Graph[N][N];//图的邻接矩阵



void floyd() { //弗洛伊德算法
	for (int k=0; k<n; k++) {
		for (int i = 0; i<n; i++) {
			
			if (Graph[i][k] == INFTY) continue;
			
			for (int j = 0; j<n; j++) {
				if (Graph[k][j] == INFTY) continue;
				
				Graph[i][j] = min(Graph[i][j],Graph[i][k] + Graph[k][j]);
			}
		}
	}
}

int main() {
	int Ne;
	cin >> n >> Ne;
	for (int i=0; i<n; i++) {
		for (int j=0; j<n; j++) {
			Graph[i][j] = (i == j ? 0 : INFTY);
		}
	}
	
	for (int i=0; i<Ne; i++) {
		int s,t,d;
		cin >> s >> t >> d;
		Graph[s][t] = d;
	}
	floyd();
	
	for (int i=0;i<n;i++) {
		if (Graph[i][i] < 0) {
			cout << "NEGATIVE CYCLE" << endl;
			return 0;
		}
 	}
 	
	for (int i=0;i<n;i++) {
		for (int j=0;j<n;j++) {
			if (j) {
				cout << " ";
			}
			if (Graph[i][j] == INFTY) {
				cout << "INF";
			} else {
				cout << Graph[i][j];
			}
		}
		cout << endl;
	}
	
}


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

int main() {
  int D, T, S;
  cin >> D >> T >> S;
  
  int kyori = T * S;
  
  if (kyori >= D) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3532
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <set>

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

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

  set<int> values;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    values.insert(tmp);
  }

  cout << values.size() << endl;

  return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Queue;

public class Main implements Runnable{

	public static void main(String[] args) {
		new Thread(null,new Main(), "" ,Runtime.getRuntime().maxMemory()).start();
	}
	
	boolean f(String str) {
		int n=str.length();
		return str.length()%2==0&&str.substring(0,n/2).equals(str.substring(n/2,n));
	}
	
	public void run() {
		FastScanner sc=new FastScanner();
		String s=sc.next();
		int ans=0;
		for(int len=1;len*2<s.length();++len) {
			if(f(s.substring(0,2*len)))ans=Math.max(ans, 2*len);
		}
		System.out.println(ans);
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 23380
import numpy
import math
a, b, h, m = map(int, input().split())

minutes = h * 60 + m

h_radian = math.radians(minutes / 60 * 30)
m_radian = math.radians(minutes * 6)

# h_x = abs(a * math.sin(h_radian))
# h_y = abs(a * math.cos(h_radian))
# m_x = abs(a * math.sin(m_radian))
# m_y = abs(a * math.cos(m_radian))

# print(math.sqrt((h_x + m_x) ** 2 + (h_y + m_y) ** 2))

h_x = a * math.sin(h_radian)
h_y = a * math.cos(h_radian)
m_x = b * math.sin(m_radian)
m_y = b * math.cos(m_radian)

i = numpy.array([h_x, h_y])
j = numpy.array([m_x, m_y])

print(numpy.linalg.norm(i - j))

# print(h_x, h_y)
# print(m_x, m_y)

Measured memory_bytes: 27276
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;

using namespace std;

int main(void){
    ll dp[100005], ar[100005];
    ll mod=998244353;
    ll N;
    cin>>N;
    ll val;
    MEMSET(dp, 0);
    MEMSET(ar, 0);
    cin>>val;
    if(val!=0){ cout<<0<<endl;
        return 0;
    }
    dp[0]++; ar[0]++;
    ll M=0;
    rep(i, N-1){
        cin>>val;
        if(val==0){ cout<<0<<endl;
            return 0;
        }
        M=max(M, val);
        ar[val]++;
    }
    ll index=1;
    while(true){
        if(ar[index]==0){
            if(index>M) break;
            else{
                cout<<0<<endl;
                return 0;
            }
        }
        ll ca=1;
        rep(j, ar[index]){
            ca*=ar[index-1];
            ca=ca%mod;
        }
        dp[index]=dp[index-1]*ca;
        dp[index]=dp[index]%mod;
        //cout<<dp[index]<<endl;
        index++;
    }
    cout<<dp[index-1]<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

//0:?????? 1:?????? 2:??? 3:??? 4:?\\ 5:?£?


class Dice{
public:
	Dice(){
		number = new int[6];
		work = new int[6];
	};
	void init(){
		setNumber(1,5,4,3,2,6);
	}

	void roll(char dst){
		for(int i = 0; i < 6; i++) work[i] = number[i];
		switch(dst){
		case 'E':
			setNumber(work[3],work[1],work[0],work[5],work[4],work[2]);
			break;
		case 'N':
			setNumber(work[1],work[5],work[2],work[3],work[0],work[4]);
			break;
		case 'S':
			setNumber(work[4],work[0],work[2],work[3],work[5],work[1]);
			break;
		case 'W':
			setNumber(work[2],work[1],work[5],work[0],work[4],work[3]);
			break;
		}
	};

	int returnPeek(){
		return number[0];
	}

private:
	void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
		number[0] = n0;
		number[1] = n1;
		number[2] = n2;
		number[3] = n3;
		number[4] = n4;
		number[5] = n5;
	}

private:
	int* number;
	int* work;
};

int main(){
	Dice dice;
	int n;
	char buf[2];

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		dice.init();

		for(int i = 0; i < n; i++){
			scanf("%s",buf);

			dice.roll(buf[0]-32);
		}

		printf("%d\n",dice.returnPeek());

	}


}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int A, B, Q;
    cin >> A >> B >> Q;
    long long a, M;
    set <long long> SeA, SeB;
    set <long long> :: iterator itA1, itB1, itA2, itB2;
    for (int i = 0; i < A; i++)
    {
        cin >> a;
        SeA.insert(a);
    }
    for (int i = 0; i < B; i++)
    {
        cin >> a;
        SeB.insert(a);
    }
    SeA.insert(-200000000000000000);
    SeB.insert(-200000000000000000);
    SeA.insert(200000000000000000);
    SeB.insert(200000000000000000);
    for (int i = 0; i < Q; i++)
    {
        cin >> a;
        itA2 = SeA.lower_bound(a);
        itB2 = SeB.lower_bound(a);
        itA1 = itA2;
        itB1 = itB2;
        itA1--;
        itB1--;
        M = 3000000000000000;
        M = min(M, max(*itB2,*itA2) - a);
        M = min(M, a - min(*itA1, *itB1));
        M = min(M, a - *itA1 + *itB2 - *itA1);
        M = min(M, a - *itB1 + *itA2 - *itB1);
        M = min(M, *itB2 - a + *itB2 - *itA1);
        M = min(M, *itA2 - a + *itA2 - *itB1);
        cout << M << "\n";
    }
    return 0;
}


Measured memory_bytes: 10752
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

int main() {
    string S; cin >> S;
    long long K; cin >> K;
    for(int i = 0; i < S.size(); ++i) {
        if (S[i]-'0' > 1 || i+1 == K) {
            cout << S[i] << endl;
            return 0;
        }
    }
}


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

int main() {

  int n, i, m = 0, x = 2;

  cin >> n;
  
  for(i = 3; i <= n; i++) {
    if(i % 3 == 0) cout << " " << i;
    else if(i % 10 == 3) cout << " " << i;
    else if(i % 3 != 0) {
      x = i;
      while(1 < x) {
	x = x / 10;
	if(x % 10 == 3) {
	  cout << " " << i;
	  break;
	}
      }
    }
  }

  cout << "\n";
  
  return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long INF=1LL<<60;


int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int i,n,ans=0,max=0;
	string s;
	cin>>n>>s;
	for(i=0;i<n;i++){
		if(s[i]=='I')ans++;
		else ans--;
		if(ans>max)max=ans;
	}
	cout<<max<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b, c, d, e, f; cin >> a >> b >> c >> d >> e >> f;
	P ans;
	double now = -1.0;
	for (int i = 0; i * a * 100 <= f; i++) {
		for (int j = 0; (i + a + j * b) * 100 <= f; j++) {
			if (i + j == 0) {
				continue;
			}
			int w = (i * a + j * b) * 100;
			int ms = min(f - w, e*w / 100);
			for (int k = 0; k * c <= ms; k++) {
				int l = (ms - k * c) / d;
				int s = k * c + l * d;
				if (now < 100.0 * s / (s + w)) {
					now = 100.0*s / (s + w);
					ans = P(s + w, s);
				}
			}
		}
	}
	cout << ans.first << " " << ans.second << endl;
	
	return 0;
}

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

int b[111111];
int main() {
	int n, k, q;
	cin >> n >> k >> q;
	for (int i = 0; i < q; i++) {
		int a;
		scanf("%d", &a);
		b[a]++;
	}
	for (int i = 0; i < n; i++)
		cout << (b[i + 1] + k > q ? "Yes\n" : "No\n");
	cout << flush;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
const int maxn=100007;
using namespace std;
int n,l[maxn],r[maxn];
long long ans;

bool cmp(int x,int y){
	return x>y;
}

int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	for(int i=1;i<=n;++i)cin>>l[i]>>r[i];
	sort(l,l+n+1,cmp);
	sort(r,r+n+1);
	for(int i=0;i<=n;++i){
		if(l[i]-r[i]<=0)break;
		ans+=(l[i]-r[i])<<1;
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 1024
a=int(input())
b=input()
r_num=0
w_num=0
for i in b :

  if i=='W' :
    w_num+=1
  else :
    r_num+=1

count=0

for i in range(r_num) :
  if b[i]=='W' :
    count+=1


print(count)


Measured memory_bytes: 67864
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

ll min(ll a, ll b) {return a < b ? a : b;}
ll min(int a, ll b) {return a < b ? a : b;}
ll min(ll a, int b) {return a < b ? a : b;}
ll min(int a, int b) {return a < b ? a : b;}

ll max(ll a, ll b) {return a > b ? a : b;}
ll max(int a, ll b) {return a > b ? a : b;}
ll max(ll a, int b) {return a > b ? a : b;}
ll max(int a, int b) {return a > b ? a : b;}

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()
#define int long long

const int N = 501000;
const int MOD = 1e9 + 7;

int A, B, M;
int a[N], b[N];
int ans = 1e18;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i += 2)
    {
        if (s[i] == 'h' && s[i + 1] == 'i') continue;
        cout << "No"; return 0;
    }
    if (s.size() % 2 != 0) cout << "No";
    else cout << "Yes";
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)

int N, Q;
char s[212345], t[212345], d[212345];

int f(int tmp) {
	rep(q, Q) {
		if (t[q] == s[tmp]) {
			if (d[q] == 'L') --tmp;
			else ++tmp;
		}
	}
	if (tmp < 0) return -1;
	else if (tmp < N) return 0;
	else return 1;
}

int main() {

	scanf("%d%d%s", &N, &Q, s);
	rep(i, Q) scanf("%s%s", &t[i], &d[i]);

	int l_l = 0, l_r = N - 1, r_l = 0, r_r = N - 1;

	while (l_r - l_l > 1) {
		int tmp = (l_l + l_r) / 2;

		if (f(tmp) == -1) l_l = tmp;
		else l_r = tmp;
	}
	if (f(l_r) == -1) l_l = l_r;
	else l_r = l_l;

	while (r_r - r_l > 1) {
		int tmp = (r_l + r_r) / 2;

		if (f(tmp) == 1) r_r = tmp;
		else r_l = tmp;
	}
	if (f(r_l) == 1) r_r = r_l;
	else r_l = r_r;

	if (f(l_l) != -1) l_l--;
	if (f(r_r) != 1) r_r++;


	printf("%d\n", N - l_l - 1 - (N - r_r));


	return 0;
}


Measured memory_bytes: 896
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <limits>
#include <tuple>
#include <queue>
#include <stack>
#include <bitset>

using namespace std;
typedef long long ll;

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

class solver {
public:
	int D;
	vector<int> c;
	vector<vector<int>> s;

	void init() {
		cin >> D;
		c.resize(26);
		s.resize(D);
		rep(i, 26) {
			cin >> c[i];
		}
		rep(j, D) {
			s[j].resize(26);
			rep(i, 26) {
				cin >> s[j][i];
			}
		}
	}

	vector<int> calc(const vector<int>& t) const {
		vector<int> last(26);
		auto down = [&last, this](int d) {
			d++;
			int v = 0;
			rep(i, 26) {
				v += c[i] * (d - last[i]);
			}
			return v;
		};
		int N = t.size();
		vector<int> v(N);
		rep(i, N) {
			if (i > 0)
				v[i] = v[i - 1];
			v[i] += s[i][t[i]];
			last[t[i]] = i + 1;
			v[i] -= down(i);
		}
		return v;
	}

	vector<int> greedy() const {
		//vector<pair<int, int>> cs;
		//rep(i, 26) {
		//	cs.emplace_back(c[i], i);
		//}
		//sort(all(cs), greater<pair<int, int>>());

		vector<vector<pair<int, int>>> ss(D);
		rep(j, D) {
			rep(i, 26) {
				ss[j].emplace_back(s[j][i], i);
			}
			sort(all(ss[j]), greater<pair<int, int>>());
		}

		vector<int> ans;
		for (auto& i : ss) {
			ans.push_back(i[0].second);
		}

		return ans;
	}
};

int main()
{
	solver solver;
	solver.init();
	auto ans = solver.greedy();
	for (auto t : ans) {
		cout << (t + 1) << endl;
	}
	return 0;
}


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

int main () {
  string s;
  cin >> s;
  sort (s.begin(),s.end());
  bool ans = true;
  if (s.size()%2 != 0) ans = false;
  for (int i = 0; i < s.size()-1; i++) {
    if ((s.at(i) != s.at(i+1)) && (i%2 == 0)) ans = false;
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>
#include <random>
#include <set>
#include <sstream>
#include <vector>
typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 1e18;
const double INFD = 1e30;
const double EPS = 1e-9;
const double PI = acos(-1);
const int MOD = 998244353;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 105;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;
char _map[MAXN][MAXN];
int dp[MAXN][MAXN];
int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) {
        scanf("%s", _map[i] + 1);
    }
    memset(dp, 0x3f, sizeof(dp));
    dp[0][1] = dp[1][0] = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (_map[i][j] == '.')
                dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]);
            else {
                dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]) + 1;
                if (_map[i - 1][j] == '#')
                    dp[i][j] = min(dp[i][j], dp[i - 1][j]);
                if (_map[i][j - 1] == '#')
                    dp[i][j] = min(dp[i][j], dp[i][j - 1]);
            }
        }
    }
    printf("%d", dp[n][m]);
    return 0;
}

Measured memory_bytes: 256
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let mut n: usize = sc.read();
    let mut d = 1;
    let mut cur = 26;
    while n > cur {
        n -= cur;
        cur *= 26;
        d += 1;
    }

    assert!(n > 0);
    n -= 1;
    let mut ans = vec![0; d];
    for i in 0..d {
        ans[i] = n % 26;
        n /= 26;
    }
    ans.reverse();
    for a in ans.into_iter() {
        let c = a as u8 + 'a' as u8;
        sc.write(c as char);
    }
    sc.write("\n");
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 2192
#include <iostream>


long long rec(long long a, long long b) {
  if(b == 0)
    return -a;

  return (a/b)*2*b + rec(b, a%b);
}

int main() {
  long long n, x;
  std::cin >> n >> x;

  std::cout << n + rec(std::min(n-x, x), std::max(n-x, x)) << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define speedX ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
template<typename T>
void __p(T a) { cout << a << " "; }
template<typename T, typename F>
void __p(pair<T, F> a) { cout << "{ "; __p(a.first); __p(a.second); cout << "}"; }
template<typename T>
void __f(const char* s, T t) { cout << s << " : "; __p(t); }
template<typename T>
void __t(const char* s, const T &x) { cout << s << " : { "; for (auto it : x) __p(it); cout << "} ";}
template<typename T, typename ... F>
void __f(const char* s, T t, F ... f) {
	int i = 0; for (;; ++i) if (s[i] == ',') break;
	cout.write(s, i) << " : "; __p(t); cout << " | "; __f(s + i + 1, f...);
}
#define trace(...) { cout<<"LINE: "<<__LINE__<<" || "; __f(#__VA_ARGS__,__VA_ARGS__); cout<<"\n\n"; }
#define debug(...) { cout<<"LINE: "<<__LINE__<<" || "; __t(#__VA_ARGS__,__VA_ARGS__); cout<<"\n\n"; }
int begtime = clock();
#define end_time() cout << "\n\nTime of execution: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define trace(...)
#define debug(...) 
#define end_time()
#endif
 
 
#define int long long 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef vector<int> vi;
typedef vector<pii> vii;

inline bool equals(ld a, ld b) {return fabs(a - b) < 1e-9;}
inline int gcd(int a, int b) { a=abs(a); b=abs(b); while(a>0 && b>0) (a>b?a%=b:b%=a); return (a==0?b:a); } 
inline int power(int x, int n, int m = LLONG_MAX)
    {  int res=1; x = (x%m + m)%m;
       while(n) { if(n&1) res=(res*x)%m;  x=(x*x)%m;  n >>= 1; }  return res;
    }
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define mod 1000000007

void solve(){
	int n;
	cin>>n;
	vi a(n+1,0),b(n+1,0),c(n+1,0);
	for(int i = 1; i<=n; i++){
		cin>>a[i]>>b[i]>>c[i];
	}
	vector<vector<int>> dp(n+1,vector<int>(3,0));
	for(int i = 1; i<=n; i++){
		dp[i][0] = a[i] + max(dp[i-1][1],dp[i-1][2]);
		dp[i][1] = b[i] + max(dp[i-1][0],dp[i-1][2]);
		dp[i][2] = c[i] + max(dp[i-1][0],dp[i-1][1]); 
	}
	cout<<max(max(dp[n][0],dp[n][1]),dp[n][2]);
}
signed main(){
	speedX;
	#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
	int t=1;
	//cin>>t;
	for(int i=1;i<=t;++i) {
		//cout<<"Case #"<<i<<": ";
		solve();
	}
	end_time();
	return 0;
}


Measured memory_bytes: 11068
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
int f(int a)
{
    if (a % 10 != 0)
    {
        int cc = 10 - a % 10;
        a += cc;
    }
    return a;
}
int main()
{
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    cout << min({f(a) + f(b) + f(c) + f(d) + e, a + f(b) + f(c) + f(d) + f(e), f(a) + b + f(c) + f(d) + f(e), f(a) + f(b) + c + f(d) + f(e), f(a) + f(b) + f(c) + d + f(e)}) << endl;
    return 0;
}

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

int main() {
    int k;
    while (cin >> k, k) {
        int s = 0;
        for (int i = 0, n = k * (k - 1) / 2; i < n; i++) {
            int c;
            cin >> c;
            s += c;
        }
        cout << s / (k - 1) << endl;
    }
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<vector>
#include <functional>
#include<stdio.h>
#include<string>
#include<cmath>
using namespace std;


int main() {
	int x = 0, y=753;
	string s;
	cin >> s;
	for (int i = 0; i < s.size() - 2; i++) {
		int a = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0') * 1;
		x = fabs(a - 753);
		if (y > x)y = x;
	}
	cout << y << endl;
	return 0;
}


Measured memory_bytes: 384
#C問題
def fib(n):
    a, b = 0, 1
    for i in range(n-1):
        a, b = b, a + b
    return b

N, M = map(int,input().split())
break_step = []
step_list = [i for i in range(N+1)]
for i in range(M):
    break_step.append(int(input()))
count_list = []
count = 0
for i in break_step:
    count = i - count
    count_list.append(count)
    count = i + 1
count = N - count + 1
count_list.append(count)
ans = 1
for i in count_list:
    ans = ans * fib(i)
if 0 in  count_list:
    print(0)
else:
    print(ans%1000000007)

Measured memory_bytes: 11836
n = int(input())
s = [input() for _ in range(n)]

a = 0
b = 0
c = 0
d = 0

ans = 0

for x in s:
    if x[0] == 'B':
        if x[-1] == 'A':
            c += 1
        else:
            b += 1
    else:
        if x[-1] == 'A':
            a += 1
        else:
            d += 1
    for i in range(len(x) - 1):
        if x[i] == 'A' and x[i+1] == 'B':
            ans += 1

if c == 0:
    ans += min(a, b)
else:
    ans += c - 1
    if a > 0:
        ans += 1
        a -= 1
    if b > 0:
        ans += 1
        b -= 1
    ans += min(a, b)

print(ans)

Measured memory_bytes: 3700