akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
const int N = 1e5 + 10, INF = 0x3f3f3f3f ;
int main(){
    int a[N][15];
    int b[N][15];
    int temp[N];
    int n,i;
    scanf("%d",&n);
    for(i = 0;i < n;i++) {
        for(int j = 0;j < 10;j++) {
            scanf("%d",&a[i][j]);
        }
    }
    for(int i = 0;i < n;i++) {
        for(int j = 0;j <= 10;j++) {
            scanf("%d",&b[i][j]);
        }
    }
    long long int res = -INF;
    for(int i = 1;i < (1<<10);i++) {
        memset(temp,0,sizeof temp);
        for(int j = 0;j < n;j++) {
            for(int k = 0;k < 10;k++) {
                if(a[j][k] && ((1<<k)&i)) {
                    temp[j]++;
                }
            }
        }
        long long int t = 0;
        for(int j = 0;j < n;j++) {
            t += b[j][temp[j]];
        }
        if(res<t)
            res=t;
    }
    printf("%lld",res);
    return 0;
}

Measured memory_bytes: 4608
s = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

K = input()
ans = s[int(K)-1]

print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
char s[111111];
int k,n;
int main(){
	scanf("%s%d",s,&k);
	n=strlen(s);
	for(int i=0; i<n; i++)
		if(s[i] != 'a'){
			int toa = 'z' + 1 - s[i];
			if(k >= toa){
				s[i] = 'a';
				k -= toa;
			}
		}
	s[n-1] = (s[n-1] - 'a' + k) % 26 + 'a';
	puts(s);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main(){
  int n; cin >> n;
  vector<int> sosu, ans;
  int cnt = 0;
  for(int i = 2; i <= 555555; i++){
    int j;
    for(j = 0; j < sosu.size(); j++){
      if(i % sosu[j] == 0){
        break;
      }
    }
    if(j == sosu.size()){
      sosu.push_back(i);
      if(i % 5 == 1){
        ans.push_back(i);
        cnt++;
        if(cnt == n){
          break;
        }
      }
    }
  }

  rep(i, n){
    if(i == 0) cout << ans[i];
    else cout << " " << ans[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
using namespace std;

int main() {
	long long a, b, c, aa, bb, cc, checka, checkb, checkc;
	long long e = 0, ans = 0;
	cin >> a >> b >> c;
	checka = a;
	checkb = b;
	checkc = c;
	if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
		ans = -1;
	}
	while (e < 1) {
		aa = (b + c) / 2;
		bb = (a + c) / 2;
		cc = (a + b) / 2;
		++ans;
		if (aa % 2 == 1 || bb % 2 == 1 || cc % 2 == 1) {
			break;
		}
		if (checka == aa && checkb == bb && checkc == cc) {
			ans = -1;
			break;
		}
		a = aa;
		b = bb;
		c = cc;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    
    int N, Q;
    cin >> N >> Q;
    
    vector<vector<int>> Ki(N+1);
    
    rep(i,N-1){
        int a,b;
        cin >> a >> b;
        Ki[a].push_back(b);
        Ki[b].push_back(a);
        
    }
    
    vector<int> q(Q), x(Q);
    rep(i,Q) cin >> q[i] >> x[i];
    
    vector<ll> ans(N+1,0);
    rep(i,Q) ans[q[i]] += ll(x[i]);
    
    queue<int> T;
    T.push(1);
    
    vector<bool> KK(N+1,false);
    KK[1] = true;
    
    while (!T.empty()) {
        int n = T.front();
        T.pop();
        rep(i,int(Ki[n].size())){
            if(!KK[Ki[n][i]]){
                T.push(Ki[n][i]);
                ans[Ki[n][i]]+=ans[n];
                KK[Ki[n][i]] = true;
            }
            
        }
    }
   
    
    for (int i = 1; i <= N; i++) {
        cout << ans[i] << " ";
    }
    cout << endl;
    
    return 0;
}



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

void solve(int m){
    if(m==2){a[0][0]=1;a[1][0]=1;return;}
    int nn=m*(m-1)/2;
    rep(i,0,m-1){a[m-1][i]=nn-i;a[i][m-2]=nn-i;}
    solve(m-1);
    return;
}

int main()
{
    int n,k=-1;cin>>n;
    for(k=0;k<1000;k++){if(k*(k-1)/2==n) break;}
    if(k>990){printf("No\n");return 0;}
    printf("Yes\n");
    printf("%d\n",k);
    solve(k);
    rep(i,0,k){
        printf("%d ",k-1);
        rep(j,0,k-1){printf("%d",a[i][j]);printf(j==k-2?"\n":" ");}
    }
    return 0;
}


Measured memory_bytes: 3072
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        String[] ABCList = S.split("ABC",-1);

        System.out.println(ABCList.length-1);


    }

}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 998244353;

vector<int> fac(300001); //n!(mod M)
vector<int> ifac(300001); //k!^{M-2} (mod M)

long long fpow(long long a,long long n){
  long long ret=1;
  if(n==1) return a;
  if(n%2==0) {
      ret = fpow(a*a%mod, n/2) %mod ;
  }else {
      ret = (a%mod)*fpow(a*a%mod, n/2) %mod;
  }
  return ret %mod;
}
int comb(int a, int b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    int tmp = ifac[a-b]* ifac[b] % mod;
    return tmp * fac[a] % mod;
}

signed main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    rep(i, n) cin >> a[i] >>b[i] >> c[i];
    vector<int> dpa(n, inf);
    vector<int> dpb(n, inf);
    vector<int> dpc(n, inf);

    dpa[0] = a[0];
    dpb[0] = b[0];
    dpc[0] = c[0];
    for (size_t i = 1; i < n; i++)
    {
        dpa[i] = a[i]+max(dpb[i-1], dpc[i-1]);
        dpb[i] = b[i]+max(dpa[i-1], dpc[i-1]);
        dpc[i] = c[i]+max(dpa[i-1], dpb[i-1]); 
    }
    // rep(i, n) {
    //     cout << dpa[i] <<" " << dpb[i] <<" " << dpc[i] << endl;
    // }
    cout << max(dpa[n-1], max(dpb[n-1], dpc[n-1])) << endl;
    return 0;
}



Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
namespace io{
	const int l=1<<20;
	char buf[l],*s,*t;
	char gc(){
		if(s==t){
			t=(s=buf)+fread(buf,1,l,stdin);
			return s==t?EOF:*s++;
		}
		return *s++;
	}
	char c;
	template<class IT>inline void gi(IT &x){
		x=0;c=gc();while(c<'0'||c>'9')c=gc();
		while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^'0');c=gc();}
	}
};
using io::gi;
#define ll long long
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
struct qwq{
	int a,b;
	inline bool operator<(const qwq &x)const{return a<x.a;}
}x[100005];
priority_queue<int>q;
int main(){
	int n,m,i,j=1,s=0;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;++i)scanf("%d%d",&x[i].a,&x[i].b);
	sort(x+1,x+n+1);
	for(i=1;i<=m;++i){
		for(;x[j].a==i&&j<=n;++j)q.push(x[j].b);
		if(!q.empty()){s+=q.top();q.pop();}
	}
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 1660
//
//  main.cpp
//  1
//
//  Created by RISHAV SINGH MEHTA on 11/01/20.
//  Copyright © 2020 RISHAV SINGH MEHTA. All rights reserved.
//

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#define ll long long
using namespace std;
int main(int argc, const char * argv[]) {
    // insert code here...
    ll int i,j,k,T,L,M,N;
    cin>>N;string S;
    vector< pair< string, ll int> > vt;
    map< string, ll int > m;
    for (i=0; i<N; i++) {
        cin>>S>>j;
        vt.push_back({S,j});
        m[S]=i;
    }
    cin>>S;L=0;
    for (i=m[S]+1; i<N; i++) {
        L=L+ vt[i].second;
    }
    cout<<L<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;

int main(){
    int r;
    cin>>r;
    cout<< r*r;
    return 0;
}


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

Measured memory_bytes: 1160
import bisect
import collections

N=int(input())

line=collections.deque()

for _ in range(N):
    A=int(input())
    index=bisect.bisect_left(line,A)
    if index==0:
        line.appendleft(A)
    else:
        line[index-1]=A
    #print(line)
    
    #print(line)

print(len(line))


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

A.sort()
n = A[-1]

r_=n/2

a_before=''
for a in A[:-1]:
    if a >= r_:
        break
    a_before = a
    
if abs(r_-a) >= abs(r_-a_before):
    r = a_before
else:
    r = a
    
print(n,r)

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

const int SZ = 10;

long long solve(string s, int buf_s, long long sum){
  if(s.empty()){
    return 0;
  }else if(s.length() <= buf_s){
    return sum + stoll(s);
  }else {
    string head = s.substr(0,buf_s);
    string rest = s.substr(buf_s, s.length() - buf_s);
    return solve(s, buf_s+1,sum) + solve(rest,1, sum + stoll(head));
  }
}

int main(){
    
    string str(SZ,'0');
    cin >> str;
    cout << solve(str, 1, 0) << endl;
}   

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

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589

using namespace std;

int gcd(int a, int b);
int lcm(int a, int b);

void solve_A(){
    int h, a;
    cin >> h >> a;

    cout << (h + a - 1)/a;
}

void solve_B(){
    int h, n, sum = 0;
    cin >> h >> n;
    int a[n];
    REP(i,n){
        cin >> a[i];
        sum += a[i];
    }

    if(sum >= h) cout << "Yes";
    else cout << "No";

}

void solve_C(){
    
}

int main(void){
    
    solve_B();
    solve_C();
    
    return 0;
}

int gcd(int a, int b){
    if(a < b) swap(a, b);

    int r = a % b;
    while(r != 0){
        a = b;  b = r;  r = a % b;
    }
    return b;
}

int lcm(int a, int b){
    return a * b / gcd(a, b);
}

Measured memory_bytes: 640
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n; readV(n);
  int[] a; readA(n, a);

  auto ans1 = 0L, s1 = 0L;
  foreach (i; 0..n) {
    s1 += a[i];
    if (i%2 == 0) {
      if (s1 <= 0) {
        ans1 += -s1 + 1;
        s1 = 1;
      }
    } else {
      if (s1 >= 0) {
        ans1 += s1 + 1;
        s1 = -1;
      }
    }
  }

  auto ans2 = 0L, s2 = 0L;
  foreach (i; 0..n) {
    s2 += a[i];
    if (i%2 == 1) {
      if (s2 <= 0) {
        ans2 += -s2 + 1;
        s2 = 1;
      }
    } else {
      if (s2 >= 0) {
        ans2 += s2 + 1;
        s2 = -1;
      }
    }
  }

  writeln(min(ans1, ans2));
}


Measured memory_bytes: 4476
#include<stdio.h>

int main()
{
	int a,b,c,x,i;
	i=0;
	scanf("%d %d %d",&a,&b,&c);
	
	for(x=a; x<=b; x++){
		if(c%x == 0)i++;
	}
	printf("%d\n",i);
	
	return 0;
}



Measured memory_bytes: 2120
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>
 
using namespace std;
typedef long long int ll;
 
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)
 
bool isagtc(char c){
  const string agtc = "AGTC";
  bool flg = false;
  rep(i, 4) if(agtc[i] == c) flg = true;
  return flg;
}
 
int main(){
  
  string s;
  cin >> s;
  int idx = 0, cnt = 0, ans = 0;
  while(s[idx]){
    if(isagtc(s[idx])){
      cnt++;
      ans = ans < cnt ? cnt : ans;
    }else{
      cnt = 0;
    }
    idx++;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  string S;
  long long K;
  cin >> S >> K;

  char c = '1';
  for(long long i=0; i<S.size(); i++){
    if(S[i] != '1'){
      c = S[i];
      break;
    }
    if(K-1 == i && S[i] == '1'){
      break;
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int arr[105];

int main() {
    int n;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        scanf("%d", &arr[i]);
    }
    int cnt = 0;
    for(int i = 1; i < n; i++) {
        if(arr[i] == arr[i - 1]) {
            cnt++;
            arr[i] = 20005;
        }
    }
    printf("%d", cnt);
}


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

int main(){
	int n;
	string s,ss;
	map<string, bool>T;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s>>ss;
		if(s[0]=='i')
		T[ss]=1;
		else {
			if(T[ss])
			cout<<"yes"<<endl;
			else cout<<"no"<<endl;
		}
	}
	return 0;
}



Measured memory_bytes: 52556
#include<iostream>
using namespace std;
int main()
{
	int x;
	cin>>x;
	string s;
	string s1;
	cin>>s;
	cin>>s1;
	int fin=2*x;
	int j=0;
	int k=0;
	for(int i=0;i<fin;i++)
	{
		if(i%2==0)
		{
			cout<<s[j];
			j++;
		}
		else{
			cout<<s1[k];
			k++;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int main() {
  int H,W; cin >> H >> W;
  vector<string> A(H);
  for (int i = 0; i < H; i++) cin >> A[i];
  
  Graph B(H, vector<int>(W,-1)); 
  
  const vector<int> dy = {-1,0,0,1};
  const vector<int> dx = {0,-1,1,0};
  
  queue <pair<int, int>> que;
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (A[i][j] == '#') {
        B[i][j] = 0;
        que.push(make_pair(i,j));
      }
    }
  }
  int ans = 0;
  while (!que.empty()) {
    for (int i = 0; i < 4; i++) {
      int y = que.front().first + dy[i];
      int x = que.front().second + dx[i];
      if (y < 0 || y >= H || x < 0 || x >= W) continue;
      if (B[y][x] != -1) continue;
      ans = B[y][x] = B[que.front().first][que.front().second] + 1;
      que.push(make_pair(y,x));
    }
    que.pop();
  }
  
  cout << ans << endl; 
}

Measured memory_bytes: 13456
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    public const long mod = 1000000007;

    static void Main(string[] args)
    {
        // 入力
        var n = long.Parse(Console.ReadLine());
        long ans = 1;
        var dic = new Dictionary<long, long>() { };
        for (long i = 0; i < n - 1; i++)
        {
            long[] f = PrimeFactors(n - i).ToArray();

            for (int k = 0; k < f.Length; k++)
            {
                if (!dic.ContainsKey(f[k]))
                {
                    dic.Add(f[k], 1);
                }
                else
                {
                    dic[f[k]]++;
                }
            }
        }

        foreach (var item in dic)
        {
            ans *= (item.Value + 1);
            ans %= mod;
        }

        ans = ans % mod;

        // 出力
        Console.WriteLine(ans);
    }

    //素因数分解
    public static IEnumerable<long> PrimeFactors(long n)
    {
        long i = 2;
        long tmp = n;

        while (i * i <= n) //※1
        {
            if (tmp % i == 0)
            {
                tmp /= i;
                yield return i;
            }
            else
            {
                i++;
            }
        }
        if (tmp != 1) yield return tmp;//最後の素数も返す
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define SZ(x) ((int) (x).size())
using namespace std;

typedef long long i64;

const int MOD = (int) 1e9 + 7;

int main() {
    #ifdef LOCAL_RUN
    freopen("task.in", "r", stdin);
    freopen("task.out", "w", stdout);
    //freopen("task.err", "w", stderr);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, m;
    cin >> n >> m;

    int64_t sum1 = 0, totalSum1 = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        totalSum1 += (int64_t) i * x - sum1;
        sum1 += x;
        totalSum1 %= MOD;
        sum1 %= MOD;
    }

    int64_t sum2 = 0, totalSum2 = 0;
    for (int i = 0; i < m; ++i) {
        int x;
        cin >> x;
        totalSum2 += (int64_t) i * x - sum2;
        sum2 += x;
        totalSum2 %= MOD;
        sum1 %= MOD;
    }
    int64_t ans = totalSum1 * totalSum2 % MOD;

    ans %= MOD;
    if (ans < 0) {
        ans += MOD;
    }
    cout << ans << '\n';
}


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

int main() {
  char c;
  cin >> c;
  
  if(c=='a' || c=='i' || c=='u' || c=='e' || c=='o'){
    cout << "vowel" <<endl;
  }
  else{
    cout << "consonant" <<endl;
  }
}


Measured memory_bytes: 256
var a,b,c,d,e,f:longint;
    max:double;
    ansx,ansy,x:longint;
    i,j,k,q:longint;
    sugar:longint;
begin
  read(a,b,c,d,e,f);
  a:=a*100;
  b:=b*100;
  for i:=0 to f div a do
    for j:=0 to (f-a*i) div b do
    if (i+j>0)and(a*i+b*j<f) then
    begin
      x:=a*i+b*j;
      if ((f-x))/f<max then continue;
      for k:=0 to (f-x) div c do
        for q:=0 to (f-x-c*k) div d do
        if (x+k*c+q*d<=f)and((i*a div 100+j*b div 100)*e>=k*c+q*d) then
        begin
          sugar:=k*c+q*d;
          if (sugar)/(x+sugar)>max then
          begin
            max:=(sugar)/(x+sugar);
            ansx:=x;
            ansy:=sugar;
          end;
        end;
    end;
  if ansx+ansy=0 then writeln(a,' ',0) else writeln(ansx+ansy,' ',ansy);
end.

Measured memory_bytes: 128
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long LL;

LL solve(LL a, LL b, LL n) {
	LL x = min(n, b - 1);
	LL p = (a * x) / b;
	LL q = a * (x / b);
	return p - q;
}

int main(int argc, char* argv[]) {
#ifdef _MSC_VER
	while (true)
#endif
	{
		LL a = -1, b, n;
		cin >> a >> b >> n;
		if (a < 0) return 0;
		LL ans = solve(a, b, n);
		cout << ans << endl;
	}
	return 0;
}


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

const int N = 3000;
const int moder = 1e9 + 7;

int power_mod(int a, int index){
	int ans = 1;
	while (index){
		if (index & 1)
			ans = 1ll * ans * a % moder;
		a = 1ll * a * a % moder;
		index >>= 1;
	}
	return ans;
}

std::vector <int> fact;
int num[N];

int main(){
	int n, k;
	scanf("%d%d", &n, &k);
	int cnt = 0;
	for (int i = 1; i * i <= n; ++ i){
		if (!(n % i)){
			fact.push_back(i);
			fact.push_back(n / i);
		}
	}
	sort(fact.begin(), fact.end());
	fact.erase(unique(fact.begin(), fact.end()), fact.end());
	int ans = 0;
	for (int i = 0; i < fact.size(); ++ i){
		num[i] = power_mod(k, (fact[i] + 1) / 2);
		for (int j = 0; j < i; ++ j){
			if (!(fact[i] % fact[j])){
				num[i] = (num[i] - num[j] + moder) % moder;
			}
		}
		if (fact[i] & 1){
			ans = (ans + 1ll * num[i] * fact[i]) % moder;
		}
		else{
			ans = (ans + 1ll * num[i] * fact[i] % moder * power_mod(2, moder - 2)) % moder;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {	
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int p[]=new int[n];
		int cnt=0;	
		for(int i=0;i<n;i++) {p[i]=sc.nextInt();}
		for(int i=0;i<n-2;i++) {
			int a=p[i];
			int b=p[i+1];
			int c=p[i+2];
			int mid = -9999;
			if(a > b && a < c || a > c && a < b || a == b || a == c )
			mid = a;
			else if(b > a && b < c || b > c && b < a || b == a || b == c )
			mid = b;
			else
			mid =c ;
			if(b==mid)cnt++;
		}
		System.out.println(cnt);
	}
}

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

#define rep(i, n)	for(int i = 0; i < (int)(n); i++)

string Sd;
string T;
vector<string> cases;

int main() {
	cin >> Sd >> T;

	const int length = Sd.length();


	// Tが収まるかチェック
	for (int i = 0; i < length; i++) {
		// ?か最初の文字が来た
		if ((Sd[i] == '?' || Sd[i] == T[0])) {
			// バッファカウント開始
			bool flag = true;
			string s = Sd;
			s[i] = T[0];

			for (int j = 1; j < T.length(); j++) {
				if (s[i + j] != T[j] && s[i + j] != '?') {
					flag = false;
					break;
				}

				s[i + j] = T[j];
			}

			if (flag) cases.push_back(s);

		}

	}

	if (cases.empty()) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}

	// 辞書順で最小を求める
	for (auto& str : cases) {
		for (int i = 0; i < length; i++) {
			// ?を見つける
			if (str[i] == '?') {
				str[i] = 'a';
			}
		}
	}

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

	cout << cases[0] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
        int n,m,k;
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<=n;++i){
		for(int j=0;j<=m;++j){
			if((n-i)*j+(m-j)*i==k)
			{
				printf("Yes");
				return 0;
			}
                }
        }
	printf("No");
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
int main()
{
	int a,b;
	char s[1000];
	scanf("%d %d",&a,&b);
	scanf("%s",s);
	int len=strlen(s);
	if(len==a+b+1)
	{
		if(s[a]=='-')
		{
			int flag=0;
			for(int i=0;i<a;i++)
			{
				if(s[i]>='0'&&s[i]<='9')
				flag=0;
				else
				{
					flag=1;
					break;
				}
			}
			if(flag==0)
			{
				for(int i=a+1;i<len;i++)
				{
					if(s[i]>='0'&&s[i]<='9')
					flag=0;
					else
					{
						flag=1;
						break;
					}
				}
				if(flag==0)
				printf("Yes\n");
				else
				printf("No\n");
			}
			else
			printf("No\n");
		}
		else
		printf("No\n");
	}
	else
	printf("No\n");
}

Measured memory_bytes: 128
M, D = map(int, input().split())

count = 0
for m in range(1, M+1):
    for d in range(1, D+1):
        d10, d1 = divmod(d, 10)
        if d10 < 2 or d1 < 2:
            continue
        if d1 * d10 == m:
            count += 1

print(count)

Measured memory_bytes: 39280
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
using namespace std; //std::の省略のため
using ll = long long;

ll MOD = 1000000007;

int main()
{
    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    ll ans = LLONG_MAX, tmp = 0;
    ll tmp_x, tmp_y;

    ll m = max(x, y);
    m *= 2;

    for (ll i = 0; i <= m; i += 2)
    {
        tmp_x = x - i / 2;
        tmp_y = y - i / 2;
        if (tmp_x < 0)
            tmp_x = 0;

        if (tmp_y < 0)
            tmp_y = 0;

        tmp = a * tmp_x + b * tmp_y + c * i;

        if (ans > tmp)
        {
            ans = tmp;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3536
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fcking interest
*******************************
I'm standing on top of my Monopoly board
That means I'm on top of my game and it don't stop
til my hip don't hop anymore
https://www.a2oj.com/Ladder16.html
*******************************
Shining through the city with a little funk and soul
*******************************
300iq as writer = Sad!
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String hi[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int A = Integer.parseInt(st.nextToken());
         int[] arr = new int[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         Arrays.sort(arr);
         long res = 0L;
         for(int choose=1; choose <= N; choose++)
         {
            long[][] dp = new long[A*choose+1][choose+1];
            dp[0][0] = 1L;
            for(int v: arr)
               for(int i=A*choose; i >= 0; i--)
                  for(int k=choose; k > 0; k--)
                     if(i-v >= 0)
                        dp[i][k] += dp[i-v][k-1];
            res += dp[dp.length-1][choose];
         }
         System.out.println(res);
      }
   }

Measured memory_bytes: 50144
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
int sum(int n){
    int res=0;
    while(n>0){
        res+=n%10;
        n/=10;
    }
    return res;
}
signed main() {
    int m,f,b;cin>>m>>f>>b;
    if(m+f<b)cout<<"NA"<<endl;
    else cout<<max((int)0,b-m)<<endl;
}



Measured memory_bytes: 3096
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <math.h>
#include <queue>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())

const int MOD = 1000000007;
const int INF = INT_MAX;


// a,bの最小公倍数
ll lcm(ll a, ll b){ll lcm = a * b; ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return lcm /= b;}
// a,bの最大公約数
ll gcd(ll a, ll b){ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return b;}
// MOD
ll modadd(ll a, ll b){return (a%MOD+b%MOD+MOD)%MOD;}
ll modmul(ll a, ll b){return a%MOD*b%MOD%MOD;}
ll modexp(ll a, ll n){if(n==0)return 1; if(n%2==0){ll e=modexp(a,n/2); return modmul(e,e);} return modexp(a,n-1)*a%MOD;}
ll modinv(ll n){return modexp(n%MOD,MOD-2);}
ll modfact(ll n){ll res=1; for (int i=1; i <= n; ++i){res *= i; res %= MOD;} return res;}
ll modncr(ll n, ll r){ll numer=1;ll denom=1;for(int i=1;i<=r;++i){numer=modmul(numer,n-r+i);denom=modmul(denom,i);}return modmul(numer, modinv(denom));}


int main(){

    int a, b, c;
    cin >> a >> b >> c;
    int k;
    cin >> k;

    int mx = max({a, b, c});
    int sum = a + b + c;

    cout << sum - mx + pow(2, k) * mx << endl;





}



//              g++ -std=c++1z


Measured memory_bytes: 760
N, K = list(map(int, input().split()))
D = [None] * K
A = []
for i in range(K):
    D[i] = int(input())
    A.append(list(map(int, input().split())))

s = set()
for i in range(K):
    for d in range(D[i]):
        s.add(A[i][d])
ans = N - len(s)
print(ans)

Measured memory_bytes: 9204
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

int main(){
  int N;
  cin >> N;
  
  vector<int> X(N);
  int l,i=0;
  while(cin >> l) {
    X[i] = l;
    i++;
  }
  
  // brute force
  int power_sum_min = 1e10;
  for(int P=1; P<=100; P++) {
    int power_sum = 0;
    for(x : X) {
      power_sum += (x-P)*(x-P);
    }
    if(power_sum < power_sum_min) {
      power_sum_min = power_sum;
    }
  }
  
  cout << power_sum_min;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        String s = scanner.next();
        if(N >= 3200){
            System.out.println(s);
        }else{
            System.out.println("red");
        }
    }
}


Measured memory_bytes: 23636
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int init[] = { 1, 2, 3, 4, 5, 6 };
const int move[][4] = {
							{ 0, 1, 5, 4 }, 	// north
							{ 0, 3, 5, 2 }, 	// east
							{ 0, 2, 5, 3 },	// west
							{ 0, 4, 5, 1 },	// south
							{ 4, 3, 1, 2 },	// right
							{ 4, 2, 1, 3 }		// left
						};
const string words[] = { "North", "East", "West", "South", "Right", "Left" };
int d[6];

void moving (int m )
{
	int temp = d[move[m][0]];
	rep (i, 3 ){
		d[move[m][i]] = d[move[m][i+1]];
	} // end rep
	d[move[m][3]] = temp;
} 

int main()
{
//	cut here before submit 
//	freopen ("testcase.dice", "r", stdin );
	int n;
	while (scanf ("%d", &n ), n ){
		memset (d, 0, sizeof (d ) );
		rep (i, 6 ) d[i] = init[i];
		int res = d[0];
		rep (i, n ){
			string w = "";
			cin >> w;
			int turn = -1;
			rep (j, 6 ){
				if (w == words[j] ){
					turn = j;
					break;
				} // end if
			} // end rep
			moving (turn );
			res += d[0];
		} // end rep
		printf ("%d\n", res );
	} // end loop
	
	return 0;
}

Measured memory_bytes: 1248
import sys
N,M = map(int,input().split())
sc = [list(map(int,input().split())) for i in range(M)]

ans = ['-1'] * N

for i in range(M):
    if ans[sc[i][0]-1] == sc[i][1]:
        continue
    elif ans[sc[i][0]-1] == '-1':
        ans[sc[i][0]-1] = sc[i][1]
    else:
        print('-1')
        sys.exit()

if N >= 2:
    if ans[0] == '-1':
        ans[0] = 1
    elif ans[0] == 0:
        print('-1')
        sys.exit()
else:
    if ans[0] == '-1':
        print(0)
        sys.exit()

for i in range(N):
    if ans[i] == '-1':
        ans[i] = 0

real = 0
for i in ans:
    real = real * 10 + i

print(real)

Measured memory_bytes: 3064
n = int(input())
a = list(map(int,input().split()))
ans = 0
issame = False
for i in range(n):
    if a[i] == i+1:
        if not issame:
            issame = True
            ans += 1
        else:
            issame = False
    else:
        issame = False
print(ans)

Measured memory_bytes: 14008
import java.awt.geom.Point2D;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;


public class Main {
	private	static	BufferedReader	br  = null;
	private	static	double			DIF = 1e-6;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}
 
    /**
     * @param args
     */
	public static void main(String[] args) {
	// TODO Auto-generated method stub
		Point2D.Double[]			seal  = null;								// シールの座標
		ArrayList<Point2D.Double>	cross = new ArrayList<Point2D.Double>();	// シール同士の交点

		while ((seal = parseSealNum()) != null) {
			int	maxlap = 1;	// シールの重なっている最大枚数

			cross.clear();

			// シールの座標を取得
			for (int loop1 = 0; loop1 < seal.length; loop1++) {
				seal[loop1] = parseSealPoint();
			}

			// シール同士の交点の座標を取得
			for (int loop1 = 0; loop1 < seal.length; loop1++) {
				for (int loop2 = loop1 + 1; loop2 < seal.length; loop2++) {
					Point2D.Double[]	tmp = getCross(seal[loop1], seal[loop2]);
					if (tmp != null) {
						for (int loop3 = 0; loop3 < tmp.length; loop3++) {
							cross.add(tmp[loop3]);
						}
					}
				}
			}

			// シールの重なっている最大枚数を計算する
			for (int loop1 = 0; loop1 < cross.size(); loop1++) {
				Point2D.Double	tmp = cross.get(loop1);
				int				lap = 0;

				for (int loop2 = 0; loop2 < seal.length; loop2++) {
					if (tmp.distance(seal[loop2]) <= 1.0 + DIF) {
						lap++;
					}
				}

				maxlap = Math.max(maxlap, lap);
			}

			System.out.println(maxlap);
		}
	}
 
	private static Point2D.Double[] getCross(Point2D.Double p1, Point2D.Double p2) {
		Point2D.Double[]	cRet = null;

		if (p1 != null && p2 != null) {
			double	length = p1.distance(p2);
			if (length <= DIF) {
				// 二つの円がほぼ同じ位置にある
				cRet    = new Point2D.Double[1];
				cRet[0] = new Point2D.Double(p1.x, p1.y);
			} else if (length <= 2.0 + DIF) {
				// 二つの円が重なっているかもしれない
				double	theta = Math.atan2(p2.y - p1.y, p2.x - p1.x);
				double	alpha = Math.acos(length / 2.0);

				cRet    = new Point2D.Double[2];
				cRet[0] = new Point2D.Double(p1.x + Math.cos(theta + alpha), p1.y + Math.sin(theta + alpha));
				cRet[1] = new Point2D.Double(p1.x + Math.cos(theta - alpha), p1.y + Math.sin(theta - alpha));
			}
		}

		return cRet;
	}
 
	private static Point2D.Double[] parseSealNum() {
		Point2D.Double[]	params = null;
        String				strin  = null;

        if ((strin = parseStdin()) != null) {
        	int	sealnum = Integer.parseInt(strin);
        	if (sealnum > 0) {
            	params = new Point2D.Double[sealnum];
        	}
        }
 
        return params;
	}

	private static Point2D.Double parseSealPoint() {
		Point2D.Double	params = null;
        String			strin  = null;

        if ((strin = parseStdin()) != null) {
        	String[]	lines = strin.split(",");
       		params = new Point2D.Double (Double.parseDouble(lines[0]), Double.parseDouble(lines[1]));
        }
 
        return params;
	}

	private static String parseStdin() {
        String  stdin = null;
        
        try {
        	String  tmp = br.readLine();
        	if (!tmp.isEmpty()) stdin = tmp;
        }
        catch (IOException e) {}
 
        return stdin;
	}
}

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

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

    ll x,y;
    cin >> x >> y;
    
    ll now = x;
    int count = 0;
    
    while(now <= y){
        now *= 2;
        count++;
    }
    
    cout << count << endl;

    return 0;
}

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

int main(){
	int N; cin>>N;
	vector<int> A(N+1, 0);
	rep(i, N) cin>>A[i];
	vector<int64_t> dp(N+1, 1000);
	rep(d, N)
		dp[d+1] = max(dp[d], dp[d] + dp[d]/A[d] * (A[d+1] - A[d]));
	cout<< dp[N] <<endl;
}


Measured memory_bytes: 3504
#!/usr/bin/env python3
import sys
#sys.setrecursionlimit(150000)


def solve(N: int, X: "List[int]"):
    st=min(X)
    end=max(X)
    costmin=1000000
    for p in range(st,end+1):
        cost=0
        for i in range(N):
            cost+=(p-X[i])**2
        if cost<costmin: costmin=cost
    print(costmin)
    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()
    N = int(next(tokens))  # type: int
    X = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
a,b,c,d=map(int,input().split())
if a*c>a*d:
  a1=a*c
else:
  a1=a*d
if b*c>b*d:
  a2=b*c
else:
  a2=b*d
if a1>a2:
  print(a1)
else:
  print(a2)

Measured memory_bytes: 9076
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void) {
	int n, k, q;
	cin >> n >> k >> q;
	vector<int> ans(n,k-q);
	rep(i, 0, q) {
		int a;
		cin >> a;
		ans[a-1]++;
	}
	rep(i, 0, n) {
		if (ans[i]>0)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>
main(){
  int i,j,n,code;
  char cm[7],o,dict[262145];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",cm);
    j=code=o=0;
    while(o!='\n'){
      scanf("%c",&o);
      if(o=='A') code+=1*pow(4,j);
      else if(o=='C') code+=2*pow(4,j);
      else if(o=='G') code+=3*pow(4,j);
      else if(o=='T') code+=4*pow(4,j);
      else j--;
      j++;
    }
    if(cm[0]=='i') dict[code] = 1;
    if(cm[0]=='f') dict[code] ? printf("yes\n") : printf("no\n");
  }
  return 0;
}

Measured memory_bytes: 496
#include <cstdio>

using namespace std;

int gcdr(int a, int b){
    if(b==0)  return a;
    return gcdr(b, a%b);
}

int main(){
    int a, b,gcd;
    long int lcm;
    while(scanf("%d%d",&a,&b)!=EOF){
        gcd = gcdr(a,b);
        //printf("%d\n",gcd);
        lcm = (long)a * b / gcd;
        printf("%d %ld\n",gcd,lcm);
    }
    
    return 0;
}


Measured memory_bytes: 2580
#include<iostream>
#include<cstdlib>
#include<stack>
#include<queue>
#include<string>
#include<algorithm>
using namespace std;

int main(){
    int n,a;
    cin>>n>>a;
    int q=n%500;
    if(a<q)cout<<"No";
    else cout<<"Yes";
    

    return 0;
}

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

int main()
{
  int n = 6;
  int dat[ n ];
  for( int i = 0; i < n; i++ ) {
    cin >> dat[ i ];
  }

  int tbl[][7] = {
    { 4, 2, 3, 5, 4, 0 },
    { 1, 4, 6, 3, 1, 0 },
    { 1, 2, 6, 5, 1, 0 },
    { 1, 5, 6, 2, 1, 0 },
    { 1, 3, 6, 4, 1, 0 },
    { 5, 3, 2, 4, 5, 0 }
  };

  int tblx = sizeof( tbl ) / sizeof( tbl[ 0 ] );
  int tbly = sizeof( tbl[ 0 ] ) / sizeof( tbl[ 0 ][ 0 ] );

  for( int i = 0; i < tblx; i++ ) {
    for( int j = 0; j < tbly; j++ ) {
      if( j == tbly - 1 ) {
        continue;
      }
      tbl[ i ][ j ] = dat[ tbl[ i ][ j ] - 1 ];
    }
  }

  int q, a, b, right;
  cin >> q;
  for( int i = 0; i < q; i++ ) {
    cin >> a >> b;
    for( int j = 0; j < tblx; j++ ) {
      for( int k = 0; k < tbly; k++ ) {
        if( tbl[ j ][ k ] == a and tbl[ j ][ k + 1 ] == b ) {

          if( false ) {
            for( int l = 0; l < tbly; l++ ) {
              cout << tbl[j][ l ] << ",";
            }
            cout << ":" << a << "/" << b << "/";
          }
          cout << dat[ j ] << endl;
        }
      }
    }
  }
  return 0;
}

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

int main()
{
  	char a;
  	cin>>a;
  	if(a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
      cout<<"vowel\n";
  	else
      cout<<"consonant\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
#define mod 1000000007
#define pi 3.1415926535
typedef long long ll;

int main(){
    int A,B,C;
    cin>>A>>B>>C;
    int ma=max({A,B,C});
    int mi=min({A,B,C});
    if((ma==B&&mi==A)||(mi==B&&ma==A)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
//typedef __int64 LL;
typedef pair<int,int> P;
const int INF=1000000000;
const int MOD_2=998244353;

int l[200010],r[200010];

int main()
{
	int n,k,c;
	int count=0;
	string s;
	cin>>n>>k>>c>>s;
	
	fill(l,l+k,INF);
	fill(r,r+k,INF);
	
	for(int i=0;i<n;i++)
	{
		if(s[i]=='x')continue;
		else
		{
			l[count]=i;
			count++;
			i+=c;
		}
		if(count>=k)break;
	}
	
	count=k-1;
	
	for(int i=n-1;i>=0;i--)
	{
		if(s[i]=='x')continue;
		else
		{
			r[count]=i;
			count--;
			i-=c;
		}
		if(count<0)break;
	}
	
	if(l[k-1]!=INF)
	{
		for(int i=0;i<k;i++)
		{
			if(l[i]==r[i])cout<<l[i]+1<<"\n";
		}
	}
	return 0;
}
	

Measured memory_bytes: 3332
import copy
N=int(input())
t=list(map(int,input().split()))
v=list(map(int,input().split()))

L=[0]
for i in range(N):
    a=[v[i] for j in range(t[i]*2)]
    #print(a)
    L+=a
X=[]
for i in range(1,len(L)):
    if L[i-1]>L[i]:
        X.append(i)
for i in X:
    L[i-1]=L[i]
L[-1]=0

S=copy.deepcopy(L)
#E=copy.deepcopy(L)
#print(L)
for i in range(1,len(L)):
    if L[i-1]<L[i]:
        for j in range(10**5):
            if S[i-1]+0.5*j>400 or (i-1+j)>(len(L)-1):
                break
            else:
                S[i-1+j]=min(S[i-1]+0.5*j,S[i-1+j])
    elif L[i-1]>L[i]:
        for j in range(10**5):
            if S[i]+0.5*j>400 or i<j:
                break
            else:
                S[i-j]=min(S[i]+0.5*j,S[i-j])
#print(S)
ans=0
for i in range(1,len(S)):
    ans+=(S[i-1]+S[i])/2
print(ans/2)

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

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 1 << 19;
int N, C;
LL S[MAX];

int main(void) {
    cin >> N;
    C = 1 << N;
    REP(i, C) cin >> S[i];

    sort(S, S + (1 << N));
    reverse(S, S + (1 << N));

    map<LL, int> cnt;
    FOR(i, 1, C) {
        cnt[S[i]]++;
    }

    queue<LL> que;
    que.emplace(S[0]);
    REP(i, N) {
        VL tmp;
        while (!que.empty()) {
            const auto cur = que.front();
            que.pop();
            auto itr = cnt.lower_bound(cur);
            if (itr == begin(cnt)) {
                cout << "No" << endl;
                return 0;
            }
            itr = prev(itr);
            const auto val = itr->first;
            if (--itr->second == 0) {
                cnt.erase(itr);
            }
            tmp.EB(cur);
            tmp.EB(val);
        }
        RSORT(tmp);
        FORE(e, tmp) que.emplace(e);
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 22784
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

string str[] = { "0111111","0000110","1011011","1001111","1100110",
				"1101101","1111101", "0100111","1111111", "1101111" };

int main()
{
	int n;
	while (1) 
	{
		string s = "";
		cin >> n;
		if (n == -1)break;

		rep(i, n) {
			int num; cin >> num;
			if (i == 0) 
				cout << str[num] << endl;
			else {
				string tmp = "";
				rep(i, 7) {
					if (str[num][i] != s[i])
						tmp += "1";
					else
						tmp += "0";
				}
				cout << tmp << endl;
			}
			s = str[num];
		}
	}
	return 0;
}

Measured memory_bytes: 3124
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int a[505][505];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, q;
    cin >> n >> m >> q;
    rep(i,m){
        int l, r;
        cin >> l >> r;
        l--,r--;
        a[l][r]++;
    }
    rep(i,n)rep(j,n)a[i+1][j] += a[i][j];
    rep(i,n)rep(j,n)a[i][j+1] += a[i][j];
    while(q--){
        int c, d;
        cin >> c >> d;
        c--,d--;
        int ans = 0;
        ans = a[d][d];
        if(c)ans -= a[c-1][d], ans -= a[d][c-1],ans+=a[c-1][c-1];
        cout << ans << "\n";
    }
}

Measured memory_bytes: 1920
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using vi = vector<int>;
using vii = vector<vi>;
using ip = pair<int,int>;
using lp = pair<ll,ll>;

const ll linf = 1LL << 62;
const int inf = 999999;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll atcoder = int(1e9 + 7);

#define Endl endl
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define all(x) x.begin(),x.end()
#define atcoder(int)1e9+7
#define rep(i,n) for(int i = 0;i<n;i++)
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)


ll gcd(ll a, ll b) {//最大公約数
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	return (a / gcd(a, b))*b;
}

int sum(ll a) {
	if (a < 10)return a;
	return sum(a / 10) + a % 10;
}

ll dp[60][60][3000] = { 0 };

int main() {

	int n, a, x[110] = { 0 };

	cin >> n >> a;
	rep(i, n)cin >> x[i];

	dp[0][0][0] = 1;

	rep(i, n) {
		rep(j, i + 1) {
			rep(k, 2510) {
				dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
				dp[i + 1][j][k] += dp[i][j][k];
			}
		}
	}

	ll ans = 0;
	rep(i, n+1) if(i>0)ans += dp[n][i][i*a];
	
	pr(ans);

	return 0;
}

Measured memory_bytes: 69888
#include <bits/stdc++.h>
using namespace std;
const int N = 101;
const int W = 100001;
long long v[N];
int wt[N];
int n, t;
long long dp[N][W];
long long calc(int idx, int left) {
	if (left == 0)
		return 0;
	if (left < 0)
		return -1e18;
	if (idx >= n)
		return 0;
	long long &ret = dp[idx][left];
	if (ret != -1)
		return ret;
	ret = max(calc(idx + 1, left - wt[idx]) + v[idx], calc(idx + 1, left));
	return ret;
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> t;
	for (int i = 0; i < n; ++i)
		cin >> wt[i] >> v[i];
	for (int i = 0; i < N; ++i)
		for (int j = 0; j < W; ++j)
			dp[i][j] = -1;
	cout << calc(0, t) << endl;
	return 0;
}

Measured memory_bytes: 79232