akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
	int N;
	cin >> N;
	string S;
	for (int i = 0; i < N; i++) {
		cin >> S;
		if (S == "Y") {
			cout << "Four" << endl;
			break;
		}
		else if (i == N-1) {
			cout << "Three" << endl;
		}
	}
}

Measured memory_bytes: 256
def main():
    # x,y = map(int,input().split())           x=1,y=2
    # a = input().split()                      a=['1','2','3',...,'n']
    # a = list(map(int,input().split()))       a=[1,2,3,4,5,...,n]
    # li = input().split('T')	              FFFTFTTFF => li=['FFF', 'F', '', 'FF']
    # 複数行の「1 2 3 4」型の入力を一配列に
    # x = sorted([list(map(int, input().split())) for _ in range(n)])
    # ソート x.sort(key=lambda y:y[1])
    # [chr(i) for i in range(97, 97+26)] 英語小文字リスト
    # [chr(i) for i in range(65, 65+26)] 英語大文字リスト atcoder
    # ord(c) chr(2) alphabet <=> number
    n,k = map(int,input().split())
    a = list(map(int,input().split()))
    f = list(map(int,input().split()))
    a.sort()
    f.sort(reverse=True)
    ok = 10**12
    ng=-1

    while ok-ng>1:
        mid=(ok+ng)//2
        cnt=0
        for x,y in enumerate(a):
            cnt+=max(0,y-mid//f[x])
        if cnt>k:
            ng=mid
        else:
            ok=mid
    print(ok)
main()

Measured memory_bytes: 119756
N = int(input())
l = input()
Wonleft = 0
Ronright = l.count('R')
ans = Ronright
for i in range(N):
    if l[i] == 'W':
        Wonleft += 1
    else:
        Ronright -= 1
    t = max(Wonleft, Ronright)
    if ans > t:
        ans = t
print(ans)

Measured memory_bytes: 9336
using System;
using System.Linq;

namespace BigOrSmall
{
	public class Program
	{
		static void Main(string[] args)
		{
			var InputValue = Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToList<int>();

			if(InputValue[0] < InputValue[1])
			{
				Console.WriteLine("a < b");
			}

			if (InputValue[0] > InputValue[1])
			{
				Console.WriteLine("a > b");
			}

			if (InputValue[0] == InputValue[1])
			{
				Console.WriteLine("a == b");
			}

		}
	}
}



Measured memory_bytes: 9412
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <tuple>
#include <algorithm>
using namespace std;

int n, k;
vector<int> graph[2001];

int dist[2001];
int distr1[2001], distr2[2001];

pair<vector<int>, int> fardist(int st, int dist[]) {
	memset(dist, -1, sizeof(int) * (n + 1));
	queue<int> q;

	int ansd = 0;
	vector<int> anslist{ st };

	dist[st] = 0;
	q.push(st);
	while (!q.empty()) {
		int u = q.front();
		q.pop();
		if (ansd < dist[u]) {
			ansd = dist[u];
			anslist = { u };
		}
		else if (ansd == dist[u]) {
			anslist.push_back(u);
		}

		for (int v : graph[u]) {
			if (dist[v] == -1) {
				dist[v] = dist[u] + 1;
				q.push(v);
			}
		}
	}

	return { anslist, ansd };
}

tuple<int, int, int> diameter() {
	auto d1 = fardist(1, dist);
	auto d2 = fardist(d1.first[0], dist);
	return make_tuple(d1.first[0], d2.first[0], d2.second);
}

int check(int st, int lmt) {
	memset(dist, -1, sizeof(dist));
	queue<int> q;

	dist[st] = 0;
	q.push(st);
	while (!q.empty()) {
		int u = q.front();
		q.pop();
		if (dist[u] >= lmt) {
			continue;
		}

		for (int v : graph[u]) {
			if (dist[v] == -1) {
				dist[v] = dist[u] + 1;
				q.push(v);
			}
		}
	}

	int cnt = 0;
	for (int i = 1; i <= n; ++i) {
		if (dist[i] == -1) {
			++cnt;
		}
	}
	return cnt;
}

int countMaxhalf(int u, int par, int maxhalfval) {
	if (dist[u] == -1) {
		return 0;
	}
	if (dist[u] == maxhalfval) {
		return 1;
	}

	int sum = 0;
	for (int v : graph[u]) {
		if (v == par) {
			continue;
		}
		sum += countMaxhalf(v, u, maxhalfval);
	}
	return sum;
}

void proc() {
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n - 1; ++i) {
		int a, b;
		scanf("%d %d", &a, &b);
		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	auto d = diameter();
	if (get<2>(d) <= k) {
		printf("0");
		return;
	}

	fardist(get<0>(d), distr1);
	fardist(get<1>(d), distr2);

	int ans = n;
	for (int i = 1; i <= n; ++i) {
		int maxhalf = (k + 1) / 2;
		int minhalf = k / 2;
		if (maxhalf == minhalf) {
			ans = min(ans, check(i, maxhalf));
		}
		else {
			int cnt = check(i, maxhalf);

			int pmax = 0, psum = 0;
			for (int v : graph[i]) {
				int p = countMaxhalf(v, i, maxhalf);
				psum += p;
				pmax = max(pmax, p);
			}

			int cnt2 = 0;
			for (int i = 1; i <= n; ++i) {
				cnt2 += (dist[i] == -1) ? 1 : 0;
			}
			ans = min(ans, cnt2 + (psum - pmax));
		}
	}

	printf("%d", ans);
}

int main() {
	//freopen("input.txt", "r", stdin);
	proc();
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  i64 n, a, b;
  cin >> n >> a >> b;
  i64 ans = b * (n - 2) - a * (n - 2) + 1;
  if (b < a) ans = 0;
  else if (n == 1) {
    if (a == b) ans = 1;
    else ans = 0;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
public class Main {

	private static void solve() {
		int n = ni();
		int a = ni();
		int b = ni();
		
		System.out.println((b - a) % 2 == 1 ? "Borys" : "Alice");
	}

	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			@Override
			public void run() {
				long start = System.currentTimeMillis();
				String debug = args.length > 0 ? args[0] : null;
				if (debug != null) {
					try {
						is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
					} catch (Exception e) {
						throw new RuntimeException(e);
					}
				}
				reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
				solve();
				out.flush();
				tr((System.currentTimeMillis() - start) + "ms");
			}
		}, "", 64000000).start();
	}

	private static java.io.InputStream is = System.in;
	private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
	private static java.util.StringTokenizer tokenizer = null;
	private static java.io.BufferedReader reader;

	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new java.util.StringTokenizer(reader.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	private static double nd() {
		return Double.parseDouble(next());
	}

	private static long nl() {
		return Long.parseLong(next());
	}

	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private static char[] ns() {
		return next().toCharArray();
	}

	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}

	private static int[][] ntable(int n, int m) {
		int[][] table = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				table[i][j] = ni();
			}
		}
		return table;
	}

	private static int[][] nlist(int n, int m) {
		int[][] table = new int[m][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				table[j][i] = ni();
			}
		}
		return table;
	}

	private static int ni() {
		return Integer.parseInt(next());
	}

	private static void tr(Object... o) {
		if (is != System.in)
			System.out.println(java.util.Arrays.deepToString(o));
	}
}


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

const char frameCh = '#';
int main(void){
  int h,w;
  char buf[128];
  
  cin >> h >> w;
  for (int i=0; i<w+2; i++) cout << frameCh;
  cout << endl;
  for (int i=0;i<h; i++){
    cin >> buf;
    cout << frameCh << buf << frameCh << endl;
  }
  for (int i=0; i<w+2; i++) cout << frameCh;
  cout << endl;
  return 0;
}
  

Measured memory_bytes: 256
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            string[] inputs = Console.ReadLine().Split(' ');
            int x = int.Parse(inputs[0]);
            int a = int.Parse(inputs[1]);
            int b = int.Parse(inputs[2]);
            string result = "dangerous";
            if (a >= b)
            {
                result = "delicious";
            }
            else if (x >= (b - a))
            {
                result = "safe";
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int w, n;
  while (cin >> w >> n) {
    vector<int> vec;
    for (int i = 0; i < w; ++i) {
      vec.push_back(i + 1);
    }
    for (int i = 0; i < n; ++i) {
      int a, b;
      scanf("%d,%d", &a, &b);
      a -= 1;
      b -= 1;
      int tmp = vec[a];
      vec[a] = vec[b];
      vec[b] = tmp;
    }
    for (int i = 0; i < vec.size(); ++i) {
      cout << vec[i] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3164
#include <iostream>
#include <algorithm>

using namespace std;

int main(void){
    int a1=0;
    int a2=0;
    int a3=0;
    int max=0;
    int min=0;

    cin >> a1 >> a2 >> a3;

    max=a1;
    if(max<=a2)max=a2;
    if(max<=a3)max=a3;

    min=a1;
    if(min>=a2)min=a2;
    if(min>=a3)min=a3;

    cout << max-min << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin >> s;
	int ans=0,x=0,tmp;
	for(int i=0;i<s.size();i++){
		if(s[i]!='9'){
			tmp=i;
		}
	}
	for(int i=0;i<s.size();i++){
		if(x==0){
			if(s[i]=='9'||tmp==0){
				ans+=s[i]-'0';
			}else{
				x++;
				ans--;
				if(i==0){
					ans+=s[i]-'0';
				}else{
					ans+=9;
				}
			}
		}else{
			ans+=9;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    int x, y;
    for (int i = 0; i < 3000; i++){
        cin >> x >> y;
        if (x == 0 && y == 0)
            break;
        else if (x < y)
            cout << x << " " << y << endl;
        else if (y < x)
            cout << y << " " << x <<endl;
        else
            cout << x << " " << y << endl; 
    }
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
int n;
struct N{
	int xi,yi;
}a[10];
int num[10];
double count(N a,N b){
	double t=1.0*(a.xi-b.xi)*(a.xi-b.xi)+1.0*(a.yi-b.yi)*(a.yi-b.yi);
	double left=0,midle,right=t;
	for(int i=1;i<=500;i++)
	{
		midle=(left+right)/2;
		if(midle*midle<t)left=midle;
		else right=midle;
	}
	return right;
}
void average(){
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i].xi>>a[i].yi;
	for(int i=1;i<=n;i++)
		num[i]=i;
	double ans=0;
	int cnt=0;
	do		//next_permutation(a,a+n)全排列函数	如果还有全排列才继续 
	{
		cnt++;
		for(int i=1;i<n;i++){
			ans+=count(a[num[i]],a[num[i+1]]); 
		}
	} while(next_permutation(num+1,num+n+1));
	ans=ans/cnt;
    cout<<fixed<<setprecision(10)<<ans;
}
int main(){
	average();
	return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define llu unsigned long long
#define U unsigned int
#define SIZE 1000002
#define pie 3.14159265358979323
#define minuss 1e-6
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{
   
        ll n,a,b,s=0;
    cin>>n>>a>>b;
    s=n*a;
    cout<<min(s,b)<<endl;
    
}


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

using namespace std;

string b[10] = {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};

void solve(void) {
  string s;
  cin >> s;

  string ans = "";
  int l = 0;
  while (l < s.size()) {
    while (l < s.size() && s[l] == '0') l++;
    if (l == s.size()) break;

    int cnt = 0, p = s[l] - '0';
    while (l < s.size() && s[l] != '0') l++, cnt++;
    if (l == s.size()) break;    
    
    ans += b[p][(cnt - 1) % b[p].size()];
  }

  cout << ans << endl;
}

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

  for (int i = 0; i < n; i++) {
    solve();
  }

  return 0;
}


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

using namespace std;


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

   long long int i,c=0,maxi=0;
   char s[5];
   cin>>s;
   for(i=0;i<3;i++)
   {
       if(s[i]=='R')
        c++;
       else
       {
        maxi=max(c,maxi);
        c=0;
       }
   }
   maxi=max(c,maxi);
   cout<<maxi<<"\n";

    return 0;
}





Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
char c[100005];
int n, l[100005], r[100005], tot, b[100005];
int main(){
	scanf("%s", (c+1));
	n=strlen(c+1);
	for(int i=n;i>=1;i--){
		if(c[i]=='L') l[i]=i;
		else l[i]=l[i+1];
	}
	for(int i=1;i<=n;i++){
		if(c[i]=='R') r[i]=i;
		else r[i]=r[i-1];
	}
	for(int i=1;i<=n;i++){
		if(c[i]=='R') {
			if((l[i]-i)%2==0) b[l[i]]++;
			else b[l[i]-1]++;
		}
		else {
			if((i-r[i])%2==0) b[r[i]]++;
			else b[r[i]+1]++;
		}
	}
	for(int i=1;i<=n;i++){
		printf("%d ", b[i]);
	}
}

Measured memory_bytes: 1664
#include <iostream>
#include <math.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <deque>  
#include <iomanip>

using namespace std;

int main(){
    int N;
    cin>>N;
    cout<<N*N*N<<endl;
    return 0;
}

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

int main(void){
	int pow3[16], c[16];
	int n, m, i, j, k, d, cnt, p;

	pow3[0] = 1;
	for(i = 1; i <= 15; ++i){
		pow3[i] = pow3[i-1] * 3;
	}

	while(scanf("%d%d", &n, &m), n){
		for(i = 0; i < 3; ++i){
			for(scanf("%d", &j); j > 0; --j){
				scanf("%d", &k);
				c[n-k] = i;
			}
		}

		p = 0;
		cnt = 0;
		for(i = n - 1; i >= 0; --i){
			d = abs(p - c[i]);
			cnt += pow3[i] * d;
			if(d == 1){
				p = 2 - p;
			}
		}

		k = pow3[n] - 1 - cnt;
		if(cnt > k){
			cnt = k;
		}
		printf("%d\n", cnt > m ? -1 : cnt);
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <functional>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;
int main(){
  string s;
  cin >> s;
  if(s == "Sunny")cout << "Cloudy" << endl;
  else if(s == "Cloudy")cout << "Rainy" << endl;
  else cout << "Sunny" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

int main()
{
	string s;
	cin>>s;;
	if(s[2]==s[3]&&s[4]==s[5])cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#include<queue>

using namespace std ;

#define N_MAX 100000

int N ,K ;
long long time[ N_MAX ] ;

priority_queue< int > que ;

int main( void )
{
	scanf( "%d %d" ,&N ,&K ) ;

	int i ,j ;
	for( i = 0 ; i < N ; ++i )
	{ 
		scanf( "%d" ,time + i ) ;

		if( i > 0 )
		{
			que.push( -(time[ i ] - time[ i - 1 ] - 1) ) ;
		}
	}

	if( K >= N )
		printf( "%d\n" ,N ) ;

	else if( K == 1 )
		printf( "%lld\n" ,time[ N - 1 ] - time[ 0 ] + 1 ) ;

	else
	{
		long long sum = N ;	N -= K ;
		for( i = 0 ; i < N ; ++i )
		{
			sum += -que.top() ;	que.pop() ;
		}

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

	return 0 ;
}


Measured memory_bytes: 3668
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int q = sc.nextInt();
        int[] a = new int[q];
        int[] b = new int[q];
        int[] c = new int[q];
        int[] d = new int[q];
        for (int i = 0 ; i < q ; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            c[i] = sc.nextInt();
            d[i] = sc.nextInt();
        }
        int min = 0;
        for (int a1 = 1 ; a1 <= m ; a1++) {
            for (int a2 = a1 ; a2 <= m ; a2++) {
                for (int a3 = a2 ; a3 <= m ; a3++) {
                    for (int a4 = a3 ; a4 <= m ; a4++) {
                        for (int a5 = a4 ; a5 <= m ; a5++) {
                            for (int a6 = a5 ; a6 <= m ; a6++) {
                                for (int a7 = a6 ; a7 <= m ; a7++) {
                                    for (int a8 = a7 ; a8 <= m ; a8++) {
                                        for (int a9 = a8 ; a9 <= m ; a9++) {
                                            for (int a10 = a9 ; a10 <= m ; a10++) {
                                                int sum = 0;
                                                int[] t = new int[] {a1, a2, a3, a4, a5, a6, a7 ,a8, a9 ,a10};
                                                for (int i = 0 ; i < q ; i++) {
                                                    if (t[b[i] - 1] - t[a[i] - 1] == c[i]) sum += d[i];
                                                }
                                                min = Math.max(sum, min);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        System.out.println(min);
    }

}


Measured memory_bytes: 42312
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int s;
  cin>>s;
  int a=s/100;
  int b=s%100;
  if(a>12||a==0){
    if(b>=1&&b<=12)cout<<"YYMM";
    else cout<<"NA";
  }
  else{
    if(b>=1&&b<=12)cout<<"AMBIGUOUS";
    else cout<<"MMYY";
  }
  return 0;
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	int dp[100100];
	dp[0] = 0;
	for( int i = 1; i <= n; ++i ) dp[i] = INF;
	for( int i = 1; i <= n; ++i ){
		for( int j = 1; j <= i; j *= 6 ){
			dp[i] = min(dp[i], dp[i-j]+1);
		}
		for( int j = 9; j <= i; j *= 9 ){
			dp[i] = min(dp[i], dp[i-j]+1);
		}
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 640
N, K = map(int, input().split())
d = []
A = []
for i in range(K):
  temp_d = int(input())
  d.append(temp_d)
  temp_A = list(map(int,input().split()))
  A.append(temp_A)


sum_A=[]

for i in range(K):
  for j in range(d[i]):
    sum_A.append(A[i][j])

ans = N - len(set(sum_A))

print(ans)

Measured memory_bytes: 9060
#include <stdio.h>


 int main(){
 int H,W,i,j;
 while(1){
 scanf("%d %d",&H ,&W);
 if(H==0&&W==0){break;};
 for(i=1;i<=H;i++){
 for(j=1;j<=W;j++){
 	if(j==1||j==W||i==H||i==1){printf("#");}
 	else{printf(".");}
 	
 };
 printf("\n");};
  printf("\n");
 }
 return 0;}



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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if(A>=B && C>=D) cout << B + D << endl;
  else if(A>=B && C<=D) cout << B + C << endl;
  else if(A<=B && C>=D) cout << A + D << endl;
  else cout << A + C << endl;
}

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

  using namespace std;

  int main()
  {
    int n,k;
    cin>>n>>k;
    int ar[n];
    int dp[n];
    for(int i=0;i<n;i++)
    {
      cin>>ar[i];
      dp[i]=INT_MAX;
    }
    if(n-1<=k)
    {
      cout<< abs(ar[n-1]-ar[0])<<endl;
      return 0;
    }
    dp[0]=0;
    for(int i=1;i<=k;i++)
      dp[i]=abs(ar[i]-ar[0]);
    //dp[2]=abs(ar[2]-ar[1]);
    for(int i=k+1;i<n;i++)
    {
      for(int j=i-1;j>=i-k;j--)
        dp[i]=min(abs(ar[i]-ar[j])+dp[j],dp[i]);
    }
    cout<<dp[n-1]<<endl;
    
    return 0;
  }

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())

// https://atcoder.jp/contests/abc137/submissions/6847236

int p;
const ll INF = 1e18; // O(|V||E|)
int MAX_V = 3000;
vector<ll> d(2501, INF); // 0からの時間
int n, e, r; // 頂点、辺、スタート
bool bell(int n, vector<vector<pii> > edge, int s) {
    d[s] = 0;
    
    rep(cnt, 2 * MAX_V) {
        
        rep(from, n) {
            if (d[from] == INF) continue;
            rep(j, SZ(edge[from])) {
                int to = edge[from][j].F;
                int cost = edge[from][j].S;
                
                if (d[to] > d[from] + cost) {
                   
                    d[to] = d[from] + cost;
                    if (cnt >= MAX_V - 1 && d[to] <= INF / 5) {
                        d[to] = -INF;
                        if (to == n - 1) return 0;
                    }
                }
            }
        }
        
    }
    
    return 1;
    
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> n >> e >> p;
    
    vector<vector<pii> > edge(n);
    rep(i, e) {
        int s, t, d;
        cin >> s >> t >> d;
        s--; t--;
        d = d - p;
        edge[s].eb(t, -d);
    }
    
    if (bell(n, edge, r) == 0) {
        out(-1);
    } else {
        out(max(0LL, -d[n - 1]));
    }
    
}


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

int main() {
  string s,s1,s2;
  int n,len;
  cin>>s;
  len=s.length();
  n=len;
  s1=s.substr(0,(len-1)/2);
  s2=s.substr((len+2)/2,len+1-((len+3)/2));
  
  int i=0;
  while(n>(len+1)/2){
    if(s.substr(0+i,1)!=s.substr(n-1,1)){cout<<"No"<<endl;return 0;}
    i++;n--;
    //cout<<n<<endl;
  }
  
  i=0;
  
  len=s1.length();
  n=len;
  while(n>(len+1)/2){
    if(s1.substr(0+i,1)!=s1.substr(n-1,1)){cout<<"No"<<endl;return 0;}
    i++;n--;
    //cout<<n<<endl;
  }
  
  i=0;
  
  len=s2.length();
  n=len;
  while(n>(len+1)/2){
    if(s2.substr(0+i,1)!=s2.substr(n-1,1)){cout<<"No"<<endl;return 0;}
    i++;n--;
    //cout<<n<<endl;
  }

  cout<<"Yes"<<endl;

}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val nodes: Array<Node> = Array(n) { i ->
        readLine()!!.split(" ").map { it.toInt() }.let { Node(i, it[0], it[1]) }
    }
    val edges: ArrayList<Edge> = ArrayList(2 * n)
    nodes.sortBy { it.x }
    for (i in 0 until n - 1) {
        val a = nodes[i]
        val b = nodes[i + 1]
        val d = b.x - a.x
        edges.add(Edge(a.id, b.id, d))
    }
    nodes.sortBy { it.y }
    for (i in 0 until n - 1) {
        val a = nodes[i]
        val b = nodes[i + 1]
        val d = b.y - a.y
        edges.add(Edge(a.id, b.id, d))
    }
    edges.sortBy { it.dist }
    var d = 0L
    val uf = UnionFind(n)
    edges.forEach {
        if (!uf.hasSameRoot(it.from, it.to)) {
            d += it.dist
            uf.unite(it.from, it.to)
        }
    }
    println(d)
}

class Node(val id: Int, val x: Int, val y: Int)

class Edge(val from: Int, val to: Int, val dist: Int)

class UnionFind(size: Int) {
    private var data: Array<Int> = Array(size) { -1 }

    fun unite(x: Int, y: Int) {
        val x = find(x)
        val y = find(y)
        if (data[x] > data[y]) {
            val temp = data[x]
            data[x] = data[y]
            data[y] = temp
        }
        data[x] += data[y]
        data[y] = x
    }

    fun find(k: Int): Int {
        if (this.data[k] < 0) return k
        data[k] = find(data[k])
        return data[k]
    }

    fun hasSameRoot(x: Int, y: Int) = find(x) == find(y)

    fun size(k: Int) = -data[find(k)]
}

Measured memory_bytes: 127048
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <set>
#include <math.h>
#define pai 3.14159265358979323846264338327950288;
#define keta(n) cout << fixed << setprecision((n));
using ll = long long;
int main()
{
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());
  if (s < t)
    cout << "Yes";
  else
    cout << "No";
}


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

int main(){
    int n, m;
    cin >> n >> m;
    int a[n][m];
    rep(i,n) {
        rep(j,m) {
            cin >> a[i][j];
            a[i][j]--;
        }
    }
    int ans = n;
    vector<bool> use(m,true); 
    rep(i,m){
        int num[m] = {};
        rep(j,n){
            int k = 0;
            while(!use[a[j][k]]){
                 k++;
            }
            num[a[j][k]]++;
        }
        int p = 0, q = -1;
        rep(j,m){
            if(num[j] > p){
                p = num[j];
                q = j;
            }
        }
        ans = min(p,ans);
        use[q] = false;
    }
    cout << ans << endl;
    return 0;
}


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



void solve(){
  int a,b;
  cin >> a >> b;
  if(a!=b) cout << 2*max(a,b) -1 << endl;
  else cout << 2*a << endl;
}

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


Measured memory_bytes: 256
import sys

def get_value_by_lists(values_list, pos):
    h, w = len(values_list), len(values_list[0])
    if 0 <= pos[1] < h and 0 <= pos[0] < w:
        return values_list[pos[1]][pos[0]]
    else:
        return None

def is_black_in_four_dir(cells_list, pos):
    for p in ((0, 1), (0, -1), (1, 0), (-1, 0)):
        if get_value_by_lists(cells_list, (pos[0]+p[0], pos[1]+p[1])) == "#":
            return True
    return False

h, w = map(lambda x: int(x), input().split(" "))
cells_list = [input() for _ in range(h)]

for y, cells in enumerate(cells_list):
    for x, cell in enumerate(cells):
        if cell == "#" and not (is_black_in_four_dir(cells_list, (x, y))):
            print("No")
            sys.exit()
print("Yes")

Measured memory_bytes: 3064
import java.util.*;

public class Main{
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int x = sc.nextInt();
            int y = sc.nextInt();
            String str = sc.next();
            String[] str2 = str.split("");
            str2[y - 1] = str2[y - 1].toLowerCase();
            for(String s : str2){
              System.out.print(s);
            }
        }
}

Measured memory_bytes: 21716
#include<stdio.h>

int main() {
	int n, b[100],i,flag,n2,b2[100];
	scanf("%d", &n);
	for (i = 0; i< n; i++) {
		scanf("%d", &b[i]);
	}
	for (n2 = n; n2 > 0; n2--) {
		flag = 1;
		for (i = n2; i > 0;i--) {
			if (b[i-1] == i) {
				flag = 0;
				b2[n2 - 1] = i;
				for (; i < n2; i++) {
					b[i-1] = b[i];
				}break;
			}
		}
		if (flag == 1) { break; }
	}
	if (flag) { printf("-1\n"); }
	else {
		for (i = 0; i < n; i++) {
			printf("%d\n", b2[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
  int N,i,j,x,MOD,A[200000]={0},check[200000]={0},move[200000]={0};
  long long K;
  x=scanf("%d %lld",&N,&K);
  for(i=0;i<N;i++)x=scanf("%d",&A[i]),check[i]=-1;
  for(i=0,j=0;;i=A[i]-1,j++)if(check[i]<0)check[i]=j,move[j]=i;else{x=j-1,MOD=j-check[i];break;}
  if(K>x)K=(K-x+MOD-1)%MOD+x-MOD+1;
  printf("%d\n",move[K]+1);
}

Measured memory_bytes: 4040
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>
#include <list>

using namespace std;

int main()
{
	char S[8];

	cin >> S;

	for (int i = 0; i < 4; i++)
	{
		int count = 0;
		for (int j = 0; j < 4; j++)
		{

			if (S[i] == S[j])
			{
				count++;
			}
		}

		if (count != 2)
		{
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		
		for(int i = 1; i <= n; i++) {
			
			if(i > 9) {
				System.out.println("No");
				break;
			}
			
			if(n % i == 0) {
				
				int a = n / i;
				
				if(a >= 1 && a <= 9) {
					System.out.println("Yes");
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 23892
N,M = map(int,input().split())
H = list(map(int,input().split()))
T = [[] for i in range(N+1)]
for i in range(M):
    a,b = map(int,input().split())
    T[a].append(b)
    T[b].append(a)

ans = [1]*(N+1)
for i in range(1,N+1):
    h = H[i-1]
    for c in T[i]:
        if h<=H[c-1]:
            ans[i] = 0
            break
print(sum(ans)-1)

Measured memory_bytes: 30124
import itertools

n = input()
ans =0

    
if len(n) < 3:
    ans = 0

else:
    if int('7'*len(n)) <= int(n):
        ans = 3**(len(n))- 3*2**(len(n)) + 3
    elif int('3'*len(n)) > int(n):
        ans = 0
    else:
        con = []
        for i in range(len(n)):
            con.append(0)
        con_num = []
        for i in range(3**len(n)):
            con[-1] +=1
            for j in range(len(n)-1,0,-1):
                if con[j] == 3:
                    con[j-1] +=1
                    con[j] = 0
            if con[0] == 0:
                b = '3'
            elif con[0] == 1:
                b= '5'
            elif con[0] == 2:
                b = '7'
            for j in range(1,len(n)):
                if con[j] == 0:
                    a = '3'
                elif con[j] == 1:
                    a = '5'
                elif con[j] == 2:
                    a = '7'
                b += a
            c = list(b)
            if c.count('3') != 0 and c.count('5') != 0 and c.count('7') != 0 and len(b) == len(n):
                con_num.append(int(b))
        for i in range(len(con_num)):
            if int(n) >= con_num[i]:
                ans +=1
    for i in range(3,len(n)):
        ans += 3**(i)- 3*2**(i) + 3
    

print(ans)

Measured memory_bytes: 9892
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define inf 1072114514
#define llinf 1145141919810364364
#define mod 1000000007

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    int i,j;
    char s[256];
    scanf("%s",s);
    for(i=strlen(s)-2;i>=0;i-=2){
        for(j=0;j<i/2;j++){
            if(s[j] != s[(i/2)+j]){break;}
            if(j == (i/2)-1){printf("%d\n",i);return 0;}
        }
    }
    return 0;
}

Measured memory_bytes: 128
#! usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    s = list(input())

    for i in range(3):
        if s[i] == "1":
            s[i] = "9"
        elif s[i] == "9":
            s[i] = "1"

    print("".join(s))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    for (int i = 0; i < 3000; i++){
        int x, y;
        cin >> x >> y;
        if(x == 0 && y == 0){
            return 0;
        }
        if(x > y){
            printf("%d %d", y, x);
        } else {
            printf("%d %d", x, y);
        }
        printf("\n");
    }
}



Measured memory_bytes: 3116
using System;
//using System.Collections.Generic;
//using System.Text;
using System.Linq;

class AtCoder{
  public static void Main(){

    string s = Console.ReadLine();
    bool b = true;
    string t;
    for(int i = 0; i < s.Length-1; i++){
      t = s.Substring(i + 1, s.Length-i-1);
      
      if(t.Contains(s[i])){
        b = false;
        break;
      }
    }
    
    if(b) Console.WriteLine("yes");
    else Console.WriteLine("no");
  }
}


Measured memory_bytes: 11220
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();

		String words[] = new String[n];
		for(int i= 0; i < n; i++) {
			String word = scan.next();
			if(Arrays.asList(words).contains(word)) {
				System.out.println("No");
				return;
			}
			words[i] = word;
		}
		scan.close();


		/*
		Map<String, Boolean> wordCounter= new HashMap<String, Boolean>();

		for(int i =0; i < n; i++) {
			if(wordCounter.containsKey(words[i])){
				System.out.println("No");
				return;
			}else {
				wordCounter.put(words[i], true);
			}
		}
		*/

		String endWord = words[0].substring(words[0].length()-1, words[0].length());
		for(int i = 1; i< n;i++) {
			String startWord = words[i].substring(0, 1);
			if(endWord.equals(startWord)) {
				endWord =  words[i].substring(words[i].length()-1, words[i].length());
			}else {
				System.out.println("No");
				return;
			}
		}

		System.out.println("Yes");
		return;
	}
}


Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,x,y,z,l;
  long long min,max,sum;

  vector<vector<int>> vec1(3, vector<int>(10, 0));
  vector<vector<int>> vec2(3, vector<int>(10, 0));
  vector<vector<int>> vec3(3, vector<int>(10, 0));
  vector<vector<int>> vec4(3, vector<int>(10, 0));

  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> l >> x >> y >> z;
    if(l == 1){
      vec1.at(x-1).at(y-1) += z;
    } else if(l == 2){
      vec2.at(x-1).at(y-1) += z;    
    } else if(l == 3){
      vec3.at(x-1).at(y-1) += z;   
    } else if(l == 4){
      vec4.at(x-1).at(y-1) += z;    
    }
  } 
  
  for (int i = 0; i < vec1.size(); i++) {
    for(int j = 0; j < vec1.at(0).size(); j++){
      cout << " " << vec1.at(i).at(j);
    }
    cout << endl;
  } 
  cout << "####################" << endl;

    for (int i = 0; i < vec2.size(); i++) {
    for(int j = 0; j < vec2.at(0).size(); j++){
      cout << " " << vec2.at(i).at(j);
    }
    cout << endl;
  } 
  cout << "####################" << endl;
  
    for (int i = 0; i < vec3.size(); i++) {
    for(int j = 0; j < vec3.at(0).size(); j++){
      cout << " " << vec3.at(i).at(j);
    }
    cout << endl;
  } 
  cout << "####################" << endl;
  
    for (int i = 0; i < vec4.size(); i++) {
    for(int j = 0; j < vec4.at(0).size(); j++){
      cout << " " << vec4.at(i).at(j);
    }
    cout << endl;
  } 
}


Measured memory_bytes: 3152
a=int(input())
if 400<=a<=599:
  print(8) 
if 600<=a<=799:
  print(7)
if 800<=a<=999:
  print(6)
if 1000<=a<=1199:
  print(5)
if 1200<=a<=1399:
  print(4)
if 1400<=a<=1599:
  print(3)
if 1600<=a<=1799:
  print(2)
if 1800<=a<=1999:
  print(1)

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> x(n), y(n);
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> y[i];
  }
  auto vx = x, vy = y;
  sort(begin(vx), end(vx));
  vx.erase(unique(begin(vx), end(vx)), end(vx));
  sort(begin(vy), end(vy));
  vy.erase(unique(begin(vy), end(vy)), end(vy));
  auto zip_x = [&](int e) {
    return lower_bound(begin(vx), end(vx), e) - begin(vx);
  };
  auto zip_y = [&](int e) {
    return lower_bound(begin(vy), end(vy), e) - begin(vy);
  };
  int h = vx.size(), w = vy.size();
  vector<vector<int>> cum(h + 1, vector<int>(w + 1));
  for (int i = 0; i < n; ++i) {
    ++cum[zip_x(x[i])][zip_y(y[i])];
  }
  for (int i = 0; i < h; ++i) {
    for (int j = w; j--; ) {
      cum[i][j] += cum[i][j + 1];
    }
  }
  for (int j = 0; j < w; ++j) {
    for (int i = h; i--; ) {
      cum[i][j] += cum[i + 1][j];
    }
  }
  while (m--) {
    int lx, ly, rx, ry;
    cin >> lx >> ly >> rx >> ry;
    ++rx, ++ry;
    lx = zip_x(lx), ly = zip_y(ly);
    rx = zip_x(rx), ry = zip_y(ry);
    int res = cum[lx][ly] - cum[lx][ry] - cum[rx][ly] + cum[rx][ry];
    cout << res << '\n';
  }
}



Measured memory_bytes: 100832
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>

using namespace std;

#define int long long
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll N=1e5+10,M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
const int INF=1e9+7;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}

#define trace(...) cerr<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma=strchr(names+1,',');
    cerr.write(names,comma-names)<<" : "<<arg1<<" | ";
    __f(comma+1,args...);
}

int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll h,w;
    cin >> h >> w;
    ll n;
    cin >> n;
    ll x=max(h,w);
    cout << n/x +bool(n%x);
    return 0;
}


Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = line[0];
        var b = line[1];
        if (a == "H") Console.WriteLine(b == "H" ? "H" : "D");
        else Console.WriteLine(b == "H" ? "D" : "H");
    }
}

Measured memory_bytes: 13140
N, K = map(int, input().split())
A = list(map(int, input().split()))
N = int(1e9 + 7)

ans = 0

for i, a in enumerate(A):
    L, R = 0, 0
    for j, b in enumerate(A):
        if b < a:
            if j < i:
                L += 1
            else:
                R += 1
    ans += (L + R) * K * (K - 1) // 2
    ans += R * K

ans = ans % N
print(int(ans))

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
	std::vector<int> T(3);
	int ans = 0;

	std::cin >> T[0] >> T[1] >> T[2];

	std::sort(T.begin(), T.end());

	ans = T[0] + T[1];


	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

#解説を読んで考えている。
#まず、探索範囲は ceil(√N)程度で良いとされた。
# これはxyzが1以上のため、
# x=最大,yz=1のケースでは、 x*x + 2x + 2 = N となるため。

import io
import sys
import math

def format_multi_line_answer(lst):
    ans = ""
    for y in lst:
        ans += f"{y}\n"
    return ans

#この演算fは、n+1に至るまで都度同じ計算をする。
def f(n):
    v_lst = [0] * (n+1)
    for x in range(1,105):  #ここの最適化も必須（Pythonでは？)
        for y in range(1,105):
            for z in range(1,105):
                # ここでnは f(i)ループのiに相当していた。ジャスト 時に追加する必要はない。
                # if ff(x,y,z) == n:
                v = ff(x,y,z) 
                if v <= n:  #よく見る、配列インデックスを直接キーとして利用する発想。
                    v_lst[v] += 1
    return v_lst

def ff(x,y,z):
    return x*x + y*y + z*z + x*y + y*z + z*x

def solve(n):
    # implement process
    ans_l = []
    
    # ループ処理は一回だけ通す。
    v_lst = f(n)

    # 配列に必要な値が全て乗っている
    for v in v_lst[1:]:
        ans_l.append(v)

    return format_multi_line_answer(ans_l)

def main():
    # input
    n = int(input())
    # process
    ans = str( solve(n) )
    
    # output
    print(ans)
    return ans
        
### DEBUG I/O ###
_DEB = 0   # 1:ON / 0:OFF

_INPUT = """\
"""+str(10000)

_EXPECTED = """\
0
0
0
0
0
1
0
0
0
0
3
0
0
0
0
0
3
3
0
0


"""

def logd(str):
    """usage:
    if _DEB: logd(f"{str}")
    """
    if _DEB: print(f"[deb] {str}")

### MAIN ###
if __name__ == "__main__":
    if _DEB:
        sys.stdin = io.StringIO(_INPUT)
        print("!! Debug Mode !!")

    ans = main()

    if _DEB:
        print()
        if _EXPECTED.strip() == ans.strip(): print("!! Success !!")
        else: print(f"!! Failed... !!\nANSWER:   {ans}\nExpected: {_EXPECTED}")


Measured memory_bytes: 9396
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include<vector>

using namespace std;
typedef long long ll;
//#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i =0;i<n;++i)
//#define mod (ll)(1e9+7)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    if(n%k==0){
        cout << 0 << endl;
    }else{
        cout << 1 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int L,R,d;
    scanf("%d %d %d",&L,&R,&d);
    int ans = 0;
    while (L <= R)
    {
        if (L % d == 0)
        {
            ans++;
        }
        L++;        
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 1724
import java.util.*;
 
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[]A = new int[N];
    
    for(int i=0; i<N; i++){
    A[i] = sc.nextInt();
}
    Arrays.sort(A); 	
        System.out.println(A[N-1]-A[0]);
}
}

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

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  vector<int> dp(N, 0);
  rep(i, N) cin >> h.at(i);

  dp.at(0) = 0;
  dp.at(1) = abs(h.at(1) - h.at(0));
  for(int i = 2; i < N; ++i){
    int mn = 0x7fffffff;
    for(int j = i-1; max(i-K,0) <= j; --j){
      mn = min(mn, dp.at(j) + abs(h.at(i) - h.at(j)));
    }
    dp.at(i) = mn;
  }
  cout << dp.at(N-1) << endl;
  return 0;
}

Measured memory_bytes: 1024
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define setbit(x) __builtin_popcount(x)
#define fff(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}
 
int32_t main() {
    fio
    
    int r;
    cin >> r;
    cout << r*r ;


	return 0;
    
}

Measured memory_bytes: 8832