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 a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int e = sc.nextInt();
        int f = sc.nextInt();
        sc.close();

        double sugar_max = (e * f) / (100 + e);
        int sugar_c_max = (int)Math.floor(sugar_max / c);
        int sugar_d_max = (int)Math.floor(sugar_max / d);
        int water_a_max = (int)Math.floor(f / (100 * a));
        int water_b_max = (int)Math.floor(f / (100 * b));
        int sugar = 0;
        int water = 0;
        double con = 0;
        double con_max = (double)e / ((double)e + (double)100);
        for (int i = 0; i <= water_b_max; i++) {
            for (int j = 0; j <= water_a_max; j++) {
                double water_weight = 100 * b * i + 100 * a * j;
                if (water_weight > f) break;

                for (int m = 0; m <= sugar_d_max; m++) {
                    double sugar_weight = m * d;
                    if (water_weight + sugar_weight > f) break;

                    for (int n = 0; n <= sugar_c_max; n++) {
                        sugar_weight = m * d + n * c;
                        if (water_weight + sugar_weight > f) break;
                        double con_temp = sugar_weight / (sugar_weight + water_weight);
                        if (con_temp > con_max) break;
                        if (con_temp >= con) {
                            con = con_temp;
                            sugar = (int)sugar_weight;
                            water = (int)water_weight;
                        }
                    }
                }
            }
        }
        System.out.println((sugar + water) + " " + sugar);
    }
}


Measured memory_bytes: 24148
//Littleboy123 Template 1.7
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

//pragmas

// #pragma comment(linker, "/stack:200000000")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")t
// #pragma GCC optimization ("unroll-loops")


typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef unsigned long long int ull;
typedef long double ld;
typedef unsigned long long ull;

const long double pi = acos(-1.0);

#define FOR(a,b,c) for(int (a)=(b);(a)<(c);++(a))
#define FORE(a,b,c) for(int (a)=(b);(a)<=(c);++(a))
#define FORN(a,b,c) for(int (a)=(b);(a)>(c);--(a))
#define FORNE(a,b,c) for(int (a)=(b);(a)>=(c);--(a))
#define TC(n) cout << "Case #" << (n) << ": "
#define DEBUG(x) cout << "DEBUG " << #x << ' ' << x << '\n';
#define MEM(a,b) memset((a), (b), sizeof((a)))
#define MAX(a,b) (a) = max((a), (b))
#define MIN(a,b) (a) = min((a), (b))
#define nl '\n'
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>

void init(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

void infile(){
    freopen("walk.in", "r", stdin);
}

void outfile(){
    freopen("output.txt", "w", stdout);
}

ll modex(ll a, ll b, ll mod){
    if(b == 0)
        return 1;
    if(b == 1)
        return a;
    ll tmp = modex(a, b/2LL, mod);
    tmp = (tmp * tmp) % mod;
    if(b & 1LL)
        tmp = (tmp * a) % mod;
    return tmp;
}

ll ex(ll a, ll b){
    if(b == 0)
        return 1;
    if(b == 1)
        return a;
    ll tmp = ex(a, b/2LL);
    tmp = (tmp * tmp);
    if(b & 1LL)
        tmp = (tmp * a);
    return tmp;
}

//End of template

int main(){
    init();

    ll n;
    cin >> n;
    int cnt = 0;
    FORE(i, 1, n){
        FORE(j, 1, n/i){
            if(i * j < n){
                cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


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

int main(){
	string back;
	cin >> back;
	int q;
	cin >> q;
	string front;
	rep(i,q){
		int t;
		cin >> t;
		if(t == 1){
			swap(back, front);
		}
		else{
			int f; char c;
			cin >> f >> c;
			if(f == 1){
				front += c;
			}else{
				back += c;
			}
		}
	}
	reverse(front.begin(), front.end());
	front += back;
    cout << front << endl;
  return 0;
}



Measured memory_bytes: 1128
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <math.h>
#define rep(i,n) for(int i = 0; i <(n); i++)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

int main(void) {
	ll i, j, k,tmp;
	vector<ll>dp;
	vector<ll>h;
	ll N;
	scanf("%lld", &N);
	for (i = 0; i < N; i++) {
		scanf("%lld", &tmp);
		h.push_back(tmp);
		dp.push_back(INF);
	}
	dp.push_back(0);
	dp.push_back(0);
	h.push_back(0);
	h.push_back(0);
	dp.at(0LL) =0;
	for (i = 0; i < N; i++) {
		chmin(dp.at(i + 1), dp.at(i) + abs(h.at(i) - h.at(i + 1LL)));
		chmin(dp.at(i + 2), dp.at(i) + abs(h.at(i) - h.at(i + 2LL)));
	}
	/*
	dp.at(1LL) = abs(h.at(1) - h.at(0));
	for (i = 2LL; i < N; i++) {
		chmin(dp.at(i), dp.at(i - 1LL) + abs( h.at(i) - h.at(i - 1LL)));
		chmin(dp.at(i), dp.at(i - 2LL) + abs( h.at(i) - h.at(i - 2LL)));
	}
	*/

	printf("%lld\n", dp.at(N - 1));
	return 0;
}

Measured memory_bytes: 2036
#include <iostream>
#include <string>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;

int main(){
  int H, W, N;
  cin >> N >> H >> W;
  int ret = (N - H + 1) * (N - W + 1);
  cout << ret << endl;
}

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

int dp[100007];
int dfs(vector<vector<int>>&adj, int s){

	if(dp[s]!=-1) return dp[s];
	if(adj[s].size()==0) {
		dp[s]=0;
		return 0;
	}
	int height=0;
	for(int i: adj[s]){

			height = max(height,dfs(adj, i));

	}

	dp[s]= height+1;
	return height+1;
	
}
int main(){
	memset(dp, -1, sizeof(dp));
	int n, m;
	cin>>n>>m;
	n; m;
	vector<vector<int>>adj(n);
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		x--;y--;
		adj[x].push_back(y);
	}

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

			ans= max(ans, dfs(adj, i));

	}
	cout<<ans<<endl;
	return 0;
	
	
}


Measured memory_bytes: 10996
#include<iostream>
using namespace std;
 
int data[10];
 
bool solve(int i, int a, int b){
 
  if(i == 10) return true;
 
  if(data[i] > a) return solve(i+1, data[i], b);
  if(data[i] > b) return solve(i+1, a, data[i]);
  if(data[i] < a>b?b:a) return false;
  
}
 
int main(){
 
  int n;
 
  cin >> n;
  while(n--){
 
    for(int i=0;i<10;i++) cin >> data[i];
 
    cout << (solve(0, 0, 0)?"YES\n":"NO\n");
 
  }
 
}

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

using namespace std;

int main() {
  int matrix[3][3];
  
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      int in = 0;
      
      cin >> in;
      
      matrix[i][j] = in;
    }
  }
  
  int N;
  
  cin >> N;
  
  for (int k = 0; k < N; k++) {
    int in = 0;
    cin >> in;
    
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        if (matrix[i][j] == in) {
          matrix[i][j] = -1;
        }
      }
    }
  }
  
  bool ans = false;
  for (int i = 0; i < 3; i++) {
    if (!ans) {
      if (matrix[i][0] == -1 && matrix[i][1] == -1 && matrix[i][2] == -1) {
        ans = true;
      }
      
      if (matrix[0][i] == -1 && matrix[1][i] == -1 && matrix[2][i] == -1) {
        ans = true;
      }
    }
  }
  
  if (!ans) {
    if ((matrix[0][0] == - 1 && matrix[1][1] == -1 && matrix[2][2] == -1)
    ||  (matrix[2][0] == - 1 && matrix[1][1] == -1 && matrix[0][2] == -1)) {
      ans = true;
    }
  }
  
  cout << (ans ? "Yes" : "No") << endl;
  
  return 0;
}

Measured memory_bytes: 256
n = int(raw_input())
a = [0 for _ in range(5)]
for _ in range(n):
  s = raw_input()
  if s[0] == 'M':
    a[0] += 1
  elif s[0] == 'A':
    a[1] += 1
  elif s[0] == 'R':
    a[2] += 1
  elif s[0] == 'C':
    a[3] += 1
  elif s[0] == 'H':
    a[4] += 1
ct = 0
for i in range(5):
  for j in range(i+1,5):
    for k in range(j+1,5):
      ct += a[i] * a[j] * a[k]
print ct


Measured memory_bytes: 5764
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools



#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]

S = str(input())
T = str(input())
for i in range(len(S)):
    if(S[i] != T[i]):
        print("No")
        break
    elif(i==len(S)-1):
        print("Yes")
        break
ans = 0


#print(ans)


Measured memory_bytes: 75024
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class ATherefore {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N;
        in>>N;
        N %= 10;
        if(N==3) out<<"bon\n";
        else if(N<=1 or N==6 or N==8) out<<"pon\n";
        else out<<"hon\n";
    }
};


int main() {
	ATherefore solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3612
MOD = 10 ** 9 + 7

n, k = map(int, input().split())
alst = list(map(int, input().split()))

alst.sort()

if n == k:
    ans = 1
    for num in alst:
        ans *= num
        ans %= MOD
    print(ans)
    exit()

if k == 1:
    print(alst[-1] % MOD)
    exit()

if alst[0] >= 0:
    ans = 1
    alst.sort(reverse = True)
    for i in range(k):
        ans *= alst[i]
        ans %= MOD
    print(ans)
    exit()

if alst[-1] <= 0:
    ans = 1
    if k % 2 == 1:
        alst = alst[::-1]
    for i in range(k):
        ans *= alst[i]
        ans %= MOD
    print(ans)
    exit()

blst = []
for num in alst:
    try:
        blst.append([abs(num), abs(num) // num])
    except ZeroDivisionError:
        blst.append([abs(num), 0])
blst.sort(reverse = True,key = lambda x:x[0])
if blst[k - 1] == 0:
    print(0)
    exit()
    
minus = 0
last_minus = 0
last_plus = 0
ans_lst = []
for i in range(k):
    if blst[i][1] == -1:
        minus += 1
        last_minus = blst[i][0]
    elif blst[i][1] == 1:
        last_plus = blst[i][0]
    else:
        print(0)
        exit()
    ans_lst.append(blst[i][0])

next_minus = 0
next_plus = 0
flg_minus = False
flg_plus = False

for i in range(k, n):
    if blst[i][1] == -1 and (not flg_minus):
        next_minus = blst[i][0]
        flg_minus = True
    if blst[i][1] == 1 and (not flg_plus):
        next_plus = blst[i][0]
        flg_plus = True
    if (flg_plus and flg_minus) or blst[i][1] == 0:
        break

if minus % 2 == 0:
    ans = 1
    for num in ans_lst:
        ans *= num
        ans %= MOD
    print(ans)

else:
    minus_s = last_minus * next_minus
    plus_s = last_plus * next_plus
    ans = 1
    if minus == k:
        ans_lst.remove(last_minus)
        ans_lst.append(next_plus)
    elif minus_s == plus_s == 0:
        if next_minus == 0:
            ans_lst.remove(last_minus)
            ans_lst.append(next_plus)
        else:
            print(0)
            exit()
        
    elif minus_s > plus_s:
        ans_lst.remove(last_plus)
        ans_lst.append(next_minus)
    else:
        ans_lst.remove(last_minus)
        ans_lst.append(next_plus)
    for num in ans_lst:
        ans *= num
        ans %= MOD
    print(ans)


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(int x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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

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

int main() {
  int N;
  cin >> N;
  int T, A;
  cin >> T >> A;
  T *= 1000;
  A *= 1000;

  int min_t = INT_MAX;
  int ans;
  int H;
  rep(i, 1, N+1) {
    cin >> H;
    int temp = T - H * 6;
    if (abs(A - temp) < min_t) {
      min_t = abs(A - temp);
      ans = i;
    }
  }

  cout << ans << endl;
};


Measured memory_bytes: 256
MM = input().split()
A = int(MM[0])
B = int(MM[1])
K = int(MM[2])
MM = set()
for i in range(A, A+K):
  if i <= B:
    MM.add(i)
for i in reversed(range(B-K+1,B+1)):
  if i >= A:
    
    MM.add(i)

MM = sorted(MM)

for i in MM:
  print(i)

Measured memory_bytes: 9184
#!/usr/bin/env python3

N = int(input())
S = input()

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

w_c = S.count('W')
e_c = S.count('E')
if S[0] == 'W':
    P[0] = {'W_l':0, 'W_r':w_c-1, 'E_l':0, 'E_r':e_c}
else:
    P[0] = {'W_l':0, 'W_r':w_c, 'E_l':0, 'E_r':e_c-1}


for i in range(1, N):
    b = P[i-1]
    if S[i] == 'W':
        if S[i-1] == 'W':
            P[i] = {'W_l':b['W_l']+1, 'W_r':b['W_r']-1, 'E_l':b['E_l'], 'E_r':b['E_r']}
        else:
            P[i] = {'W_l':b['W_l'], 'W_r':b['W_r']-1, 'E_l':b['E_l']+1, 'E_r':b['E_r']}

    else: # S[i] == 'E'
        if S[i-1] == 'W':
            P[i] = {'W_l':b['W_l']+1, 'W_r':b['W_r'], 'E_l':b['E_l'], 'E_r':b['E_r']-1}
        else:
            P[i] = {'W_l':b['W_l'], 'W_r':b['W_r'], 'E_l':b['E_l']+1, 'E_r':b['E_r']-1}


ans = 10**9
for i in range(N):
    ans = min(P[i]['W_l']+P[i]['E_r'], ans)
print(ans)


Measured memory_bytes: 114084
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll h,n,a,s=0;cin>>h>>n;
  rep(i,n) {cin>>a;s+=a;}
  if(s>=h) puts("Yes");else puts("No");
  return 0;
}

Measured memory_bytes: 256
/*************************************************************************
> File Name: test.cpp
> Author: Akira 
> Mail: qaq.febr2.qaq@gmail.com 
************************************************************************/

#include<bits/stdc++.h>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))
#define ALL(a) a.begin(), a.end()
#define mp make_pair
#define pb push_back
using namespace std;

#define MaxN 200005
#define MaxM MaxN*10
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
const int mod = 1E9+7;
const double eps = 1e-6;
#define bug cout<<88888888<<endl;
#define debug(x) cout << #x" = " << x << endl;
template<typename T> T abs(T val){return val>0?val:-val;}
inline int max2(int a, int b) {return ((a > b)? a : b);}
inline int min2(int a, int b) {return ((a < b)? a : b);}
inline int max3(int a, int b, int c) {return max2(a, max2(b, c));}
inline int min3(int a, int b, int c) {return min2(a, min2(b, c));}
template <class T> inline void read(T &ret) {char c; ret=0;while((c=getchar())<'0'||c>'9');while(c>='0'&&c<='9') ret=ret*10+(c-'0'),c=getchar();}
template <class T> inline void out(T x) {if(x>9) out(x/10);putchar(x%10+'0');}

char str[MaxN];
int loc[MaxN][26], to[26], cost[MaxN];
void solve()
{
	int len = strlen(str);
	for(int i=0;i<26;i++) to[i] = len+1;
	for(int i=len;i>=0;i--)
	{
		memcpy(loc[i], to, sizeof(to));
		to[str[i-1]-'a'] = i;
	}
	for(int i=len;i>=0;i--)
	{
		cost[i] = len+3;
		for(int j=0;j<26;j++)
		{
			cost[i] = min(cost[i], cost[loc[i][j]]+1);
		}
	}
	int u = 0,v;
	while(u!=len+1)
	{
		for(v=0;v<26;v++)
		{
			if(cost[u]==cost[loc[u][v]]+1) break;
		}
		printf("%c", v+'a');
		u = loc[u][v];
	}
	puts("");
}
int main()
{
	while(~scanf("%s", &str))
		solve();
}


Measured memory_bytes: 21504
#include <cstdio>
#include <algorithm>

using namespace std;

int T,N;
int shelves[40000];
int mincost[10000][3];

int bookstate(int n){
  if(n == 0)
    return shelves[0] + shelves[2*N]*2;
  else if(n == N)
    return shelves[2*N-1] + shelves[4*N-1]*2;
  else
    return (shelves[n*2-1] || shelves[n*2]) + (shelves[2*N+n*2-1] || shelves[2*N+n*2])*2;
}

int cost(int from, int to, int n){
  from *= 2;
  to *= 2;
  switch(bookstate(n)){
  case 0:
    return abs(from-to)/2;
  case 1:
    return (abs(from-1)+abs(to-1))/2;
  case 2:
    return (abs(from-3)+abs(to-3))/2;
  case 3:
    return 1+min(abs(from-1)+abs(to-3),abs(from-3)+abs(to-1))/2;
  default:
    return 1000;
  }
}

int main(){
  scanf("%d\n",&T);

  while(T--){
    scanf("%d\n",&N);

    for(int i=0; i<4*N; i++){
      shelves[i] = (getchar()=='Y')?1:0;
    }

    mincost[0][0] = cost(0,0,0);
    mincost[0][1] = cost(0,1,0);
    mincost[0][2] = cost(0,2,0);

    for(int n=1; n<=N; n++){
      for(int to=0; to<3; to++){
	mincost[n][to] = 1000000;
	for(int from=0; from<3; from++){
	  mincost[n][to] = min(mincost[n][to],mincost[n-1][from]+cost(from,to,n));
	}
      }
    }

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

Measured memory_bytes: 1296
#include<stdio.h>
#include<string.h>
 
int main(){
	int a;
  	char s[5];
  	scanf("%s", s);
	if(strcmp(s,"SUN")==0){  
  	a=7;
    } else if(strcmp(s,"MON")==0){
    a=6;  
    } else if(strcmp(s,"TUE")==0){
    a=5;  
    } else if(strcmp(s,"WED")==0){
    a=4;  
    } else if(strcmp(s,"THU")==0){
    a=3;  
    } else if(strcmp(s,"FRI")==0){
    a=2;  
    } else if(strcmp(s,"SAT")==0){
    a=1;
    }
      
  	printf("%d",a);
  
  return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;

#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define f first
#define ss second

template<class T> bool remin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool remax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

void solve_case() {
    // :pray: :fishy: :orz:
    int n,i,j,m;
    cin >> n;
    if(n>=30) cout << "Yes\n";
    else cout << "No\n";
}

signed main() {
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.tie(0);
    int Testcases = 1;
    //std::cin >> Testcases;
    while(Testcases--) {
        solve_case();
    }
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    int d=sqrt(m),ans=0;
    for(int i=1;i<=d;i++)
    {
        if(m%i==0)
        {
            int temp=m/i;
            if(i>=n)
                ans=max(ans,temp);
            if(m/i>=n) ans=max(ans,i);
        }
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

# コインの組み合わせを手持ちのもので組める限りすべて探索する
ans = 0
for i in range(A + 1):  # 実は、range関数は　0から引数-1まで　の値を格納したリスト
    for j in range(B + 1):
        for k in range(C + 1):
            x = 500*i + 100*j + 50*k
            if x == X:
               ans += 1

print(ans)     

Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
#include<vector>
#include<utility>

using namespace std;
typedef long long ll;

int main(void){
  ll n,p;
  cin >> n >> p;
  if( n == 1){
    cout << p << endl;
    return 0;
  }
  vector< pair<ll, ll> > factor(sqrt(p));
  for( ll i=2; i<= sqrt(p); ++i){
    ll count = 0;
    while( (p % i) == 0){
      ++count;
      p /= i;
    }
    if( count != 0){
      factor.push_back(make_pair(i, count));
    }
  }
  ll ret=1;
  for( vector< pair<ll, ll> >::iterator itr=factor.begin(); itr!=factor.end(); ++itr){
    //if( (*itr).second > 0) cout << (*itr).second / n << endl;
    if( ((*itr).second / n) >= 1){
      ret *= (ll)pow(((*itr).first),((*itr).second / n))  ;
    }
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 32384
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

int main() {
    int N; cin >> N;
    int a[N], b[N], c[N];
    for (int i=0; i<N; i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    int dp[N][3];
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    for (int i=1; i<N; i++){
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i];
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i];
    }
    cout << max({dp[N-1][0], dp[N-1][1], dp[N-1][2]}) << endl;
}

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

int main(){
  int n, a, b; cin >> n >> a >> b;
  int c = a + b, num = 0, sumb = 0;
  string s; cin >> s;
  for(int i = 0; i < n; i++){
    if(s.at(i) == 'a' && num < c){
      num++; cout << "Yes" << endl;
    }
    else if(s.at(i) == 'b'){
      sumb++;
      if(num < c && sumb <= b){
        num++; cout << "Yes" << endl;
      }
      else cout << "No" << endl;
    }
    else cout << "No" << endl;
  }  
}  

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

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

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

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
#define all(x) x.begin(),x.end()
typedef pair<int,pi> pp;
#define p(x,y,z) pp(z,pi(x,y))


int h1,s1,h2,s2;

int32_t main() {
	cin >> h1 >> s1 >> h2 >> s2;
	bool flip = true;
	while (h1 > 0 and h2 > 0) {
		if (flip) h2 -= s1;
		else h1 -= s2;
		flip = !flip;
	}
	if (h1 <= 0) cout << "No";
	else cout << "Yes";
}




Measured memory_bytes: 3636
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = a;i < n;i++)
	
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
	int a,b,k,temp;
	cin >> a >> b >> k;
	
	rep(i,0,k){
		
		if(i % 2 == 0){
			if(a % 2){
				a--;
			}
			a /= 2;
			b += a;
		}
		else{
			if(b % 2){
				b--;
			}
			b /= 2;
			a += b;
		}
	}
	
	cout << a << " " <<  b << endl;
  	return 0;
}





Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>

using namespace std;

int main(){
    map<string, int> memo;
    
    int n;
    cin >> n;

    for(int i=0; i<n; i++){
        string s;
        cin >> s;
        memo[s] += 1;
    }

    int maxv=0;
    for(auto x : memo){
        int v = x.second;
        if(v>maxv) maxv = v;
    }
    for(auto it = memo.begin(); it != memo.end(); it++){
        if(it->second == maxv){
            cout << it->first << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
 
#define Set(a, b) memset(a, (b), sizeof(a))
#define F first
#define S second
#define FT front()
#define BK back()
#define PB push_back
#define MP make_pair
#define repi(i, l, r) for (int i=l ; i <= (int)(r) ; ++i)
#define repd(i, r, l) for (int i=r ; i >= (int)(l) ; --i)
#define repv(x, v) for (auto (x) : v)
#define all(cont) cont.begin(), cont.end()
#define Sort(n) sort(all(n))
#define Sortcmp(n) sort(all(n), cmp)
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define nl "\n"

using namespace std;

bool cmp(const pair<long,long> &a,
              const pair<long,long> &b)
{
    return (a.second < b.second || (a.second == b.second && a.first < b.first));
}

bool binarySearch(int arr[], int n, int x){
    int k = 0;
    for (int b = n/2; b >= 1; b/2)
        while (k+b < n && arr[k+b] <= x) k += b;

    if (arr[k] == x) return k;
    return -1;
}

/* ASCII Table */
/* 48 == '0', 57 = '9', 65 == 'A', 90 == 'Z', 97 == 'a', 122 == 'z' */  

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

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    string s;

    cin >> s;

    if(s.length() == 3){
        repd(i, s.length()-1, 0)
            cout << s[i];
    } else {
        cout << s;
    }

    cout << nl;

}

/* Compile */
// g++ -std=c++11 -O2 -Wall test.cpp -o test
 
 
/* Source code dengan case
 
int main(){
    int T;
    cin >> T;
    for(int counterT = 1 ; counterT <= T ; T++){
         
        printf("%d\n", ans);
    }
    return 0;
}
 */
 
/* Source code dengan case
 
int main(){
    int T;
    cin >> T;
    for(int counterT = 1 ; counterT <= T ; T++){
         
        printf("Case #%d: %d\n", counterT, ans);
    }
    return 0;
}
 */

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

public class Main{

	
	public static void main(String[] args){
	
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		//int K = stdIn.nextInt();
		//int ans = 0;
		int[] A = new int[N];
		int[] ans = new int[N];

		for(int i = 0;i < N;i++){
			A[i] = stdIn.nextInt() - 1;
			ans[A[i]] = i + 1;
		}

		
		for(int i = 0;i < N;i++){
			System.out.print(ans[i] + " ");
		}
	}
}

Measured memory_bytes: 61372
#include <iostream>
#include <ctype.h>
using namespace std;

int main(){
    char ch;
    int count[26]= {};
    while(cin >> ch){
        ch = tolower(ch);
        int num = ch - 'a';
        count[num]++;
    }
    for(int i=0; i<26; i++){
        cout << (char)('a' + i) << " : " << count[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 1140
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 10000)

func readLine() string {
	buf := make([]byte, 0, 10000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func main() {
	in := readLine()
	ins := strings.Split(in, " ")

	n, _ := strconv.Atoi(ins[0])
	a, _ := strconv.Atoi(ins[1])
	b, _ := strconv.Atoi(ins[2])

	den := n * a
	tax := b
	if den > b {
		fmt.Println(tax)
	} else {
		fmt.Println(den)
	}
}


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

int main(){
	int y;
	char S[3];
	y = 700;
	cin >> S[1] >> S[2] >> S[3];
	for(int i = 0;i < 4; i++){
		if(S[i] == 'o'){
			y += 100;
		}else{
			y += 0;
		}
	}
	cout << y ;
	return 0;
}

Measured memory_bytes: 256
let n = stdin.ReadLine() |> int
let a = stdin.ReadLine().Split(' ') |> Array.map int
let b = stdin.ReadLine().Split(' ') |> Array.map int
let c = stdin.ReadLine().Split(' ') |> Array.map int

let x = Array.sum b

(
 [1..(n-1)]
 |>List.sumBy (fun x -> if a.[x-1]+1=a.[x] then c.[a.[x-1]-1] else 0)
)
+ x
|>stdout.WriteLine

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

A, B = [int(x) for x in input().split()]

if A % 3 == 0:
    print ("Possible")
elif B % 3 == 0:
    print("Possible")
elif (A + B) % 3 == 0:
    print("Possible")
else:
    print("Impossible")


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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<double> v_double;
typedef std::vector<std::vector<double> > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 

int main(void)
{
    ll n, h;
    cin >> n >> h;
    
    v_ll b(n);
    ll max_a = -1;

    irep(i, n) {
        ll a; 
        cin >> a >> b[i];
        if(a > max_a) { max_a = a; }
    }

    sort(b.rbegin(), b.rend());

    ll ans = 0;
    irep(i, n) {
        if(max_a >= b[i] || h <= 0) { break; }
        h -= b[i];
        ans++;
    }

    if(h>0) {
        ans += (h+max_a-1)/max_a;
    }

    cout << ans << endl;
    return 0;
}
/** atcoder **/


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

int main(){
    int n;
    cin >> n;
    vector<vector<int>> a(2,vector<int>(n));
    for(int i = 0;i < 2;i++){
        for(int j = 0;j < n;j++){
            cin >> a[i][j];
        }
    }
    vector<int> s_upper(n+1,0),s_lower(n+1,0);
    for(int i = 0;i < n;i++){
        s_upper[i+1] = s_upper[i] + a[0][i];
        s_lower[i+1] = s_lower[i] + a[1][i];
    }
    int ans = s_upper[n] + a[1][n-1];
    for(int i = 0;i < n-1;i++){
        ans = max(ans,s_upper[i+1] + s_lower[n] - s_lower[i]);
    }
    cout << ans << endl;
}

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

int main() {
  int K;
  cin >> K;
  if (K%2==0) {
    cout << (K*K)/4 << endl;
  }
  else {
    cout << ((K+1)*(K-1))/4 << endl;
  }
}


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

int main(){
    int64_t n, a, b;
    cin >> n >> a >> b;
    if ((b - a) & 1){
        cout << min(n - (a + b - 1) / 2, (a + b - 1) / 2) << endl;
    } else {
        cout << (b - a) / 2 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int dp[200005];

int main(){
  int N;
  cin >> N;
  vector<int> v;
  rep(i,N){
    int a;
    cin >> a;
    v.push_back(a);
  }

  rep(i,200005) dp[i] = -1;

  rep(i,N){
    if(dp[v[i]] != -1) continue;
    if(v[i] == 1){
      dp[1] = i;
    }else{
      if(dp[v[i]-1] != -1){
        dp[v[i]] = i;
      }
    }
  }

  int mx = -1;
  REP(i,1,N+1){
    if(dp[i] != -1) mx = max(mx, i);
  }

  if(mx == -1) cout << -1 << endl;
  else cout << N - mx << endl;
  
  return 0;
}



Measured memory_bytes: 1908
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
	int n, mm, m, i, t, c, tintin;
	scanf("%d %d", &n, &mm);

	vector<int> point;

	m = mm-1;

	c = 0;

	for(i = 0;i < mm;++i){
		scanf("%d %d", &t, &tintin);
		if(t >= n){
			--m;
		}else{
			point.push_back(t);
		}
	}

	sort(point.begin(), point.end());
	reverse(point.begin(), point.end());

	i = 0;
	while(m > 0){
		c += n - point[i];
		++i;
		--m;
	}

	printf("%d\n", c);

	return 0;
}

Measured memory_bytes: 2816
n=int(input())
towns=[None]*n
for i in range(n):
  x,y=map(int,input().split())
  towns[i]=[x,y]
routes=0
import math
for i in range(len(towns)):
  for j in range(i+1,len(towns)):
    routes+=math.sqrt((towns[i][0]-towns[j][0])**2+(towns[i][1]-towns[j][1])**2)

# routes 全ルートの合計
if n==2:
  print(routes)
else:
  print(routes*2/n)


Measured memory_bytes: 3064
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int k, a, b;
	cin >> k >> a >> b;
	repn(i, a, b + 1){
		if(i % k == 0){
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 3604
// finish date: 2018/06/06
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define pii pair<int,int>
const int bigmod = 1000000007;
#define INF 1050000000


int main() {
    int N;
    cin >> N;
    int ans = INF;
    FOR(i, 1, N / 2 + 1) {
        int A = i;
        int B = N - A;
        int sum = 0;
        while (A != 0) {
            sum += A % 10;
            A /= 10;
        }
        while (B != 0) {
            sum += B % 10;
            B /= 10;
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;

    return 0;
}





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

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

Measured memory_bytes: 3916
#include<bits/stdc++.h>
#define ll long long
#define fo(i,n) for(int i=0;i<n;i++)
#define rfo(i,n) for(int i=n-1;i>=0;i--)
#define Fo(i,q,n) for(int i=q;i<n;i++)
#define rFo(i,q,n) for(int i=n-1;i>=q;i--)
#define fO(i,n,k) for(int i=0;i<n;i+=k)
#define FO(i,q,n,k) for(int i=q;i<n;i+=k)
#define zero(a,n) memset(a,0,sizeof(a[0])*n)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define Endl "\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
using namespace std;
const int MOD=1000000007;
void print(){cout <<endl;}
template <typename T, typename... Types> 
void print(T var1, Types... var2){cout << var1 << " " ;print(var2...) ;}
//ceil of a/b
template <typename T>
T fceil(T a,T b){return (T)(a+b-1)/b;}
template <typename T>
void printvec(vector<T> v){ for(int i=0;i<(int)v.size();i++){ cout<<v[i]<<" ";} cout<<endl;}
template <typename T>
void printarr(T a[],int n){ for(int i=0;i<n;i++){ cout<<a[i]<<" ";} cout<<endl;}
//const int N=2e5;
//int arr[N+1];

 
int main(){
	int d,t,s;
	cin>>d>>t>>s;
	if(fceil(d,s)<=t){cout<<"Yes"<<Endl;}
	else{cout<<"No"<<endl;}
	return 0;
}






/*NOTE: Take MOD after sorting and not before sorting!*/


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int,int>;

int main(){
    int n;
    cin >> n;
    vector<p> ratio;
    for(int i = 0; i < n; i++){
        int t, a;
        cin >> t >> a;
        ratio.push_back(p(t, a));
    }
    ll ans = 0;
    ll tt = 1, aa = 1;
    for(int i = 0; i < n; i++){
        ll n, tmpt = ratio[i].first, tmpa = ratio[i].second;
        n = max((tt + tmpt - 1)/tmpt, (aa + tmpa - 1)/tmpa);
        tt = n*tmpt;
        aa = n*tmpa;
    }
    cout << tt + aa << endl;
}


Measured memory_bytes: 3560
//Program.cpp
//Author : Aaryan Srivastava 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#define pb push_back
#define popb pop_back
#define ull unsigned long long  
#define beg begin
#define mp make_pair
#define pii pair<int, int>
#define piii pair<pii,int>
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define ff first
#define ss second 
#define fill(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
using ll = long long;
#define int ll
const int N = 2*1e5 +5 ;
const int mod = 1e9 + 7 ;
const int inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace std;

#ifdef AaryanS
#define mycout cout
#define mycerr cerr 
#endif

#ifndef AaryanS
#define mycout if(false) cout
#define mycerr if(false) cerr
#define AaryanS 0 
#endif


void solve()
{
    int a,b,t ;
    cin >> a >>b >> t ;
    for(int i = 0 ; i <= 100 ; ++i){
        if(a*(i) > t) {
            cout << b*(i-1) ;
            return ;
        }
    }
}   

     
int32_t main(int32_t argc, char *argv[])
{
    double t1 = clock() ;
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case " << t << ":\n" ;
        solve();
    }
    mycerr << "Time : " << 1000 *(clock() - t1)/CLOCKS_PER_SEC << " ms\n" ;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define PRIM 3
#define INF (1 << 29)
#define LINF (1LL << 60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;

Int R, C, K, r, c, v;
Int values[3000][3000];
Int dp[3000][3000][4];

int main()
{
    cin >> R >> C >> K;
    for (int i = 0; i < K; i++) {
        cin >> r >> c >> v;
        r--, c--;
        values[r][c] = v;
    }
    dp[0][0][1] = values[0][0];
    for (int i = 0; i < R; i++) {
        for (int j = 0; j < C; j++) {
            for (int k = 0; k < 4; k++) {
                if (i + 1 < R) {
                    dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][k]);
                    dp[i + 1][j][1] =
                        max(dp[i + 1][j][1], dp[i][j][k] + values[i + 1][j]);
                }
                if (j + 1 < C) {
                    dp[i][j + 1][k] = max(dp[i][j + 1][k], dp[i][j][k]);
                    if (k + 1 <= 3) {
                        dp[i][j + 1][k + 1] =
                            max(dp[i][j + 1][k + 1],
                                dp[i][j][k] + values[i][j + 1]);
                    }
                }
            }
        }
    }
    cout << *max_element(dp[R - 1][C - 1], dp[R - 1][C - 1] + 4) << endl;
    return 0;
}

Measured memory_bytes: 354560
import java.util.Scanner;

public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static long res = 0;
    public static int[] ary;
    public static void main(String[] args) throws Exception {
        int w = sc.nextInt();
        ary = new int[w+1];
        for (int i = 0; i <= w; i++) {
            ary[i] = i;
        }
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            String[] s = sc.next().split(",");
            int a = Integer.parseInt(s[0]);
            int b = Integer.parseInt(s[1]);
            int t = ary[a];
            ary[a] = ary[b];
            ary[b] = t;
        }
        
        for (int i = 1; i <= w; i++) {
            System.out.println(ary[i]);
        }
    }
}

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

using namespace std;

int N, A[3][3], b[10];
bool appear[3][3];
int main() {
    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) 
            cin >> A[i][j];
    }
    cin >> N;
    for(int i = 0; i < N; i++) 
        cin >> b[i];
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            appear[i][j] = false;
            for(int k = 0; k < N; k++) {
                if(A[i][j] == b[k]) appear[i][j] = true;
            }
        }
    }
    string ANS = "No";
    for(int i = 0; i < 3; i++) {
        if(appear[i][0] and appear[i][1] and appear[i][2]) ANS = "Yes";
    }
    for(int i = 0; i < 3; i++) {
        if(appear[0][i] and appear[1][i] and appear[2][i]) ANS = "Yes";
    }
    if(appear[0][0] and appear[1][1] and appear[2][2]) ANS = "Yes";
    if(appear[0][2] and appear[1][1] and appear[2][0]) ANS = "Yes";
    cout << ANS << endl;
    return 0;
}

Measured memory_bytes: 3620
N = int(input())
S = [input() for i in range(N)]

xs1total = 0 # ((
xs2 = [] # )((
xs3 = [] # ))(
xs4total = 0 # ))

for s in S:
    n = 0
    m = 0
    for c in s:
        if c == "(":
            n += 1
        elif c == ")":
            n -= 1
            m = min(m, n)
    k = n - m
    if m == 0 and k == 0:
        continue
    elif m == 0:
        xs1total += k
    elif k == 0:
        xs4total += -m
    else:
        if -m < k:
            xs2.append((-m, k))
        else:
            xs3.append((-m, k))

xs2.sort()
xs3.sort(key=lambda x:-x[1])

def check(xs1total, xs2, xs3, xs4total):
    t = xs1total
    for x in xs2:
        if t < x[0]:
            return False
        t = t - x[0] + x[1]
    for x in xs3:
        if t < x[0]:
            return False
        t = t - x[0] + x[1]
    return t == xs4total

#print(xs1total, xs2, xs3, xs4total)

if check(xs1total, xs2, xs3, xs4total):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 52228
#include<bits/stdc++.h>
#define LL long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const LL mo=1e9+7;
char s[2][55];
int n,mp[55],len;
LL f[55];
int main()
{
	scanf("%d%s%s",&n,s[0]+1,s[1]+1);
	for(int i=1;i<=n;i++){
		if(s[0][i]==s[1][i]) mp[++len]=1;
		else mp[++len]=2,i++;
	}
//	for(int i=1;i<=len;i++) cout<<mp[i]<<" "; cout<<endl;
	f[1] = mp[1]==1 ? 3 : 6;
	for(int i=2;i<=len;i++){
		if(mp[i]==2&&mp[i-1]==2)
		  f[i]=f[i-1]*3%mo;
		else if(mp[i]==1&&mp[i-1]==1)
		  f[i]=f[i-1]*2%mo;
		else if(mp[i]==2&&mp[i-1]==1)
		  f[i]=f[i-1]*2%mo;
		else 
		  f[i]=f[i-1];
	}
	cout<<f[len]<<endl;
	return 0;
}

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

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C& _a4, C _b4) { _a4 = min(_a4, _b4); }
template<class C> void maxi(C& _a4, C _b4) { _a4 = max(_a4, _b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream& operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto& vv : V) os << vv << ","; os << "]";
  return os;
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

#define MAX 101
int n,m;
int t[MAX];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n >> m;
  int np = 0;
  R(i,m){
    cin >> t[i];
    if(t[i] & 1){
      np++;
    }
  }
  if(m == 1){
    if(n == 1){
      cout << "1\n1\n1\n"; 
    }else
      cout << n << "\n2\n" << n-1 << " 1\n";
    return 0;
  }
  if(((n&1) && (np != 1)) || np > 2){
    cout << "Impossible\n";
    return 0;
  }
  if(n&1){
    sort(t,t+m,[](int a,int b){
      return (a&1) > (b&1);
    });
  }else{
    sort(t,t+m,[](int a,int b){
      return (a&1) > (b&1);
    });
    sort(t+1,t+m,[](int a,int b){
      return (a&1) < (b&1);
    });
  }
  R(i,m)
    cout << t[i] << " ";
  t[0]++;
  t[m-1]--;
  if(t[m-1] == 0)m--;
  cout << "\n" << m << "\n";
  R(i,m)
    cout << t[i] << " ";
  cout << "\n";
  
  
}


Measured memory_bytes: 256
#include <iostream>
using std :: cout;
using std :: cin;
using std :: endl;
int main()
{
    int A;
    int B;
    int C;
    int D;
    cin >> A >> B >> C >> D;
    int count = 1;
    while((A > 0) && (C > 0))
    {
        if(count % 2 != 0)
        {
            C -= B;
        }
        else
        {
            A -= D;
        }
        count++;
    }
    if (A > 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef pair<int, int> PII;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define INF 999999999
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    REP(i,max(a,b)){
        cout<<min(a,b);
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 
int main(){
 int n, r;
 cin >> n >> r;
 if(n<=10){
 cout << r + (10-n)*100 << endl;
 }
 else {
 cout << r << endl;
 }
}

Measured memory_bytes: 256