akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

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

bool intersect(int a1, int a2, int b1, int b2) {
	bool o1 = a1 >= b1 && a1 <= b2;
	bool o2 = a2 >= b1 && a2 <= b2;
	return o1 || o2;
	// return a1 <= b2 && b1 <= a2;
}

void solve() {
	const string yes = "War", no = "No War";
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<int> x_arr(n);
	vector<int> y_arr(m);
	for (int i = 0; i < n; i++) {
		cin >> x_arr[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> y_arr[i];
	}
	sort(x_arr.begin(), x_arr.end());
	sort(y_arr.begin(), y_arr.end());
	//x range must be less than y range
	if (x_arr[n - 1] >= y_arr[0]) {
		cout << yes;
		return;
	}
	// Check overlap
	if (intersect(x_arr[0], x_arr[n - 1], y_arr[0], y_arr[m - 1])) {
		cout << yes;
		return;
	}
	int range_begin = x_arr[n - 1] + 1;
	int range_end = y_arr[0];
	int z_begin = x + 1;
	int z_end = y;
	if (intersect(range_begin, range_end, z_begin, z_end)) {
		cout << no;
	} else {
		cout << yes;
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	#ifdef LOCAL
		ifstream in("in");
		cin.rdbuf(in.rdbuf());
	#endif
	solve();
}

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

int main() {
  int n;long long ans = 0;
  cin >> n;
  vector<long long>a(n+1);
  vector<long long>b(n+1);
  for(int i = 0;i < n+1;i++){
    cin >> a.at(i);
  }
  for(int i = 0;i < n;i++){
    cin >> b.at(i);
  }
  b.at(n) = 0;
  for(int i = 0;i < n;i++){
    if(b.at(i) > a.at(i)){
      if(b.at(i)-a.at(i) > a.at(i+1)){
        ans += a.at(i+1);
        a.at(i+1) = 0;
      }
      else{
        ans += b.at(i)-a.at(i);
        a.at(i+1) -= b.at(i)-a.at(i);
      }
      ans += a.at(i);
    }
    else{
      ans += b.at(i);
    }
  }
  if(a.at(n) >= b.at(n)){
    ans += b.at(n);
  }
  else{
    ans += a.at(n);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;
int main(){
	int i,k,x;
	cin >> k >> x;
	for(i=x - k + 1;i<=x + k -1;i++){
		if(i<-1000000 || i>1000000) continue;
		cout << i << " ";
	}
	cout << endl;
}

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

struct Task {
    size_t a;
    size_t b;
};

int main() {
    size_t n;
    std::cin >> n;

    std::vector<Task> task(n);
    for (auto&& ti : task) std::cin >> ti.a >> ti.b;

    std::sort(task.begin(), task.end(), [](const auto& ti, const auto& tj){
        return ti.b < tj.b;
    });

    std::vector<size_t> cum(n + 1);
    cum[0] = 0;
    bool is_feasible = true;
    for (size_t i = 1; i <= n; ++i) {
        cum[i] = cum[i - 1] + task[i - 1].a;
        if (cum[i] > task[i - 1].b) {
            is_feasible = false;
            break;
        }
    }
    
    std::cout << (is_feasible ? "Yes" : "No") << std::endl;
}

Measured memory_bytes: 4992
n,k = list(map(int,input().split(" ")))
nums = list(map(int,input().split(" ")))


prefix = [0] * len(nums)
prefix[0] = nums[0]
for i in range(1,len(nums)):
    prefix[i] = prefix[i-1] + nums[i]

mm = prefix[k-1]
idx = 0
for i in range(k,len(nums)):
    curr = prefix[i] - prefix[i-k]
    if curr > mm:
        mm = curr
        idx = i

s = 0
for i in range(idx-k+1,idx+1):
    s += (nums[i]+1)/2
print(s)

Measured memory_bytes: 25604
#s = input()
#s = "258362843"
n = int(input())
#n = 999999999

k = 357
#array = [3 , 5, 7]

def check(v):
    s = str(v)
    if s.find('3') != -1 and s.find('5') != -1 and s.find('7') != -1:
        return 1
    return 0

def next(x):
#    print(x)
    i = x % 10
    if (i == 3):
        return x + 2 
    if (i == 5):
        return x + 2
    if (i == 7):
        if x >= 10:
            q = next(int(x / 10))
        else:
            q = 3
        return q * 10 + 3

count = 0
while k <= n:
    c = check(k)
    if c:
        count = count + 1
#        print(count, k, c)
    k = next(k)

print(count)
#print(next(377))



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

string solve(string a,string b,int m, int n){
   int dp[m+1][n+1];
   for(int i=0;i<m+1;i++){
      for(int j=0;j<n+1;j++){
         if(i==0||j==0){
            dp[i][j]=0;
         }
         else{
            if(a[i-1]==b[j-1]){
               dp[i][j]=1+dp[i-1][j-1];
            }
            else{
               dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
            }
         }
      }
   }
   string s;
   int i=m,j=n;
   while(i>0 && j>0){
      if(a[i-1]==b[j-1]){
         s+=a[i-1];
         i--;j--;
      }
      else{
         if(dp[i-1][j]>dp[i][j-1]){
            i--;
         }
         else{
            j--;
         }
      }
   }
   return s;
}
int main(){
   string a,b;
   cin>>a>>b;
   string s=solve(a,b,a.size(),b.size());
   for(int i=0;i<s.size();i++){
      cout<<s[s.size()-1-i];
   }
   return 0;
}

Measured memory_bytes: 38792
from itertools import combinations_with_replacement

N, M, Q = map(int, input().split())
input_lst = [list(map(int, input().split())) for _ in range(Q)]

max_score = 0
for pattern in combinations_with_replacement(range(1, M + 1), N):
    score = 0
    for row in input_lst:
        a, b, c, d = row
        if pattern[b - 1] - pattern[a - 1] == c:
            score += d
    if score > max_score:
        max_score = score
print(max_score)

Measured memory_bytes: 9204
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().solve();
	}

	private void solve() throws IOException {
		try {
			solveA();
			//			 solveB();
			//			 solveC();
			//			 solveD();
			//			 solveE();
			//			 solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		char x = next().charAt(0);
		char y = next().charAt(0);

		out.println(x < y ? "<" : x > y ? ">" : "=");
	}

	private void solveB() {
		int numN = nextInt();

		out.println("");
	}

	private void solveC() {
		int numN = nextInt();

		out.println("");
	}

	private void solveD() {
		int numN = nextInt();

		out.println("");
	}

	private void solveE() {
		int numN = nextInt();

		out.println("");
	}

	private void solveF() {
		int numN = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

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

using namespace std;

typedef unsigned long long ull;

int main() 
{
    int n, i, a, b;
    char c;
    ull d;
    string e;
    cin >> n;
    
    vector<tuple<int, int, char, ull, string> > v;
    
    for(i = 0; i < n; i++)
    {
        cin >> a >> b >> c >> d >> e;
        v.emplace_back(make_tuple(a, b, c, d, e));
    }
    
    sort(v.begin(), v.end());
    
    for(i = 0; i < n; i++)
    {
        tie(a, b, c, d, e) = v[i];
        cout << a << " " << b << " " << c << " " << d <<  " " << e << "\n";
    }
        
    return 0;
}


Measured memory_bytes: 12352
#include<stdio.h>

void swap(int x, int y) {   
	int tempX = x;    int tempY = y;   
	x = tempY;    y = tempX;}
int gcd(int x,int y){
/*int n,d ;
n=x;
if (y<x){n=y;y=x;x=n;}
    for(int i=n;i>0;i--)
        if(x%i==0&&y%i==0){d=i;break;}
 */
int r;
	 if (x < y)
        swap(x, y);
    while (y > 0){
        r = x % y;
        x = y;
		y = r;}



            return x;
}


int main()
{
int x,y,r;
r=0;
scanf("%d %d",&x,&y);
r=gcd(x,y);
printf("%d\n",r);
return 0;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) {rep(i,x.size()) cout << x[i] << " "; cout << endl;}
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 2e5;

int main() {
    int n; cin >> n;
    vector<P> data(n);
    vector<P> sum;
    rep(i,n) {
        int a, b; cin >> a >> b;
        data[i] = P(a,b);
        sum.push_back(P(a+b,i));
    }
    sort(rall(sum));
    ll ans = 0;
    rep(i,n) {
        if (i&1) ans -= data[sum[i].second].second;
        else ans += data[sum[i].second].first;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4912
g = []
def gcd(b):
    b-=1
    g.insert(0, b%26)
    if(b//26 > 0):
        gcd(b//26)
a = 'abcdefghijklmnopqrstuvwxyz'
n = int(input())
s = 0; i=0;
gcd(n)
ans = ''
for i in g:
    ans += a[i]
print(ans)

Measured memory_bytes: 61832
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <iostream>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>

using namespace std;
const int mod=998244353;





int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    long long int n,m,k,q,d,x,l,a,b,c;
    cin>>n>>m;
    vector<long long int > v(n+1);
    vector<vector<long long int> > vec(n+1,vector<long long int>(m+1));
    vec[0][0]=1;
    for (int i=1; i<=n; i++) {
        cin>>v[i];
    }
    long long int ans =0;
    for (int i=1; i<=n; i++) {
        vec[i]=vec[i-1];
        vec[i][0]++;
        for (int j=v[i]; j<=m; j++) {
            vec[i][j]+=vec[i-1][j-v[i]];
            vec[i][j]%=mod;
        }
        ans+=vec[i][m];
        ans%=mod;
    }
    cout<<ans<<"\n";
    
    return 0;
}


Measured memory_bytes: 70784
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	vector<int>s;
	bool x = true;
	int n;
	int aux;
	int total = 0;
	int rest = 105;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> aux;
		s.push_back(aux);
		total += aux;
	}
	if (total % 10 != 0){
		cout << total << endl;
		x = false;
}
	else if (total % 10 == 0) {
		for (int i = 0; i < n; i++) {
			if (s[i] % 10 > 0)
			rest = min(rest, s[i]);
		}
		if (rest<105) {
			
		cout << total-rest << endl;
		x = false;
		}
	}
	if (x == true) cout << 0 << endl;
	return(0);
}

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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define Sort(x) sort(x.begin(), x.end())
#define Sort_rev(x) sort(x.begin(), x.end(), greater<int>())
#define ALL(v) (v).begin(), (v).end()

//π M_PI
//deg = rad*180/M_PI

int main() {
    int a, b;
    cin >> a >> b;
    if ( a < b ) {
        rep(i, b) {
            cout << a;
        }
    } else {
        rep(i, a) {
            cout << b;
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

int N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
    cin>>N;
    vector<double> p(N);
    rep(i,N) cin>>p.at(i);
    vector<vector<double> > dp(N,vector<double>(N+1,0));
    dp[0][0] = 1.0-p[0];
    dp[0][1] = p[0];
    reps(i,1,N){
        rep(j,N+1){
            if(j == 0) dp[i][0] = dp[i-1][0]*(1.0-p[i]);
            else dp[i][j] = dp[i-1][j-1]*p[i]+dp[i-1][j]*(1.0-p[i]);
        }
    }
    double ans = 0;
    reps(i,(N+1)/2,N+1) ans += dp.at(N-1).at(i);
    /*rep(i,N){
        rep(j,N+1){
            cout<<dp.at(i).at(j)<<' ';
        }
        cout<<endl;
    }*/
    cout<<fixed<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
//#define MOD 100000007
#define MOD 1000000007

using namespace std;

typedef long long int lli;

const lli NMAX = 5LL * 100005LL;
lli fact[NMAX];
lli inv_fact[NMAX];
lli inv[NMAX];

lli c(lli a, lli b){
	return (fact[a] * ((inv_fact[a-b] * inv_fact[b]) % MOD)) % MOD;
}

int main(){
	ios_base::sync_with_stdio(false);
	fact[0] = fact[1] = inv_fact[0] = inv_fact[1] = 1LL;

	inv[1] = 1LL;
	for(lli i=2LL; i<NMAX; i++)
	    inv[i] = (MOD - (MOD/i) * inv[MOD%i] % MOD) % MOD;


	for(lli i=1LL; i<NMAX; i++){
		fact[i] = (i * fact[i-1]) % MOD;
		inv_fact[i] = (inv[i] * inv_fact[i-1]) % MOD;
	}

	lli n, m, k;
	cin >> n >> m >> k;
	lli d=0LL;

	for(lli i=0LL; i<n; i++){
		lli num = (n-i)*m*m % MOD;
		d = (d + i*num % MOD) % MOD;
	}	

	for(lli i=0LL; i<m; i++){
		lli num = (m-i)*n*n % MOD;
		d = (d + i*num % MOD) % MOD;
	}
	//dbg(c(200000, 100000));
	//d %= MOD;
	d *= c(n*m-2LL, k-2LL) % MOD;
	d %= MOD;
	cout << d << endl;
	return 0;
}

Measured memory_bytes: 12032
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <functional>
#include <set>
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<double,int>;
const ll M = 998244353;
void add(ll& x, ll y) {x+=y; x%=M;}
void chmax(ll& x, ll y) {if (x<y) x=y;}

int main() {
  string s; cin>>s;
  int n=2*s.size();
  ll u[n+1][n+1]; fill(u[0],u[n+1],0);
  u[0][0]=1;
  int a=0,b=0;
  for(int i=0;i<n;i++) {
    if (i<n/2) {
      if (s[i]=='0') a+=2;
      else if (s[i]=='1') a++,b++;
      else b+=2;
    }
    for(int c=0;c<=i;c++) {
      int d=i-c; // (c,d)
      if (u[c][d]>0) {
        if (c+1<=a) add(u[c+1][d],u[c][d]);
        if (d+1<=b) add(u[c][d+1],u[c][d]);
      }
    }
  }
  cout<<u[a][b]<<endl;
}

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

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

    int ans=0;

    if(n>=2){
        ans+=  (n-1)*n/2;
    }

    if(m>=2){
        ans+= (m-1)*m/2;
    }

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

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
def dfs(i):
  if reached[i] == 1:
    return
  reached[i] = 1
  for dic in uv[i]:
    to = dic["to"]
    w = dic["weight"]
    if w % 2 == 0:
      color[to] = color[i]
    else:
      color[to] = int(not color[i])
    dfs(to)

n = int(input())
color = [0]*(n+1)
reached = [0]*(n+1)
uv = [[] * (n+1) for i in range(n+1)]
for i in range(n-1):
  u,v,w = map(int,input().split())
  uv[u].append({"to":v, "weight":w})
  uv[v].append({"to":u, "weight":w})
dfs(1)
for i in color[1:]:
  print(i)

Measured memory_bytes: 114248
#include "algorithm"
#include "cmath"
#include "iostream"
#include "map"
#include "string"
#include "unordered_map"
#include "vector"
constexpr int MOD = 1000000007;
constexpr int INF = 1000000000;
using namespace std; // std::を省略して書くことができる

int dp[1000001][2];
int main() {
  for (int i = 0; i < 1e6; i++) {
    dp[i][0] = INF;
    dp[i][1] = INF;
  }
  vector<int> list;
  vector<int> list_odd;
  for (int i = 1; i < INF; i++) {
    int SUM = i * (i + 1) * (i + 2) / 6;
    if (SUM <= 1e6) {
      list.push_back(SUM);
      if (SUM % 2 == 1)
        list_odd.push_back(SUM);
    } else {
      break;
    }
  }
  dp[0][0] = 0;
  dp[0][1] = 0;
  for (int i = 0; i < 1e6 + 1; i++) {
    for (int j = 0; j < 179; j++) {
      for (int k = 1; k < 10; k++) {
        if (i + list[j] * k < 1e6 + 1) {
          dp[i + list[j] * k][0] = min(dp[i + list[j] * k][0], dp[i][0] + k);
        } else {
          break;
        }
      }
    }

    for (int j = 0; j < 44; j++) {
      for (int k = 1; k < 10; k++) {
        if (i + list_odd[j] * k < 1e6 + 1) {
          dp[i + list_odd[j] * k][1] =
              min(dp[i + list_odd[j] * k][1], dp[i][1] + k);
        } else {
          break;
        }
      }
    }
  }

  int n;
  cin >> n;
  while (n != 0) {
    cout << dp[n][0] << " " << dp[n][1] << endl;
    cin >> n;
  }
}


Measured memory_bytes: 10976
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    string s, t;
    cin >> s >> t;

    if(s.size() < t.size()) { 
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    int idx = -1;
    for(int i = 0; i <= s.size() - t.size(); i++) {
        int cnt = 0;

        for(int j = 0; j < t.size(); j++) {
            if(s[i+j] == t[j] || s[i+j] == '?') {
                cnt++;
            }
        }

        if(cnt == t.size()) {
            idx = i;
        }
    }

    string ans;

    if(idx != -1) {
        for(int i = 0; i < t.size(); i++) {
            s[idx+i] = t[i];
        }

        for(int i = 0; i < s.size(); i++) {
            if(s[i] == '?') {
                s[i] = 'a';
            }
        }

        ans = s;
    }
    else {
        ans = "UNRESTORABLE";
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9+7;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
#define INT_MAX 1e9+7

ll n;
ll a[16][16];
vl dp(V,-linf);
ll rec(ll S) {
    if (dp[S] != -linf) return dp[S];
    ll res = 0;
    rep(i,n) {
        REP(j,i+1,n) if ((S & (1 << i)) && (S & (1 << j))) res += a[i][j];
    }
    for(ll T=(S-1)&S; T>0; T=(T-1)&S){
        res = max(res, rec(T)+rec(S^T));
    }
    return dp[S] = res;
}

int main(){
    cin >> n;
    rep(i,n) rep(j,n) cin >> a[i][j];
    cout << rec((1<<n)-1) << endl;
}

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

int main() {
	int p,ps=2001,j,js=2001;
	for(int i=1; i<=3; i++){
		cin>>p;
		if(ps>p)
			ps=p;
	}
	for(int i=1; i<=2; i++){
		cin>>j;
		if(js>j)
			js=j;
	}
	cout<<ps+js-50<<endl;
	return 0;
}

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

namespace ABC167
{
    class A
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var T = Console.ReadLine();

            var t = T.Substring(0, S.Length);

            if (S == t && S.Length == T.Length - 1) Console.WriteLine("Yes");
            else Console.WriteLine("No");


        }
    }
}


Measured memory_bytes: 25772
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;

int solve(const vector<string> &v, const vector<int> &line, const int &k) {
	//cout<<"solve->";
	const int n = v[0].size();
	const int m = line.size();
	vector<vector<int>> t(m, vector<int>(n, 0));
	for (int j = 0; j < n; j++) {
		int i = 0;
		int l = 0;
		while (i < v.size()) {
			while (i <= line[l]) {
				t[l][j] += v[i][j] == '0' ? 0 : 1;
				if (t[l][j] > k) return -1;
				i++;
			}
			l++;
		}
	}
	vector<int> s(m, 0);
	for (int i = 0; i < m; i++) s[i] = t[i][0];
	int j = 1;
	int res = 0;
	while (j < n) {
		bool need = false;
		for (int i = 0; i < m; i++) {
			s[i] += t[i][j];
			if (s[i] > k) {
				need = true;
				break;
			}
		}
		if (need) {
			res++;
			s = vector<int>(m, 0);
			for (int i = 0; i < m; i++) s[i] = t[i][j];
		}
		j++;
	}
	//cout<<res<<endl;
	return res;
}

void dfs(const vector<string> &v, const int &m, int cur, int cut, vector<int> &line, int &res, const int &k) {
	if (cur == m-1) {
		line.push_back(m-1);
		int s = solve(v, line, k);
		//cout<<s<<endl;
		if (s != -1) res = min(res, cut + solve(v, line, k));
		line.pop_back();
		return;
	}
	dfs(v, m, cur+1, cut, line, res, k);
	line.push_back(cur);
	dfs(v, m, cur+1, cut+1, line, res, k);
	line.pop_back();
}

int main() {
	ios_base::sync_with_stdio(false);
	int m, n, k;
	cin>>m>>n>>k;
	vector<string> v(m);
	for (int i = 0; i < m; i++) {
		cin>>v[i];
	}
	vector<int> line;
	int res = INT_MAX;
	dfs(v, m, 0, 0, line, res, k);
	cout<<res<<endl;
	return 0;

}

Measured memory_bytes: 384
while True:
    n,m = map(int,input().split())
    if n == m == 0:
        break
    N = [int(input()) for i in range(n)]
    M = [int(input()) for i in range(m)]
    x = 1
    for i in range(m):
        x += M[i]
        if n <= x:
            print(i+1)
            break
        else:
            x +=  N[x-1]
            if n <= x:
                print(i+1)
                break


Measured memory_bytes: 5640
def top_number(num):
    top = 0
    while num > 0:
        top = num
        num //= 10
    return top


def main():
    N = int(input())
    group = [[0] * 10 for _ in range(10)]
    result = 0
    for i in range(1, N + 1):
        group[top_number(i)][i % 10] += 1
    for i in range(10):
        for j in range(10):
            result += group[i][j] * group[j][i]
    print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll N;
ll L[4000];
 
void input() {
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> L[i];
}
 
void solve() {
    input();
    vector<ll> v(N);
    for(int i = 0; i < N; i++) v[i] = L[i+1];
    sort(v.begin(), v.end());
    ll ans = 0;
    for(ll mid = N - 1; mid >= 0; mid--) {
        for(ll low = mid - 1; low >= 0; low--) {
            auto itr = lower_bound(v.begin(), v.end(), v[mid] + v[low]);
            ll ng = distance(itr, v.end());
            ans += (N - 1 - mid) - ng;
            //cerr << v[mid] + v[low] << " " << ng << " " << (N-1-mid)-ng << endl;
        }
    }
    cout << ans << endl;
    return;
}
 
int main() {
    solve();
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i, n) for (int i = 0; i < ((int)(n)); i++) // 0-indexed昇順

int main()
{
  string S;
  cin >> S;
  if (S.at(0) == '9' || S.at(1) == '9') {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll _,i,j,n,a,b,e,k,u,t,x=1,m,y,q,f=1,c=0,d=0,l,p,z,o,r,g;
    string ss,s;
    cin>>s;
    if(s[1]=='R')cout<<"ABC"<<endl;
    else cout<<"ARC"<<endl;


}


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

int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L.at(i);
  }
  int result = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      for (int k = j + 1; k < N; k++) {
        if (L.at(i) != L.at(j) && L.at(j) != L.at(k) && L.at(k) != L.at(i)) {
          int maxL = max({L.at(i), L.at(j), L.at(k)});
          if (maxL * 2 - L.at(i) - L.at(j) - L.at(k) < 0) {
            result++;
          }
        }
      }
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3628
import java.util.*;
 
class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        StringBuilder S = new StringBuilder(sc.next());
                        int N = sc.nextInt();
                        for (int i = 0; i < N; i++) {
                                String operator = sc.next();
                                        int a = sc.nextInt(), b = sc.nextInt() + 1;
                                if (operator.equals("print")) {
                                        System.out.println(S.substring(a, b));
                                } else if(operator.equals("reverse")) {
                                        S.replace(a, b, (new StringBuilder(S.substring(a, b))).reverse().toString());
                                } else {
                                        String x = sc.next();
                                        S.replace(a, b, x);
                                }
                        }
                }
        }
}


Measured memory_bytes: 29308
#include <bits/stdc++.h>
using namespace std; 
int arrCount[200005] = { 0 };
bool cmp(int iNum1, int iNum2){ 
    return iNum1 > iNum2;
}
int main(){
    int nCount, nDiff, i, iTemp, iSum=0;
    cin >> nCount >> nDiff; 
    for (i = 1; i <= nCount; ++i){
        cin >> iTemp; 
        ++arrCount[iTemp];
    }
    sort(arrCount, arrCount + 200005,cmp);
    for (i = nDiff;arrCount[i]!=0;++i){
        iSum += arrCount[i];
    }
    cout << iSum << endl;
    return 0; 
}

Measured memory_bytes: 1024
N,W=map(int,input().split())
dp=[[-1]*301 for i in range(N+1)]
dp[0][0]=0

for i in range(N):
    w,v=map(int,input().split())
    if i==0:
        base=w
    for i in range(N)[::-1]:
        for j in range(301)[::-1]:
            if dp[i][j]!=-1:
                dp[i+1][j+w-base]=max(dp[i][j]+v,dp[i+1][j+w-base])

ans=0
for index,item in enumerate(dp):
    if W-index*base+1<=0:
        break
    ans=max(max(item[:W-index*base+1]),ans)

print(ans)

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

using namespace std;

int main(){
    int N, T;
    cin >> N >> T;
    int A[N], B[N];
    for(int i = 0; i<N; i++){
        cin >> A[i] >> B[i];
    }

    int dp[2][N][T];
    // initialize
    for(int t =0 ; t<T; t++){
        if(t < A[0]) dp[0][0][t] = 0;
        else         dp[0][0][t] = B[0];
                     dp[1][0][t] = B[0];
    }

    for(int i = 0; i < N -1; i++){
        for(int t = 0; t < T; t++){
            if(t-A[i+1] >= 0){
                dp[0][i+1][t] = max(dp[0][i][t], dp[0][i][t-A[i+1]] + B[i+1]);
                dp[1][i+1][t] = max({dp[1][i][t], dp[1][i][t-A[i+1]] + B[i+1], dp[0][i][t] + B[i+1]});
            }
            else{
                dp[0][i+1][t] = dp[0][i][t];
                dp[1][i+1][t] = max(dp[1][i][t], dp[0][i][t] + B[i+1]);
            }
        }
    }
    cout << dp[1][N-1][T-1] << endl;
    return 0;
}

Measured memory_bytes: 70528
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

int main(){
	int n;
	string s,t;
	cin>>n>>s>>t;
	string ans="";
	rep(i,n){
		ans+=s[i];
		ans+=t[i];
	}
	cout<<ans<<endl;

}

Measured memory_bytes: 256
# Circumscribed Circle of a Triangle

import sys
import math


n = 0
datas = []

for (i, line) in enumerate(sys.stdin):
	if i == 0:
		n = int(line)
	else:
		datas.append(map(float, line.split()))

for data in datas:
	x1, y1, x2, y2, x3, y3 = data
	a1 = x2 - x1
	b1 = y2 - y1
	a2 = x3 - x1
	b2 = y3 - y1
	px = (b2 * (a1 * a1 + b1 * b1) - b1 * (a2 * a2 + b2 * b2)) / (2 * (a1 * b2 - a2 * b1))
	py = (a1 * (a2 * a2 + b2 * b2) - a2 * (a1 * a1 + b1 * b1)) / (2 * (a1 * b2 - a2 * b1))
	r = math.sqrt(px * px + py * py)
	px += x1
	py += y1
	print "{0:.3f} {1:.3f} {2:.3f}".format(px, py, r)

Measured memory_bytes: 4416
#include<deque>
#include<stdint.h>
#include<set>
#include<stack>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#include<map>
using namespace std;
long long a[100010],n,m,i,j,ans;
bool flg;
int main()
{
	ios::sync_with_stdio(0);
	cin>>n;
	for (i=1;i<=n;i++) cin>>a[i];
	for (i=1<<30;i;i/=2)
	{
		flg=0;
		for (j=1;j<=n;j++)
		{
			if (a[j]>i)
			{
				if (a[j]==i*2)
				{
					flg=1;
				}
				else if (!flg) flg=1;
				else ans++,flg=0;
				a[j]=i;
			}
			else if (flg) ans++,flg=0;
		}
		if (flg) ans++,flg=0;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
n, q = map(int, input().split())
s = input()

ac = [0 for i in range(n)]
for i in range(1, n):
    if s[i - 1] == 'A' and s[i] == 'C':
        ac[i] = 1

for i in range(n - 1):
    ac[i + 1] += ac[i]
for i in range(q):
    l, r = map(int, input().split())
    l -= 1
    r -= 1
    ret = ac[r] - ac[l]
    print(ret)


Measured memory_bytes: 7692
#include <vector>
#include <cstdio>
using namespace std;
typedef pair<int,int>pii;
main(){
	int n,x,i,q;
	pii p;
	for(;scanf("%d%d",&n,&x),n;printf("%d\n",x)){
		vector<pii>v;
		v.push_back(make_pair(x,1));
		for(i=1;i<n;i++)
			if(p=v.back(),scanf("%d",&x),x==p.first)v.back().second++;
			else if(i&1){
				if(v.pop_back(),q=0,v.size())q=v.back().second,v.pop_back();
				v.push_back(make_pair(x,q+p.second+1));
			}else v.push_back(make_pair(x,1));
		for(x=i=0;i<v.size();i++)if(!v[i].first)x+=v[i].second;
	}
}

Measured memory_bytes: 1028
#include <math.h>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;

int main()
{
string s;
string p;
string ans="Yes";
cin >> s >> p;
s+=s;
if(s.find(p)==string::npos)ans="No";
cout << ans << endl;
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                                               \
  ifstream in("atcoder-problems/codefestival_2016_final_b.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  ll N;
  cin >> N;

  ll tot = 0;
  ll MAX = 0;
  rep(i, N + 1) {
    tot += i;
    MAX = i;
    if (tot >= N) break;
  }

  ll diff = tot - N;

  repi(i, 1, MAX + 1) {
    if (i == diff) continue;
    cout << i << endl;
  }
}

Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main() {
    int sum = 0;
    for(int i = 0; i < 4; ++i) {
        int n;
        cin >> n;
        sum += n;
    }
    cout << sum / 60 << endl;
    cout << sum % 60 << endl;

    return 0;
}

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

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; }

long long dp[110][100100] = {0};

int main(){
    long long n,W;
    cin >> n >> W;
    long long v[110],w[110];
    for(int i = 0; i < n; i++){
        cin >> v[i] >> w[i];
    }

    for(int i = 0; i < n; i++){
        for(int sum_w = 0; sum_w <= W; sum_w++){
            if(sum_w - w[i] >= 0){
                chmax(dp[i + 1][sum_w], dp[i][sum_w - w[i]] + v[i]);
            }
            chmax(dp[i + 1][sum_w], dp[i][sum_w]);
        }
    }
    cout << dp[n][W] << endl;
}


Measured memory_bytes: 11192
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define jell        998244353
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define DEC(N)  cout << std::fixed; cout << setprecision(N);
using namespace std;
ll add(ll x,ll y)
{
return (x%hell+y%hell)%hell;
}
ll mul(ll x,ll y)
{
return ((x%hell)*(y%hell))%hell;
}
ll sub(ll x,ll y)
{
return (x-y+hell)%hell;
}
#define N  100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
 //  cin>>t;
    for(int ok=1;ok<=t;ok++)
    {
      ll x,n;
      cin>>x>>n;
      map<ll,ll>lol;
      for(int i=1;i<=n;i++)
      {
        ll o;
        cin>>o;
        lol[o]++;
      }
      ll ans=hell,kl=-1;
      for(int i=0;i<=101;i++)
      {
             if(lol[i]==0)
             {
                 if(abs(i-x)<ans)
                 {
                    ans=abs(i-x);
                    kl=i;
                 }
             }
      }
      cout<<kl;

     
    }
    return 0;
}

Measured memory_bytes: 3504
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<iterator>
#include<set>
#include<queue>

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

using namespace std;


int main(){
	string s; cin >> s;
	bool flag1 = false;
	bool flag2 = false;
	rep(i,s.size()){
		if(s[i] == 'C' && !flag1){
			flag1 = true;
		}
		else if(s[i] == 'F' && !flag2 && flag1){
			flag2 = true;
			break;
		}
	}
	if(flag2)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int isPrime(int x){
	int i;
	if ( x == 2 ){
		return 1;
	}
	else if ( x < 2 || x % 2 == 0 ){
		return 0;
	}
		for( i = 3 ; i * i <= x ; i+=2 ){
			if( x % i == 0 ){
				return 0;
			}
                }
			return 1;
		}
		
	int main(void){
		int n,x,i;
		int ans = 0;
		
		scanf("%d",&n);
		for( i = 0 ; i < n ; i++ ){
			scanf("%d",&x);
			if ( isPrime(x) ){
				ans = ans + 1 ;
			}
        }
			printf("%d\n",ans);
			
			return 0;
			
		}
		

Measured memory_bytes: 1836
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	ll n, m;
	cin >> n >> m;
	if (n == 1 && m == 1) cout << 1 << endl;
	else if (n == 1) cout << (m-2) << endl;
	else if (m == 1) cout << (n-2) << endl;
	else cout << ((n-2)*(m-2)) << endl;
	return 0;
}
 

Measured memory_bytes: 256
import numpy as np
N, K = map(int, input().split())
S = list(input())
nums = []
now = 1
cnt = 0
for s in S:
    if s == str(now):
        cnt += 1
    else:
        nums.append(cnt)
        now = 1 - now
        cnt = 1
if cnt != 0:
    nums.append(cnt)
if len(nums) % 2 == 0:
    nums.append(0)

sums = [0] + list(np.cumsum(nums))
left = 0
right = left + K * 2
maxi = 0
if N < 3:
    maxi = N
while right < len(nums):
    if sums[right+1] - sums[left] > maxi:
        maxi = sums[right+1] - sums[left]
    right += 2
    left += 2
if maxi == 0:
    maxi = sum(nums)
print(maxi)


Measured memory_bytes: 32916
#include<cstdio>
#include<cstring>
using namespace std;

__int128 n;

void read(){
    __int128 x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=ch-'0';
        n+=x;
        ch=getchar();
    }
}
int main(){
	read();
	if(n%9==0)
		printf("Yes");
	else printf("No");
}

Measured memory_bytes: 3160
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
using namespace std;
#define inf INT_MAX/2
int n, haba;
string in;
int r[13];
double dist[13][13], dp[1<<13][13];
void input(string in) {
    int i;
    string x="";
    for (i=0; i<in.length(); i++) {
        if (in[i]==' ') {
            stringstream ss;
            ss<<x;
            ss>>haba;
            x="";
            break;
        } else {
            x+=in[i];
        }
    }
    for (;i<in.length(); i++) {
        if (in[i]==' ') {
            stringstream ss;
            ss<<x;
            ss>>r[n];
            x=""; n++;
        } else {
            x+=in[i];
        }
    }
    stringstream ss;
    ss<<x;
    ss>>r[n]; n++;
}
double calc(int i, int j) {
    return sqrt((double)(r[i]+r[j])*(r[i]+r[j])-(double)(r[i]-r[j])*(r[i]-r[j]));
}
int main() {
    while (getline(cin,in)) {
        n=0; memset(r,0,sizeof(r));
        input(in);
        for (int i=1; i<n; i++) {
            dist[0][i]=dist[i][0]=r[i];
            for (int j=i+1; j<=n; j++) {
                dist[i][j]=dist[j][i]=calc(i,j);
            }
        }
        for (int S=0; S< 1<<n; S++) {
            fill(dp[S], dp[S]+n, inf);
        }
        dp[(1<<n)-1][0]=0;
        for (int S=(1<<n)-2; S>=0; S--) {
            for (int v=0; v<n; v++) {
                for (int u=0; u<n; u++) {
                    if (!(S>>u&1)) {
                        dp[S][v]=min(dp[S][v],dp[S|1<<u][u]+dist[v][u]);
                    }
                }
            }
        }
        if (dp[0][0]>haba) puts("NA");
        else puts("OK");
    }
}

Measured memory_bytes: 1760
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int x = sc.nextInt();
        int t = sc.nextInt();

        int res = (n + (x-1)) / x * t;
        System.out.println(res);
    }

}

Measured memory_bytes: 35612
#include <bits/stdc++.h>
using namespace std;
 
int main(){
int n,x,a; int i=0; int xxx=0;
cin >> n >> x;
vector<int> l;
while(i<n){
    cin >> a;
  l.push_back(a); 
  i++;
}
 
i=0;
while(xxx<=x){
    i++;
if(i<=n){
xxx += l.at(i-1);
}else{
    break;
}
}
cout << i << endl;
return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> P;

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

int main()
{
  ll N;
  cin >> N;
  if (N < 105) {
    cout << 0 << endl;
  }else if (N < 135) {
    cout << 1 << endl;
  }else if (N < 165) {
    cout << 2 << endl;
  }else if (N < 189){
    cout << 3 << endl;
  }else if (N < 195) {
    cout << 4 << endl;
  }else {
    cout << 5 << endl;
  }
  return 0;
}
// int main()
// {
//   string S;
//   ll K;
//   cin >> S >> K;
//   for (int i = 0;i < S.length();i++) {
//     if (S[i] != '1') {
//       cout << S[i] << endl;
//       return 0;
//     }
//   }
//   cout << 1 << endl;
//   return 0;
// }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,cnt=0;
  string s;
  cin >> n >> s;
  for(int i=0;i<n;i++){
    if(s[i]=='R')cnt++;
  }
  if(cnt>n-cnt){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//1行目の入力
		int N = sc.nextInt();
		int C = sc.nextInt();
		int K = sc.nextInt();
		//2行目以降の入力
		int[] T = new int[N];
		for(int i=0; i<N; i++){
			T[i]  = sc.nextInt();
		}
		//T[i]を並び替える
		int val;
		int j;
		for(int i=1; i<N; i++){
			val = T[i];
			j = i;
			while(j>0 && T[j-1]>val){
				T[j] = T[j-1];
				j--;
			}
			T[j] =val;
		}
		//バスの数をカウントする
		int count = 1;
		int firstPassenger = 0;
		for(int i=0; i<N; i++){
			if(i-firstPassenger==C || T[i]>T[firstPassenger]+K){
				count++;
				firstPassenger = i;
			}
		}
		//出力
		System.out.println(count);

	}

}


Measured memory_bytes: 51160
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
using namespace std;

int main(){
    int n;cin>>n;
    int p[30];
    for(int i=0;i<n;++i){
        cin>>p[i];
    }
    int cnt=0;
    for(int i=1;i<n-1;++i){
        if(p[i-1]<p[i]){
            if(p[i]<p[i+1]){
                cnt++;
            }

        }else if(p[i-1]>p[i]){
            if(p[i]>p[i+1]){
                cnt++;
            }
        }
    
        
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <string.h>
#include <cstdlib>
#include <iomanip>
#include <stdio.h>

using namespace std;

int main(){

        int n,m,e;
        int *mat_orig,*mat,*vec_orig,*vec;

        scanf("%d %d\n",&n,&m);

        mat_orig = mat = (int *)malloc(n*m*sizeof(int));
        vec_orig = vec = (int *)malloc(m*sizeof(int));

        for(int i=0;i<n;i++){
                for(int j=0;j<m;j++){
                        scanf("%d ",mat);
                        mat++;
                }
        }

        for(int i=0;i<m;i++){
                scanf("%d\n",vec);
                vec++;
        }

        for(int i=0;i<n;i++){
                e=0;
                for(int i=0;i<m;i++){
                        e += *mat_orig * vec_orig[i];
                        mat_orig++;
                }
                printf("%d\n",e);
        }

        return 0;
}


Measured memory_bytes: 3228
<?php
  fscanf(STDIN, "%d", $n);
  $d = explode(" ", trim(fgets(STDIN)));
  $sum = 0;
  for ($i = 0; $i < $n; $i++) for ($j = 0; $j < $n; $j++) {
    if ($i <= $j) continue;
    $sum += $d[$i] * $d[$j];
  }
  echo $sum;
?>

Measured memory_bytes: 4728
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;

int main(){


    int n;
    cin >> n;

    string s;
    cin >> s;


    ll ans = 0;
    for(int i = 0; i < (int)s.size() - 2; i++){
        if( s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C' ) ans ++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 764
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#include <numeric>
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
const double EPS = 1e-10;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

const int MAX_N = 505050;
vector<int>e[MAX_N], er[MAX_N];
int fin[MAX_N], cmp[MAX_N], state[MAX_N];
int cnt = 0;
int num = 0;
void dfs1(int now) {
	state[now] = 1;
	fore(x, e[now]) {
		if (state[x] == 0) {
			cnt++;
			dfs1(x);
		}
	}
	cnt++;
	fin[now] = cnt;
}
void dfs2(int now, int num) {
	state[now] = 1;
	cmp[now] = num;
	fore(x, er[now]) {
		if (state[x] == 0)dfs2(x, num);
	}
}
void scc(int N) {
	//各頂点について終了時間を計算
	for (int i = 0; i < N; i++) {
		if (state[i] == 0)dfs1(i);
	}
	//逆辺を計算
	for (int i = 0; i < N; i++) {
		fore(x, e[i])er[x].pb(i);
	}

	for (int i = 0; i < N; i++)state[i] = 0;

	//終了時間の降順でdfsをしていく
	vector<pair<int, int>>finli;
	for (int i = 0; i < N; i++) {
		finli.pb({ fin[i],i });
	}
	sort(all(finli));
	reverse(all(finli));
	for (int i = 0; i < N; i++) {
		int v = finli[i].second;
		if (state[v] == 0) {
			dfs2(v, num);
			num++;
		}
	}
}

void add_edges(int x, int y,int sz) {
	e[(x+sz)%(2*sz)].pb(y%(2*sz));
	e[(y+sz)%(2*sz)].pb(x%(2*sz));
}


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

	int N, D;
	cin >> N >> D;
	vector<int>zahyou;
	vector<pair<int,int>>li;
	for (int i = 0; i < N; i++) {
		int x, y;
		cin >> x >> y;
		li.pb({ x,y });
		zahyou.pb(x);
		zahyou.pb(y);
	}
	sort(all(zahyou));
	zahyou.erase(unique(all(zahyou)), zahyou.end());

	int sz = zahyou.size();

	for (int i = 0; i < N; i++) {
		int x = li[i].first;
		int y = li[i].second;
		li[i].first = lower_bound(all(zahyou), x) - zahyou.begin();
		li[i].second = lower_bound(all(zahyou), y) - zahyou.begin();
	}

	for (int i = 0; i < N; i++) {
		int xidx = li[i].first;
		int yidx = li[i].second;
		add_edges(xidx,yidx,sz);
		add_edges(xidx+sz,yidx+sz,sz);
	}


	for (int i = 0; i < sz; i++) {
		for (int j = i + 1; j < sz; j++) {
			if (zahyou[j] - zahyou[i] >= D)continue;
			add_edges(i+sz,j+sz,sz);
		}
	}

	scc(2*sz);

	//check
	for (int i = 0; i < sz; i++) {
		if (cmp[i] == cmp[i + sz]) {
			puts("No");
			return 0;
		}
	}


	puts("Yes");
	for (int i = 0; i < N; i++) {
		int xidx = li[i].first;
		int yidx = li[i].second;
		if (cmp[xidx + sz] < cmp[xidx])puts(zahyou[xidx]);
		else puts(zahyou[yidx]);
	}



	return 0;
}

Measured memory_bytes: 27680