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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)

using LL  = long long;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<int> a(n), b(n), c(n);
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<n;i++) cin >> b[i];
    for(int i=0;i<n;i++) cin >> c[i];

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    //for(int i=0;i<n;i++) cout << a[i] << " ";
    //cout << endl;
    //for(int i=0;i<n;i++) cout << b[i] << " ";
    //cout << endl;
    //for(int i=0;i<n;i++) cout << c[i] << " ";
    //cout << endl;

    vector<LL> a_ans(n, 0), b_ans(n, 0);
    vector<LL> b_sum(n, 0);

    for(int i=0;i<n;i++){
        b_ans[i] = c.end() - upper_bound(c.begin(), c.end(), b[i]);
        //cout << b_ans[i] << " ";
    }
    //cout << endl;

    b_sum[n-1] = b_ans[n-1];
    for(int i=n-2;i>=0;i--){
        b_sum[i] = b_sum[i+1] + b_ans[i];
    }

    LL ans = 0;
    for(int i=0;i<n;i++){
        int p = b.end() - upper_bound(b.begin(), b.end(), a[i]);
        p = n - p;
        if(p == n) continue;
        ans += b_sum[p];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3840
#include"bits/stdc++.h"
using namespace std;
#define int long long
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int> P;
constexpr long long inf = 1e17;
constexpr int mod = 998244353;

signed main() {
	int n, k; cin >> n >> k;
	vector<int>v1(n), v2(n), v3(n);
	for (int i = 0; i < n; i += 2) {
		v1[i] = k; k++;
	}
	for (int i = 1; i < n; i += 2) {
		v1[i] = k; k++;
	}
	for (int i = 1; i < n; i += 2) {
		v2[i] = k; k++;
	}
	for (int i = 0; i < n; i += 2) {
		v2[i] = k; k++;
	}
	rep(i, n) {
		v3[i] = k; k++;
	}
	int flg = 0;
	rep(i, n) {
		if (v1[i] + v2[i] > v3[i])flg++;
	}
	if (flg)cout << -1 << endl;
	else {
		rep(i, n) {
			cout << v1[i] << ' ' << v2[i] << ' ' << v3[i] << endl;
		}
	}
}

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

const int N = 100;
const int L = 1000;
const int INF = 1e+8 + 10;
const int MAX_V = L * 2 + 2;

struct data{
  int p, t;
  data(int p=0, int t=0):p(p),t(t){}
  bool operator < (const data &d) const {
    return t < d.t;
  }
};

struct edge{
  int to, cap, rev;
  edge(int t=0, int c=0, int r=0):to(t),cap(c),rev(r){}
};
  
void add_edge(int from, int to, int cap, vector<edge> G[MAX_V]){
  G[from].push_back(edge(to, cap, G[to].size()));
  G[to].push_back(edge(from, 0, G[from].size()-1));
}
 
int dfs_f(int v, int t, int f, vector<edge> G[MAX_V], bool used[MAX_V]){
  if(v == t) return f;
  used[v] = true;
  for(int i=0;i<G[v].size();i++){
    edge &e = G[v][i];
    if(!used[e.to] && e.cap > 0){
      int d = dfs_f(e.to, t, min(f, e.cap), G, used);
      if(d > 0){
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}
 
int max_flow(int s, int t, vector<edge> G[MAX_V]){
  int flow = 0;
  while(1){
    bool used[MAX_V];
    fill(used, used+MAX_V, false);
    int f = dfs_f(s, t, INF, G, used);
    if(f == 0) return flow;
    flow += f;
  }
}



int n, m, l, G[N][N];
vector<data> v;

int solve(){
  vector<edge> fG[MAX_V];

  for(int i=0;i<n;i++) G[i][i] = 0;
  for(int k=0;k<n;k++){
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
      }
    }
  }

  sort(v.begin(), v.end());
  for(int i=0;i<l;i++){
    add_edge(l*2, i, 1, fG);
    add_edge(l+i, l*2+1, 1, fG);
    //add_edge(i, l+i, 1, fG);
    for(int j=i+1;j<l;j++){
      if(G[v[i].p][v[j].p] < INF && v[i].t + G[v[i].p][v[j].p] <= v[j].t) {
        add_edge(j, l+i, 1, fG);
      }
    }
  }

  // ?????§???????????? = V - ????°?????????????
  return l - max_flow(l*2, l*2+1, fG);
}

int main(){
  int x, y, d;
  while(cin >> n >> m >> l && (n|m|l)){
    fill(G[0], G[n], INF);
    v.clear();
    for(int i=0;i<m;i++){
      cin >> x >> y >> d;
      G[x][y] = min(G[x][y], d);
      G[y][x] = min(G[y][x], d);
    }
    for(int i=0;i<l;i++){
      cin >> x >> y;
      v.push_back(data(x,y));
    }
    cout << solve() << endl;
  }
}

Measured memory_bytes: 17064
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<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()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

use std::cmp::max;
fn main() {
    let a: i64 = read();
    let b: i64 = read();
    let c: i64 = read();
    let d: i64 = read();
    let ans = max(max(a * c, a * d), max(b * c, b * d));
    println!("{}", ans);
}


Measured memory_bytes: 2156
#include <stdio.h>

int main(void){
   int n,i;
   scanf("%d",&n);

   double coin[n],t=0; char ch[n][4];
   for(i=0;i<n;i++)
      scanf("%lf%s",&coin[i],ch[i]);

   for(i=0;i<n;i++){
      if(ch[i][0]=='J'){
         t+=coin[i];
      } else {
         t+= coin[i]*380000;
      }
   }

   printf("%lf\n",t);
   return 0;
}

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

using namespace std;

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

    int wa = 0, ac = 0;
    unordered_map<int, int> waCount, acCount;

    for (int i = 0; i < m; i++)
    {
        int x;
        string verdict;
        cin >> x >> verdict;
        if (verdict == "WA")
            waCount[x]++;
        else if (verdict == "AC")
        {
            if (acCount[x] == 0)
            {
                acCount[x] = 1;
                ac++;
                wa += waCount[x];
            }
        }
    }
    cout << ac << " " << wa << endl;
    return 0;
}

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

#define lli long long int
#define endl "\n"
#define forn(i, in, fin) for(int i = in; i<fin; i++)
#define all(v) v.begin(), v.end()
#define fastIO(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;

const lli INF = numeric_limits<lli>::max();

int main()
{
    fastIO();
    lli n; cin>>n;
    vector<lli> slimes(n);
    for(auto &x: slimes)
    {
        cin>>x;
    }
    vector<lli> prefix(n);
    prefix[0] = slimes[0];
    forn(i, 1, n)
    {
        prefix[i] = prefix[i-1] + slimes[i];
        //cout<<prefix[i]<<" ";
    }

    vector< vector<lli> > dp(n, vector<lli>(n, INF));
    for(int L = n-1; L>=0; L--)
    {
        for(int R = L; R<n; R++)
        {
            if(L==R) //Unico elemento
            {
                dp[L][R] = 0;
                continue;
            }
            lli suma = prefix[R] - (L<=0?0: prefix[L-1]);
            //cout<<suma<<endl;
            for(int pivot = L; pivot<R; pivot++)
            {
                dp[L][R] = min(dp[L][R], dp[L][pivot] + dp[pivot+1][R] + suma);
            }
        }
    }
    cout<<dp[0][n-1]<<endl;


    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  string s;
  cin >>s;
  ll ss=s.size(),i=0;
  reverse(s.begin(),s.end());
  while(1){
    if(i>=ss) break;
    if(s[i]=='e'){
      if(s.substr(i,5)=="esare") i+=5;
      else{
       cout <<"NO"<<endl;
       return 0;
      }
    }
    else if(s[i]=='m'){
      if(s.substr(i,5)=="maerd") i+=5;
      else{
       cout <<"NO"<<endl;
       return 0;
      }
    }
    else if(s[i]=='r'){
      if(s.substr(i,6)=="resare") i+=6;
      else if(s.substr(i,7)=="remaerd") i+=7;
      else{
       cout <<"NO"<<endl;
       return 0;
      }
    }
  }
  cout <<"YES"<<endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;
 
int main() {
	int n,m,l; cin>>n>>m>>l;
  	vector<vector<long long>> data1(n,vector<long long>(m));
  	vector<vector<long long>> data2(m,vector<long long>(l));
  	vector<vector<long long>> data3(n,vector<long long>(l));
  
  	for (int i=0;i<n;i++){
      for (int j=0;j<m;j++){
    		cin>>data1.at(i).at(j);
    	}  
	}
  
  	for (int j=0;j<m;j++){
      for (int k=0;k<l;k++){
    		cin>>data2.at(j).at(k);
    	}  
	}
  	
  	for(int i=0;i<n;i++){
      for(int j=0;j<l;j++){
        for(int k=0;k<m;k++){
    		data3.at(i).at(j)+=data1.at(i).at(k)*data2.at(k).at(j);
        }
      }
    }
  	for(int i=0;i<n;i++){
      for(int j=0;j<l;j++){
     	cout<<data3.at(i).at(j);
        if(j!=l-1) cout<<" ";
      }
      cout<<endl;
    }
  
}	


Measured memory_bytes: 3264
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const int maxN = 1005;
const int maxP = 5005;
int n;
int x[maxN];
int ans[maxN];
vector < int > g[maxN];
int dp[maxN][maxP];
int ndp[maxP];
const int INF = (int)1e9;
void dfs(int v) {
    for (int i = 0; i < maxP; i++) {
        dp[v][i] = INF;
    }
    dp[v][0] = 0;
    for (int to : g[v]) {
        dfs(to);
        for (int j = 0; j < maxP; j++) {
            ndp[j] = INF;
        }
        for (int j = 0; j < maxP; j++) {
            if (j + x[to] < maxP) {
                ndp[j + x[to]] = min(ndp[j + x[to]], dp[v][j] + ans[to]);
            }
            if (j + ans[to] < maxP) {
                ndp[j + ans[to]] = min(ndp[j + ans[to]], dp[v][j] + x[to]);
            }
        }
        for (int j = 0; j < maxP; j++) {
            dp[v][j] = ndp[j];
        }
    }
    ans[v] = INF;
    for (int j = 0; j <= x[v]; j++) {
        ans[v] = min(ans[v], dp[v][j]);
    }
    if (ans[v] > INF / 2) {
        cout << "IMPOSSIBLE";
        exit(0);
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n;
    for (int i = 2; i <= n; i++) {
        int x;
        cin >> x;
        g[x].push_back(i);
    }
    for (int i = 1; i <= n; i++) {
        cin >> x[i];
    }
    dfs(1);
    cout << "POSSIBLE";
    return 0;
}

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

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class DMovingPiece {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, k; cin >> n >> k;
      vector<ll> p(n), c(n);
      rep(i, n) {
        cin >> p[i];
        p[i]--;
      }
      rep(i, n) {
        cin >> c[i];
      }

      vector<P> dp(n);
      rep(i, n) {
        int pos = i;
        ll now = c[pos];
        int loop = 1;
        while(p[pos] != i) {
          pos = p[pos];
          now += c[pos];
          loop++;
        }
        dp[i] = {now, loop};
      }

      ll ret = LLONG_MIN;

      rep(i, n) {
        if (dp[i].first <= 0) {
          int pos = i;
          ll now = 0;
          rep(j, min(dp[i].second, (ll)k)) {
            now += c[pos];
            chmax(ret, now);
            pos = p[pos];
          }
        } else {
          ll cnt = (k - dp[i].second) / dp[i].second;
          chmax(cnt, 0LL);
          ll now = cnt * dp[i].first;
          ll remaining = k - dp[i].second*cnt;
          int pos = i;
          rep(j, remaining) {
            now += c[pos];
            chmax(ret, now);
            pos = p[pos];
          }



        }
      }

      cout << ret << endl;


    }
};

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

Measured memory_bytes: 3784
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>
#include <fstream>
#include <ctime>

using namespace std;
using ll = long long;

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

template <class T>
std::vector<T> enum_div(T n) {
    std::vector<T> ret;
    for (T i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) {
                ret.push_back(n / i);
            }
        }
    }
    return ret;
}

bool isPrime(ll num) {
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;


    for (ll i = 3; i * i <= num; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
};


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

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

template<class T>
bool is_integer(T x) {
    return std::floor(x) == x;
}

struct ToUpper {
    char operator()(char c) { return toupper(c); }
};

struct ToLower {
    char operator()(char c) { return tolower(c); }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int R;
    cin >> R;
    cout << R * R << endl;
    return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
int a[1234], b[1234], dp[1234][1234];
signed main() {
	int w, n, l = 1;
	while (cin >> w, w) {
		cin >> n;
		for (int j = 1; j <= n; j++) {
			string s; cin >> s;
			int pw = 0;
			for (int i = 0; i < s.size(); i++) {
				if (s[i] == ',') {
					a[j] = pw; pw = 0;
				}
				else {
					pw *= 10; pw += s[i] - '0';
				}
			}
			b[j] = pw;
		}
		for (int i = 0; i <= n; i++) {
			for (int j = 0; j <= w; j++) {
				dp[i][j] = -1;
			}
		}
		dp[0][0] = 0;
		for (int i = 1; i <= n; i++) {
			for (int j = 0; j <= w; j++)dp[i][j] = dp[i - 1][j];
			for (int j = 0; j + b[i] <= w; j++) {
				if (dp[i-1][j] >= 0) {
					dp[i][j + b[i]] = max(dp[i][j + b[i]], dp[i - 1][j] + a[i]);
				}
			}
		}
		int ans1 = 0, ans2 = 0;
		for (int i = 0; i <= w; i++) {
			if (ans1 < dp[n][i]) {
				ans1 = dp[n][i];
				ans2 = i;
			}
		}
		cout << "Case " << l << ":\n";
		cout << ans1 << endl << ans2 << endl;
		l++;
	}
}


Measured memory_bytes: 12728
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    int N, L;
    string s;
    vector<string> v;
    cin >> N >> L;
    for(int i = 0; i < N; i++){
        cin >> s;
        v.push_back(s);
    }
    sort(v.begin(), v.end());
    for(int i = 0; i < N; i++){
        cout << v[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    debt = 100000

    for i in range(n):
        tmp_debt = debt * 1.05
        debt = int(tmp_debt / 1000) * 1000

        if int(tmp_debt) > debt:
            debt += 1000

    print(debt)


if __name__ == '__main__':
    main()

Measured memory_bytes: 6752
# Aizu Problem ITP_1_9_B: Shuffle
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


while True:
    string = input().strip()
    if string == '-':
        break
    n = int(input())
    for _ in range(n):
        h = int(input())
        string = string[h:] + string[:h]
    print(string)

Measured memory_bytes: 7648
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let mut graph = vec![vec![]; n];
    for _ in 1..n {
        let a = sc.read::<usize>();
        let b = sc.read::<usize>();
        graph[a].push(b);
        graph[b].push(a);
    }

    match (0..n).find(|&v| graph[v].len() >= 3) {
        Some(v) => {
            println!("{}", dfs(v, v, &graph).1);
        }
        None => {
            println!("1");
        }
    }
}

fn dfs(v: usize, p: usize, graph: &Vec<Vec<usize>>) -> (bool, usize) {
    let mut ans = vec![];
    for &next in graph[v].iter() {
        if next == p {
            continue;
        }
        ans.push(dfs(next, v, graph));
    }
    if ans.len() == 0 {
        (true, 1)
    } else if ans.len() == 1 {
        ans[0]
    } else {
        let mut has_line = false;
        let mut sum = 0;
        for (is_line, count) in ans.into_iter() {
            has_line |= is_line;
            sum += count;
        }

        if has_line {
            (false, sum - 1)
        } else {
            (false, sum)
        }
    }
}

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) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.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: 17276
#include <iostream>
#include <vector>
#include <algorithm>
#include <sstream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(n) n.begin(),n.end()

int to(int data[]){
	stringstream ss;
	rep(i,8)ss << data[i];
	return atoi( ss.str().c_str() );
}
int main(){
	int table[] = {4,1,2,1,2,1,4,1};
	int n;
	string s;
	while( getline(cin,s) &&  s != "" ){
		int M = (1<<21);
		int ret[8],data[8];
		stringstream ss(s);
		
		rep(i,8)ss >> data[i];
		
		rep(i,8){
			int sum = 0;
			rep(j,8)if(data[j]>table[j])sum += data[j]-table[j];
			if( M > sum || (M == sum && to(table) < to(ret)) ){
				M = sum;
				rep(j,8)ret[j] = table[j];
			}
			rotate(table,table+1,table+8);
		}	
		rep(i,8)cout << (i?" ":"") << ret[i];cout << endl;
	}
}
	

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<math.h>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<vector>
#include<string>
#define MAXN 300010
#define Endl '\n'
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ll long long int
#define pii pair<ll,ll>
#define all(v) v.begin(),v.end()
#define fi(x,n) for(ll i=x;i<n;i++)
#define fj(x,n) for(ll j=x;j<n;j++)
#define fk(x,n) for(ll k=x;k<n;k++)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll exp(ll x,ll y,ll mod)
{
	ll res=1;
	x=x%mod;
	while(y>0)
	{
		if(y&1)
			res=(res*x)%mod;
		y = y>>1;
		x=(x*x)%mod;
	}
	return res;
}
ll modinverse(ll x,ll mod)
{
    return exp(x,mod-2,mod);
}
using namespace std;
const ll inf = 0x3f3f3f3f3f3f3f3fll;
void solve()
{
    double t,d,s;
    cin>>d>>t>>s;

    if(t>=(d/s))
        cout<<"Yes";
    else
        cout<<"No";
}
int main()
{
    fastio;
    ll t;
    t=1;
    while(t--)
        solve();

    return 0;
}


Measured memory_bytes: 3720
#define  _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"
#define int ll

using namespace std;
typedef string::const_iterator State;
#define eps 1e-8L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
    static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
    unsigned long t = (x^(x << 11));
    x = y; y = z; z = w;
    return (w = (w^(w >> 19))^(t^(t >> 8)));
}

void init() {
    iostream::sync_with_stdio(false);
    cin.tie(0);
}

void solve() {
    int n;
    cin >> n;
    map<string, int> hoges;
    REP(i, n) {
        string a;
        cin >> a;
        hoges[a]++;
    }
    string go[4] = { "AC","WA","TLE","RE" };
    REP(i, 4) {
        cout << go[i] << " x " << hoges[go[i]] << endl;
    }
}


#undef int
int main() {
    init();
    solve();
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define REP(i,x,n) for(int i = (x); i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

int main(void)
{
    ll n, cnt=0;
    string s;
    cin >> n >> s;
    rep(i,1000){
        ll num[3] = {i/100, (i/10)%10, i%10};
        ll id = 0;
        rep(j,n){
            if(s[j] == num[id] + '0') id++;
            if(id == 3) break;
        }
        if(id == 3) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

using ll = long long;

signed main()
{
  string s; ll k; cin>>s>>k;
  ll n=s.size();
  ll ans=0;
  
  if(n==1){
    ans=k/2;
    cout<<ans<<endl;
    return 0;
  }
  
  ll top=0;
  ll back=0;
  
  ll cnt;
  for(ll i=0;i<n;i+=cnt){
    cnt=1;
    for(ll j=i+1;j<n;j++){
      if(s[i]==s[j]) cnt++;
      else break;
    }
    if(i==0){
        top=cnt;
        continue;
    }
    if(i+cnt>=n){
        back=cnt;
        continue;
    }
    ans+=cnt/2;
  }
  
  ans*=k;
  
  if(top==n){
    ans=(n*k)/2;
  }else{
    if(s[0]==s[n-1]) ans+=(top+back)/2*(k-1)+top/2+back/2;
    else ans+=k*(top/2+back/2);
  }
  
  cout<<ans<<endl;
  return 0;
}

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

int main(){
    int a(0),b(0),d;
    string s;
    cin >> s;

    int n = s.size();

    rep(i,n){
        if(s[i]=='0'){
            a++;
        }else{
            b++;
        }
    }
    d = max(a,b)-min(a,b);
    cout << (max(a,b)-d)*2 << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n;
	cin >> n;
	cout << "ABC" << n << endl;
	return 0;
}

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

int main() {
  int i, maxi, n, y, b, r, t;
  while(cin >> n, n) {
    cin >> y;
    double maxm = 0;
    for(i = 0; i < n; ++i) {
      cin >> b >> r >> t;
      double m = (t == 1) ? (double)(1.0 + (double)y * (double)r / 100) : (double)(pow((1 + (double)r / 100), y));
      if(maxm < m) {
        maxm = m;
        maxi = b;
      }
    }
    cout << maxi<< endl;
  }
  return 0;
}

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

int main(){
	string s,t;cin >>s>>t;
  int n=s.size();
  bool flg=false;
  for(int i=0;i<n;i++){
  string s0=s.substr(i,n-i)+s.substr(0,i);
  if(s0==t)flg=true;
  }
  cout<<(flg?"Yes":"No")<<endl;
}

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

int main() {

  int n;
  int x,y,h,w;
  int r1[6] = {60,80,100,120,140,160};
  int r2[6] = {2,5,10,15,20,25};
  int r3[6] = {600,800,1000,1200,1400,1600};
  
  while(1){  
    cin >> n;
    if(n == 0) break;
    int sum = 0;
    
    for(int i=0;i<n;i++) {     

      cin >> x >> y >> h >> w;
      int size = x + y + h;
      
      for(int j=0;j<6;j++) {
	if(size <= r1[j] && w <= r2[j]){
	  sum += r3[j];
	  break;
	}
      }
     
    }

    cout << sum << endl;

  }

  return 0;

}
	  

      

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

queue = list()
time = 0

n, q = [int(x) for i, x in enumerate(input().split()) if i < 2]
for i in range(n):
    temp = input().split()
    temp[1] = int(temp[1])
    queue.append(temp)
while(len(queue)):
    process = queue.pop(0)
    if process[1] <= q:
        time += process[1]
        print("{0} {1}".format(process[0], time))
    else:
        time += q
        process[1] -= q
        queue.append(process)

Measured memory_bytes: 19584
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7;
 
int h,w,a,b,fac[200006],ans=0,inv_fac[200006];
int binpow(int x,int y){
	if(y==0) return 1;
	else{
		long long tmp=binpow(x,y/2);
		if(y%2==1) return ((tmp*tmp)%mod*x)%mod;
		else return (tmp*tmp)%mod;
	}
}
 
int C(int k,int n) {
	return fac[n]*inv_fac[k]%mod*inv_fac[n-k]%mod;
}
 
int path(int x1,int y1,int x2,int y2) {
	if(x1>x2||y1>y2) return 1;
	return  C(x2-x1,x2-x1+y2-y1)%mod;
}
 
signed main() {
	cin>>h>>w>>a>>b;
	fac[0]=1;
	inv_fac[0]=1;
	for(int i=1;i<=200005;++i) 
	{
		fac[i]=((i % mod)*fac[i-1])%mod;
		inv_fac[i]=binpow(fac[i],mod-2)%mod;
	}
	for(int i=1;i<=h-a;++i) {
		ans+=((path(1,1,i,b)%mod)*(path(i,b+1,h,w)%mod))%mod;
	}
	cout<<ans%mod;
}

Measured memory_bytes: 3328
n = gets.chomp.to_i
s = gets.chomp
char = s.chars
strings = ""

alphabets = ("A".."Z").to_a
if n > 0
  char.each do |i|
    index = alphabets.index(i)
    strings += alphabets[(index + n) % 26]
  end
else strings = s
end

puts strings

Measured memory_bytes: 47004
#include<bits/stdc++.h>
using namespace std;
/*
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds; 
//order_of_key(k)= # of items strictly smaller than 'k'  //find_by_order(x)= iterator to x'th largest element (counting from ZERO) //erase("iterator") [log(n)] //end(<name>)
//os.find_by_order(os.order_of_key(x)=iterator to 'x' in the rb tree
template<class T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/
//#pragma GCC optimization ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target ("avx2")
//#pragma GCC optimize ("O3")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef priority_queue<ll> pq;                                        //min-heap-> multiply the values by '-1'
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define forr(i,a,b) for (ll i = a; i < b; i++)
#define test ll t;cin>>t;while(t--)
#define summ(a,n) accumulate(a,a+n,0)
#define bsrch(v,n) lower_bound(v.begin(), v.end(), n)
#define minindex(v) distance(v.begin(),min_element(v.begin(),v.end()))         //returns index of minimum(/max) element in the vector
#define bp(x) _builtin_popcount(x)
#define inf 1000000000000
#define PI = 3.1415926535897932384626
#define mod 1000000007

ll dp[100001][3];

int main()
{
    ll n; cin>>n;
  	ll a[n][3];
  	forr(i,0,n) cin>>a[i][0]>>a[i][1]>>a[i][2];
  
  	dp[0][0]=a[0][0], dp[0][1]=a[0][1], dp[0][2]=a[0][2];
  	forr(i,1,n) 
  	{
  	    dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
  	    dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
  	    dp[i][2]=a[i][2]+max(dp[i-1][0],dp[i-1][1]);
  	}
  	cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
}

Measured memory_bytes: 8224
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;

const ll INF=1e10+100;

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    cout << a[n-1]-a[0] << endl;
    return 0;
} 

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

int dp[5005][5005];

int main() {
  int n;
  string s;
  cin >> n >> s;
  for (int i = n-1; i >= 0; --i) {
    for (int j = n-1; j >= 0; --j) {
      if (s[i] != s[j]) dp[i][j] = 0;
      else dp[i][j] = dp[i+1][j+1]+1;
    }
  }
  int ans = 0;
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n; j++) {
      if (i >= j) continue; // i < j;
      int now = min(dp[i][j], j-i);
      ans = max(ans, now);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 98048
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
  int sump, price;
  while (true) {
    cin >> sump;
    if (sump == 0)
      break;
    for (int i = 0; i < 9; i++) {
      cin >> price;
      sump -= price;
    }
    cout << sump << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>
#define ll long long
#define INF 1ll<<60

using namespace std;
int main(){
	ll N,K;
  cin >> N >> K;
  vector<ll> h(N);
  for(ll i=0;i<N;i++){
  	cin >> h[i];
  }
  vector<ll> dp(N);
  for(ll i=0;i<N;i++){
    dp[i]=INF;
  }
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  for(ll i=2;i<N;i++){
    for(ll j=1;j<=min(i,K);j++){
    	dp[i]=min(dp[i-j]+abs(h[i]-h[i-j]),dp[i]);
    }
  }

  cout << dp[N-1] << endl;
}

Measured memory_bytes: 4764
# 17:49
def seive(n):
    is_prime = [1] * (n + 1)
    is_prime[0] = 0
    is_prime[1] = 0
    for i in range(2, int(n ** 0.5) + 1):
        if is_prime[i]:
            for j in range(i * i, n + 1, i):
                is_prime[j] = 0
    return is_prime


N = int(input())
cands = [i for i, p in enumerate(seive(1381)) if p and i % 5 == 1]
print(*cands[:N])


Measured memory_bytes: 9336
#include <stdio.h>

int n, k, max = 0;
int weights[100005];

int try(int num) {
  int i, ans = 1, cur = num;

  if (num < max)
    return 0;

  for (i = 0; i < n; i++) {
    if (cur >= weights[i])
      cur -= weights[i];
    else {
      ans++;
      cur = num - weights[i];
    }
  }

  if (ans <= k)
    return 1;

  return 0;
}

int main() {
  int i, left = 0, right = 1000000000, middle;//sum = 0;

  scanf("%d %d", &n, &k);

  for (i = 0; i < n; i++) {
    scanf("%d", &weights[i]);
    if (weights[i] > max)
      max = weights[i];
    //sum += weights[i];
  }

  //minOut = sum / k;
  //printf("starting value %d\n", minOut);

  while (right > left + 1) {
    middle = (left + right) / 2;
    if (try(middle))
      right = middle;
    else
      left = middle;
  }

  printf("%d\n", right);
}



Measured memory_bytes: 2228
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
typedef long long ll;
//
int main(){
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

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

int main()
{
    int n;
    string s, a, b;
    cin >> n >> s;

    if (n % 2)
    {
        cout << "No\n";
        return 0;
    }

    a = s.substr(0, n / 2);
    b = s.substr(n / 2, n / 2);

    if (a == b) cout << "Yes\n";
    else cout << "No\n";
}

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

int main(){
  int n,d;
  cin >> n >> d;
  cout << (n + 2*d)/(2*d + 1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define repd(i,a,b) for (ll i = (a); i < (b); i++)
#define INF LLONG_MAX
#define mod 1000000007
typedef long long ll;

int main(void)
{
	int N;
	cin >> N;
	int A;
	set<int> st;
	rep(i, N) 
	{
		cin >> A;
		st.insert(A);
	}

	if(st.size()==N) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


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

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

    map<char, int> m;
    for (int i = 0; i < 4; i++) {
        m[s.at(i)]++;
    }

    if ((int)m.size() != 2 || m[s.at(0)] != 2) {
        cout << "No" << endl;
    }
    else cout << "Yes" << endl;

}

Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

int main(){
    int N, W;
    cin >> N >> W;
    vector< pair<int, int> > goods(N);
    rep(i, N){
        int v, w;
        cin >> v >> w;
        goods[i] = make_pair(v, w);
    }
    int dp[110][10010]; //dp[i][j] i番目まで、重さj以下で選んだときの価値の最大値
    rep(i, N+1){
        dp[i][0] = 0;
    }
    REP(i, 1, N+1){
        rep(j, W+1){
            if(j >= goods[i-1].second){
                dp[i][j] = max(dp[i-1][j], dp[i][j-goods[i-1].second] + goods[i-1].first);
            }else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    cout << dp[N][W] << endl;
    return 0;
}


Measured memory_bytes: 7012
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {
	int A,B;
	scanf("%d%d" , &A, &B);

	if ((A == 4 || A == 6 || A == 9 || A == 11) && ((B == 4 || B == 6 || B == 9 || B == 11))) {
		printf("Yes");
	}
	else if ((A == 1 || A == 3 || A == 5 || A == 7 || A == 8 || A == 10 || A == 12) && (B == 1 || B == 3 || B == 5 || B == 7 || B == 8 || B == 10 || B == 12)) {
		printf("Yes");
	}
	else {
		printf("No");
	}

}

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

int n;
int sum = 0;
vector <int> v;
int main()
{
    scanf("%d",&n);
    while(n--)
    {
        int x;
        scanf("%d",&x);
        if (x%10)
            v.push_back(x);
        sum += x;
    }
    if (v.size()==0)
    {
        printf("0");
        return 0;
    }
    sort(v.begin(),v.end(),greater<int>());
    while (sum%10==0)
    {
        int u = v.back();
        sum -= u;
        v.pop_back();
    }
    printf("%d",sum);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define md 1000000007
#define ld long double
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n, i = 0, j= 0, k = 0, l = 0, m = 0, a = 0, b = 0, sum = 0, x = 0, y = 0, z = 0, c, p;
    cin >> n;
    ll arr[n], brr[n], crr[n];
    for(i = 0; i < n; i++){
        cin >> arr[i];
        crr[i] = arr[i];
    }
    for(i = 0; i < n; i++){
        cin >> brr[i];
    }
    sort(crr,crr+n);
    do{
        x = 0; y = 0;
        for(i = 0; i < n; i++){
            if(arr[i] != crr[i]){
                x = -1;
                break;
            }
        }
        if(x == 0){
            a = j;
        }
        for(i = 0; i < n; i++){
            if(brr[i] != crr[i]){
                y = -1;
                break;
            }
        }
        if(y == 0){
            b = j;
        }
        j++;
    }while(next_permutation(crr,crr+n));
    cout << abs(a-b);

    return 0;
}


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

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

int main() {
  string s;
  cin >> s;
  unordered_set<char> us;
  bool flg = true;
  rep(i, s.length()) {
    if (us.find(s[i]) == us.end())
      us.insert(s[i]);
    else
      flg = false;
  }

  cout << (flg ? "yes" : "no") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
typedef pair<int, int> P;
typedef pair<P, char> S;
int N;
map<P, int> m;
S s[20000];
bool h_used[40000];
bool l_used[40000];
int dfs(int idx){
  if(idx == N) return true;
  int x = s[idx].first.first, y = s[idx].first.second;
  int x2 = x, y2 = y;
  if(s[idx].second == 'x') x2++;
  else y2++;
  vector<int> useidx1;
  REP(r, 4){
    int nx = x + dx[r], ny = y + dy[r];
    if(m.count(P(nx, ny))){
      useidx1.push_back(m[P(nx, ny)]);
    }
  }
  vector<int> useidx2;
  REP(r, 4){
    int nx = x2 + dx[r], ny = y2 + dy[r];
    if(m.count(P(nx, ny))){
      useidx2.push_back(m[P(nx, ny)]);
    }
  }
  REP(iter, 2){
    if(!h_used[m[P(x, y)]] && !l_used[m[P(x2, y2)]]){
      //printf("put (%d, %d) idx = %d\n", x, y, idx);
      //printf("leg is (%d, %d)\n", x2, y2);
      bool mem1[4] = {};
      bool mem2[4] = {};
      REP(i, useidx1.size()) {mem1[i] = l_used[useidx1[i]]; l_used[useidx1[i]] = true;}
      REP(i, useidx2.size()) {mem2[i] = h_used[useidx2[i]]; h_used[useidx2[i]] = true;}
      if(dfs(idx + 1)) return true;
      REP(i, useidx1.size()) l_used[useidx1[i]] = mem1[i];
      REP(i, useidx2.size()) h_used[useidx2[i]] = mem2[i];
    }
    if(iter == 0){
      swap(x, x2); swap(y, y2); swap(useidx1, useidx2);
    }
  }
  return false;
}
int main(){
  while(cin>>N && N){
    m.clear();
    int ID = 0;
    REP(i, N) scanf("%d %d %c", &s[i].first.first, &s[i].first.second, &s[i].second);
    sort(s, s + N);
    REP(i, N){
      int x = s[i].first.first, y = s[i].first.second;
      m[P(x, y)] = ID++;
      if(s[i].second == 'x'){
        m[P(x + 1, y)] = ID++;
      }else{
        m[P(x, y + 1)] = ID++;
      }
    }
    memset(h_used, 0, sizeof(h_used));
    memset(l_used, 0, sizeof(l_used));
    if(dfs(0)){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 9500
#include <iostream>

int f(const int &a, const int &m) {
	auto res = a;
	int count = 1;
	while (res != 1) {
		res = (res * a) % m;
		++count;
	}
	return count;
}
long long int gcd(const long long int &a, const int &b) {
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
long long int lcd(const long long int &a, const int &b) {
	return a * b / gcd(a, b);
}
int main() {
	int a, m;
	while (std::cin >> a >> m && a != 0 && m != 0) {
		long long int min = f(a, m);
		for (auto i = 0; i < 2; ++i) {
			std::cin >> a >> m;
			min = lcd(min, f(a, m));
		}
		std::cout << min << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3068
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final String[] line = in.nextLine().split(" ");
        final int n = Integer.parseInt(line[0]);
        final double d = Integer.parseInt(line[1]);
        int res = 0;
        for (int i = 0; i < n; i++) {
            final String[] curr = in.nextLine().split(" ");
            final long a = Long.parseLong(curr[0]);
            final long b = Long.parseLong(curr[1]);
            final double currD = Math.sqrt((a * a) + (b * b));
            if (Double.compare(currD, d) <= 0) {
                res++;
            }
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 61440
s=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K=int(input())
print(s[K-1])

Measured memory_bytes: 3060
//
//  main.cpp
//  B- Frog 2
//  Category: Dynamic Programming
//  Created by dz2701 on 8/25/20.
//  Copyright © 2020 dz2701. All rights reserved.
//

#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5+1;
const int INF = 1e9;

int N, K, dp[MAX],stone[MAX];
//dp[i] --> min cost to get to i

int main(){
    cin >> N >> K;
    for(int i=1;i<=N;i++){
        cin >> stone[i];
    }
    //init dp
    fill(&dp[1],&dp[N],0);
    dp[0]=INF; //impossible
    
    for(int i=2;i<=N;i++){
        int res = INF;
        for(int j=1;j<=K and i-j>0;j++){
            res = min(res, dp[i-j]+abs(stone[i]-stone[i-j]));
        }
        dp[i] = res;
    }
    cout << dp[N];
    return 0;
}


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

int main() {
	
	char s[21];
	int n[2] = {0};
	scanf("%s", s);
	int len = strlen(s);
	bool A = true;
	for(int i = 0; i < len; i++) {
			if(A) {
				if(s[i] == 'A') {
					n[0]++;
					A = !A;
				}
			} else {
				if(s[i] == 'Z') {
					n[1]++;
					A = !A;
				}
			}
	}
	
	if(n[1] > 0) {
		for(int i = 0; i < n[1]; i++) {
			printf("AZ");
		}
		printf("\n");
	} else {
			printf("-1\n");
	}
	
	return 0;
	
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n = 3;
  vector<int> a(n); rep(i,n) cin >> a[i];
  int n5=0,n7=0;
  rep(i,n){    
    if(a[i] == 5) n5++;
    else if(a[i] == 7) n7++;
  }
  if(n5==2 && n7 == 1) cout << "YES" << endl;
  else cout << "NO" << endl;
      
  
  return 0;
}


Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>

#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define RREP(i,a) for(long (i)=(a)-1;(i)>=0;(i)--)
#define FORR(i,a,b) for(long (i)=(a)-1;(i)>=(b);(i)--)
#define MOD 1000000007
#define PI acos(-1.0)
#define DEBUG(C) cout<<C<<endl;
#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<long,long>
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).begin(),(a).end(),greater<int>())
#define MP(a,b) make_pair(a,b)
#define FORE(a,b) for(auto &&a:b)

typedef long long LL;
typedef unsigned long long ULL;

using namespace std;

int main(void){
	vector<int> v(3);
	REP(i,3) cin>>v[i];
	SORT(v);
	REP(i,2) cout<<v[i]<<" ";
	cout<<v[2]<<endl;
}

Measured memory_bytes: 3148
from numpy import*
n,M=map(int,input().split())
l=n*3+1
d=zeros((l,n*5),int64)
d[0][0]=1
for i in range(1,l):j,k=i-1,i-2;d[i]=((d[i-3]*k+roll(d[k],-1))*j+roll(d[j],1))%M
print(sum(d[-1][:l])%M)

Measured memory_bytes: 481520
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long  ll;
const int N=1e5+5;
int main(){
ll a,b,c,k;
cin>>a>>b>>c>>k;
if(k<=a)cout<<k;
if(k>a&&k<=a+b)cout<<a;
if(k>a+b)cout<<a-(k-a-b);
return 0;}


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

using namespace std;

int main() {

	int n;
	cin >> n;

	int l, r, total = 0;
	for (int i = 0; i < n; i++) {
		cin >> l >> r;
		total += r - l + 1;
	}
	cout << total << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100001
int main(void){
  char s[N];
  int count=0;
    scanf("%s",s);
  for(int j=0;j<N;j++){
    if(s[j]==s[j+1]){
      if(s[j+1]=='0'){
        s[j+1]='1';
        count++;
      }
      else if(s[j+1]=='1'){
        s[j+1]='0';
        count++;
      }
    }
  }
  printf("%d",count);
  return 0;
}

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

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int c[200010];

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> P(N);
    for (int i=0; i<N; ++i) cin >> P[i];

    int res = 0;
    c[0] = 1;
    for (int i=1; i<N; ++i) {
        if (P[i-1] < P[i]) {
            c[i] = c[i-1]+1;
            if (c[i] >= K) res = 1;
        } else {
            c[i] = 1;
        }
    }

    set<int> st(P.begin(), P.begin()+K);

    if (c[K-1] < K) {
        res ++;
    }
    for (int i=1; i+K-1<N; ++i) {
        if (i > 1) st.erase(P[i-2]);
        st.insert(P[i+K-1]);

        if (K <= c[i+K-1]) continue;
        if (P[i-1] == *st.begin() && P[i+K-1] == *st.rbegin()) continue;
        res ++;
    }
    cout << res << endl;

    return 0;
}

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

def main():
	values = [int(x) for x in raw_input().split(" ")]
	if values[0] > values[1]:
		values[0], values[1] = values[1], values[0]
	if values[1] > values[2]:
		values[1], values[2] = values[2], values[1]
	if values[0] > values[1]:
		values[0], values[1] = values[1], values[0]
	print "%s %s %s" % tuple(values)

if __name__ == '__main__':
	main()

Measured memory_bytes: 4240