akhauriyash/Code-Regression huggingface dataset:
/*
 * Author : Andrew J
*/
#include <bits/stdc++.h>
using namespace std;
#define rall(x) x.rbegin() , x.rend()
#define all(x) x.begin() , x.end()
#define fi first
#define se second
#define pb push_back
using ll = long long;
using ii = pair <int , int>;
void in(int &x);
// const int N = ;
#define singleCase
// #define multipleCase
int n;

void work() {
   in(n);
   int odd = 0;
   for (int i = 0, x ; i < n ; i++) {
      in(x);
      if (x & 1) odd++;
   }
   puts(odd & 1 ? "NO" : "YES");
   return;
}

int main() {
   #ifdef multipleCase
      int nQ; in(nQ);
      while (nQ--)
         work();
   #endif
   #ifdef singleCase
      work();
   #endif
   return 0;
}

void in(int &x) {
	bool neg = false;
	register int c;
	x = 0;
	c = getchar();
	if(c == '-') {
		neg = true;
		c = getchar();
	}
	for (; c > 47 && c < 58; c = getchar())
	  x = (x << 1) + (x << 3) + c - 48;
	if (neg) x *= -1;
}


Measured memory_bytes: 3604
N = int(input())

import itertools
ans = 0
candidate = [3,5,7]

for j in range(3,len(str(N))+1):
    for i in itertools.product(candidate, repeat=j):
        if int("".join(map(str, list(i)))) <= N:
            if 3 in list(i) and 5 in list(i) and 7 in list(i):
                ans += 1


print(ans)

Measured memory_bytes: 3064
from itertools import groupby
def calc():
  s = 0
  for i in range(h):
    gr = groupby(g[i])
    j = 0
    for key,it in gr:
      l = len(list(it))
      if key!=-1:
        if l >= K:
          # g[i][j:j+l] = [-1]*l
          for k in range(l):
            g[i][j+k] = -1
          s += key*l
      j += l
 
  return s

def flatten():
  for j in range(w):
    lst = []
    for i in range(h-1, -1, -1):
      if g[i][j] > 0:
        lst.append(g[i][j])

    lst += [-1] * (h - len(lst))

    for i in range(h-1, -1, -1):
      g[i][j] = lst[h-i-1]

h,w,K = map(int,input().split())
mat = [ [int(e) for e in list(input())] for _ in range(h) ]

res = 0
for i in range(h):
  for j in range(w):
    score = 0
    g = [ [ mat[n][m] for m in range(w) ] for n in range(h) ]
    g[i][j] = -1
    time = 0
    flatten()
    while True:
      s = calc()
      if s==0: break
      score += (2**time)*s
      flatten()
      time += 1
    res = max(res, score)

print(res)


Measured memory_bytes: 75992
#include <stdio.h>          // printf(), scanf()

int
main(int argc, char** argv)
{
	int t;
	int n, i;

	t = 100000;
	scanf("%d", &n);
	for (i = 0; i < n; ++i)
	{
		t = (t * 105) / 100;
		t = (t + 999) / 1000;
		t *= 1000;
	}

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

Measured memory_bytes: 592
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
signed main(){
  string s;cin>>s;
  int n=0;
  rep(i,3){
    if(s[i]!='x'){
      n++;
    }
  }
  cout<<700+100*n<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;

int main()
{
    ll X;
    cin >> X;

    ll i = 0;
    ll sum = 100;
    while (sum < X)
    {
        ll a = sum * 0.01;
        sum += a;
        i++;
    }

    cout << i << endl;

    return 0;
}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n,k,i,j,l,m,ans=-2e9;
  cin>>n>>k;
  vector<int64_t> p(n+1),c(n+1);
  vector<vector<int64_t>> a(n+1);
  for(i=1;i<=n;i++) cin>>p.at(i);
  for(i=1;i<=n;i++) cin>>c.at(i);
  for(i=1;i<=n;i++){
    a.at(i).push_back(0);
    l=0;
    j=p.at(i);
    while(j!=i){
      a.at(i).push_back(a.at(i).at(l)+c.at(j));
      l++;
      j=p.at(j);
    }
    a.at(i).push_back(a.at(i).at(l)+c.at(j));
  }
  for(i=1;i<=n;i++){
    l=a.at(i).size();
    if(k<=l-1){
      for(j=1;j<=k;j++) if(ans<a.at(i).at(j)) ans=a.at(i).at(j);
    }
    else if(a.at(i).at(l-1)<0){
      for(j=1;j<=l-1;j++) if(ans<a.at(i).at(j)) ans=a.at(i).at(j);
    }
    else if(a.at(i).at(l-1)>=0){
      m=(k/(l-1)-1)*a.at(i).at(l-1);
      for(j=1;j<=l-1;j++) if(ans<m+a.at(i).at(j)) ans=m+a.at(i).at(j);
      m=k/(l-1)*a.at(i).at(l-1);
      for(j=1;j<=k%(l-1);j++) if(ans<m+a.at(i).at(j)) ans=m+a.at(i).at(j);
    }
  }
  cout<<ans<<endl;
}

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

int main()
{
    int k = 0;
    string str;
    cin >> k;
    cin >> str;
    if (str.size() > k)
    {
        for (int i = 0; i < k; i++)
            cout << str[i];
        cout << "...";
    }
    else
        cout << str;
    return 0;
}

Measured memory_bytes: 3600
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
ll a[410];
ll subsum[410];
ll dp[410][410];

inline ll range_sum(int l, int r) {
    return subsum[r] - subsum[l];
}

ll calc(int l, int r) {
    if (r - l < 1) return 1e15;
    if (r - l == 1) return 0;
    if (dp[l][r] < 0) {
        ll res = 1e15;
        for (int i = l+1; i < r; i++) {
            res = min(res, calc(l, i) + calc(i, r) + range_sum(l, r));
        }
        dp[l][r] = res;
    }
    return dp[l][r];
}

ll solve() {
    memset(dp, -1, sizeof(dp));
    for (int i = 1; i <= n; i++) {
        subsum[i] = subsum[i-1] + a[i-1];
    }
    return calc(0, n);
}

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

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 1664
N=io.read("n")
t={}
for i=0,N do
  count=0
  k=i
  j=N-i 
  while (k>0) do
    count=count+k%6
    k=k//6
  end
  while (j>0) do
    count=count+j%9
    j=j//9
  end
  t[i+1]=count
end
table.sort(t)
print(t[1])

Measured memory_bytes: 2424
#include<bits/stdc++.h>
using namespace std;
int n,W;
long long dp[110][100010];
int w,v;
int main()
{
	cin>>n>>W;
	memset(dp,-1,sizeof(dp));
	dp[0][0]=0;
	for(int i=0;i<n;i++){
		cin>>w>>v;
		for(int j=0;j<=W;j++){
			if(dp[i][j]!=-1){
				dp[i+1][j]=max(dp[i+1][j],dp[i][j]);//不取 
				if(j+w<=W)
				   dp[i+1][j+w]=max(dp[i+1][j+w],dp[i][j]+v);//可以取也可以不取 
			}
		}
	}
	long long ans=0;
	for(int i=0;i<=W;i++)
	   ans=max(ans,dp[n][i]);
	cout<<ans<<endl;
	return 0;
}


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

int main() {
	// your code goes here
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  int cnt=0;
  for(int i=0;i<n;i++)
  {
    if(i%2==0&&a[i]%2)
      cnt++;
  }
  cout<<cnt;
  return 0;
}


Measured memory_bytes: 3592
using System;

namespace ITP1_11_B
{
    class Dice
    {
        private readonly int[,] adj = new int[6, 4] { { 1, 2, 4, 3 }, { 0, 3, 5, 2 }, { 0, 1, 5, 4 }, { 0, 4, 5, 1 }, { 0, 2, 5, 3 }, { 1, 3, 4, 2 } };
        private int top, front;
        private int[] vals = new int[6];
        public int Top { get { return vals[top]; } }
        public Dice(int[] values)
        {
            Array.Copy(values, vals, 6);
            top = 0;
            front = 1;
        }

        public void N()
        {
            int index = GetIndex(front, top);
            top = front;
            front = adj[front, (index + 2) % 4];
        }

        public void W()
        {
            int index = GetIndex(top, front);
            top = adj[top, (index + 1) % 4];
        }
        public void S()
        {
            int index = GetIndex(top, front);
            front = top;
            top = adj[top, (index + 2) % 4];
        }
        public void E()
        {
            int index = GetIndex(top, front);
            top = adj[top, (index + 3) % 4];
        }

        public int GetRight(int top, int front)
        {
            int topKey = GetKey(top);
            int frontKey = GetKey(front);
            return vals[adj[topKey, (GetIndex(topKey, frontKey) + 1) % 4]];
        }

        private int GetKey(int val)
        {
            for (int i = 0; i < 6; i++) if (vals[i] == val) return i;
            throw new Exception();
        }

        private int GetIndex(int top, int val)
        {
            for (int i = 0; i < 4; i++) if (adj[top, i] == val) return i;
            throw new Exception();
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            Dice dice = new Dice(Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse));
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                Console.WriteLine(dice.GetRight(input[0], input[1]));
            }
        }
    }
}

Measured memory_bytes: 9028
program main
integer :: n
integer,allocatable :: a(:),cnt(:)

read(*,*)n
allocate(a(n),cnt(n))
read(*,*)a(1:n-1)
cnt = 0
do i = 1,n
cnt(a(i)) =  cnt(a(i)) + 1
end do
do i = 1,n
write(*,*)cnt(i)
end do
end program main

Measured memory_bytes: 5088
use std::io;

/// 一行を読み込んで、空白で区切ったベクタにして返す
#[allow(dead_code)]
fn read<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect()
}

/// n行を読み込んで、数字を空白で区切って二次元のベクタにして返す
#[allow(dead_code)]
fn read_table<T>(n: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut ret: Vec<Vec<T>> = Vec::new();
    for _ in 0..n {
        ret.push(read::<T>());
    }
    ret
}

/// n行を読み込んで、1文字ずつを二次元のベクタにして返す
#[allow(dead_code)]
fn read_char_table(n: usize) -> Vec<Vec<char>> {
    let mut ret: Vec<Vec<char>> = Vec::new();
    for _ in 0..n {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        let chr = buf.trim().chars().collect();
        ret.push(chr);
    }
    ret
}

/// n行を読み込んで、一次元のベクタにして返す
#[allow(dead_code)]
fn read_array<T>(n: usize) -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut array = Vec::new();

    for _ in 0..n {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        array.push(buf.trim().parse().unwrap());
    }
    array
}

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();

    let mut t = String::new();
    io::stdin().read_line(&mut t).unwrap();

    let mut ss = s.chars().collect::<Vec<char>>();
    let st = t.chars().collect::<Vec<char>>();
    let count = s.chars().count() - 1;
    for _ in 0..count {
        if ss == st {
            println!("Yes");
            return;
        }
        let last = ss[count - 1];

        for i in 0..count - 1 {
            ss[count - i - 1] = ss[count - i - 2];
        }

        ss[0] = last;
    }
    println!("No");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;


int main() {
    ios_base::sync_with_stdio(false);

    rep(i,3) {
        string s;
        cin >> s;
        cout << char((s[0]-'a')+'A');
    }
    cout << endl;
    

    return 0;   
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long int ll;

int sum(int x){
  int wa=0;
  for(int i=1;i<=x;++i){
    wa+=i;
  }
  return wa;
}

int main() {
  int N,K;
  cin>>N>>K;
  
  vector<double> p(N);
  vector<double> q(N);
 
  rep(i,N){
    cin>>p[i];
    q[i]=sum(p[i])/p[i];
  }
  
  double E_i=0;
  double E_ik=0;
  
  for(int i=0;i<K;++i){
    E_ik+=q[i];
  }
  
  double ans=E_ik; 
  for(int i=0;i<N-K;++i){
    E_i+=q[i];
    E_ik+=q[i+K];
    ans=max(ans,E_ik-E_i);
  }
  
  cout<<fixed;
  cout<<setprecision(6)<<ans<<endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) {
    cin >> s[i];
  }

  ll ans = 0;
  rep(i, n) {
    bool f = true;
    rep(j, n) {
      rep(k, n) {
        if (s[(k+i)%n][j] != s[(j+i)%n][k]) {
          f = false;
        }
      }

    }
    if (f) ans++;
  }
  cout << ans*n << endl;
}


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

int main() {
    int S;
    cin >> S;
    if(S % 100 > 0 && S % 100 < 13){
        if(S / 100 > 0 && S / 100 < 13){
            cout << "AMBIGUOUS";
        }else {
            cout << "YYMM";
        }
    }else{
        if(S / 100 > 0 && S / 100 < 13){
            cout << "MMYY";
        }else {
            cout << "NA";
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define N 100005

using namespace std;

int n, cnt;
int prime[N], a[N], b[N];
long long ans[502][502];
bool vis[N];

long long lcm(long long x, long long y){
	return x / __gcd(x, y) * y;
}

int main(){
	scanf("%d", &n); int m = 1e5;
	if(n == 2){
		puts("4 7"); puts("23 10");
		return 0;
	}
	for(int i = 2; i <= m; ++i){
		if(!vis[i]) prime[++cnt] = i;
		for(int j = 1; j <= cnt && i * prime[j] <= m; ++j){
			vis[i * prime[j]] = true; 
			if(i % prime[j] == 0) break;
		}
	}
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= n; ++j){
			if((i + j) & 1) continue;
			int p1 = (i - j) / 2 + (n + 1) / 2;
			int p2 = (i + j) / 2 + n;
			ans[i][j] = 1ll * prime[p1] * prime[p2];
		}
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= n; ++j){
			if(!((i + j) & 1)) continue;
			long long tmp = 1;
			if(i != 1) tmp = lcm(tmp, ans[i - 1][j]);
			if(j != 1) tmp = lcm(tmp, ans[i][j - 1]);
			if(i != n) tmp = lcm(tmp, ans[i + 1][j]);
			if(j != n) tmp = lcm(tmp, ans[i][j + 1]);
			ans[i][j] = tmp + 1;
		}
	for(int i = 1; i <= n; ++i, puts(""))
		for(int j = 1; j <= n; ++j)
			printf("%lld ", ans[i][j]);
	return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
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, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


int main() {
  ll n; cin >> n;
  V x(n); cin >> x;
  ll l, q;
  cin >> l >> q;

  VV dp(n, V());
  dp[n-1].push_back(INF);

  drep(i, n-1) {
    int y = upper_bound(all(x), x[i]+l) - x.begin() - 1;
    dp[i].push_back(y);
    rep(j, n) {
      int k = dp[i].back();
      int y;
      if (dp[k].size() <= j) y = INF;
      else y = dp[k][j];
      dp[i].push_back(y);
      if (y == INF) break;
    }
  }
  
  rep(_, q) {
    int a, b; cin >> a >> b;
    --a, --b;
    if (a > b) swap(a, b);

    int ans = 0;
    int now = a;
    while (now < b) {
      int k = lower_bound(all(dp[now]), b) - dp[now].begin() - 1;
      if (k == -1) {
        ans += 1;
        break;
      }
      ans += (1<<k);
      now = dp[now][k];
    }

    cout << ans << "\n";
  }
  
  return 0;
}


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

int main() {
  long n,a,b,c=0,ans=0;
  cin>>n;
  for(long i=1;i<=n;i++)
  {
    long temp=i,c=0;
    while(temp>0)
    {
      temp/=10;
      c++;
    }
    if(c & 1)
    {
      ans++;
    }
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define mod 100000

int H, W, dp[2][1 << 19][2][2], bits[10946], maxbits;

char M[20][21];

int main()
{
	scanf("%d", &H);
	scanf("%d", &W);

	for (int i = 0; i < H; i++) scanf("%s", M[i]);

	if (M[0][0] == 'J' || M[0][0] == '?') dp[0][0][0][0] += 1;
	if (M[0][0] == 'O' || M[0][0] == '?') dp[0][0][1][0] += 1;
	if (M[0][0] == 'I' || M[0][0] == '?') dp[0][0][1][0] += 1;

	for (int i = 0; i < (1 << (W - 1)); i++)
	{
		bool ok = true;

		for (int j = 0; j < W - 2; j++)
		{
			if ((i & (1 << j)) && (i & (1 << (j + 1))))
			{
				ok = false; break;
			}
		}

		if (ok) bits[maxbits++] = i;
	}

	for (int i = 0; i < H * W - 1; i++)
	{
		for (int j = 0; j < maxbits; j++)
		{
			dp[(i ^ 1) & 1][bits[j]][0][0] = 0;
			dp[(i ^ 1) & 1][bits[j]][0][1] = 0;
			dp[(i ^ 1) & 1][bits[j]][1][0] = 0;
			dp[(i ^ 1) & 1][bits[j]][1][1] = 0;
		}

		char nowc = M[i / W][i % W];
		char nxtc = M[(i + 1) / W][(i + 1) % W];

		for (int j = 0; j < maxbits; j++)
		{
			int nxt = (bits[j] << 1) % (1 << (W - 1));

			int sum0 = (dp[i & 1][bits[j]][0][0] + dp[i & 1][bits[j]][1][0]) % mod;
			int sum1 = (dp[i & 1][bits[j]][0][1] + dp[i & 1][bits[j]][1][1]) % mod;

			if (nxtc == 'J' || nxtc == '?')
			{
				dp[(i ^ 1) & 1][nxt][0][0] += sum0;
				dp[(i ^ 1) & 1][nxt][0][1] += sum1;
			}

			if (nxtc == 'O' || nxtc == '?')
			{
				if ((nowc == 'J' || nowc == '?') && i % W != W - 1)
				{
					dp[(i ^ 1) & 1][nxt + 1][1][0] += dp[i & 1][bits[j]][0][0];
					dp[(i ^ 1) & 1][nxt + 1][1][1] += dp[i & 1][bits[j]][0][1];

					dp[(i ^ 1) & 1][nxt + 1][1][0] %= mod;
					dp[(i ^ 1) & 1][nxt + 1][1][1] %= mod;

					dp[(i ^ 1) & 1][nxt][1][0] += (sum0 - dp[i & 1][bits[j]][0][0] + mod);
					dp[(i ^ 1) & 1][nxt][1][1] += (sum1 - dp[i & 1][bits[j]][0][1] + mod);
				}
				else
				{
					dp[(i ^ 1) & 1][nxt][1][0] += sum0;
					dp[(i ^ 1) & 1][nxt][1][1] += sum1;
				}
			}

			if (nxtc == 'I' || nxtc == '?')
			{
				if (bits[j] & (1 << (W - 2)))
				{
					dp[(i ^ 1) & 1][nxt][1][1] += sum0;
				}
				else
				{
					dp[(i ^ 1) & 1][nxt][1][0] += sum0;
				}

				dp[(i ^ 1) & 1][nxt][1][1] += sum1;
			}

			dp[(i ^ 1) & 1][nxt][1][0] %= mod;
			dp[(i ^ 1) & 1][nxt][1][1] %= mod;
		}
	}

	int ret = 0;

	for (int i = 0; i < maxbits; i++)
	{
		ret += dp[(H * W - 1) % 2][bits[i]][0][1];
		ret += dp[(H * W - 1) % 2][bits[i]][1][1];

		ret %= mod;
	}

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

	return 0;
}

Measured memory_bytes: 5316
N = int(raw_input())
t = [[0,0] for i in range(N)]
for i in range(N):
    l = []
    l = raw_input().split()
    t[i][0] = int(l[0])
    t[i][1] = int(l[1])
min_ = [0,0]
min_[0] = t[0][0]
min_[1]= t[0][1]
for i in range(1,N):
#    cnt = max(int(math.ceil(1.0*min_[0]/t[i][0])),int(math.ceil(1.0*min_[1]/t[i][1])))
    cnt_0 = min_[0]/t[i][0]
    if min_[0]%t[i][0]!=0:
        cnt_0+=1
    cnt_1 = min_[1]/t[i][1]
    if min_[1]%t[i][1]!=0:
        cnt_1+=1
    cnt = max(cnt_0,cnt_1)
    min_[0] = cnt*t[i][0]
    min_[1] = cnt*t[i][1]
print min_[0]+min_[1]


Measured memory_bytes: 2696
import java.io.*;

class Main{

    public static void main(String[] args)throws IOException{

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	while(true){
	    String input = br.readLine();
	    String[] div = input.split(" ");
	    int height = Integer.parseInt(div[0]);
	    int width = Integer.parseInt(div[1]);

	    if(height == 0 && width == 0){
		break;
	    }
	    
	    for(int i = 0; i < height; i++){
		for(int j = 0; j < width; j++){
		    System.out.printf("#");
		}
		System.out.printf("\n");
	    }
	    System.out.printf("\n");
	    
	}
	

    }

}

Measured memory_bytes: 48104
import sys
import itertools
def line():return sys.stdin.readline().strip()

p = ["+","-","*"]
n = [[0,2,0,1],[0,1,2,3]]
def f(l):
    for i in range(len(n)):
        L = l[:]
        L[n[i][0]] = "(" + L[n[i][0]]
        L[n[i][1]] = L[n[i][1]] + ")"
        L[n[i][2]] = "(" + L[n[i][2]]
        L[n[i][3]] = L[n[i][3]] + ")"
        for i in range(3):
            for j in range(3):
                for k in range(3):
                    N = L[:]
                    N[0]+=p[i]
                    N[1]+=p[j]
                    N[2]+=p[k]
                    e = " ".join(N)
                    exec("x=" + e,globals())
                    if x == 10:
                      return e
    return "0"

while True:
    l = line().split()
    if l[0] == "0":break
    ans = "0"
    for i in list(itertools.permutations(l)):
        i = f(list(i))
        if i != "0":
            ans = i
            break
    print(ans)

Measured memory_bytes: 7608
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <array>
using namespace std;

typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<n+1;i++)
int main(){
    int N,A=0,a;
    ll M;
    map<ll,int> m;
    map<ll,bool> ind;
    vector<int> vec;
    m[0]=1;
    ind[0]=true;
    vec.push_back(0);
    cin>>N>>M;
    rep(i,N){
        cin>>a;
        A=(A+a)%M;
        // cout<<A<<endl;
        m[A]=m[A]+1;
        if(!ind[A]){
            ind[A]=true;
            vec.push_back(A);
        }
    }
    
    ll ans=0;
    while(!vec.empty()){
        // cout<<vec.back()<<" "<<m[vec.back()]<<endl;
        ans+=(((ll)m[vec.back()]-1)*(ll)m[vec.back()])/2;
        vec.pop_back();
    }
    cout<<ans<<endl;    
    return 0;
}

Measured memory_bytes: 8320
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
#define mp make_pair
#define pb push_back
#define f first
#define s second


//var 
int a,b,t;

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

	cin >> a >> b >> t;
	cout << b * (t/a) << endl;

	cout.flush();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
	
using namespace std;
	
#define endl "\n"
#define ll long long
#define vi vector <int >
#define vii vector < pii >
#define vll vector <ll >
#define pii pair <int, int>
#define pdd pair< double, double>
#define piii pair < pii, int > 
#define pll pair<ll, ll >
#define umap unordered_map
#define pb push_back
#define pq priority_queue
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define rep(i,b,c) for(int i = (int)b; i < (int)c; i++)
#define double long double
#define a first
#define b second

vi arr(100010);

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

	int m,n;
	cin >> m >> n;
	if(n == m) cout << "Yes" << endl;
	else cout << "No" << endl;



	return 0;
}


Measured memory_bytes: 640
import scala.io.Source

object Main {

  def transform(target: String, cmd: Array[String]) = cmd(0) match {
    case "print" => { println(target.slice(cmd(1).toInt, cmd(2).toInt+1)); target }
    case "reverse" => target.take(cmd(1).toInt) + target.slice(cmd(1).toInt, cmd(2).toInt+1).reverse + target.drop(cmd(2).toInt+1)
    case "replace" => target.take(cmd(1).toInt) + cmd(3) + target.drop(cmd(2).toInt+1)
  }

  def main(args: Array[String]): Unit = {
    val src = Source.stdin.getLines
    val target = src.next
    src.next
    src.map(_.split(" ")).foldLeft(target)(transform)
  }

}

Measured memory_bytes: 44856
#include<bits/stdc++.h>
using namespace std;
int main() {
	int xr, xl, yo, yu, n, w, h;
	cin >> w >> h >> n;
	xr = w;
	xl = 0;
	yo = h;
	yu = 0;
	for (int i = 0; i < n; i++) {
		int x, y, a;
		cin >> x >> y >>a;
		if (a == 1 && xl < x) {
			xl = x;
		}
		else if (a == 2 && xr > x) {
			xr = x;
		}
		else if (a == 3 && yu < y) {
			yu = y;
		}
		else if (a == 4 && yo > y) {
			yo = y;
		}
	}
	if (xr - xl > 0 && yo - yu > 0) {
		cout << (xr - xl)*(yo - yu) << endl;
		return 0;
	}
	cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int mod = 1000000007;

int a[maxn];
void gcd(ll a,ll b, ll& d,ll& x,ll& y){  //      已经测试 FZU 1402
  if(!b) {d=a;x=1;y=0;}
  else   {	gcd(b,a%b,d,y,x);	y-=a/b*x;}
}

ll inv(ll a,ll n)  { //无逆元返回-1
  ll d,x,y;	gcd(a,n,d,x,y);
  return d==1?(x%n+n)%(n/d):-1;
}
int n,m;
ll p[maxn];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  cin>>n>>m;
  for(int i=0;i<n;i++)cin>>a[i];
  p[0]=1;
  for(int i=1;i<=n;i++)p[i]=p[i-1]*i%mod;
  sort(a,a+n);
  ll ret = 0;
  for(int i=0;i<n;i++){
    if(n-i>=m){
      ll tmp = a[i] * p[n-i-1]%mod*inv(p[m-1]*p[n-i-m]%mod,mod)%mod;
      ret = (ret +mod-tmp)%mod;
    }
    if(i+1>=m){
      ll tmp = a[i] * p[i] %mod*inv(p[m-1]*p[i-m+1]%mod, mod)%mod;
      ret = (ret+tmp)%mod;
    }
  }
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 1408
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def main():
    x = [y for y in map(int,input().split())]
    x.sort()
    f = 0
    s = 0
    for i in x:
        if i == 5:
            f += 1
        elif i == 7:
            s += 1
        else:
            print("NO")
            return
    if f==2 and s==1:
        print("YES")
    else:
        print("NO")
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 38636
#include<stdio.h>
#include<stdlib.h>
int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;} 
int main(void)
{
  int a,b,c,d,i=0;
    scanf("%d %d %d %d",&a,&b,&c,&d);
  while(i==0)
  {
    c-=b;
    if(c<=0)
    { 
     printf("Yes");
      break;
    }
    a-=d;
    if(a<=0)
    { 
     printf("No");
      break;
    }
    }
}

Measured memory_bytes: 1728
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x) // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

ll v[100002];

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    for (ll i = 0; i < n; i++)
    {
        ll a;
        cin >> a;
        v[a]++;
    }
    ll m = 0;
    for (ll i = 1; i <= 100000; i++)
    {
        ll temp = v[i - 1] + v[i] + v[i + 1];
        m = max(m, temp);
    }
    cout << m << endl;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys


def solve(X: int):
    f = lambda x, y: x**5 - y**5
    for i in range(-200, 200):
        for j in range(-200, 200):
            if f(i, j) == X:
                print(str(i) + ' ' + str(j))
                return
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9192
#include<iostream>
#include<cstdio>
using namespace std;
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
int n, m[N][N];
int color[N], d[N], f[N], tt;
void dfs_visit(int u) {
	int v;
	color[u] = GRAY;
	d[u] = ++tt;
	for (v = 0; v < n; v++) {
		if (m[u][v] == 0)continue;
		if (color[v] == WHITE) {
			dfs_visit(v);
		}
	}
	color[u] = BLACK;
	f[u] = ++tt;
}
void dfs() {
	int u;
	for (u = 0; u < n; u++)color[u] = WHITE;
	tt = 0;
	for (u = 0; u < n; u++) {
		if (color[u] == WHITE)dfs_visit(u);
	}
	for (u = 0; u < n; u++) {
		printf("%d %d %d\n", u + 1, d[u], f[u]);
	}
}
int main() {
	int u, v, k, i, j;
	cin >> n;
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			m[i][j] = 0;
		}
	}
	for (i = 0; i < n; i++) {
		cin >> u >> k;
		u--;
		for (j = 0; j < k; j++) {
			cin >> v;
			v--;
			m[u][v] = 1;
		}
	}
	dfs();
	return 0;
}

Measured memory_bytes: 3208
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <fstream>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
using namespace std;

constexpr int INF       = 1000000000;/* 1e+9a */
constexpr int MODULO    = 1000000007;

#define int long

#define REP(i,f,n) for(int i=(f); i < (n); ++i)
#define PER(i,f,n) for(int i=(n-1); i >= f; --i)

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

//----------------------------------
//----------------------------------

template<typename STL> inline void print_STL(STL c, string ab = ""){
	cout << ab << c[0];
	for(int i = 1; i < c.size(); ++i) cout << ' ' << c[i]; }

template<typename STL> inline void import_STL(STL& c, int n){
	typename STL::value_type tmp;
	for(int i = 0; i < n; ++i){	cin >> tmp; c.push_back(tmp);} }

signed main()
{
	cin.tie(0);
    ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int total = 100000;
	REP(i, 0, n)
	{
		total += total / 20;
		if(total % 1000)
			total += 1000 - total % 1000;
	}
	cout << total << '\n';
}

Measured memory_bytes: 3088
#include <iostream>
#include <cstdio>
using namespace std;
 
int p[110], q[110], cnt;
long long N;
     
void solve(long long n){
	if(n<=1)	return;
   	if(n&1){
   		q[++q[0]]=cnt++;
   		solve(n-1);
   	}else{
   		p[++p[0]]=cnt++;
   		solve(n>>1);
 	}
}
    
int main(){
  	scanf("%lld", &N);
  	solve(N+1);
  	printf("%d\n", cnt*2);
  	for(int i=1; i<=q[0]; i++)	printf("%d ", cnt-q[i]);
  	for(int i=p[0]; i; i--)		printf("%d ", cnt-p[i]);
   	for(int i=1; i<=cnt; i++)	printf("%d ", i);
 	return 0;
}

Measured memory_bytes: 256
r=0...gets.to_i
x,y=$<.map{|l|l.split.map &:to_i}
c=r.map{|i|(x[i]-y[i]).abs}
(1..3).map{|p|puts"%f"%c.map{|v|v**p}.reduce(:+)**(1.0/p)}
p c.max

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

int main(){
    long long int N,A,B,C,D,E;
    cin>>N>>A>>B>>C>>D>>E;
    long long int num_min= min(A,min(B,min(C,min(D,E))));
    long long int time2pass;
    if(N%num_min==0){
        time2pass=N/num_min;
    }else{
    time2pass=N/num_min+1;
    }
    cout<<time2pass+4<<endl;
}

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

int main(){
	long long n, x;
	long long c, pr;
	long long vmax, res;
	cin >> n >> c;
	vector<pair<long long, long long>> input(n);
	vector<long long> ret(n+1);
	vector<long long> dir(n+1);
	for(int i=0; i<n; i++){
		cin >> input[i].first;
		cin >> input[i].second;
	}
	dir[0] = input[0].second;
	pr = 0;
	for(int i=1; i<n; i++){
		dir[i] = dir[i-1] + input[i].second - input[i].first + pr;
		pr = input[i].first;
	}
	ret[0] = 0;
	pr = 0;
	for(int i=1; i<n+1; i++){
		ret[i] = ret[i-1] + input[n-i].second - 2*(c - input[n-i].first) + pr;
		pr = 2*(c - input[n-i].first);
	}

	dir[0] = 0;
	pr = 0;
	for(int i=1; i<n+1; i++){
		dir[i] = dir[i-1] + input[i-1].second - input[i-1].first + pr;
		pr = input[i-1].first;
	}

	vmax = 0;
	for(int i=0; i<n+1; i++){
		vmax = max(vmax, dir[i]);
		dir[i] = vmax;
	}
	vmax = 0;
	for(int i=0; i<n+1; i++){
		vmax = max(vmax, ret[i]);
		ret[i] = vmax;
	}
	vmax = 0;
	for(int i=0; i<n+1; i++){
		vmax = max(vmax, dir[n-i] + ret[i]);
	}
	res = vmax;
	

	dir[0] = 0;
	pr = 0;
	for(int i=1; i<n+1; i++){
		dir[i] = dir[i-1] + input[n-i].second - (c - input[n-i].first) + pr;
		pr = (c - input[n-i].first);
	}
	ret[0] = 0;
	pr = 0;
	for(int i=1; i<n+1; i++){
		ret[i] = ret[i-1] + input[i-1].second - 2*input[i-1].first + pr;
		pr = 2*input[i-1].first;
	}

	vmax = 0;
	for(int i=0; i<n+1; i++){
		vmax = max(vmax, dir[i]);
		dir[i] = vmax;
	}
	vmax = 0;
	for(int i=0; i<n+1; i++){
		vmax = max(vmax, ret[i]);
		ret[i] = vmax;
	}
	vmax = 0;
	for(int i=0; i<n+1; i++){
		vmax = max(vmax, dir[n-i] + ret[i]);
	}
	//cout << res << endl;
	res = max(res, vmax);
	cout << res << endl;
	//for(int i=0; i<n+1; i++){
	//	cout << dir[i] << " ";
	//}
	//cout << endl;
	//for(int i=0; i<n+1; i++){
	//	cout << ret[i] << " ";
	//}
	//cout << endl;
	return 0;
}

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

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

    int cnt = 0;
    for(int i = 0; i < m; i++){
        int x;
        cin >> x;

        cnt += x;
    }

    if(cnt > n)
        cout << -1 << '\n';
    else
        cout << n - cnt << '\n';
    return 0;
}


Measured memory_bytes: 3604
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC073A
{
    class Program
    {
        static void Main(string[] args)
        {
            String n;

            n = Console.ReadLine();

            if (n[0] == '9' || n[1] == '9')
                Console.WriteLine("Yes");

            else 
            Console.WriteLine("No");

            Console.ReadKey();
            }


    }
}


Measured memory_bytes: 11092
K, N = map(int, input().split())
A = list(map(int, input().split()))

dist = [0] * N

for i in range(N - 1):
    dist[i] = A[i + 1] - A[i]

dist[-1] = K - (A[-1] - A[0])

ans = K - max(dist)

print(ans)

Measured memory_bytes: 26444
#include<cstdio>
using namespace std;
int a, b;
int main() {
	scanf("%d%d", &a, &b);
	if(a == 1) a += 13;
	if(b == 1) b += 13;
	if(a == b) printf("Draw");
	else printf("%s", a > b ? "Alice" : "Bob");
	return 0;
}

Measured memory_bytes: 128
import numpy as np


x, y, z, k = map(int, input().split())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))
Cs = list(map(int, input().split()))

As = sorted(As, reverse=True)
Bs = sorted(Bs, reverse=True)
Cs = sorted(Cs, reverse=True)

idx_1, idx_2, idx_3 = 0, 0, 0
INF = 10 ** 11
answers = list()

candidates = [(idx_1, idx_2, idx_3)]
end_cands = set()
values = [As[idx_1] + Bs[idx_2] + Cs[idx_3]]
for i in range(k):
    while True:
        ans_idx = np.argmax(values)
        cand = candidates.pop(ans_idx)
        ans = values.pop(ans_idx)
        if cand not in end_cands:
            break
    idx_1, idx_2, idx_3 = cand
    answers.append(ans)
    end_cands.add(cand)
    # print(cand, ans)

    if idx_1 + 1 != x:
        candidates.append((idx_1 + 1, idx_2, idx_3))
        values.append(As[idx_1 + 1] + Bs[idx_2] + Cs[idx_3])
    if idx_2 + 1 != y:
        candidates.append((idx_1, idx_2 + 1, idx_3))
        values.append(As[idx_1] + Bs[idx_2 + 1] + Cs[idx_3])
    if idx_3 + 1 != z:
        candidates.append((idx_1, idx_2, idx_3 + 1))
        values.append(As[idx_1] + Bs[idx_2] + Cs[idx_3 + 1])

for ans in answers:
    print(ans)


Measured memory_bytes: 14920
def p_d():
    N, K = map(int, input().split())
    S = input()
    ans = 0

    for n in range(N - 1):
        if S[n] == S[n + 1]:
            ans += 1

    np = N - ans - 1

    for k in range(K):
        if np > 1:
            ans += 2
            np -= 2
        elif np == 1:
            ans += 1
            np -= 1

    print(ans)


if __name__ == '__main__':
    p_d()


Measured memory_bytes: 39408
#include<stdio.h>
int main(){
  int n,k,x,i,ans = 0;
  scanf("%d",&n);
  scanf("%d",&k);
  for (i=0;i<n;i++){
    scanf("%d",&x);
    if (x > k - x) {
      ans += k - x;
    }else {
      ans += x;
    }
  }
  ans *= 2;
  printf("%d\n",ans);
  return 0 ;
}


Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e8;

signed main() {
	int a, b;
	cin >> a >> b;
	int sa = b - a;
	int sum = sa * (sa + 1) / 2;
	int ans = sum - b;
	cout << ans;
}

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

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws Exception
	{
		BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
		int n=Integer.parseInt(bu.readLine());
		System.out.print(2.0*Math.PI*n);
	}
}

Measured memory_bytes: 33336
import re
 
def main():
    S = input()
    N = len(S) + 1
 
    ans = 0
    s_list = re.split("><", S)
    nelem = len(s_list)
    for i in range(nelem):
        elem = s_list[i]
        ln = elem.count(">") + 1
        rn = elem.count("<") + 1
        if i == 0:
            rn -= 1
        if i == nelem - 1:
            ln -= 1
        nmax = max([ln, rn])
        nmin = min([ln, rn])
        ans += (0 + nmax) * (nmax + 1) / 2
        ans += (0 + nmin - 1) * (nmin) / 2
    print(int(ans))
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 55880
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define pb push_back
set<int > se;

int main(){
	int a;
	cin >> a;
	if(a%1000 ==0){
		cout << 0 << endl;
	}
	else if(a<1000){
		cout << 1000-a << endl;
	}
	else {
		cout << 1000-(a%1000) << endl;
	}
}


Measured memory_bytes: 3644
#include<stdio.h>
#include<math.h>

#define true 1
#define false 0

int isPrime(int);

int main(){
  int n,i,j,c,count=0;

  scanf("%d",&n);

  for(i = 0;i < n;i++){
    scanf("%d",&c);

    if(isPrime(c) == 1){
      count++;
    }

  }

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

  return 0;
}

int isPrime(int x){
  int i;
  double d,sq;

  d = x;
  sq = sqrt(d);

  if(x == 2){
    return true;
  }

  if(x < 2 || x % 2 == 0){
    return false;
  }

  i = 3;
  while(i <= sq){
    if(x % i == 0){
      return false;
    }
    i = i + 2;
  }

  return true;
}

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

using namespace std;

const int ms = 2e5 + 17;
map<string, pair<int, int> > cards;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, m;
    cin >> n;

    for(int i = 1; i <= n; ++i)
    {
        string s;
        cin >> s;

        ++cards[s].first;
    }

    cin >> m;

    for(int i = 1; i <= m; ++i)
    {
        string s;
        cin >> s;

        ++cards[s].second;
    }

    int answer = 0;
    for(map<string, pair<int, int> > :: iterator i = cards.begin(); i != cards.end(); ++i)
    {
        answer = max(answer, (i->second.first) - (i->second.second));
    }

    cout << answer << '\n';
    }


Measured memory_bytes: 256
import sys,math,collections,itertools
input = sys.stdin.readline

N,M=list(map(int,input().split()))
road = [0]*(N)
for _ in range(M):
    l,r=map(int,input().split())
    road[l-1]+=1
    road[r-1]-=1
road = list(itertools.accumulate(road))[:-1]

flag=0
for ro in road:
    if ro%2==1:
        print('NO')
        exit()
print('YES')
        



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

int main(){
	int x,a=0,t=100;
	cin>>x;
	while(t){
		if(x/t==1)	a=a*10+9;
		if(x/t==9)	a=a*10+1;
		x%=t;
		t/=10;
	}
	cout<<a;
}

Measured memory_bytes: 256
//
//  second.cpp
//  CoderTest
//
//  Created by yuya on 2019/07/25.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int (i) = 0; (i) < (int)(n); i++)
#define rep1(i,n) for(int (i) = 1; (i) <= (int)(n); i++)
#define INF 1000000
#define MOD (ll)(1e9 + 7)





int main()
{
    
    double A, B;
    cin >> A >> B;
    double amin =  A / 0.08, amax = (A + 1) / 0.08;
    double bmin =  B / 0.1, bmax = (B + 1) / 0.1;
    
    if (bmax <= amin || amax <= bmin) {
        cout << -1 << endl;
    } else {
        cout << max(ceil(amin) , ceil(bmin)) << endl;
    }
    
    
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long arr[200005];
long long psum[200005];
long long moder = 1000000007;
int main(){
	int n;
	cin>>n;
	for(int i=1; i<=n; i++) cin>>arr[i];
	for(int i=1; i<=n; i++) psum[i]=psum[i-1]+arr[i];
	long long ret = 0;
	for(int i=1; i<n; i++){
		ret+=(((psum[n]-psum[i])%moder)*arr[i])%moder;
		ret%=moder;
	}
	cout<<ret;
}

Measured memory_bytes: 6708
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    long long n,k,i,a[2000],j,min=0;
    cin>>n>>k;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+1+n);
    for(j=1;j<=k;j++)
    {
        min+=a[j];
    }
    cout<<min<<endl;
    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
inline int rnd(int x){
	return rand()%x;
}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=100005;
int n,m,flag,vis[N],gu,sum;
vector<int> v[N];
void dfs(int p,int color){
	if(vis[p]==-1)vis[p]=color;
	else {if(vis[p]!=color)flag=1; return;}
	for(unsigned i=0;i<v[p].size();i++)dfs(v[p][i],color^1);
}
int main(){
	n=read(); m=read();
	for(int i=1;i<=m;i++){
		int s=read(),t=read();
		v[s].push_back(t); v[t].push_back(s);
	}
	memset(vis,-1,sizeof(vis));
	int gu=0,fe=0,er=0;
	for(int i=1;i<=n;i++)if(vis[i]==-1){flag=0; dfs(i,0); if(v[i].size()){if(flag)fe++; else er++;} else gu++;}
	//cout<<gu<<" "<<fe<<" "<<er<<endl;
	cout<<(ll)gu*gu+(ll)gu*(n-gu)*2+(ll)fe*er*2+(ll)er*er*2+(ll)fe*fe<<endl;
}
/*
2 1
2 6
3 4
3 5

(2,3) (1,6) (1,4) (1,5) (
(1,2)-(1连出的点，2连出的点）
*/

Measured memory_bytes: 9984