akhauriyash/Code-Regression huggingface dataset:
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

// xのn乗%modを計算
ll mod_pow(ll x, ll n, ll mod){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res*x%mod;
        x = x*x%mod;
        n >>= 1;
    }
    return res;
}

int main(){
    ll N,P;
    cin>>N>>P;
    string tmp;
    cin>>tmp;

    vector<ll> S(N);
    REP(i,N){
        S[i]=tmp[i]-'0';
    }
    vector<ll> U(N+1,0);
    map<ll,ll> mp;
    mp[0]++;
    ll ans=0;
    if(P==2||P==5){
        REP(i,N){
            if(S[i]%P==0) ans+=(i+1);
        }
    }else{
        REP(i,N){
            U[N-1-i]=(U[N-i]+mod_pow(10,i,P)*S[N-1-i])%P;
            if(mp.count(U[N-i-1])){
                ans+=mp[U[N-1-i]];
            }
            mp[U[N-1-i]]++;
        }
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 7088
import queue
import copy
q = queue.Queue()
h, w = map(int, input().split())
a = [list('#'+input()+'#') for _ in range(h)]
a = [['#']*(w+2)]+a+[['#']*(w+2)]
a1 = copy.deepcopy(a)
ans = []
        
for i in range(1, h+1):
    for j in range(1, w+1):
        a = copy.deepcopy(a1)
        if a[i][j] == '#':
            continue        
        q.put([i, j, 0])
        while not q.empty():
            now = q.get()
            
            if a[now[0]][now[1]] == '.':
                ans.append(now[2])
                a[now[0]][now[1]] = '#'
            else:
                continue
                
            if a[now[0]+1][now[1]] != '#':
                q.put([now[0]+1, now[1], now[2]+1])
            if a[now[0]-1][now[1]] != '#':
                q.put([now[0]-1, now[1], now[2]+1])
            if a[now[0]][now[1]+1] != '#':
                q.put([now[0], now[1]+1, now[2]+1])
            if a[now[0]][now[1]-1] != '#':
                q.put([now[0], now[1]-1, now[2]+1])
        a1[i][j] == '#'
print(max(ans))


Measured memory_bytes: 10760
#include<stdio.h>
#include<string.h>
 
int main(){
    int i,num,m,h;
    char c[200],c2[200];
    while (1){
        scanf("%s",c);
        if (c[0]=='-') 
            break; 
        num=strlen(c);
        scanf("%d",&m);
        while (m--){
            scanf("%d",&h);
            for (i=0;i<h;i++){
                c2[i]=c[i];
            }
            for (i=h;i<num;i++){
                c[i-h]=c[i];
            }
            for (i=0;i<h;i++){
                c[i+num-h]=c2[i];
            }
        }
        printf("%s\n",c);
    }
    return 0;
}


Measured memory_bytes: 2612
N = int(input())
red = []
blue = []
for i in range(N):
    red.append(list(map(int, input().split())))

for i in range(N):
    blue.append(list(map(int, input().split())))

ans = 0
red = sorted(red, key=lambda tup: tup[1], reverse=True)
blue.sort()

for i in range(N):
    for j in range(len(blue)):
        if red[i][0] < blue[j][0] and red[i][1] < blue[j][1]:
            ans += 1
            del blue[j]
            break

print(ans)


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();

		int sum = 0;
		for(int i = 1; i <= k; i++){
			for(int j = 1; j <= k; j++){
				for(int l = 1; l <= k; l++){
					sum += gcd(gcd(i,j),l);
				}
			}
		}
		System.out.println(sum);
	}

	public static int gcd(int a, int b){
		if(a % b == 0){
			return b;
		}
		return gcd(b, a % b);
	}

}


Measured memory_bytes: 35888
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
typedef pair<int, int> pint;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

bool judge(Int cut, vector<Int> logs, Int k){
    Int ans=0;
    if(cut==0) return false;
    for(int i=0; i<logs.size(); i++){
        if(logs[i]%cut!=0) ans+=(logs[i]/cut);
        else ans+=(logs[i]/cut-1);
        if(ans>k) return false;
    }
    if(ans>k) return false;
    return true;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    Int n,k; cin>>n>>k;
    vector<Int> a(n,0);
    rep(i,n) cin>>a[i];
    Int ok=1000000100;
    Int ng=-1;
while(abs(ok-ng)>1){
        Int mid=(ok+ng)/2;
        if(judge(mid,a,k)){
            ok=mid;
        }else{
            ng=mid;
        }
    }
    cout<<ok<<endl;
    return 0;
}

Measured memory_bytes: 6344
// AOJ 0302: Star Watching
// 2017.12.27 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX 524290

#define MIN(a,b) ((a)<=(b)?(a):(b))

#define INF 0x11111111
typedef struct { int x, y, l; } T;
T tbl[MAX];
int seg[4][MAX], sz;
char buf[30], *p;

int in()
{
	int n = 0;
	while (*p >= '0') n = 10*n + (*p++ & 0xf);
	p++;
	return n;
}

#if 0
void segtree(int id, int n)
{
	int k;
	k = 1; while (k < n) k <<= 1;
	sz = k;
	memset(seg[id], INF, sizeof(seg[id]));
}
#endif

// update kth value to v
void update(int id, int k, int v)
{
//	int t;
	k += sz-1;
	seg[id][k] = v;
	while (k > 0) {
#if 0
		if (!(k & 1)) k--;
		t = k, k >>= 1;
		v = seg[id][t++]; if (v > seg[id][t]) v = seg[id][t];
		seg[id][k] = v;
#else
		k = (k-1)/2;
		seg[id][k] = MIN(seg[id][k*2+1], seg[id][k*2+2]);
#endif
	}
}

int query2(int id, int a, int b, int k, int l, int r) 
{
	int m, lmin, rmin;

	if (r <= a || b <= l) return INF;
    if (a <= l && r <= b) return seg[id][k];
#if 0
	k <<= 1, m = (l + r) >> 1;
    lmin = query2(id, a, b, ++k, l, m);
    rmin = query2(id, a, b, ++k, m, r);
    if (lmin > rmin) lmin = rmin; 
    return lmin;
#else
	m = (l + r) / 2;
	lmin = query2(id, a, b, k*2+1, l, m);
    rmin = query2(id, a, b, k*2+2, m, r);
	return MIN(lmin, rmin);
#endif
}

// get min in [a, b)
int query(int id, int a, int b)
{
	return query2(id, a, b+1, 0, 0, sz);
}

int cmp(T *a, T *b) { return a->l - b->l; }

int main()
{
	int n, d, i, j;
	long long ans, a;

	fgets(p=buf, 30, stdin);
	n = in(), d = in();
	for (i = 0; i < n; i++) {
		fgets(p=buf, 30, stdin);
		tbl[i].x = in(), tbl[i].y = in(), tbl[i].l = in();
	}
	qsort(tbl, n, sizeof(T), cmp);
	tbl[n].l = INF;

	sz = 1; while (sz < n) sz <<= 1;
	memset(seg, INF, sizeof(seg));

	for (i = 0; i < n; i++) {
		update(0, i, -tbl[i].x), update(1, i, tbl[i].x);
		update(2, i, -tbl[i].y), update(3, i, tbl[i].y);
	}

	ans = 0;
	for (j = i = 0; i < n; i++) {
		while (j < n && tbl[j].l - tbl[i].l <= d) j++;
		j--;

		a = (((long long)query(0, i, j)) + query(1, i, j)) *
			(((long long)query(2, i, j)) + query(3, i, j));
		if (a > ans) ans = a;

	}
	printf("%lld\n", ans);
	return 0;
}

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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }

    friend std::istream &operator>>(std::istream &in, mint &o) {
        ll a;
        in >> a;
        o = a;
        return in;
    }

    friend std::ostream &operator<<(std::ostream &out, const mint &o) {
        out << o.x;
        return out;
    }

};

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

    vector<int> claim(n);
    rep(i, n) cin >> claim[i];

    int a = 0, b = 0, c = 0;
    mint ans = 1;
    rep(i, n) {
        int j = claim[i];

        int now = 0;
        if (a == j) now++;
        if (b == j) now++;
        if (c == j) now++;
        ans *= now;

        if (a == j) a++;
        else if (b == j) b++;
        else if (c == j) c++;
    }

    cout << ans << endl;

}


Measured memory_bytes: 640
n = int(input())
a = list(map(int,input().split()))

aa = [0]*n
bb = [0]*n

for i in range(n):
    aa[a[i]-1] += 1

for i in range(n):
    bb[i] = (aa[i]-1) * aa[i] // 2

sums = sum(bb)
for i in range(n):
    a_a = a[i] - 1
    b = bb[a_a]
    c = (aa[a_a]-1) * (aa[a_a]-2) // 2
    print(sums - b + c)


Measured memory_bytes: 26140
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

struct Clothes{
	int A,B,C;
};

int abso(int n){
	if(n<0) return n*-1;
	return n;
}

int main(){
	Clothes clothes[200];
	int day[201],dp[201][200]={},N,D,ans=0;
	cin>>D>>N;
	for(int i=1;i<=D;i++){
		cin>>day[i];
	}
	for(int i=0;i<N;i++){
		cin>>clothes[i].A>>clothes[i].B>>clothes[i].C;
	}
	for(int i=1;i<D;i++){
		for(int j=0;j<N;j++){
			//printf("%d ",dp[i][j]);
			if(day[i]<clothes[j].A || clothes[j].B<day[i]) continue;
			for(int k=0;k<N;k++){
				if(day[i+1]<clothes[k].A || clothes[k].B<day[i+1]) continue;
				dp[i+1][k]=max(dp[i+1][k], dp[i][j]+abso(clothes[j].C-clothes[k].C));
			}
		}//puts("");
	}
	for(int i=0;i<N;i++){
		//printf("%d ",dp[D][i]);
		ans=max(ans,dp[D][i]);
	}//puts("");
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1312
#include <stdio.h>
#include <string.h>)
int main()
{
	int i,n,j,k=0;
	char a[100];
	scanf("%s",a); 
	n=strlen(a);
    for(i=0;i<n;i++)
    {
    	for(j=i+1;j<n;j++)
    {
    	if(a[i]==a[j]) k=1;
    }	
    
    }
    if(k==1)
    printf("no");
    else printf("yes");
	
	
 
	return 0;
}

Measured memory_bytes: 128
macro_rules! debug {
    ($($a:expr),*) => {
   //     eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}


fn ExamA(){
    let s = get!(String);
    if s.contains("a") && s.contains("b") && s.contains("c") {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn ExamB(){

}

fn ExamC(){
    println!("hoge");
}

fn main() {
    ExamA();
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main(){
  int n, tmp, ans = 0;
  int a[n], b[n], c[n-1];
  cin >> n;
  for(int i=0; i<n; i++){cin >> tmp;a[i] = tmp - 1;}
  for(int i=0; i<n; i++){cin >> b[i];}
  for(int i=0; i<n-1; i++){cin >> c[i];}
  ans = b[a[0]];
  for(int i=1; i<n; i++){
    ans += b[a[i]];
 	if(a[i] - a[i-1] == 1)
      ans += c[a[i-1]];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
using namespace std;

const double PI=acos(-1);

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

    bool a[26] = {false}, z = true;
    for(int i = 0; i < s.length(); i++){
        if(a[s[i]-'a']){
            z = false;
            break;
        }else{
            a[s[i]-'a'] = true;
        }
    }
    if(z) cout << "yes" << endl;
    else cout << "no" << endl;
    return 0;
}

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

using namespace std;

typedef int itn;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef map<int, int> M;
typedef pair<int, int> P;
typedef stack<int> S;
typedef queue<int> Q;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b, k;
    cin >> a >> b >> k;
    set<int> s;
    for (int i = 0; (i < k) && (a + i <= b) && (b - i >= a); ++i)
    {
        s.insert(a + i);
        s.insert(b - i);
    }
    for (auto x: s) cout << x << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);

		while (sc.hasNext()) {
			int a = sc.nextInt();
			int b = sc.nextInt();

			int ans = 0;
			a += b;
			while (a > 0) {
				ans++;
				a /= 10;
			}
			System.out.println(ans);
		}
	}

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

Measured memory_bytes: 20412
n,m=gets.split.map(&:to_i)
r=Array.new(n, nil)
m.times do
  s,c=gets.split.map(&:to_i)
  if (!r[s-1].nil? && r[s-1] != c )|| (n != 1 && s == 1 && c ==0)
    puts -1
    exit 0
  end
  r[s-1]=c
end

r = r.map { |i| i.nil? ? 0 : i}

r[0] = 1 if r.first == 0 && n!=1
puts r.join






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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,m;
vi g[125252];
int indeg[125252];
int len[125252], bef[125252];

int main(){
  scanf("%d%d",&n,&m);
  REP(i,m){
    int x,y;
    scanf("%d%d",&x,&y);
    --x; --y;
    g[x].push_back(y);
    indeg[y]++;
  }
  fill(bef,bef+n,-1);
  stack<int> S;
  REP(i,n)if(indeg[i]==0)S.push(i);
  while(S.size()){
    int p = S.top(); S.pop();
    for(int to : g[p]){
      if(len[p]+1 > len[to]){
        len[to] = len[p]+1;
        bef[to] = p;
      }
      indeg[to]--;
      if(indeg[to]==0)S.push(to);
    }
  }
  printf("%d\n",*max_element(len,len+n));
  // 勢い余って復元まで書いてしまった
  return 0;
}


Measured memory_bytes: 7424
N, T = map(int, input().split())
C_T = []

for n in range(N):
    temp = []
    c, t = map(int, input().split())
    temp += [c,t]
    C_T.append(temp)

C_can = []

for n in range(N):
    if C_T[n][1] <= T:
        C_can.append(C_T[n][0])

if len(C_can) == 0:
    print('TLE')
else:
    print(int(min(C_can)))

Measured memory_bytes: 3064
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      long m = 1;
      long k = (long) Math.pow(10,9)+7;
      for(int i = 1;i <= n;i++){
      	m *= i;
        m = m%k;
      }
      System.out.println(m);
    }
}


Measured memory_bytes: 21844
#include <stdio.h>
int main(void)
{
    char c;
    int a;
    while(scanf("%c", &c), c != '0'){
        a=0;
        a += c%48;
        while(scanf("%c", &c), c != '\n'){
            a += c%48;
        }
        printf("%d\n", a);
    }
    return 0;
}

Measured memory_bytes: 536
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

#define __ { \
	freopen("input.txt","r",stdin); \
	freopen("output.txt","w",stdout); \
}
#define _ { \
	ios_base::sync_with_stdio(false); \
    cin.tie(NULL); \
}

int main(){
   _;
 //  __;
   ll n,a,b;cin>>n>>a>>b;
   cout<<(n/(a+b))*a+min(a,n%(a+b));
}

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

#define INF 1e9

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

  vector<int> d(n + 1);
  vector<int> c(m + 1);
  for(int i = 1; i <= n; i++){ cin >> d[i]; }
  for(int i = 1; i <= m; i++){ cin >> c[i]; }

  vector<vector<int> > dp(n + 1, vector<int>(m + 1, INF));
  for(int i = 0; i <= m; i++){ dp[0][i] = 0; }
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= m; j++){
      dp[i][j] = min(dp[i][j - 1],
                     dp[i - 1][j - 1] + d[i] * c[j]);
    }
  }
  cout << dp[n][m] << endl;

  return 0;
}

Measured memory_bytes: 5956
#include <stdio.h>
#include <string.h>
int main(void){
    int N,X[101];
    int max=-1,min=101,Smin=1000000000,S;
    scanf("%d\n",&N);
    for (int i=0; i<N; i++) {
        scanf("%d",&X[i]);
        if(X[i]>max){
            max=X[i];
        }
        if(min>X[i]){
            min=X[i];
        }
    }
    for (int i=min; i<=max; i++) {
        S=0;
        for (int j=0 ; j<N ; j++) {
            S+=(X[j]-i)*(X[j]-i);
        }
        if(S<Smin){
            Smin=S;
        }
    }
    printf("%d\n",Smin);
    return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  auto getPositions = [&]() {
    vector<int> res;
    for (int i = 0; i < n && res.size() < k;) {
      if (s[i] == 'o') {
        res.push_back(i);
        i += c+1;
      } else {
        ++i;
      }
    }
    return res;
  };
  vector<int> l, r; // おける位置
  l = getPositions();
  reverse(s.begin(),s.end());
  r = getPositions();
  for(int i = 0; i < k; i++) {
    r[i] = n-1-r[i];
  }
  reverse(s.begin(),s.end());

  vector<int> lastL(n+1, -1);
  for(int i = 0; i < k; i++) {
    lastL[l[i]+1] = i; // 位置から件数単位に
  }
  for(int i = 0; i < n; i++) {
    if (lastL[i+1] == -1) {
      lastL[i+1] = lastL[i];
    }
  }

  vector<int> lastR(n+1, -1);
  for(int i = 0; i < k; i++) {
    lastR[r[i]] = i; // 位置から件数単位に
  }
  for (int i = n-1; i >= 0; --i) {
    if (lastR[i] == -1) {
      lastR[i] = lastR[i+1];
    }
  }

  for(int i = 0; i < n; i++) {
    if (s[i] == 'x') continue;
    int li = lastL[i];
    int ri = lastR[i+1];
    int cnt = 0;
    if (li != -1) cnt += li+1;
    if (ri != -1) cnt += ri+1;
    if (li != -1 && ri != -1 && r[ri] - l[li] <= c) {
      --cnt;
    }
    // その日働くとして、左右の日数を足した場合、日数を超えていたら
    if (cnt >= k) continue;
    cout << i + 1 << endl;
  }
  return 0;
}

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

using namespace std;

struct TEAM
{
	short id;
	short af;
	int pt;
	char ac;
};
typedef struct TEAM team;

int main()
{
	int n;
	team tt[300];
	char ok[1001];

	while(cin >> n, n)
	{
		for(int i=0; i < n; i++) {
			cin >> tt[i].id;
			cin >> tt[i].af;
			char tmp; cin >> tmp; tt[i].ac = tmp - '0';
			cin >> tt[i].pt;
		}
		// sort
		int nn = n - 1;
		for(int i=0; i < nn; i++) {
			for(int j=i+1; j < n; j++) {
				if(tt[i].ac < tt[j].ac) {
					swap(tt[i], tt[j]);
				}
				else if(tt[i].ac == tt[j].ac) {
					if(tt[i].pt > tt[j].pt) {
						swap(tt[i], tt[j]);
					}
					else if(tt[i].pt == tt[j].pt) {
						if(tt[i].id > tt[j].id) {
							swap(tt[i], tt[j]);
						}
					}
				}
			}
		}
		// \sort
		for(int i=0; i < 1001; i++) ok[i] = 0;
		int cnt = 0;
		for(int i=0; i < n; i++) {
			if(cnt < 10) { // rule1
				if(ok[tt[i].af] < 3) {
					ok[tt[i].af]++;
					cnt++;
					cout << tt[i].id << endl;
				}
			}
			else if(cnt < 20) { // rule2
				if(ok[tt[i].af] < 2) {
					ok[tt[i].af]++;
					cnt++;
					cout << tt[i].id << endl;
				}
			}
			else if(cnt < 26) { // rule3
				if(ok[tt[i].af] < 1) {
					ok[tt[i].af]++;
					cnt++;
					cout << tt[i].id << endl;
				}
			}
			else
				break;
		}
	}
	return 0;
}

Measured memory_bytes: 0
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#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()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-9
//#define int ll

int l[300], r[300], o[300], cnt[300];
signed main(void)
{
	while(true) {
		int n;
		cin >> n;
		if(!n) break;
		REP(i, n) cin >> l[i];

		int ss = -1, aa = -1, cc = -1;
		double mi = 1e9;
		REP(s, 16) REP(a, 16) REP(c, 16) {
			r[0] = s;
			REP(i, 256) cnt[i] = 0;
			FOR(i, 1, n+1) {
				r[i] = (a*r[i-1]+c) % 256;
				cnt[(l[i-1]+r[i])%256]++;
			}
			double ent = 0;
			REP(i, 256) {
				if(cnt[i] != 0) ent -= (cnt[i] / (double)(n) * log(cnt[i] / (double)(n)));
			}
			if(ent+EPS < mi) {
				mi = ent;
				ss = s;
				aa = a;
				cc = c;
			}
		}
		cout << ss << " " << aa << " " << cc << endl;
	}

	return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

vector<int> edge[100000];
int prevv[100000];
bool visited[100000];

int main() {
  int n, m;
  cin >> n >> m;
  rep(i, n) prevv[i] = -1;
  int s, g;
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    edge[a].eb(b);
    edge[b].eb(a);
    if (i == 0) {
      s = a;
      g = b;
      visited[s] = visited[g] = true;
      prevv[g] = s;
    }
  }

  int cnt = 2;
  while (true) {
    int ns = -1;
    rep(i, edge[s].size()) {
      if (!visited[edge[s][i]]) ns = edge[s][i];
      if (ns != -1) break;
    }

    if (ns != -1) {
      cnt++;
      prevv[s] = ns;
      s = ns;
      visited[s] = true;
      continue;
    }

    int ng = -1;
    rep(i, edge[g].size()) {
      if (!visited[edge[g][i]]) ng = edge[g][i];
      if (ng != -1) break;
    }

    if (ng != -1) {
      cnt++;
      prevv[ng] = g;
      g = ng;
      visited[g] = true;
      continue;
    }

    break;
  }

  cout << cnt << endl;
  for (int i = g; i != -1; i = prevv[i]) cout << i + 1 << ' ';
  cout << endl;
}


Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e6+10;
int main()
{
	int n,a[120]={0},sum=0;
	scanf("%d",&n);
	for(int i=0;i<n-1;i++)
	{
		scanf("%d",&a[i]);
	}
	for(int i=0;i<n-1;i++)
	{
		sum+=min(a[i],a[i+1]);
	}
	sum=sum+a[0]+a[n-2];
	cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <iostream> 
#include <cstdio> 
using namespace std;
int main()
{
	long long n,a,b,c;
	scanf("%d",&n);
	for(long long a=1;a<=3500;a++)
		for(long long b=1;b<=3500;b++){
			long long x=n*a*b;
			long long y=4*a*b-n*b-n*a;
			if(y>0 && x%y==0){
				printf("%lld %lld %lld\n",a,b,x/y);
				return 0;
			}
		}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, r;

signed main() {
	cin >> n >> r;
	if (10 <= n)cout << r << endl;
	else cout << r + 100 * (10 - n) << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <string>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <utility>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll mod = 1000000007;

ll solve(void);

int main(void)
{
	while (solve())
	{
	}
	return 0;
}

ll solve(void)
{
	ll N, T;
	cin >> N >> T;
	vector<pll> V;
	
	V.push_back(pll(0, 0));
	for (ll i = 0; i < N; i++) {
		pll pl;
		cin >> pl.first >> pl.second;
		V.push_back(pl);
	}

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

	vector<vector<ll>> dp(N+2, vector<ll>(T+1, 0));
	ll ans = 0;

	for (ll t = 0; t < T; t++) {
		for (ll n = 0; n < N; n++) {
			dp[n+1][t] = max(dp[n][t], dp[n+1][t]);
			ll nt = t + V[n+1].first;
			if (!(nt < T)) { continue; }
			dp[n+1][nt] = max(dp[n+1][nt], dp[n][t] + V[n+1].second);
		}
	}

	for (ll t = 0; t < T; t++) {
		for (ll n = 0; n < N; n++) {
			ans = max(ans, dp[n][t] + V[n+1].second);
		}
	}
	
	cout << ans << endl;

	return 0;
}



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

int main(){
    int a,b;
    cin >> a >> b;
    if(a%2 == 0){
        cout << "Even" << endl;
        return 0;
    }
    else if(b%2 == 0){
        cout << "Even" << endl;
        return 0;
    }
    cout << "Odd" << endl;
    return 0;
}

Measured memory_bytes: 256
def fac1(num, div):
    """How many times can the factorial of `num` be divided by `div`?"""
    if num == 0:
        return 0
    return num // div + fac1(num // div, div)


def fac2(num, div):
    """How many times can the double factorial of `num` be divided by `div`?"""
    return fac1(num // 2, div)


def main():
    num = int(input())
    if num % 2 == 1:
        return 0
    else:
        return fac2(num, 5)


if __name__ == '__main__':
    ans = main()
    print(ans)


Measured memory_bytes: 9108
n, k = map(int, input().split())
a = list(map(int, input().split()))
pos = 1
path = [1]
flag = [True] * n
flag[0] = False
for i in range(k):
    pos = a[pos - 1]
    if flag[pos - 1]:
        path.append(pos)
        flag[pos - 1] = False
    else:
        break
d = path.index(pos)
ans = (k-d) % (len(path) - d) + d
print(path[ans])

Measured memory_bytes: 32304
M = int(input())
d=[]
c=[]
count = 0
surplas = 0
for i in range(M):
    D, C = map(int, input().split())
    count += C-1
    count += (D*C-1)//9
    surplas += (D*C-1) % 9 + 1
count += M-1
count += (surplas-1) // 9
print(count)

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


using namespace std;

int GCD(int a, int b){
  return b != 0? GCD(b,a%b) : a;
}


int main(void){
  int N;

  cin >> N;
  vector<int> a(N);
  vector<int> left(N+1,0),right(N+1,0); //配列の中を全部ゼロにできる

  //入力
  for(int i = 0; i < N; i++)cin >> a[i];
  //左
 for(int i = 0; i < N; i++)left[i+1]=GCD(left[i],a[i]);
//   //右
 for(int i = N - 1; i >= 0; i--)right[i] = GCD(right[i + 1],a[i]);
//   //合体
vector<int> M(N);
for(int i =0; i < N; i++)M[i] = GCD(left[i],right[i+1]);
int max =*max_element(M.begin(),M.end());
cout << max << endl;

}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int N=1005;
const long long inf=6000000000000000000ll;
int Q,n,m,D,c[27],a[N][27],t[N],su[27],ans,i,j,x,y,as[N],s;
set<int> p[27];
int cal(int x,int y)
{
	int sum=ans;
	sum-=a[x][t[x]];
	sum+=a[x][y];
	auto it=p[t[x]].find(x);
	auto e=it;
	--e;
	++it;
	sum+=c[t[x]]*(-(*it-*e)*(*it-*e-1)/2+(x-*e)*(x-*e-1)/2+(*it-x)*(*it-x-1)/2);
	it=p[y].lower_bound(x);
	e=it;
	--e;
	sum-=c[y]*(-(*it-*e)*(*it-*e-1)/2+(x-*e)*(x-*e-1)/2+(*it-x)*(*it-x-1)/2);
	return sum;
}
void Change(int x,int y)
{
	ans-=a[x][t[x]];
	ans+=a[x][y];
	auto it=p[t[x]].find(x);
	auto e=it;
	--e;
	++it;
	ans+=c[t[x]]*(-(*it-*e)*(*it-*e-1)/2+(x-*e)*(x-*e-1)/2+(*it-x)*(*it-x-1)/2);
	p[t[x]].erase(x);
	t[x]=y;
	p[t[x]].insert(x);
	it=p[t[x]].find(x);
	e=it;
	--e;
	++it;
	ans-=c[t[x]]*(-(*it-*e)*(*it-*e-1)/2+(x-*e)*(x-*e-1)/2+(*it-x)*(*it-x-1)/2);
}
void up()
{
	if(s<ans)
	{
		s=ans;
		for(int i=1;i<=D;++i)
			as[i]=t[i];
	}
}
mt19937 rnd(time(0));
double rand_f() {return double(rnd())/double(RAND_MAX);}

void SA()
{
	double T=1000;
	while(T>0.001)
	{
		int a=rnd()%D+1,b=rnd()%26+1;
		while(b==t[a])
			b=rnd()%26+1;
		int tmp=cal(a,b);
		if(tmp>ans||rand_f()<exp((tmp-ans)/T))
		{
			Change(a,b);
			up();
		}
		T=T*0.995;
	}
}
int main()
{
	scanf("%d",&D);
	for(i=1;i<=26;++i)
	{
		scanf("%d",&c[i]);
		p[i].insert(D+1);
		p[i].insert(0);
	}
	for(i=1;i<=D;++i)
		for(j=1;j<=26;++j)
			scanf("%d",&a[i][j]);
	for(i=1;i<=D;++i)
		scanf("%d",&t[i]);
	for(i=1;i<=D;++i)
	{
		for(j=1;j<=26;++j)
			++su[j];
		t[i]=1;
		for(j=2;j<=26;++j)
			if(su[t[i]]*c[t[i]]+a[i][t[i]]<su[j]*c[j]+a[i][j])
				t[i]=j;
		ans+=a[i][t[i]];
		su[t[i]]=0;
		for(j=1;j<=26;++j)
			ans-=su[j]*c[j];
		p[t[i]].insert(i);
		as[i]=t[i];
	}
	s=ans;
	while(1.0*clock()/CLOCKS_PER_SEC<1.5)
	{
		SA();
		SA();
		SA();
		SA();
		//cout<<s<<endl;
	}
//	cout<<s<<endl;
	for(i=1;i<=D;++i)
		cout<<as[i]<<endl;
}

Measured memory_bytes: 4360
n=int(input())
a=list(map(int,input().split()))
count=0
a_abs=[0 for j in range(n)]
min_abs=abs(a[0])
for i in range(n):
    a_abs[i]=abs(a[i])
    if a[i]<0:
        count+=1
    if abs(a[i])<min_abs:
        min_abs=abs(a[i])
        

if count%2==0:
    ans=sum(a_abs)
else:
    ans=sum(a_abs)-2*min_abs
    
print(ans)

Measured memory_bytes: 14412
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
// #define int ll
using namespace std;
const int INF (1 << 30);
const ll LLINF (1LL << 55LL);
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    string s;
    ll w;
    cin>>s>>w;
    for(ll i=0;i<(ll)s.size();i+=w){
        cout<<s[i];
    }
    cout<<endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  string hinaarare;
  int count_P = 0, count_W = 0;
  int count_G = 0, count_Y = 0, zeroflag = 0;

  
  for(int i = 0 ; i < N; i++)
  {
    cin >> hinaarare;
    if(hinaarare == "P")
    {
      count_P++;
    }
    else if(hinaarare == "W")
    {
      count_W++;
    }
    else if(hinaarare == "G")
    {
      count_G++;
    }
    else if(hinaarare == "Y")
    {
      count_Y++;
    }
  }
  if(count_P == 0)
  {
    zeroflag++;
  }
  if(count_W == 0)
  {
    zeroflag++;
  }
  if(count_G == 0)
  {
    zeroflag++;
  }
  if(count_Y == 0)
  {
    zeroflag++;
  }
    
  if(zeroflag == 0)
  {
    cout << "Four" << endl;
  }
  else if(zeroflag == 1)
  {
    cout << "Three" << endl;
  }
}



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

int main(){
    int n, k;
    cin >> n >> k;
    vector<char> v(k);
    for(int i=0; i<k; i++) cin >> v[i];

    for(int i=n; i<1000000; i++){
        string s = to_string(i);
        bool flag = false;
        for(int j=0; j<s.size(); j++){
            for(int l=0; l<k; l++) if(s[j] == v[l]) flag = true;
        }
        if(!flag){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
using namespace std;
 
signed main()
{
    tezz
    
    string s;
    cin>>s;

    cout<<s[0]<<((s.length() - 2))<<s[s.length()-1];
} 

Measured memory_bytes: 256
a,b,c,d,e,f=map(int,input().split())

dp=[[False]*(f+2) for i in range(f+2)]
# dp[i][j]: iは入れた砂糖の重さ、jは水、値は濃度

dp[0][0]=True

for j in range(f+1):
    i=0
    if dp[i][j] and j<=f:
        if 0<i+j+100*a<=f:
            dp[i][j+100*a]=True
        if 0<i+j+100*b<=f:
            dp[i][j+100*b]=True

for i in range(f+1):
    for j in range(1,f+1):
        if dp[i][j] and i+j<=f:
            if 0<i+c+j<=f:
                dp[i+c][j]=True
            if 0<i+d+j<=f:
                dp[i+d][j]=True

tmpi=0
tmpj=min(a*100,b*100)
for i in range(f+1):
    for j in range(1,f+1):
        if dp[i][j] and i*100<=e*j and 0<j+i<=f and tmpi*j<i*tmpj:
            tmpi=i
            tmpj=j
        if i*100==e*j:
            break

print(tmpi+tmpj, tmpi)

Measured memory_bytes: 136496
N, K = map(int, input().split())

count = 0
if K == 0:
    count = N ** 2
else:
    for b in range(1, N + 1):
        d = N // b
        r = N % b
        count += d * max(0, b - K) + max(0, r - K + 1)
print(count)

Measured memory_bytes: 3060
ABCD = input()

for i in range(2**3):
    ans = int(ABCD[0])
    tmp_abcd = ABCD
    for j in range(3):
        if i >> j & 1:
            tmp_abcd = tmp_abcd[:3-j] + "+" + tmp_abcd[3-j:]
            ans += int(ABCD[3-j])
        else:
            tmp_abcd = tmp_abcd[:3-j] + "-" + tmp_abcd[3-j:]
            ans -= int(ABCD[3-j])
    if ans == 7:
        print(tmp_abcd + "=7")
        break


Measured memory_bytes: 3060
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N = int(input())
A = list(map(int, input().split()))
A.sort()

print(abs(A[-1]-A[0]))

Measured memory_bytes: 65440
N = input()
final = len(N)-1
if((N[final] == '2') | (N[final] == '4') | (N[final] == '5') | (N[final] == '7') | (N[final] == '9')):
  print('hon')
if((N[final] == '0') | (N[final] == '1') | (N[final] == '6') | (N[final] == '8')):
  print('pon')
if(N[final] == '3'):
  print('bon')

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

int main(){
  int a,b;
  cin>>a>>b;
  int ans=0;
  for(int i=a;i<=b;i++){
    string s=to_string(i);
    string t=s;
    reverse(t.begin(),t.end());
    if(s==t) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#! /usr/bin/env python3
# -*- coding:utf-8 -*-

def get_clock_distance(A, B, H, M):
    import math
    angle = min(abs(30 * H + 0.5 * M - 6 * M), abs(360 - (30 * H + 0.5 * M - 6 * M)))
    return (A**2 + B**2 - 2 * A * B * math.cos(math.radians(angle)))**0.5

def main():
    A, B, H, M = map(int, input().split())
    print(get_clock_distance(A, B, H, M))

if __name__ == "__main__":
    main()


Measured memory_bytes: 9520
import sys
X, N = map(int,input().split())
if N == 0:
  print(X)
  sys.exit()
p = set(map(int,input().split()))
for i in range(51):
  a = X - i
  if not(a in p):
    print(a)
    sys.exit()
  a = X + i
  if not(a in p):
    print(a)
    sys.exit()

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

#define REP(i, x) for (int i = 0; i < (x); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)

using ll = long long;

int main() {
    const ll INF = (1LL << 50);
    const int MAXN = 210;

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

    ll dist[MAXN][MAXN];
    REP (i, N) REP(j, N) dist[i][j] = (i == j ? 0 : INF);

    vector<int> r(R);
    REP (i, R) {
        cin >> r[i];
        r[i]--;
    }
    sort(r.begin(), r.end());

    REP (i, M) {
        int A, B, C;
        cin >> A >> B >> C;
        A--; B--;
        dist[A][B] = dist[B][A] = C;
    }

    REP (k, N) {
        REP (i, N) {
            REP (j, N) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    ll ans = INF;

    do {
        ll sum = 0;
        REP (i, R - 1) {
            sum += dist[r[i]][r[i + 1]];
        }
        ans = min(ans, sum);
    } while (next_permutation(r.begin(), r.end()));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>
#include <stack>
  
using namespace std;
 
int w,h;
int sx,sy;
int res;
int table[30][30];
int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};
 
void dfs(int x,int y,int cnt){
	if(cnt>=res) return ;
     
	for(int dir=0;dir<4;dir++){
		int nx=x+dx[dir],ny=y+dy[dir];
         
		if(nx<0 || w<=nx || ny<0 || h<=ny) continue;
		else if(table[ny][nx]==1) continue; 
		else if(table[ny][nx]==3){res=cnt; return;} 
         
		while(true){
			nx+=dx[dir]; ny+=dy[dir];
			if(nx<0 || w<=nx || ny<0 || h<=ny) break; 
			else if(table[ny][nx]==1){
				table[ny][nx]=0;                     
				dfs(nx-dx[dir],ny-dy[dir],cnt+1);    
				table[ny][nx]=1;        
				break;
			}else if(table[ny][nx]==3){
				res=cnt;  
				return ;
			}
		}
         
	}
     
}
 
 
int main()
{
     
	while(cin>>w>>h,w){     
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin>>table[i][j];
				if(table[i][j]==2){sx=j;sy=i;}
			}
		}
         
		res=11;
		dfs(sx,sy,1);
		if(res>10) res=-1;
		cout<<res<<endl;
         
	}

	return 0;
}

Measured memory_bytes: 1164
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            String[] array = reader.readLine().split(" ");
            int A = Integer.parseInt(array[0]);
            int B = Integer.parseInt(array[1]);
            int C = Integer.parseInt(array[2]);

            System.out.println(Math.max(B + C - A, 0));
        }
    }

}


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

#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        n: usize, m: usize, X: i64, Y: i64,
        x: [i64;n],
        y: [i64;m] 
    }

    let mut xm = x;
    xm.push(X);
    let mut ym = y;
    ym.push(Y);
    xm.sort();
    ym.sort();
    println!("{}", if xm[xm.len()-1] < ym[0] {"No War"} else {"War"});
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
typedef long long int ll;
int main()
{
    ll n,k;
    cin>>n>>k;
    int a[n];
    ll sum=0;
    for(int i=0;i<k;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    if(sum>n)
        cout<<"-1\n";
    else
    {
        cout<<n-sum<<endl;
    }
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef long double ld;


using Graph = vector<vector<int>>;

int main(){
    ll N, M;
    cin >> N >> M;

// グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // BFS のためのデータ構造
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    rep(i,N){
        if(dist[i] != -1) continue;
        que.push(i); // 0 を橙色頂点にする

        // BFS 開始 (キューが空になるまで探索を行う)
        while (!que.empty()) {
            int v = que.front(); // キューから先頭頂点を取り出す
            que.pop();

            // v から辿れる頂点をすべて調べる
            for (int nv : G[v]) {
                if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

                // 新たな白色頂点 nv について距離情報を更新してキューに追加する
                dist[i] = i;
                dist[nv] = i;
                que.push(nv);
            }
        }
    }

    ll ans = 0;
    vector<ll> check(N,0);
    rep(i,N){
        if(dist[i] == -1) ans++;
        else{
            check[dist[i]] = 1;
        }
    }
    rep(i,N) ans += check[i];
    ans--;
    cout << ans << endl;
}

Measured memory_bytes: 9596
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');
var n = lines[0];

var A1 = lines[1].split(' ');
for (var i = 0; i < n; i++) {
	for (var j = n - 1; j > i; j--) {
		if (A1[j].split('')[1] < A1[j - 1].split('')[1]) {
			var tmp = A1[j];
			A1[j] = A1[j - 1];
			A1[j - 1] = tmp;
		}
	}
}
console.log(A1.join(' '));
console.log('Stable');

var A2 = lines[1].split(' ');
for (var i = 0; i < n; i++) {
	var min = i;
	for (var j = i; j < n; j++) {
		if (A2[j].split('')[1] < A2[min].split('')[1])
			min = j;
	}

	if (min == i)
		continue;

	var tmp = A2[i];
	A2[i] = A2[min];
	A2[min] = tmp;
}  

console.log(A2.join(' '));
console.log(A1.join(' ') == A2.join(' ') ? 'Stable' : 'Not stable');

Measured memory_bytes: 8696
INFTY = 10000000000000000000000000000
n = int(raw_input())
A = {}
for i in range(n):
    A[i] = {}
    for j,c in enumerate(raw_input().strip().split(' ')):
        c = int(c)
        if c > -1: A[i][j] = c

d = {}
chosen = {}
for i in range(n):
    d[i] = INFTY
    chosen[i] = False
d[0] = 0

ans = 0
while True:
    mincost = INFTY
    u = -1
    for i in range(n):
        if (not chosen[i]) and mincost > d[i]:
            mincost = d[i]
            u = i
    if mincost == INFTY: break
    ans += mincost
    chosen[u] = True
    for i in range(n):
        if not chosen[i] and i in A[u] and A[u][i] < d[i]:
            d[i] = A[u][i]


print ans

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

int main() {
    int64_t N;
    cin >> N;
    vector<int64_t> h(N);
    for ( int64_t i = 0; i < N; ++i){
        cin >> h.at(i);
    }
    vector<int64_t> dp(N,1e+15);
    dp[0] = 0;
    for ( int64_t i = 0; i < N-1; ++i){
        dp[i+1] = min(dp[i+1],dp[i] + abs( h[i+1] - h[i] ));
        if ( i + 2 <=  N - 1) {
            dp[i+2] = min(dp[i+2],dp[i] + abs( h[i+2] - h[i] ));
        }
    }
    cout << dp[N-1] << endl;
    
    return 0;
}


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

lint n, k;
lint mod = 1e+9 + 7;

int main() {
    cin >> n >> k;
    lint ans = 0;
    for (lint i = k; i <= n + 1; i++) {
        lint m = i * (i - 1) / 2 % mod;
        lint M = i * (2 * n - i + 1) / 2 % mod;
        lint add = (M - m + 1) % mod;
        ans = (ans + add) % mod;
    }
    if (ans < 0) {
        ans = (ans + mod) % mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		sc.close();
		int left = 15- str.length();
		int win = 0;
		for(int i = 0; i < str.length(); i++) {
			if(str.charAt(i) == 'o') {
				win ++;
			}
		}
		if((win + left) <8) {
			System.out.println("NO");
		}else {
			System.out.println("YES");
		}
	}
}

Measured memory_bytes: 21844