akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.close();
        int a = n / 100;
        int b = (n - a * 100) / 10;
        int c = n % 10;
        if(a == 7 || b == 7 || c == 7){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35636
fn solve() {
    let stdin = std::io::stdin();
    let mut scn = Scanner { stdin: stdin.lock() };
    let s = scn.chars();
    //coffee
    if s[2] == s[3] && s[4] == s[5] {
        println!("Yes");
        return 
    }
    println!("No");
    return ;
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}
pub mod utils {
    const DYX: [(isize, isize); 8] = [
        (0, 1),   //right
        (1, 0),   //down
        (0, -1),  //left
        (-1, 0),  //top
        (1, 1),   //down right
        (-1, 1),  //top right
        (1, -1),  //down left
        (-1, -1), //top left
    ];

    pub fn try_adj(y: usize, x: usize, dir: usize, h: usize, w: usize) -> Option<(usize, usize)> {
        let ny = y as isize + DYX[dir].0;
        let nx = x as isize + DYX[dir].1;
        if ny >= 0 && nx >= 0 {
            let ny = ny as usize;
            let nx = nx as usize;
            if ny < h && nx < w {
                Some((ny, nx))
            } else {
                None
            }
        } else {
            None
        }
    }
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .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: 8572
export default solve;

// =================================================
// ABC110C
// =================================================

// main
function main(lines) {
  console.log(solve(lines));
}

// interface
type Tuple = { value: number; count: number; even: boolean };

// solver
function solve(lines: string[]): string {
  const { N, evens, odds } = parseLines(lines);

  const evenTuples = getDescSortedTuplesByExistsNumberCount(evens);
  const oddTuples = getDescSortedTuplesByExistsNumberCount(odds);
  const steps: number[] = [];
  for (let i = 0; i < 2; i++) {
    for (let j = 0; j < 2; j++) {
      const evenTuple = evenTuples[i];
      const oddTuple = oddTuples[j];
      if (evenTuple && oddTuple && evenTuple.value === oddTuple.value) {
        steps.push(N - (evenTuple ? evenTuple.count : 0));
      } else {
        steps.push(N - (evenTuple ? evenTuple.count : 0) - (oddTuple ? oddTuple.count : 0));
      }
    }
  }
  return Math.min(...steps).toString();
}

// helpers
function getDescSortedTuplesByExistsNumberCount(nums: number[]): Tuple[] {
  const numsCountMap: Record<number, number> = nums.reduce((acc, v) => {
    !acc[v] ? (acc[v] = 1) : acc[v]++;
    return acc;
  }, {});
  const sortedTuples: Tuple[] = Object.entries(numsCountMap)
    .map(v => ({ value: +v[0], count: v[1], even: true }))
    .sort((x, y) => y.count - x.count);
  return sortedTuples;
}

function parseLines(lines: string[]) {
  const N = +lines[0];
  const nums = lines[1].split(' ').map(s => +s);
  const evens = nums.filter((v, i) => i % 2 === 0);
  const odds = nums.filter((v, i) => i % 2 !== 0);
  const obj = { N, nums, evens, odds };
  debug(obj);
  return obj;
}

// general helpers
function debug(message?: any, ...optionalParams: any[]) {
  if (!!process.env.LOCAL_DEBUG) console.log(message, ...optionalParams);
}

// reader
if (!process.env.LOCAL_DEBUG) {
  const { stdin: input, stdout: output } = process;
  input.resume().setEncoding('utf8');
  const lines = [];
  require('readline')
    .createInterface({ input, output })
    .on('line', line => lines.push(line))
    .on('close', () => main(lines));
}

// polyfills
if (!Object.entries) {
  Object.entries = function(obj) {
    var ownProps = Object.keys(obj),
      i = ownProps.length,
      resArray = new Array(i); // preallocate the Array
    while (i--) resArray[i] = [ownProps[i], obj[ownProps[i]]];
    return resArray;
  };
}


Measured memory_bytes: 58440
#include<iostream>
#include<cmath>
using namespace std;
const long long INF = 1LL << 60;

template<class T>inline void min(T& a, T b) {
	a = a < b ? a : b;
}

int main() {
	int n, k;
	cin >> n >> k;
	long long* h = new long long[n], * dp = new long long[n];
	for (int i = 0; i < n; i++) {
		cin >> h[i];
		dp[i] = INF;
	}
	dp[0] = 0;
	for (int i = 0; i < n ; i++) {
		for (int j = 1; j <= k; j++) {
			if (i + j <= n) {
				min(dp[i + j], dp[i] + abs(h[i] - h[j+i]));
			}
		}
	}
	cout << dp[n - 1] << endl;
	delete[] h, dp;
}

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

int main(){
    int n; cin >> n; deque<int> a;
    for (int i = 0; i < n; i++) {
        int input; cin >> input;

        if (n&1){
            if (i&1) a.push_back (input);
            else     a.push_front(input);
        } else {
            if (i&1) a.push_front(input);
            else     a.push_back (input);
        }
    }

    for (deque<int>::iterator i = a.begin(); i != a.end(); i++){
        if (i != a.begin()) cout << ' ';
        cout << *i;
    } cout << endl;

    return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n); for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pi pair<int,int>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/
int modpow(int x,int n){
  int res=1;
  while(n>0){
    if(n&1) res=(res*x)%MOD;
    x=(x*x)%MOD;
    n>>=1;
  }
  return res;
}
signed main(){
  int n,k;
  cin>>n>>k;
  int ans=0;
  vi memo(k+1,0);//個数
  for(int g=k;g>0;g--){
    memo[g]=modpow(k/g,n);
    for(int i=2*g;i<=k;i+=g){
      memo[g]+=MOD-memo[i];
      memo[g]%=MOD;
    }
    memo[g]+=MOD;
    memo[g]%=MOD;
    
    ans=(ans+g*memo[g])%MOD;
  }

  

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


Measured memory_bytes: 4052
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	class Edge {
		int from, to, cost, time;

		public Edge(int from, int to, int cost, int time) {
			// TODO 自動生成されたコンストラクター・スタブ
			this.from = from;
			this.to = to;
			this.cost = cost;
			this.time = time;
		}
	}

	int n, m;
	LinkedList<Edge> edges;

	void solve(int p, int q, int r) {
		int INF = Integer.MAX_VALUE;
		int[] d = new int[m + 1]; // 各駅への最短距離
		for (int i = 0; i < d.length; i++)
			d[i] = INF / 2;
		d[p] = 0;
		while (true) {
			boolean update = false;
			for (Edge e : edges) {
				if (d[e.from] != INF
						&& d[e.to] > d[e.from] + (r == 0 ? e.cost : e.time)) {
					d[e.to] = d[e.from] + (r == 0 ? e.cost : e.time);
					update = true;
				}
			}
			if (!update)
				break;
		}
		System.out.println(d[q]);
	}

	void run() {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			n = scanner.nextInt();
			m = scanner.nextInt();
			if (n == 0 || m == 0)
				break;
			edges = new LinkedList<Edge>();
			for (int i = 0; i < n; i++) {
				int a = scanner.nextInt();
				int b = scanner.nextInt();
				int cost = scanner.nextInt();
				int time = scanner.nextInt();
				edges.add(new Edge(a, b, cost, time));
				edges.add(new Edge(b, a, cost, time));
			}
			int k = scanner.nextInt();
			if (k == 0)
				return;
			for (int i = 0; i < k; i++) {
				int p = scanner.nextInt();
				int q = scanner.nextInt();
				int r = scanner.nextInt();
				solve(p, q, r);
			}
		}
	}

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		new Main().run();
	}

}

Measured memory_bytes: 63800
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
#define min(x,y) (x < y ? x : y)
#define max(x,y) (x < y ? y : x)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

vector<ll> extend(P p) {
  ll d, c; tie(d, c) = p;
  vector<ll> res;
  rep(i, c) res.pb(d);
  return res;
}

P merge_naive(P p1, P p2, ll& ans) {
  // cout << "naive" << endl;
  vector<ll> v1 = extend(p1), v2 = extend(p2);
  stack<ll> S;
  reverse(all(v2));
  each(x, v2) S.push(x);
  reverse(all(v1));
  each(x, v1) S.push(x);
  while (S.size() > 1) {
    ll x = S.top(); S.pop();
    ll y = S.top(); S.pop();
    x += y; ++ans;
    if (x >= 10) {
      x = x / 10 + x % 10;
      ++ans;
    }
    S.push(x);
  }
  assert(S.size() == 1);
  assert(0 <= S.top() && S.top() <= 9);
  return P(S.top(), 1);
}

P calc(P p, ll& ans) {
  ll d, c; tie(d, c) = p;
  if (p.second == 0) return p;
  if (d == 0) {
    ans += c-1;
    return P(0, 1);
  }
  ll L = (10 + d - 1) / d;
  assert(L >= 1);
  P p1(d * L, c / L), p2(d, c % L);
  ans += (L - 1) * (c / L);

  p1.first = p1.first / 10 + p1.first % 10;
  assert(1 <= p1.first && p1.first <= 9);
  ans += p1.second;

  p1 = calc(p1, ans);
  return merge_naive(p1, p2, ans);
}

void solve() {
  ll n; cin >> n;
  P cur(0, 0);
  ll ans = 0;
  rep(i, n) {
    ll c, d; cin >> d >> c;
    P p(d, c);
    // cur = merge_naive(cur, p, ans);
    p = calc(p, ans);
    cur = merge_naive(cur, p, ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <unordered_map>
//#include <iostream>//POJ
//#include <vector>
//#include <string>
//#include <iomanip>
//#include <math.h>
using namespace std;
#define setc cin.tie(0);ios::sync_with_stdio(0)
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
template<typename T> T vpop(vector<T> *v) {
	T res = v->back();
	v->pop_back();
	return res;
}
char vpop(string *v) {
	char res = v->back();
	v->pop_back();
	return res;
}
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define contain(q) !q.empty()
#define cont(q) !q.empty()
//#define qpop(q, a, b) a=q.back().first;b=q.back().second;q.pop()
//#define pqpop(p, a, b) a=q.top().first;b=q.top().second;q.pop()
#define el "\n"
#define sp " "
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX
#define wildcard(T) numeric_limits<T>::min()

#define pb push_back
#define pq priority_queue
#define np next_permutation

#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
const unsigned int bf0 = (1 << 0);
const unsigned int bf1 = (1 << 1);
const unsigned int bf2 = (1 << 2);
const unsigned int bf3 = (1 << 3);
const unsigned int bf4 = (1 << 4);
const unsigned int bf5 = (1 << 5);
const unsigned int bf6 = (1 << 6);
const unsigned int bf7 = (1 << 7);

typedef long long lint;
typedef vector<int> ivec; typedef vector<string> svec;
typedef vector<lint> lvec;
typedef vector<vector<int>> ivvec;
typedef pair<int, int> P;

const int
	dx8[8] = { 0,1,1,1,0,-1,-1,-1 },
	dy8[8] = { 1,1,0,-1,-1,-1,0,1 },
	dx4[4] = { 0,1,0,-1 },
	dy4[4] = { 1,0,-1,0 };

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

int main() {
	setc;

	lint n, m, in, s = 0, ans = 0; cin >> n >> m;
	unordered_map<lint, lint> ma;
	++ma[0];
	rep(i, n) {
		cin >> in;
		s = (s + in) % m;
		++ma[s];
	}

	for (auto i : ma) {
		ans += i.second * (i.second - 1) / 2;
	}
	co(ans);
	gc();
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

const int mod=1000000007;

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(){
    int n;cin>>n;
    int a[n];rep(i,n)cin>>a[i];
    UnionFind uf(n);
    bool reached[n];
    rep(i,n)reached[i]=0;
    rep(i,n){
        int b=a[i]-1;
        if(b){
            if(reached[b-1]==1){
                uf.unite(b-1,b);
            }
        }
        reached[b]=1;
    }
    int ans=0;
    rep(i,n)chmax(ans,uf.size(i));
    cout<<n-ans<<endl;
}

Measured memory_bytes: 2048
#include<iostream>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<algorithm>//min,max,swap,rand,reverse,sort,lower_bound
#include<functional>
#include<vector>
#include<list>
#include<map>
#include<tuple>
#include<cmath>//abs, sin, cos
#include<bitset>
using namespace std;

int main()
{
	int N;
	int prev = 0, target = 0;
	int t = 0;
	int count = 0;
	cin >> N;
	vector<int> d;
	for (int i = 0; i < N; i++)
	{
		cin >> t;
		d.push_back(t);
	}

	sort(d.begin(), d.end());
	int mid = 0;
	mid = (N / 2)-1; //mid left
	prev = d[mid];
	target = d[mid + 1];
	if (d[mid] == d[mid + 1])
		cout << 0 << endl;
	else {
		while (prev != target) {
			prev++;
			count++;
		}
		cout << count << endl;
	}

	return 0;
}

Measured memory_bytes: 892
##### 解けた #####

import numpy as np

S=np.asarray(list(input()))
T=np.asarray(list(input()))
OKflag=False # 一致するかどうかを示すフラグ

for i in range(len(S)):
    Sr=np.roll(S,i) # ロールさせる
    
    if (Sr==T).all(): # 一致する場合、フラグを立てて終了
        OKflag=True
        break

if OKflag==True: # 回転させて一致するなら
    print("Yes")
else: # 一致しないなら
    print("No")

Measured memory_bytes: 12504
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

ll power(ll a, int b) {
  if(!b) return 1;
  ll c = power(a, b/2);
  if(b%2) return c*c%INF*a%INF;
  return c*c%INF;
}

int main() {
  int K;
  string S;
  cin >> K >> S;
  int N=S.size();
  
  ll ans=0;
  vl fac(K+N,1);
  rep(i,K+N-1) fac[i+1]=fac[i]*(i+1)%INF;
  rep(i,K+1) {
    ans+=power(25,K-i)*power(26,i)%INF*fac[K-i+N-1]%INF*power(fac[N-1]*fac[K-i]%INF,INF-2)%INF;
    ans%=INF;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 19976
import sys
sys.setrecursionlimit(10 ** 7)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a
#リストの最小公倍数
def lcm(a):    
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

N = ir()
A = lr()
A.sort()
if N == 1:
    print(1)
    exit()
MOD = 10 ** 9 + 7
l = []
first = A[0]
l = [x//gcd(x, first) for x in A[1:]]
x = lcm(l) #B[0]
answer = x%MOD

for i in range(1, N):
    answer += first * x // A[i]

print(answer%MOD)


Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
#define ii pair<int,int>

int n,l,t;

int pos[100005];
int dir[100005];

ii fin[100005];

int norm(long long i,int j){
	i%=j;
	if (i<0) i+=j;
	return i;
}

main(){
	//freopen("input.txt","r",stdin);
	scanf("%d%d%d",&n,&l,&t);
	
	for (int x=0;x<n;x++){
		scanf("%d%d",&pos[x],&dir[x]);
	}
	
	for (int x=0;x<n;x++){
		if (dir[x]==1) fin[x]=ii(norm(pos[x]+t,l),x);
		else fin[x]=ii(norm(pos[x]-t,l),x);
	}
	
	sort(&fin[0],&fin[n],[](ii i,ii j){
		if (i.first!=j.first) return i.first<j.first;
		else return (i.second<j.second)==(dir[0]==2);
	});
	
	//for (int x=0;x<n;x++) printf("%d %d\n",fin[x].first,fin[x].second);
	
	long long shifts=0;

	t*=2;
	int tmp;
	for (int x=1;x<n;x++){
		if (dir[0]!=dir[x]){
			if (dir[0]==1) tmp=norm(pos[x]-pos[0],l);
			else tmp=norm(pos[0]-pos[x],l);
			
			if (tmp<=t) shifts+=1+(t-tmp)/l;
		}
	}
	
	if (dir[0]==1) shifts=norm(shifts,n);
	else shifts=norm(-shifts,n);
	
	//printf("%d\n",shifts);
	
	int startpos;
	for (int x=0;x<n;x++){
		if (fin[x].second==0) startpos=(x-shifts+n)%n;
	}
	//printf("%d\n\n",startpos);
	
	for (int x=0;x<n;x++) printf("%d\n",fin[(x+startpos)%n].first);
}


Measured memory_bytes: 2816
#include<iostream>
using namespace std;
int main (void)
{
  long long int n,k;
  cin>>k;
  n=0;
  for(int i=1;i<150000000;i++)
  {
    n=10*n+7;
    n=n%k;
    if(n==0){cout<<i<<endl;return 0;}

  }
  cout<<"-1"<<endl;
}

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

int main(void) {
    int64_t N,M;
    int64_t total=0;
    int64_t limit;

    string output = "Yes\n";
    cin >> N >> M;

    vector<int64_t> A(N);
    for(int i=0;i<N;i++) {
        cin >> A[i];
        total += A[i];
    }

    if(total% (4*M)) {
        limit = total / (4*M);
    } else {
        limit = (total / (4*M)) -1;
    }

    sort(A.begin(),A.end());
    int chk  = 0;
    for(int i=A.size()-1;i>=0;i--) {
        if(A[i] <= limit) {
            output = "No\n";
            break;
        }
        if((++chk) == M){
            break;
        }
    }

    cout << output;
    return 0;
}


Measured memory_bytes: 256
h,w,k=map(int,input().split())
c=[list(input()) for i in range(h)]
ans=0
for maskR in range(1<<h):
    for maskC in range(1<<w):
        black=0
        for i in range(h):
            for j in range(w):
                if ((maskR>>i)&1)==0 and ((maskC>>j)&1)==0 and c[i][j]=="#":
                    black+=1
        if black==k:
            ans+=1

print(ans)

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

const int H=100;
const int W=100;

bool checked[H+1][W+1];
char field[H+1][W+1];
int count;

bool is_in(int y,int x){
    return 0<=y && y<=H && 0<=x && x<=W;
}

void dfs(int old_y,int old_x,int y,int x){
    if(!is_in(y,x)) return;
    if(checked[y][x]) return;
    else if(field[old_y][old_x]==field[y][x]){
        checked[y][x]=true;
        dfs(y,x,y+1,x);
        dfs(y,x,y,x+1);
        dfs(y,x,y-1,x);
        dfs(y,x,y,x-1);
    }else{
        return;
    }
}

int main(){
    int h,w;
    char c;

    while(cin>>h>>w,h|w){
        int i,j;

        for(i=0;i<h;i++){
            for(j=0;j<w;j++){
                cin>>field[i][j];
                checked[i][j]=false;
            }
            field[i][j]=0;
        }

        for(j=0;j<=w;j++){
            field[h][j]=0;
            checked[h][j]=true;
        }

        for(i=0;i<h;i++){
            for(j=0;j<w;j++){
                if(checked[i][j]) continue;
                dfs(i,j,i,j);
                count++;
            }
        }

        cout<<count<<endl;

        count=0;
    }

    return 0;
}

Measured memory_bytes: 1796
N = int(input())
S = input()
SS = [chr(i) for i in range(65,65+26)]+[chr(i) for i in range(65,65+26)]
ss = [chr(i) for i in range(97,97+26)] +[chr(i) for i in range(97,97+26)]
ans = ""
for s in S:
    if s.islower():
        ans += ss[ord(s)-97+N]
    else:
        ans += SS[ord(s)-65+N]
print(ans)

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

ll inf=1ll<<60,mod=1e9+7;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	string a,s1,s2;
	int i,j,ans;
	cin>>a;
	for (i=2;i<=a.size()-2;i+=2){
		for (j=0;2*j<i;j++){
			s1.push_back(a[j]);
		}
		for (j=i/2;j<i;j++){
			s2.push_back(a[j]);
		}
		if (s1==s2){
			ans=2*s1.size();
		}
		s1.clear();
		s2.clear();
	}
	cout<<ans;
	return 0;
}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
string s;
cin>>s;
int Q;
cin>>Q;
ll t1=0;
string forward_str="",back_str="";
rep(i,Q){
    int q;
    cin>>q;
    if(q==1){
        t1++;
    }
    else if(q==2){
        int f;
        string c;
        cin>>f>>c;
        if(t1%2==0){
            if(f==1)forward_str=c+forward_str;
            else back_str+=c;
        }
        else{
            if(f==1)back_str+=c;
            else forward_str=c+forward_str;;
        }
    }
}
string ans;
if(t1%2==0){
    ans=forward_str+s+back_str;
}
else{
    ans=forward_str+s+back_str;
    reverse(ans.begin(),ans.end());
}
cout<<ans<<endl;
//system("pause");
return 0;
}

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

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

int main(){
  int h,w;
  int s_h,s_w;
  int e_h,e_w;
  int cost = 0;
  cin >> h >> w >> s_h >> s_w >> e_h >> e_w;
  vector<string> m(h);
  for(int i = 0;i < h;i++){
    cin >> m[i];
  }
  vector<vector<int>> dist(h,vector<int>(w, -1));
  vector<vector<int>> warp(h,vector<int>(w, -1));

  dist[s_h - 1][s_w - 1] = 0;

  queue<pair<int ,int>> que;
  queue<pair<int ,int>> warp_que;

  que.push(make_pair(s_h - 1,s_w - 1));

  while(!que.empty()){
    while(!que.empty()){
    pair<int, int> cur = que.front();
    int x = cur.first;
    int y = cur.second;
    que.pop();

    for (int dir = 0; dir < 4; ++dir) {
      int next_x = x + dx[dir];
      int next_y = y + dy[dir];
      if (next_x < 0 || next_x >= h || next_y < 0 || next_y >= w) continue;
      if (m[next_x][next_y] == '#') continue; 

      if (dist[next_x][next_y] == -1) {
          que.push(make_pair(next_x, next_y));
          dist[next_x][next_y] = dist[x][y] + 1; 
        }
      }
      for(int k = x - 2;k <= x + 2;k++){
        for(int l = y - 2;l <= y + 2;l++){
          if (k < 0 || k >= h || l < 0 || l >= w) continue;
          if (m[k][l] == '#') continue;
          if (warp[k][l] == -1) {
            warp[k][l] = cost + 1;
            warp_que.push(make_pair(k,l));
          }
        }
      }
    }
    if(dist[e_h - 1][e_w - 1] != -1)break;

    while(!warp_que.empty()){
      pair<int,int> w_cur = warp_que.front();
      int w_x = w_cur.first;
      int w_y = w_cur.second;
      warp_que.pop();
      
      if(dist[w_x][w_y] == -1 && warp[w_x][w_y] != -1){
          que.push(make_pair(w_x,w_y));
          dist[w_x][w_y] = 0; 
        }
    }
    cost++;
  }
  if(dist[e_h- 1][e_w - 1] != -1)cout << cost << endl;
  else cout << -1 << endl;
}


Measured memory_bytes: 13380
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		int k = Integer.parseInt(sc.nextLine());

		List<String> dic = new ArrayList<>();

		String term = "";

		for(int i = 0; i < s.length(); i++){
			String sub = s.substring(i);
			for(int j = 1; j < sub.length() + 1; j++){
				if(j > k) break;
				term = sub.substring(0, j);
				if(!dic.contains(term)) dic.add(term);
				}
		}

		Collections.sort(dic);
		System.out.println(dic.get(k-1));
	}

}


Measured memory_bytes: 40588
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String input = br.readLine();
		int n = Integer.parseInt(input);
		
		int result = 0;
		
		for(int i = 1; i < input.length(); i += 2){
			result += 9*Math.pow(10, i - 1);
		}
		
		if(input.length() % 2 == 1){
			result += n - Math.pow(10, input.length() - 1) + 1;
			
			if(n % 10 == 0){
				result -= 0;
			}
		}
		System.out.println(result);
	}

}


Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second

int a, b;

int main(){
	cin >> a >> b;
	if (a == b){
		cout << "Draw" << endl;
		return 0;
	}
	if (a == 1){
		cout << "Alice" << endl;
		return 0;
	}
	if (b == 1){
		cout << "Bob" << endl;
		return 0;
	}
	if (a > b){
		cout << "Alice" << endl;
	}
	else if (a < b){
		cout << "Bob" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long 
int n, a[100005]; 
int dp[100005]; 

int func(int ind) {
	if(ind==(n-1)) return 0; 
	if(ind>=n) return INT_MAX; 

	if(dp[ind]!=-1) return dp[ind]; 
    
	int left = abs(a[ind]-a[ind+1]) + func(ind+1); 
	int right = INT_MAX; 
	if(ind+2<n) {
		right = abs(a[ind] - a[ind+2]) + func(ind+2); 
	}

	return dp[ind] = min(left, right); 
}
signed main() {
	
	cin >> n;

	memset(dp, -1, sizeof dp); 
	
	for(int i = 0;i<n;i++) {
		cin >> a[i]; 
	}

	cout << func(0); 
}


Measured memory_bytes: 9808
n=int(input())
d1=[0]*n
d2=[0]*n
for i in range(n):
    d1[i],d2[i]=list(map(int,input().split()))
    
yn=""
for i in range(n-2):
    if d1[i]==d2[i] and d1[i+1]==d2[i+1] and d1[i+2]==d2[i+2] :
        print("Yes")
        yn="Yes"
        break
if yn!="Yes":
    print("No")


Measured memory_bytes: 62292
/**
 *      ABC 43 D
 *      author  : kyomukyomupurin
 *      created : 2018-10-11 21:03:00
**/

#include <algorithm>
#include <array>
#include <cassert>
#include <climits>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#define int64 long long
using namespace std;

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

    string s; cin >> s;
    if ((int) s.size() == 1){
        cout << -1 << " " << -1 << endl; return 0;
    }
    else if ((int) s.size() == 2){
        if (s[0] == s[1]){
            cout << 1 << " " << 2 << endl; return 0;
        }
        else {
            cout << -1 << " " << -1 << endl; return 0;
        }
    }
    for (auto i = 0; i < (int) s.size() - 2; ++i) {
        if (s[i] == s[i + 1] || s[i] == s[i + 2]){
            cout << i + 1 << " " << i + 3 << endl; return 0;
        }
    }
    cout << -1 << " " << -1 << endl;
    
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int 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;}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

int stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}

int main() {
    
    string s;
    cin>>s;
    fin(stringcount(s,'+')-stringcount(s,'-'));
}



Measured memory_bytes: 256
function main( input ){

  var as = input.split( /\n/ )[1]
                .split( /\s/ )
                .map( function( n ){
                  return parseInt( n )
                } )

  var r = 0
  for( var i=1; i<as.length; i++ )
    r += as[i]

  var position = 1
  var l = as[0]
  var m = Math.abs( r - as[0] )

  for( ; as.length-1>position; position++ ){
    l += as[position]
    r -= as[position]

    if( m > Math.abs( l - r ) )
      m = Math.abs( l - r )
  }

  console.log( m )

}

main(
  require( 'fs' )
    .readFileSync( '/dev/stdin', 'utf8' )
)


Measured memory_bytes: 33480
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  long a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  long long sum=0;
  for(int i=1;i<n;i++)
  {
    if(a[i]<a[i-1])
    {
      sum+=a[i-1]-a[i];
      a[i]=a[i-1];
    }
  }
  cout<<sum;
}
      

Measured memory_bytes: 5156
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

string S;
ll K;
void input(){
    fast_io();
    cin >> S >> K;
}

int solve(){
    for (int i = 0; i < S.length(); i++)
    {
        if(S[i]!='a' && ('z'-S[i]+1)<=K){
            K -= ('z'-S[i]+1);
            S[i] = 'a';
        }
    }
    K%=26;
    S[S.length()-1] = (S[S.length()-1]-'a'+K)%26+'a';
    cout << S << endl;
    return 0;
}   

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

Measured memory_bytes: 592
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		@SuppressWarnings("resource")
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		
		int[][] f = new int[n][10];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 10; j++) {
				f[i][j] = scanner.nextInt();
			}
		}
		
		int[][] p = new int[n][11];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 11; j++) {
				p[i][j] = scanner.nextInt();
			}
		}
		
		int[] pe = new int[1024];
		for (int i = 1; i < 1024; i++) {
			int[] op = new int[10];
			for (int j = 0; j < op.length; j++) {
				op[j] = (i >> j) & 1;
			}
			
			pe[i] = 0;
			
			for (int j = 0; j < n; j++) {
				int c = 0;
				for (int k = 0; k < 10; k++) {
					if (op[k] == 1 && f[j][k] == 1) {
						c += 1;
					}
				}
				pe[i] += p[j][c];
			}
		}
		
		int maxp = pe[1];
		for (int i = 2; i < pe.length; i++) {
			if (maxp < pe[i]) {
				maxp = pe[i];
			}
		}
		
		System.out.println(maxp);
		
	}
}


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

int main()
{

    ios_base::sync_with_stdio(false); 
            cin.tie(NULL);
    LL R,B,G;
    cin>>R>>G>>B;
    LL K;
    cin>>K;
    while(R>=G and K)
    {
        G=G*2;
        K--;
    }
    while(G>=B and K)
    {
        B=B*2;
        K--;
    }
    if(G>R and B>G)
        cout<<"Yes";
    else
        cout<<"No";
}



Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<sstream>
#include<bits/stdc++.h>
using namespace std;
int a[5],n;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		string s;
		cin>>s;
		if(s[0]=='A')a[1]++;
		if(s[0]=='W')a[2]++;
		if(s[0]=='T')a[3]++;
		if(s[0]=='R')a[4]++;
	}
	cout<<"AC x "<<a[1]<<endl;
	cout<<"WA x "<<a[2]<<endl;
	cout<<"TLE x "<<a[3]<<endl;
	cout<<"RE x "<<a[4]<<endl;
}


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

using namespace std;
using ll = long long;
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

    ll n;
    cin >> n;

    ll cnt = 0;
    FOR(i, 1, n+1) if(i%2) cnt++;
    cout << fixed << setprecision(15) << (double)cnt/n << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[4];
int main() {
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++){
		string s;
		cin>>s;
		if(s=="AC"){
			a[0]++;
		}
		else if(s=="WA"){
			a[1]++;
		}
		else if(s=="TLE"){
			a[2]++;
		}
		else{
			a[3]++;
		}
	}
	cout << "AC x "<<a[0]<<endl;
	cout <<"WA x "<<a[1]<<endl;
	cout << "TLE x "<<a[2]<<endl;
	cout << "RE x "<<a[3];
	// your code goes here
	return 0;
}

Measured memory_bytes: 3624
/*Saurav Paul*/
#include<bits/stdc++.h>
using namespace std;

int main()
{
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;

  vector<int> cnt(n), paisi(n);
  for (int i = 0; i < m; i++){
    int p;
    string vr;
    cin >> p >> vr;
    if(vr=="AC"){
      paisi[p - 1] = 1;
    }
    else if(vr=="WA"){
      if(paisi[p-1] == 0){
        cnt[p - 1]++;
      }
    }
    else
      assert(false);
  }
  int ac = 0, pnl = 0;
  for (int i = 0; i < n; i++){
    if(paisi[i]){
      ++ac;
      pnl += cnt[i];
    }
  }
  cout << ac << " " << pnl << endl;
  return 0;
}


Measured memory_bytes: 1024
#ITP1_11_A

def west(d):
	tmp=d[4]
	d[4]=d[1]
	d[1]=d[3]
	d[3]=d[6]
	d[6]=tmp

def east(d):
	tmp=d[4]
	d[4]=d[6]
	d[6]=d[3]
	d[3]=d[1]
	d[1]=tmp

def north(d):
	tmp=d[1]
	d[1]=d[2]
	d[2]=d[6]
	d[6]=d[5]
	d[5]=tmp

def south(d):
	tmp=d[1]
	d[1]=d[5]
	d[5]=d[6]
	d[6]=d[2]
	d[2]=tmp

def spin(d):
	tmp=d[2]
	d[2]=d[3]
	d[3]=d[5]
	d[5]=d[4]
	d[4]=tmp

def kaiten(d, op):
	if   op == "W": west(d)
	elif op == "E": east(d)
	elif op == "N": north(d)
	elif op == "S": south(d)

def inputDice():
	return list(map(int,("-1 "+input()).split()))

def equal(da, db):
	for op in list("NWWWN-"):
		for i in range(4):
			if(da[1]==db[1] and da[2]==db[2] and da[3]==db[3] and da[4]==db[4] and da[5]==db[5] and da[6]==db[6]):
				return True
			spin(db)
		kaiten(db,op)
	return False

da=inputDice()
db=inputDice()
if equal(da,db):
	print("Yes")
else:
	print("No")



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

using namespace std;
const int INF = 1e9+5;
int main(){ 
	int n, k;
	cin>>n>>k;
	int nxt = 0;
	vector<int> v(n);
	for(int& x : v)
		scanf("%d", &x);
	vector<int> dp(n, INF);
	dp[0]=0;
	for(int i =0; i<n; i++){
		for(int j =1; j<=k; j++){
			nxt = 0;
			nxt=j+i;
			if(nxt<n){
				dp[nxt]=min(dp[nxt], dp[i]+abs(v[i] - v	[nxt]));
			}
		}
	}
	printf("%d\n", dp[n-1]);
}


Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>

using namespace std;
typedef long long LL;
const LL inf = 0x3f3f3f3f3f3f3f3f;
const int MaxN = 2e5 + 5;

int n,k;
LL dp[MaxN],a[MaxN];

int main()
{
	scanf("%d %d",&n,&k);
	for(int i = 1;i <= n; i++) scanf("%lld",&a[i]);
	dp[0] = 0;
	dp[1] = 0;
	for(int i = 2;i <= n; i++) dp[i] = inf;
	for(int i = 2;i <= n; i++){
		for(int j = 1;j <= min(k,i - 1); j++){
			dp[i] = min(dp[i],dp[i - j] + abs(a[i - j] - a[i]));
		}
	}
	printf("%lld\n",dp[n]);
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define fi first
#define se second
#define lson l,mid,p<<1
#define rson mid+1,r,p<<1|1
#define pb push_back
#define ll long long
using namespace std;
const int inf=1e9;
const int mod=1e9+7;
const int maxn=1e5+10;
int n;
int p[11],q[11];
int a[11];
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>p[i];
		a[i]=i+1;
	}
	for(int i=0;i<n;i++){
		cin>>q[i];
	}
	int cnt=1,x,y;
	do{
		int f1=1,f2=1;
		for(int i=0;i<n;i++){
			if(a[i]!=p[i]) f1=0;
			if(a[i]!=q[i]) f2=0;
		}
		if(f1) x=cnt;
		if(f2) y=cnt;
		cnt++;
	}while(next_permutation(a,a+n));
	cout<<abs(x-y)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>
main(){
  char str[100];
  int upper,lower,right,left,back,current,i,tmp[4],kaisu,tmp2[25][2],hoge;
  srand((unsigned)time(NULL));
  scanf("%d%d%d%d%d%d",&current,&lower,&right,&left,&upper,&back);
  scanf("%d",&kaisu);
  for(i=0;i<kaisu;i++){
    scanf("%d%d",&tmp2[i][0],&tmp2[i][1]);
  }
  for(i=0;i<kaisu;i++){
    while(1){
      hoge=rand()%4;
      if(hoge==0){
	tmp[0]=current;
	tmp[1]=upper;
	tmp[2]=back;
	tmp[3]=lower;
	current=tmp[1];
	upper=tmp[2];
	back=tmp[3];
	lower=tmp[0];
      }
      if(hoge==1){
	tmp[0]=current;
	tmp[1]=upper;
	tmp[2]=back;
	tmp[3]=lower;
	current=tmp[3];
	upper=tmp[0];
	back=tmp[1];
	lower=tmp[2];
      }
      if(hoge==2){
	tmp[0]=current;
	tmp[1]=right;
	tmp[2]=left;
	tmp[3]=back;
	current=tmp[2];
	right=tmp[0];
	left=tmp[3];
	back=tmp[1];
      }
      if(hoge==3){
	tmp[0]=current;
	tmp[1]=right;
	tmp[2]=left;
	tmp[3]=back;
	current=tmp[1];
	right=tmp[3];
	left=tmp[0];
	back=tmp[2];
      }
      if(current==tmp2[i][0]&&lower==tmp2[i][1]){
	printf("%d\n",right);
	break;
      }
      
    }
  }
  /* printf("%d\n",current); */
  return 0;
}

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

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

  vector<int> a(n + 1), idx(n + 1);
  // for (auto &i : a) cin >> i;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    idx[a[i]] = i;
  }

  vector<int> l(n + 2), r(n + 2);
  for (int i = 0; i <= n + 1; ++i) {
    l[i] = i - 1;
    r[i] = i + 1;
  }

  long long ans = 0;
  for (long long i = n; i > 0; --i) {
    long long j = idx[i];
    ans += i * (j - l[j]) * (r[j] - j);
    l[r[j]] = l[j];
    r[l[j]] = r[j];
  }

  cout << ans << endl;
}


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

int main()
{
	int a , b , c , n;
	
	cin >> a >> b >> c >> n;
	
	int ans = 0;
	
	for(int i = 0 ; a*i<=n ; i++)
	{
		for(int j  = 0 ; b*j<=n ; j++)
		{
			if((n - (a*i+b*j))%c==0 && (n-(a*i+b*j))>=0)
			{
				ans++;
				//cout << a*i << " " << b*j << " " << n-(a*i+b*j) << endl;
			}
		}
	}
	
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
 
int main() {
    int n;cin >> n;
    int m;cin >> m;
    vector<pair<long long int,int>> a(n);

    for(int i=0;i<n;i++) {
        long long int c; int b;
        cin>>c>>b;
        a[i] = {c,b};
    }

    sort(a.begin(),a.end());
  	
    long long int price  = 0,bottle = 0;
 
    for(int i=0;i<n;i++){

        if(bottle + a[i].second > m){
            price += a[i].first * (m-bottle);
            break;
        }
        else{
            bottle += a[i].second;
            price += (a[i].first)*(a[i].second);
        }
     
    }
    cout << price << endl;
    return 0;
}



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

using namespace std;

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

    vector <int> a(n),b(n);

    for(int i=0;i<n;i++) cin >> a[i];

    b = a;

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

    int temp =0;

    bool k = false;

    for(int i=0;i<n-1;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(a[i]>a[j]){

                temp = a[i];
                a[i] = a[j];
                a[j] = temp;

                k = true;
            }





            if(a == b)
            {
                cout << "YES" << endl;
                return 0;
            }

            if(k==true){
            temp = a[j];
            a[j]= a[i];
            a[i]= temp;

            k = false;
            }
        }
    }

    cout << "NO" << endl;

    return 0;
}


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

using namespace std;

int main(){
  long long d, g;
  cin >> d >> g;
  long long p[d], c[d];
  for (int i = 0; i < d; i++)
    cin >> p[i] >> c[i];
  int ans=1e9;
  for (int mask = 0; mask < (1 << d); ++mask){
    int s = 0, num = 0, rest_max = -1;
    for (int i = 0; i < d; ++i){
      if (mask >> i & 1){
        s += 100 * (i + 1) * p[i] + c[i];
        num += p[i];
      }
      else
        rest_max = i;
    }
    if (s < g){
      int s1 = 100 * (rest_max + 1);
      int need = (g - s + s1 - 1) / s1;
      if (need >= p[rest_max])
        continue;
      num += need;
    }
    ans = min(ans, num);
  }
  cout << ans << endl;
  return 0;
}


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

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

int main() {
  lli n; cin >> n;
  lli r = 0;
  for (lli i = 0; i < n; ++i) {
    char c; cin >> c;
    if (c == 'R') ++r;
  }
  if (r > n - r) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}



Measured memory_bytes: 256