akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

class city_info
{
public:
	int p;
	int y;
	int idx;
	string result;

public:
	city_info(int _p, int _y, int _idx)
		: p(_p), y(_y), idx(_idx), result()
	{}
};

vector<city_info> city_list;

string make_id(int p, int y)
{
	string sp = to_string(p);
	string sy = to_string(y);

	string result;

	for (int i = 0; i < 6 - sp.size(); i++)
	{
		result.push_back('0');
	}
	result += sp;

	for (int i = 0; i < 6 - sy.size(); i++)
	{
		result.push_back('0');
	}
	result += sy;

	return result;
}

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

	int N, M;
	cin >> N >> M;

	for (int i = 0; i < M; i++)
	{
		int p, y;
		cin >> p >> y;

		city_list.emplace_back(p, y, i);
	}

	sort(city_list.begin(), city_list.end(), [](const city_info& l, const city_info& r)
	{
		if (l.p == r.p) return l.y < r.y;
		return l.p < r.p;
	});

	int city_id = 1;
	int prev_p = city_list.front().p;
	for (int i = 0; i < M; i++)
	{
		if (prev_p != city_list[i].p)
		{
			city_id = 1;
		}

		city_list[i].result = make_id(city_list[i].p, city_id);

		city_id++;
		prev_p = city_list[i].p;
	}

	sort(city_list.begin(), city_list.end(), [](const city_info& l, const city_info& r)
	{
		return l.idx < r.idx;
	});

	for (city_info e : city_list)
	{
		cout << e.result << "\n";
	}

	return 0;
}

Measured memory_bytes: 10736
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

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

  int r = 0;
  int w = 0;
  rep(i, n){
    if(s[i] == 'R') r++;
    if(s[i] == 'W') w++;
  }

  int dr = 0;
  int dw = 0;
  rep(i, r){
    if(s[i] != 'R') dr++;
  }
  rep(i, w){
    if(s[r+i] != 'W') dw++;
  }

  cout << dr << endl;

  return 0;
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll n, k;
    cin >> n >> k;
    if(k % 2 == 0)
    {
        ll a = n - k / 2;
        ll ans1 = 0;
        if(a >= 0)
        {
          ll b = a / k;
          ans1 = (b+1) * (b+1) * (b+1);
        }
        ll c = n / k;
        ll ans2 = c * c * c;
        cout << ans1 + ans2 << endl;
    }
    else
    {
        ll a = n / k;
        cout << a * a * a << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
const int N = 1e5+1;
using namespace std;
int a[N];
bool o[N];
int main() {
	int n, m;
	cin >> n >> m;
	int ans, cnt;
	ans = cnt = 0;
	for (int i = 0;i < m;i++) {
		string s;
		int x;
		cin >> x >> s;
		if (o[x])continue;
		if (s == "WA") a[x]++;
		else if (s == "AC") {
			ans++;
			o[x] = true;
			cnt+=a[x];
		}
	}
	cout << ans << " " << cnt << endl;
	return 0;
}

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

int main(){
  ll N,M;cin>>N>>M;
  vector<ll> island_to1,island_toN;
  rep(i,M){
    ll a,b;cin>>a>>b;
    if(a==1) island_to1.push_back(b);
    if(b==1) island_to1.push_back(a);
    if(a==N) island_toN.push_back(b);
    if(b==N) island_toN.push_back(a);  
  }
  vector<ll> v;
  rep(i,island_to1.size()) v.push_back(island_to1[i]);
  rep(i,island_toN.size()) v.push_back(island_toN[i]);
  sort(v.begin(),v.end());
  bool flag=false;
  rep(i,v.size()-1) if(v[i]==v[i+1])flag=true;
  if(flag) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
}

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

int N,T,S;
int A[3010],B[3010];
int dp[3010][3010] = {};
int main(){
	cin >> N >> T >> S;
	for(int i=1;i<=N;i++){
		cin >> A[i] >> B[i];
	}
	int ans = 0;
	for(int i=1;i<=N;i++){
		for(int j=1;j<=T;j++){
			if(j-B[i]<0 || (j-B[i]<S && S<j)) dp[i][j] = dp[i-1][j];
			else dp[i][j] = max(dp[i-1][j],dp[i-1][j-B[i]]+A[i]);
			ans = max(ans,dp[i][j]);
		}
	}
/*	for(int i=1;i<=N;i++){
		for(int j=1;j<=T;j++){
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}
*/	cout << ans << endl;
}


Measured memory_bytes: 38400
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let k: usize = sc.read();
    let a: usize = sc.read();
    let b: usize = sc.read();
    for i in a..=b {
        if i % k == 0 {
            println!("OK");
            return;
        }
    }
    println!("NG");
}

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

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


Measured memory_bytes: 2184
#include "bits/stdc++.h" // {{{
using namespace std;
#define val         const auto
#define eb          emplace_back
#define emp         emplace
#define fi          first
#define se          second
#define X           first
#define Y           second
#define outl(x)     cout << (x) << '\n'
#define rep(i,n)    for(int i=0; i < (int)(n); ++i)
#define ALL(x)      begin(x), end(x)
#define TMPLT(T,U)  template<class T, class U>
#define ten(p)      ((long long)(1e##p))
#define FILL(a,v)   memset((a), (v), sizeof(a))
#define FAST()      ios::sync_with_stdio(false), cin.tie(nullptr)
#ifndef DEBUG
#define debug(...)
#define show(x)
#define show2(x,y)
#define LN()
#endif
typedef long long ll;
typedef pair<int,int> pii;
namespace ydk{
TMPLT(T,U) inline bool chmax(T &a, U b){return b>a ? a=b,1 : 0;}
TMPLT(T,U) inline bool chmin(T &a, U b){return b<a ? a=b,1 : 0;}
TMPLT(T,U) inline constexpr common_type_t<T,U> gcd(T x, U y)
{ return (x<y)? gcd(y,x) : (y <= 0)? x : gcd(y, x % y); }
TMPLT(T,U) inline constexpr ll lcm(T x, U y) { return (ll)x/gcd(x,y) * y; }
constexpr int INF   = 0x3f3f3f3f;
constexpr ll LINF   = 0x3f3f3f3f3f3f3f3fLL;
// }}}

constexpr int MX = ten(4) + 10;

void Xx_main_xX()
{
    int N, W;
    int v[MX], w[MX];

    cin >> N >> W;
    rep(i, N) {
        cin >> v[i] >> w[i];
    }

    static int dp[2][MX];
    FILL(dp, 0);

    int *now = dp[0];
    int *nxt = dp[1];
    now[0] = nxt[0] = 0;

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= W; ++j) {
            chmax(nxt[j], now[j]);
            if (j + w[i] <= W) {
                chmax(nxt[j + w[i]], now[j] + v[i]);
            }

        }
        swap(now, nxt);
    }

    outl(now[W]);

    return;
}

} // {{{

signed main(){cout << fixed << setprecision(9); ydk::Xx_main_xX(); return 0;} // }}}




Measured memory_bytes: 3208
/////////////////////////////////////////
////////// ^\/^ *_* :) :-D '~' \\\\\\\\\\
/////////////////////////////////////////
#include <bits/stdc++.h>
//#include <algorithm>
//#include <cstdio>
//#include <functional>
#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
//#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
//#include <string>
//#include <time.h>
//#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
//#include <string.h>
 
#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
 
using namespace std;
 
const LL MOD=1e9+7;
 
int n,m;
vector <pii> v[100010];
bool vis[100010];
int tot[100010];
 
void dfs(int pla,int all)
{
	if(vis[pla])
	{
		if(tot[pla]!=all)
		{
			puts("No");
			exit(0);
		}
		return;
	}
	vis[pla]=true;
	tot[pla]=all;
	rep(i,v[pla].size())
	{
		dfs(v[pla][i].fi,all+v[pla][i].se);
	}
}
 
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m;
	rep(i,m)
	{
		int x,y,z;
		cin>>x>>y>>z;
		v[x].pb(mpr(y,z));
		v[y].pb(mpr(x,-z));
	}
	repn(i,n)
	{
		if(!vis[i])
		{
			//memset(tot,0,sizeof(tot));
			dfs(i,0);
		}
	}
	puts("Yes");
	rt0;
}

Measured memory_bytes: 12160
sx,sy,tx,ty=map(int,input().split())
yoko=tx-sx
tate=ty-sy
print('U'*tate+'R'*yoko+'D'*tate+'L'*yoko+'L'+'U'*(tate+1)+'R'*(yoko+1)+'D'+'R'+'D'*(tate+1)+'L'*(yoko+1)+'U')


Measured memory_bytes: 3060
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
import fractions
from functools import reduce

rr = lambda: sys.stdin.buffer.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.buffer.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

n = ri()
li = [ri() for _ in range(n)]
ans = 1
for i in li:
  a = fractions.gcd(i, ans)
  ans = ans * i // a
print(ans)


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }

int main(){
  ll i, j;
  ll n;
  cin >> n;
  vector<ll> hash1(100005);
  vector<ll> hash2(100005);
  ll count1a = 0, count1b = 0, count2a = 0, count2b = 0;
  ll result1a = 0, result1b = 0, result2a = 0, result2b = 0;
  
  ll v;
  for(i = 0; i < n; i++){
    cin >> v;
    if(i % 2 == 0){
      hash1[v]++;
      if(hash1[v] > count1a){
        count1a = hash1[v];
        result1a = v;
      }
      else if(hash1[v] > count1b){
        count1b = hash1[v];
        result1b = v;
      }
    }
    if(i % 2 == 1){
      hash2[v]++;
      if(hash2[v] > count2a){
        count2a = hash2[v];
        result2a = v;
      }
      else if(hash2[v] > count2b){
        count2b = hash2[v];
        result2b = v;
      }
    }
  }
      
  ll result;
  if(result1a != result2a)
    result = n - count1a - count2a;
  else
    result = n - max(count1a + count2b, count2a + count1b);
        
  cout << result << endl;

  return 0;
}

Measured memory_bytes: 1792
from pprint import pprint
import sys


def solve(n):
    for x in range(50001):
        if int(x * 1.08) == n:
            print(x)
            return
        elif x >= n:
            print(":(")
            return
    print(":(")
    

if __name__ == "__main__":
    n = int(sys.stdin.readline().strip())
    solve(n)

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

using namespace std;

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

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


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

	while (cin >> N >> M >> K, N) {
		vector<vector<bool>>v(N, vector<bool>(M, true));
		vector<string>s(K);
		vector<string>t(K);
		for (int i = 0; i < K; i++) {
			cin >> s[i] >> t[i];
		}
		for (int i = 1; i < K; i++) {
			for (int j = 0; j < N; j++) {
				s[i][j] = (s[i][j] != s[i - 1][j]) + '0';
			}
		}
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < K; j++) {
				for (int k = 0; k < M; k++) {
					v[i][k] = v[i][k] && (s[j][i] == t[j][k]);
				}
			}
		}
		vector<int>ans(M, -1);
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < M; j++) {
				if (v[i][j]) {
					if (ans[j] == -1)ans[j] = i;
					else ans[j] = -2;
				}
			}
		}
		for (int i = 0; i < M; i++) {
			if (ans[i] < 0)cout << "?";
			else if (ans[i] < 10)cout << ans[i];
			else cout << char('A' + ans[i] - 10);
		}
		cout << endl;
	}
}


Measured memory_bytes: 4292
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
 
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
 
int X,T;
 
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>X>>T;
	cout<<max(X-T,0)<<endl;
}
 
 
int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main(void){
    string s;cin >> s;
    int count=0,flag=1;
    for(char c='a'; c<='z'; c++){
        int count=0;
        for(int i=0; i<s.size(); i++){
            if(s[i]==c)count++;
        }
        if(count%2!=0)flag=0;
    }
    cout << (flag?"Yes":"No") << endl;
}

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

const int64_t MOD = 1000000007;
typedef int64_t ll;
typedef uint64_t ull;

#define INF LLONG_MAX

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int n,m;
  cin >> n >> m;
  
  int p[n]={};
  for(int i=0;i<n;i++){
    cin >> p[i];
    p[i]--;
  }
  
  vector< vector<int> > op(n);
  
  int x,y;
  for(int i=0;i<m;i++){
    cin >> x >> y;
    x--;y--;
    op[x].push_back(y);
    op[y].push_back(x);
  }

  int flag[n] = {};
  int groupCount = 1;
  int totalCount = 0;
  for(int i=0;i<n;i++){
    if(flag[i]!=0) continue;

    list<int> currentGrp;
    map<int, int> currentGrpPMap;

    queue<int> q; q.push(i);
    flag[i] = groupCount;

    while(!q.empty()){
      int node = q.front(); q.pop();
      currentGrp.push_back(node);
      currentGrpPMap[p[node]]++;
      for(auto nd:op[node]){
        if(flag[nd]==0) q.push(nd);
        flag[nd] = groupCount;
      }
    }
    currentGrp.sort();
    for(auto nd:currentGrp){
      if(currentGrpPMap[nd]>0){
        totalCount++;
      }
    }
    groupCount++;  
  }
  cout << totalCount << endl;
  return 0;
}



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

#define INF (2e9)
#define FOR(i, a, b) for (ll (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)

using namespace std;

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

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

using ll = long long;
using ld = long double;

#define ALL(x) (x).begin(), (x).end()
template<class T>
using vc = vector<T>;
using vi = vc<ll>;
using vvi = vc<vi>;

template<class T>
using va = valarray<T>;
using vad = va<ld>;
using vai = va<ll>;

vi Read(ll n) {
    auto      v = vi(n);
    for (auto i = std::size_t(0); i < n; ++i) {
        cin >> v[i];
    }
    return v;
}

template<class T>
void Dump(const T& A) {
    for (const auto& value : A)
        cout << value << "\n";
}

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

    ll n, m;
    cin >> n;
    const auto A = Read(n);
    cin >> m;
    const auto B = Read(m);

    cout << lexicographical_compare(ALL(A), ALL(B)) << endl;
    return 0;
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
string s;
signed main(){
    cin>>s;
    if(s=="AAA"||s=="BBB")puts("No");
    else puts("Yes");
    return 0;
}


Measured memory_bytes: 768
#include<iostream>
using namespace std;
int main() {
    int s; 
    cin >> s;
    int h = s / 3600;
    s %= 3600;
    int m = s / 60;
    s %= 60;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}

Measured memory_bytes: 1164
//  SMOKE SHISHA PLAY FIFA  // 
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define mod 1000000007
#define lp(start,end) for(ll i=start;i<=end;i++) 
#define deb1(a) cout<<#a<<" = "<<(a)<<endl;
#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;


ll modu(ll a, ll b)
{
	ll ans =1;
	while(b>0)
	{
		if(b&1)
		ans = (ans*a)%mod;
		b/=2;
		a = (a*a)%mod;
	}
	return ans;
}

int main()
{
	fastio
	ll n;
	cin >> n;
	ll arr[n+1];
	for(ll i=1;i<=n;i++)
		cin >> arr[i];
	ll ans=0;
	for(ll i=2;i<=n;i++)
	{
		if(arr[i]<arr[i-1])
		{
			ans+= arr[i-1]-arr[i];
			arr[i]= arr[i-1];
		}
	}
	cout << ans << endl;
	return 0;	
}


Measured memory_bytes: 5128
/*
 * main.c
 *
 *  Created on: 2020/03/28
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;
typedef unsigned long long int ull;

int sort_inc(const void *a, const void *b) { return (*(int*)a - *(int*)b);}
int sort_dec(const void* a, const void* b) { return (*(int*)b - *(int*)a);}
int sort_dec_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = -1; }
    else if (da == db) { val = 0; }
    else { val = 1; }
    return val;
}
int sort_inc_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = 1; }
    else if (da == db) { val = 0; }
    else { val = -1; }
    return val;
}
int sort_dic(const void *a, const void *b) {
    char *pa = (char *)a;    char *pb = (char *)b;    int i = 0, val = 0, N = 10;
    for (i = 0; i < N; i++) {
    	char da = pa[i], db = pb[i];
    	if (da == db) continue;
  		if (da > db) val = 1; else val = -1;
        break;
    }
    return val;
}

void yesno(int ans) {
	if (ans == 1) {	printf("Yes\n");
	} else {		printf("No\n");	}
	return;
}

void okng(int ans) {
	if (ans == 1) { printf("OK\n");
	} else { 		printf("NG\n");	}
	return;
}

char S[200001] = {0};
char T[200001] = {0};

int main()
{
	scanf("%s", S);
	scanf("%s", T);

	int i = 0, len = 0, ans = 0;
	len = strlen(S);
	for (i = 0; i < len; i++) {
		if (S[i] != T[i]) {
			ans++;
		}
	}
	printf("%d\n", ans);
	//yesno(ans);
	//okng(ans);
	return 0;
}


Measured memory_bytes: 2068
use std::io::*;
use std::str::FromStr;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let a:Vec<u64> = (0..n).map(|_| read()).collect();

    let mut money = 1000;
    for i in 0..n-1{
        if a[i] < a[i+1]{
            let stock = money/a[i];
            money += stock * (a[i+1] - a[i]);
        }
    }
    println!("{}",money);
}


Measured memory_bytes: 2152
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.lang.*;


public class Main {


    public static void main(String[] args) {
        FastReader in = new FastReader();
        int n = in.nextInt();
        int arr[] = new int[n];
        for(int i=0;i<n;i++){
            arr[i] = in.nextInt();
        }
        int a = 0;
        int b = Math.abs(arr[1] - arr[0]);
        for(int i=3;i<=n;i++){
            int temp = b;
            b = Math.min(Math.abs(arr[i-1]-arr[i-2])+b , Math.abs(arr[i-1]-arr[i-3]) + a );
            a = temp;
        }
        System.out.println(b);


    }



    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}



Measured memory_bytes: 32260
#coading Shit_JIS

def judge(ch1,ch2):
	if ch1!=ch2: return 1
	return 0

while 1:
	str1=input().split('"')
	if str1[0]=='.': break
	str2=input().split('"')
	l1=len(str1)
	l2=len(str2)
	flag=[0]*2
	if l1-l2!=0: flag[0]=1
	else:
		for j in range(l1):
			if len(str1[j])!=len(str2[j]):
				flag[j%2]+=1
			else:
				for i in range(len(str1[j])):
					if judge(str1[j][i],str2[j][i]):
						flag[j%2]+=1
					
				
			
		
	if flag[0]!=0 or flag[1]>=2: print("DIFFERENT")
	elif flag[1]==1: print("CLOSE")
	else: print("IDENTICAL")


Measured memory_bytes: 5584
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
using namespace std;

#define DEBUG 0
#define REP(i, n) for (int i = 0; i < (n); i++) 
typedef long long ll;
typedef pair<int,int> pint;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

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

    res = n + m;
    res %= 24;


    cout << res << endl;
 
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};
 
 
void solve(){
    char a,b;
    cin>>a>>b;
    if(a=='H'&&b=='H') cout<<"H"<<endl;
    else if(a=='H'&&b=='D') cout<<"D"<<endl;
    else if(a=='D'&&b=='H') cout<<"D"<<endl;
    else if(a=='D'&&b=='D') cout<<"H"<<endl;

    
} 
 
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
     
    ll Q=1;
    // cin>>Q;
    rep(_,Q){
 
        solve();
 
    }
   
 
 
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>

#define MAX 200000
#define INF INT_MAX
typedef long long ll;

void merge(int*, int, int, int);
void mergesort(int*, int, int);

ll ans;

int n, a[MAX];

int main(){
  int i;

  scanf("%d" ,&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d" ,a + i);
  }
  mergesort(a,0,n);
  printf("%lld\n" ,ans);

  return 0;
}

void merge(int a[], int left, int mid, int right){//マージソートのソート部分
  int n1 = mid - left, n2 = right - mid;
  int L[n1+1], R[n2+1], i, j, k;
 
  for(i = 0 ; i < n1 ; i++){
    L[i] = a[left + i];
  }
 
  for(i = 0 ; i < n2 ; i++){
    R[i] = a[mid + i];
  }
 
  L[n1] = R[n2] = INF;
 
  for(i = 0, j = 0, k = left ; k < right ; k++){
    if(i < n1 && (j == n2 || L[i] <= R[j])){
      a[k] = L[i++];
    }else{
      ans += (n1 + n2) / 2 - i;
      a[k] = R[j++];
    }
  }
}
 
void mergesort(int a[], int left, int right){//マージソートを利用して計算を行う
  int mid;
 
  if(left + 1 < right){
    mid = (left + right) / 2;
    mergesort(a, left, mid);
    mergesort(a, mid, right);
    merge(a, left, mid, right);
  }
}



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

int p[5],v[100005],o[100005],f=1;
vector<int>b[100005];

void dfs(int a,int d){
	int i;
	//cout<<a<<' '<<d<<endl;
	if(o[a]!=0){
		if(v[a]!=d)f=0;
		return;
	}
	
	v[a]=d;
	o[a]=1;
	
	for(i=0;i<b[a].size();i+=2){
		dfs(b[a][i],d+b[a][i+1]);
	}
	
	return;
}

int main(){
	int n,m,i;
	cin>>n>>m;
	
	for(i=1;i<=m;i++){
		cin>>p[1]>>p[2]>>p[3];
		b[p[1]].push_back(p[2]);
		b[p[1]].push_back(p[3]);
		b[p[2]].push_back(p[1]);
		b[p[2]].push_back(0-p[3]);
	}
	
	for(i=1;i<=n;i++){
		if(o[i]==0)dfs(i,0);
	}
	
	if(f==1)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	
	return 0;
}

Measured memory_bytes: 12416
#include <iostream>
using namespace std;
int n,count;
int main(){
	while(1){
		cin >> n;
		if(n==0)break;
		n=1000-n;
		count=0;
		count+=n/500;
		n=n%500;
		count+=n/100;
		n=n%100;
		count+=n/50;
		n=n%50;
		count+=n/10;
		n=n%10;
		count+=n/5;
		n=n%5;
		count+=n;
		cout << count <<endl;
	}
	return 0;
}

Measured memory_bytes: 3040
#include <bits/stdc++.h>
    using namespace std;
     
    string solve(vector<int>& v,int k){
     
      bool dp[k+1];
      memset(dp,0,sizeof dp);
      for(int i=1;i<=k;i++){
        for(int move :v){
            if(move>i){
              continue;
            }
            if(dp[i-move]==0){
              dp[i]=1;
            }
        }
      }
      return dp[k] ? "First":"Second";
     
    }
     
     
    int main(){
        int n,k;
        cin>>n>>k;
        vector<int> v(n);
        for(int i=0;i<n;i++){
          cin>>v[i];
        }
       cout<<solve(v,k);  
    }

Measured memory_bytes: 3724
N,M,L = map(int,input().split())

A = [list(map(int,input().split())) for i in range(N)] #N*M配列の取得
B = [list(map(int,input().split())) for i in range(M)] #M*L配列の取得
ANS = [[0]*L for i in range(N)] #N*L


for x in range(N):
    for y in range(L):
        for z in range(M):
            ANS[x][y] += B[z][y]*A[x][z]

for row in range(N):
    print("%d"%ANS[row][0],end = "")
    for col in range(1,L):
        print(" %d"%(ANS[row][col]),end = "")
    print()



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

typedef long long int ll;
#define endl "\n"
#define pll pair<ll, ll>
#define pii pair<int, int>
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pair<int, int>>
#define mems(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define forn(i, s, e) for (int i = s; i < (e); ++i)
#define FASTIO                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define FILEIO                          \
    freopen("./input.txt", "r", stdin); \
    freopen("./output.txt", "w", stdout);
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d)                                                               \
    for (                                                                       \
        auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); \
        blockTime.second;                                                       \
        debug("%s : %lld ms\n ", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false)
const int M = 1e9 + 7;

template <class T>
T ABS(const T &x) { return x > 0 ? x : -x; }
ll gcd(ll n1, ll n2) { return n2 == 0 ? ABS(n1) : gcd(n2, n1 % n2); }
ll lcm(ll n1, ll n2) { return n1 == 0 && n2 == 0 ? 0 : ABS(n1 * n2) / gcd(n1, n2); }

int main()
{
    FASTIO
#ifdef LOCAL
    FILEIO
#endif
    int n, i;
    cin >> n;
    if (n % 111 == 0)
    {
        cout << n << endl;
        return 0;
    }
    for (i = 1; i < 10; ++i)
    {
        if (n < i * 111)
        {
            break;
        }
    }
    cout << i * 111 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long X;
  cin >> X;
  long cul;
  int flag = 0;

  for (long i = -120; i < 120 ; i++) {
      if(flag == 1){
            break;
        } 
    for (long j = i+1; j < 120 ; j++) {
        cul = j*j*j*j*j - i*i*i*i*i;
        if(cul == X){
            cout << j << " " << i <<endl;
            flag = 1;
            break;
        }

    }
  }
}

Measured memory_bytes: 3632
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

int main(){
	char s[100];
	char s2[200];
	char p[100];
	int num=0;
	int i, j;
	int flag;


	scanf("%s", s);
	scanf("%s", p);
	strcpy(s2, s);
	strcat(s2, s);

	for(i=0; i< strlen(s); i++){
		flag = 1;
		for(j=0; j<strlen(p); j++){
			if(s2[i + j] != p[j])
				flag = flag * 0;
		}
		if(flag == 1)
			num = num + 1;
	}
	
	if(num > 0)
		printf("Yes\n");
	else
		printf("No\n");

	return 0;

}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s, t;
  cin >> s >> t;
  int sl = s.length(), tl = t.length();
  vector<vector<string>> dp(2, vector<string>(sl + 1));
  for(int j = 1; j <= tl; j++) {
    for(int i = 1; i <= sl; i++) {
      if(s[i - 1] == t[j - 1]) {
        dp[1][i] = dp[0][i - 1];
        dp[1][i].push_back(s[i - 1]);
      } else {
        if(dp[1][i - 1].length() < dp[0][i].length())
          dp[1][i] = dp[0][i];
        else
          dp[1][i] = dp[1][i - 1];
      }
    }
    swap(dp[0], dp[1]);
  }
  cout << dp[0][sl] << "\n";
}

Measured memory_bytes: 16812
n = int(input())

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

diff = [data[i]-(i+1) for i in range(n)]

res = 0
for i in range(n-1):
    if diff[i] == 0:
        diff[i] = diff[i+1]+1
        diff[i+1] = -1
        res+=1
if diff[n-1] == 0:
    res+=1
print(res)


Measured memory_bytes: 13880
#include <bits/stdc++.h>
#define name "bai2"
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ll long long

using namespace std;

const ll mod=1e9+7;
ll n,k,a[2009];
int main()
{
    cin >> n >> k;
    for(int i=1; i<=n; ++i)cin >> a[i];
    ll ans=0;
    /// cal in group
    for(int i=1; i<=n; ++i)
        for(int j=1; j<i; ++j)
        if(a[j]>a[i])++ans;
    ans=(ans*k)%mod;
    /// out group
    ll t=(k*(k-1)/2) % mod;
    for(int i=1; i<=n; ++i){
        ll s=0;
        for(int j=1; j<=n; ++j)
        if(a[i]>a[j])++s;
        ans=(ans+(s*t)%mod)%mod;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 
 //    String[] nyu=sc.nextLine().split(" ");

     String nyu=sc.nextLine();
//int A=Integer.parseInt(nyu[0]);
//int B=Integer.parseInt(nyu[1]);
//int C=Integer.parseInt(nyu);



//double A=Double.parseDouble(nyu[0]);
//double B=Double.parseDouble(nyu[1]);
/*
switch(C){
case 7:
case 5:
case 3:
System.out.println("YES") ;
break;
default:
System.out.println("NO") ;

break;
}
*/

//int res=A*B;
//if(res%2==0){

System.out.println(nyu.replace("2017" , "2018"));
//}else{
//System.out.println("Odd");

//}




	}
}

Measured memory_bytes: 21716
#include <iostream>

using namespace std;

int main()
{
int n,t,sum =0,remainder;
cin>>n;
t=n;

while (t!=0){
    remainder =t%10;
    sum=sum +remainder;
    t=t/10;
}

if (n%sum==0)
    cout<<"Yes";

else
    cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair

using namespace std;

typedef pair<int, int> P;
typedef long long LL;
static const int INF = INT_MAX;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, h, w;
    cin >> n >> h >> w;
    cout << (n - h + 1) * (n - w + 1) << endl;
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++)
    cin >> a.at(i);
  
  sort(a.begin(), a.end());
  int dif=0;
  for(int i=0; i<n-1; i++){
    dif += a.at(i+1) - a.at(i);
  }
  cout << dif << endl;
}

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


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

// #define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif
#define LDcout(x,n) fixed<<setprecision(n)<<x

#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
int n,s;
int main(){
	cin>>n>>s;
	s--;
	vector<pair<pll,int> > v(n);
	rep(i,n){
		cin>>v[i].F.F>>v[i].F.S;
		v[i].S=i;
		swap(v[i].F.F,v[i].F.S);
	}
	sort(ALL(v));
	rep(i,n){
		swap(v[i].F.F,v[i].F.S);
	}
	vvll vv;
	initvv(vv,n,n);
	rep(i,n){
		rep(j,n){
			cin>>vv[i][j];
		}
	}
	rep(k,n){
		rep(i,n){
			rep(j,n){
				vv[i][j]=min(vv[i][j],vv[i][k]+vv[k][j]);
			}
		}
	}
	vll dp(n,LLONG_MIN/2);
	//21 50
	rep(i,n){
		if(vv[s][v[i].S]>v[i].F.S) continue;
		dp[v[i].S]=v[i].F.S-max(v[i].F.F,vv[s][v[i].S]);
	}
	vector<vector<pll> > ed(n);
	rep(i,n){
		rep(j,n){
			if(i==j) continue;
			ll t=v[j].F.S-max(v[j].F.F,vv[i][j]+v[i].F.S);
			if(t<=0) continue;
			ed[i].PB(pll(j,t));
		}
	}
	rep(i,n){
		rep(j,n){
			if(v[i].F.S+vv[v[i].S][v[j].S]>v[j].F.S) continue;
			ll t=v[j].F.S-max(v[j].F.F,vv[v[i].S][v[j].S]+v[i].F.S);
			dp[v[j].S]=max(dp[v[j].S],dp[v[i].S]+t);
		}
	}
	ll ans=0;
	rep(i,n){
		ans=max(ans,dp[i]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 5756
#include<vector>
#include<map>
#include<string>
#include<iostream>
#include<numeric>
#include<algorithm>
using namespace std;
int main(){for(int n,k;cin>>n>>k,n;){
	vector<string> v;string s;
	for(;n;n--)cin>>s,v.push_back(s);
	map<string,int>m;
	sort(v.begin(),v.end());
	do{
		m[accumulate(v.begin(),v.begin()+k,string(),[](string x,string y){return x+y;})]=1;
		//http://origin.googlecode.com/svn-history/r366/trunk/core/include/origin/algorithm/boost_combination.hpp
		if(v.begin()==v.begin()+k)break;
		reverse(v.begin()+k,v.end());
	}while(next_permutation(v.begin(),v.end()));
	cout<<m.size()<<endl;
}}

Measured memory_bytes: 1508
import collections

n = int(input())
v = list(map(int, input().split()))

ve = []
for i in range(0, n, 2):
    ve.append(v[i])
ce = collections.Counter(ve).most_common()
vo = []
for i in range(1, n, 2):
    vo.append(v[i])
co = collections.Counter(vo).most_common()

if ce[0][0] != co[0][0]:
    print(n - (ce[0][1] + co[0][1]))
elif len(ce) == 1 and len(co) == 1:
    print(n // 2)
elif len(ce) == 1 and len(co) >= 2:
    print(n // 2 - co[1][1])
elif len(ce) >= 2 and len(co) == 1:
    print(n // 2 - ce[1][1])
else:
    print(n - max((ce[0][1] + co[1][1]), (ce[1][1] + co[0][1])))

Measured memory_bytes: 21212
#include <bits/stdc++.h>
typedef long long ll;

#define pll pair<ll,ll>
#define ff first
#define snd second
#define pb push_back
#define vll vector<ll>
#define vpll vector<pll>
#define endl "\n"
#define MOD 1000000007
using namespace std;

ll const N = 1e5+1;


void solve()
{
   ll n;
   cin>>n;
   ll a[n];
   ll xv = 0;
   for(int i=0;i<n;i++)
   {
           cin>>a[i];
           xv^=a[i];
   }
   
   for(int i=0;i<n;i++)
   {
           cout<<(xv^a[i])<<" ";
   }
   
}
 
int main() {
            ios_base::sync_with_stdio(false);
            cin.tie(NULL);
	    int t=1;
	    //cin>>t;
	    while(t--)
	    {
	            solve();
	    }
	    return 0;
}

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

int n,w,d;

class Cake{
public:
	int x,y,id;
	Cake(int x,int y,int id):x(x),y(y),id(id){}
	Cake(){}
	int calc(){return x*y;}
};

int main()
{
	while(cin>>n>>w>>d && w!=0){
		vector<Cake> Now;
		vector<Cake> Next;
		Next.push_back(Cake(w,d,1));
		for(int turn=1;turn<=n;turn++){
			Now=Next;
			Next.clear();
			int p,s;
			cin>>p>>s;
			for(int i=0;i<Now.size();i++){
				if(Now[i].id==p){
					Cake c1,c2;
					s%=Now[i].x+Now[i].y;
					if(s<Now[i].x){
						c1.y=c2.y=Now[i].y;
						c1.x=s;
						c2.x=Now[i].x-s;
					}
					else{
						c1.x=c2.x=Now[i].x;
						c1.y=s-Now[i].x;
						c2.y=Now[i].y-(s-Now[i].x);
					}
					if(c1.calc()<c2.calc()){ c1.id=turn;c2.id=turn+1;}
					else{c1.id=turn+1;c2.id=turn;}
					Next.push_back(c1);
					Next.push_back(c2);
				}
				else{
					if(Now[i].id>p) Now[i].id--;
					Next.push_back(Now[i]);
				}
			}
		}
		vector<int> ans;
		for(int i=0;i<Next.size();i++)
			ans.push_back(Next[i].calc());
		sort(ans.begin(),ans.end());
		for(int i=0;i<ans.size();i++){
			cout<<ans[i];
			if(i!=ans.size()-1) cout<<" ";
		}
		cout<<endl;
		
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <math.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
ll d,p[15],c[15],g,o[20],ans=1005;
int main(void){
    cin>>d>>g;
    for(int i=0;i<d;i++){
        cin>>p[i]>>c[i];
    }
    for(int i=0;i<d;i++)o[i]=i;
    do{
        ll s=0,t=0;
        for(ll i=0;i<d;i++){
            if(s+100*(o[i]+1)*p[o[i]]+c[o[i]]<g){
                s+=100*(o[i]+1)*p[o[i]]+c[o[i]];
                t+=p[o[i]];
            }else{
                if(s+100*(o[i]+1)*p[o[i]]+c[o[i]]>=g){
                    ans=min(ans,t+p[o[i]]);
                }
                t+=(g-s+100*(o[i]+1)-1)/(100*(o[i]+1));
                ans=min(ans,t);
                break;
            }
        }
    }while(next_permutation(o,o+d));
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

    public class Main {
    	public static void main(String[] args) {
    		Scanner sc = new Scanner(System.in);
    		int n = sc.nextInt();
    		int x =0;
    		int max=0;
    		String s = sc.next();
    		String tmp= "";
    		for(int i=0;i<n;i++) {
    			tmp=s.substring(i, i+1);
    			if(tmp.equals("I")){
    				x++;
    			}
    			else {
    				x--;
    			}
    			if(max<x) {
    				max=x;
    			}
    		}
    		System.out.println(max);
    	}
    }

Measured memory_bytes: 21716
// https://atcoder.jp/contests/abc158/tasks/abc158_e

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

#define DEBUG 0
#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#if DEBUG
  #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " ")
  #define DUMP2D(b) REP(_j, b.size()) DUMP(b[_j]); cout << endl
#else
  #define DUMP(a)
  #define DUMP2D(b)
#endif

const int N_MAX = 2*1e5;
const int P_MAX = 10000;

int N, P;
string S;

vector<int> v;
map<int, int> mp;

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

  ll ans = 0;
  if (10 % P == 0) {
    REP(i, N) {
      int d = S[i] - '0';
      if (d % P == 0) {
        ans += i + 1;
      }
    }
  } else {
    v = vector<int>(N);
    reverse(S.begin(), S.end());

    int w = 0;
    int mag = 1;
    REP(i, N) {
      int d = S[i] - '0';
      v[i] = w = (d * mag % P + w) % P;
      mp[v[i]]++;
      mag = mag * 10 % P;
    }

    DUMP(v);

    ans = mp[0];
    REP(i, N - 1) {
      mp[v[i]]--;
      ans += mp[v[i]];
#if DEBUG
      cout << i << "," << v[i] << "," << mp[v[i]] << endl;
#endif
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 4684
import java.util.Scanner;
 
class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
 
    int temp = sc.nextInt();
    if(temp >= 30){
      System.out.println("Yes");
  }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 35604
#include <iostream>
using namespace std;
int main(){
	int W,H,x,y,r;
	cin>>W>>H>>x>>y>>r;
	if(W>=x+r&&H>=y+r&&0<=x-r&&0<=y-r){
	cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 3088
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(void){

  char w[10];
  char t[1000];
  char e[] = {"END_OF_TEXT"};
  int i, ii, iii;
  int c = 0;

  scanf("%s", w);
  ii = strlen(w);
  for(i = 0; i > -1; i++){
    for(i = 0; i < ii; i++){
      w[i] = tolower(w[i]);
    }
    scanf("%s", t);
    if(strcmp(e, t) == 0) break;
    iii = strlen(t);
    for(i = 0; i < iii; i++){
      t[i] = tolower(t[i]);
    }
    if(strcmp(w, t) == 0) c++;
  }
  printf("%d\n",c);
  return 0;
}

Measured memory_bytes: 552
N=gets.to_i
a = gets.split.map(&:to_i) + [0]
all_cost = a[0].abs
N.times do |i|
  all_cost += (a[i] - a[i+1]).abs
end
ans = []
N.times do |i|
  ans << all_cost + (a[i-1] - a[i+1]).abs - (a[i]-a[i-1]).abs - (a[i]-a[i+1]).abs
end
puts ans

Measured memory_bytes: 13188
fun main(args: Array<String>) {
    val (w,h,n)= readLine()!!.split(" ").map { it.toInt() }
    val xya = (1..n).map { readLine()!!.split(" ").map { it.toInt() } }

    var l=0
    var r=w
    var u=h
    var d=0
    xya.forEach {
        when(it[2]){
            1 -> l=Math.max(l,it[0])
            2 -> r=Math.min(r,it[0])
            3 -> d=Math.max(d,it[1])
            4 -> u=Math.min(u,it[1])
        }
    }
    if(r-l<0||u-d<0){
        println(0)
    }else{
        println((r-l)*(u-d))
    }
}

Measured memory_bytes: 37932
k = int(input())
if k <10:
    print(k)
    exit()
ls = [0] * (k+1)
for i in range(10):
    ls[i] = str(i)

l = len(str(k))
cnt = 10
tag = 1
f = False
for j in range(k+1):
    s = ls[tag]
    for i in range(10):
        if  abs(int(s[-1])-i) <=1:
            ls[cnt] =  s+str(i)
            cnt+=1
        if cnt ==k+1:
            f = True
            break
    if f:
        break
    tag +=1
print(ls[-1])


Measured memory_bytes: 10100
class Culuculation():
  N = 0
  K = 0
  H = []
  
  #初期化。ここで引数も受け取る
  def __init__(self):
    self.N, self.K = ( int(x) for x in input().split(' '))
    self.H = [int(x) for x in input().split(' ')]

  #計算処理
  def culc(self):
    self.H.sort(reverse=True)
    if self.N >= self.K:
      del self.H[0:self.K]
    else:
      self.H.clear()
    print(sum(self.H))

def main():
  tmp = Culuculation()
  tmp.culc()

if __name__=='__main__':
  main()

Measured memory_bytes: 26024