akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

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

  rep(i, 3){
    if(N[i] == '7'){
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
  
  return 0;
}


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int WWW = 0;WWW < (n);WWW++)cerr << v[WWW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007

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

vector<pair<int,int>> edge;
vector<vector<int>> v(111111);
vector<vector<int>> vv(111111);
vector<bool> erase(111111);
vector<int> score(111111);
int n;

pair<int,int> dfs(int saisyo){
	queue<pair<pair<int,int>,int>> q;
	q.push(MP(MP(saisyo,-1),0));
	int ret = -1;
	int cou = 0;
	while(!q.empty()){
		auto now = q.front();q.pop();
		int node = now.FI.FI;
		int prev = now.FI.SE;
		int cost = now.SE;
		REP(i,v[node].size()){
			if(v[node][i] == prev)continue;
			int seica = cost + score[v[node][i]] + 1;
			if(cou <= seica){
				cou = seica;
				ret = v[node][i];
			}
			q.push(MP(MP(v[node][i],node),seica));
		}
	}
	
	return MP(ret,cou);
}

int f(){
	pair<int,int> hazi;
	REP(i,n){
		if(!erase[i]){
			DBG(cout << "HOGE" << endl;);
			hazi = dfs(i);
			break;
		}
	}
	if(hazi.FI == -1){
		return 0;
	}
	DBG(cout << "THREE" << endl;);
	return dfs(hazi.FI).SE;
}

int main(){
	
	ll ans = 0;
	cin >> n;
	REP(i,n-1){
		int a,b;cin >> a >> b;
		a--;b--;
		edge.PB(MP(a,b));
		vv[a].PB(b);
		vv[b].PB(a);
	}
	
	string str;
	cin >> str;
	
	queue<int> q;
	REP(i,n)if(str[i] == 'B' && vv[i].size() == 1)q.push(i);
	int flag = 0;
	REP(i,n)if(str[i] == 'W')flag++;
	if(flag == 0){
		cout << 0 << endl;
		return 0;
	}
	else if(flag == 1){
		cout << 1 << endl;
		return 0;
	}
	
	while(!q.empty()){
		int now = q.front();q.pop();
		if(str[now] != 'B')continue;
		int cou = 0;
		int seica;
		REP(i,vv[now].size()){
			if(!erase[vv[now][i]]){
				cou++;
				seica = vv[now][i];
				if(cou > 1)break;
			}
		}
		if(cou <= 1){
			erase[now] = true;
			if(cou == 1)q.push(seica);
		}
	}
	DBG(cout << "ONE" << endl;);
	REP(i,n-1){
		int a = edge[i].FI;
		int b = edge[i].SE;
		if(!erase[a] && !erase[b]){
			DBG(cout << "NEW EDGE " << a << ' ' << b << endl;);
			v[a].PB(b);
			v[b].PB(a);
			ans += 2;
		}
	}
	DBG(cout << "ANS1 " << ans << endl;);
	DBG(SHOW1d(erase,n););
	REP(i,n){
		int tmp = 0;
		tmp += (str[i] == 'W');
		tmp += (v[i].size() % 2 == 1);
		if(tmp == 1){
			DBG(cout << 1 ;);
			ans += 1;
			score[i] = 1;
		}
		else{
			DBG(cout << 0;);
			score[i] = -1;
		}
	}
	DBG(cout << endl;);
	DBG(cout << "TWO" << endl;);
	DBG(cout << "ANS2 " << ans << endl;);
	cout << ans - f() << endl;
	
	return 0;
}


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

using namespace std;



int main(){

	int N,M,r;
	while(cin >> N >> M && !(N == 0 && M == 0)){
		// Ô
		vector<pair<int,int> > Gakusei[10001];
		cin >> r;
		pair<int,int> pc[1001];
		for(int i = 0; i < r; i++){
			int t;
			int n;
			int m;
			int s;
			cin >> t >> n >> m >> s;
			if(s == 1){
				pc[n].first = t;
			}
			else{
				pc[n].second = t;
				Gakusei[m].push_back(pc[n]);
			}
		}

		int q;
		cin >> q;
		for(int i = 0; i < q; i++){
			int cnt = 0;
			int ts,te,m;
			cin >> ts >> te >> m;
			sort(Gakusei[m].begin(),Gakusei[m].end());
			int cTime = ts;
			for(int j = 0; j < Gakusei[m].size(); j++){
				// æÃ~ÉJnÔª¢©ç©Ä¢­
				if(cTime >= Gakusei[m][j].second || Gakusei[m][j].first >= te)
					continue;
				else{
					cnt += (min(te,Gakusei[m][j].second) - max(cTime,Gakusei[m][j].first));
					cTime = min(te,Gakusei[m][j].second);
				}
			}
			cout << cnt << endl;
		}

	}
	return 0;
}

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

int main(){

	int n;
	cin >> n;

	int ans=0;
	int sum; 
	for(int a=1;a<=n;a++){
		sum=n/a;
		if(a*sum==n)sum--;
		ans+=sum;
	}

	cout << ans << endl;

}


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

using namespace std;

int dp[100009][3];

int main() {
  int n;
  cin >> n;
  int daysForEach[n][3];

  for (int i = 0; i < n; i++)
    cin >> daysForEach[i][0] >> daysForEach[i][1] >> daysForEach[i][2];

  dp[0][0] = daysForEach[0][0];
  dp[0][1] = daysForEach[0][1];
  dp[0][2] = daysForEach[0][2];

  for (int i = 1; i < n; i++) {
    dp[i][0] = max(dp[i-1][1] + daysForEach[i][0], dp[i-1][2] + daysForEach[i][0]);
    dp[i][1] = max(dp[i-1][0] + daysForEach[i][1], dp[i-1][2] + daysForEach[i][1]);
    dp[i][2] = max(dp[i-1][0] + daysForEach[i][2], dp[i-1][1] + daysForEach[i][2]);
  }

  cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << endl;
}


Measured memory_bytes: 2560
N = int(input())
H = list(map(int, input().split()))

def lower(n):
  flag = 0
  for i in range(n, N-1):
    if H[i] >= H[i+1]:
      flag += 1
    else :
      break
      
  return flag
ma = 0
i = 0
while i < N:
  hoge = lower(i)
  if hoge > ma:
    ma = hoge
  i += hoge+1
print(ma)

Measured memory_bytes: 14224
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int D = sc.nextInt();
        System.out.println(N % ((2 * D) + 1) == 0 ? N / ((2 * D) + 1) : N / ((2 * D) + 1) + 1);
    }
}


Measured memory_bytes: 22228
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()

    red = S.count('0')
    blue = len(S) - red

    print(min(red, blue) * 2)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9224
#include <iostream>
#include <string>
#define ll long long
using namespace std;
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	ll a; string b; cin>>a>>b;
	ll ret = a * (b[0] - '0') * 100;
	ret += (a * (b[2] - '0')) * 10;
	ret += (a * (b[3] - '0'));
	cout<<ret / 100;
}

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

using namespace std;

#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define MP make_pair
#define PB push_back
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

#define int long long
#define trace(x) cerr << #x << ": " << x << " " << endl;


inline int add(int a, int b){a += b; if(a >= MOD)a -= MOD; return a;}
inline int sub(int a, int b){a -= b; if(a < 0)a += MOD; return a;}
inline int mul(int a, int b){return (int)((int) a * b %MOD);}


#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int mat[16][16];
int dp[1<<16];
signed main()
{
    IOS
    int n;
    cin >> n;
    REP(i, n)
    REP(j, n)
    cin >> mat[i][j];
    REP(i, (1<<n))
    {
        REP(j, n)
        {
            FOR(k, j+1, n, 1)
            {
                // cout << i << " " << (1<<j) << " " << (1<<k) << "\n";
                // cout << i << " " << (i&(1<<j)) << " " << (i&(1<<k)) << " " << ((i & (1<<(j))) && (i & (1<<(k)))) << "\n";
                if( (i & (1<<(j))) && (i & (1<<(k))))
                {
                    dp[i] += mat[j][k];
                }
            }
        }

        // cout << dp[i] << "\n";
    }

    REP(i, (1<<n))
    {
        int s = i;
        while(s>0)
        {
            int s2 = i^s;
            dp[i] = max(dp[i], dp[s2]+dp[s]);
            s=(s-1)&i;
        }
    }

    cout << dp[(1<<n)-1];
    
}

Measured memory_bytes: 768
N=int(input())
A=[[]for _ in range(N)]
for i in range(N):
    for _ in range(int(input())):
        A[i].append(list(map(int,input().split())))

ans=[]
for i in range(2**N):
    Bit = [1]*N
    for j in range(N):
        if (i >> j) & 1:
            Bit[j] = 0
    i=0
    no=0
    while i<N:
        if Bit[i]==1:
            for x,y in A[i]:
                if Bit[x-1]!=y:
                    no=1
        i+=1
    if no:
        ans.append(0)
    else:
        ans.append(Bit.count(1))

print(max(ans))

Measured memory_bytes: 9448
h, w = map(int, input().split())
M = [str(input()) for _ in range(h)]
M = ['.'*w] + M + ['.'*w]
M = ['.'+c+'.' for c in M]

#print(M)

flag = True
for i in range(1, h+1):
    for j in range(1, w+1):
        if M[i][j] == '#':
            for p, q in (-1, 0), (1, 0), (0, 1), (0, -1):
                ni = i+p
                nj = j+q
                if M[ni][nj] == '#':
                    break
            else:
                flag = False

if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>
#include <cstdint>
#include <complex>

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

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

const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

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


bool dp[5010][5010];

int main() {
    int n, k; cin >> n >> k;
    vector<int> a(n); rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());

    int left = -1;
    int right = n;
    int mid;
    while (right - left > 1) {
        mid = (left + right) / 2;

        
        memset(dp, false, sizeof(dp));
        dp[0][0] = true;
        rep(i, n) {
            rep(j, k+1) {
                if (i == mid) {
                    dp[i+1][j] |= dp[i][j];
                } else {
                    dp[i+1][j] |= dp[i][j];
                    if (j + a[i] <= k) {
                        dp[i+1][j+a[i]] |= dp[i][j];
                    } else {
                        dp[i+1][k] |= dp[i][j];
                    }
                }
            }
        }
        bool flag = 0;
        for (int j = max(0, k - a[mid]); j < k; j++) {
            flag |= dp[n][j];
        }
        if (flag) right = mid;
        else left = mid;
    }

    cout << left + 1 << endl;

    return 0;
}


    

Measured memory_bytes: 24832
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
int N;
vector<int>G[1<<17];
int d[1<<17];
int parent[20][1<<17];
main()
{
	cin>>N;
	parent[0][0]=-1;
	for(int i=1;i<N;i++)
	{
		int p;cin>>p;p--;
		parent[0][i]=p;
		G[p].push_back(i);
	}
	for(int k=0;k<19;k++)
	{
		for(int i=0;i<N;i++)if(parent[k][i]>=0)parent[k+1][i]=parent[k][parent[k][i]];
	}
	vector<int>a;
	queue<int>P;
	P.push(0);
	d[0]=0;
	while(!P.empty())
	{
		int u=P.front();
		P.pop();
		a.push_back(u);
		for(int i=0;i<G[u].size();i++)
		{
			d[G[u][i]]=d[u]+1;
			P.push(G[u][i]);
		}
	}
	long ans=0;
	for(int i=1;i<a.size();i++)
	{
		int x=a[i-1],y=a[i];
		if(d[x]>d[y])x^=y^=x^=y;
		ans+=d[x]+d[y];
		for(int k=20;k--;)
		{
			if(d[y]-d[x]>>k&1)y=parent[k][y];
		}
		for(int k=20;k--;)
		{
			if(parent[k][x]!=parent[k][y])
			{
				x=parent[k][x];
				y=parent[k][y];
			}
		}
		if(x!=y)x=parent[0][x];
		ans-=2*d[x];
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 17904
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(x) (x).begin(),(x).end()

int main() {
  ll N,D,cnt=0;
  cin>>N>>D;
  rep(i,N) {
    ll x,y;
    cin>>x>>y;
    if(x*x+y*y<=D*D) cnt++;
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 3628
#include <vector> 
#include <list> 
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <complex>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;

typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(t,c) for(typeof((c).begin()) t=(c).begin(); t!=(c).end(); ++t)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(t,a,b) for(int t=(a);t<(b);++t)
#define REP(t,n)  FOR(t,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;



const LL mod = 1000000007;

LL gcd(LL a, LL b) { if (a%b == 0) { return b; } else return gcd(b, a%b); }
LL lcm(LL a, LL b) { return a / gcd(a, b)*b; }

#define Yes_ cout<<"Yes"<<endl; return 0;
#define No_ cout<<"No"<<endl; return 0;


#define YES_ cout<<"YES"<<endl; return 0;
#define NO_ cout<<"NO"<<endl; return 0;

#define POSSIBLE cout<<"POSSIBLE"<<endl; return 0;
#define IMPOSSIBLE cout<<"IMPOSSIBLE"<<endl; return 0;

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

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

char F[51][51];

int main() {
	cin >> H >> W;
	REP(i, H)REP(j, W) {
		cin >> F[i][j];
	}

	REP(i, H)REP(j, W) {

		if (F[i][j] == '#') {
			REP(k, 4) {
				int nx = j + dx[k], ny = i + dy[k];
				if (ok(nx, ny) && F[ny][nx] == '#') {
					goto NEXT;
				}
			}
			No_;
		}
	NEXT:;
	}

	Yes_;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;

public class Main{
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  
	  int N = sc.nextInt();
	  int[] H = new int[N];
	  for(int i=0; i<N; i++) {
		  H[i] = sc.nextInt();
	  }
	 int[] DP = new int[N];
	 DP[0] = 0; DP[1] = H[1] - H[0];  if(DP[1]< 0) DP[1]= -DP[1];
	 
	 for(int i = 2; i< N; i++) {
		 int oneD = H[i] - H[i - 1]; if(oneD<0)oneD = -oneD;
		 int twoD = H[i] - H[i - 2]; if(twoD<0)twoD = -twoD;
		 int oneStep = DP[i-1] + oneD;
		 int twoStep = DP[i-2] + twoD;

		 int dp = oneStep > twoStep ? twoStep: oneStep;
		 DP[i] = dp;	
	 }
	out.println(DP[N - 1]);
  }
}

Measured memory_bytes: 46912
N, M = map(int, input().split())

S = []
for _ in range(M):
    K = list(map(int, input().split()))
    S.append(K[1:])

P = list(map(int, input().split()))

ans = 0
for i in range(2 ** N):
    on_switch = []
    for j in range(N):
        if ((i >> j) & 1):
            on_switch.append(j + 1)
    clear = True
    for k, s in enumerate(S):
        res = 0
        for si in s:
            if si in on_switch:
                res += 1
        if res % 2 != P[k]:
            clear = False
            break
    if clear:
        ans += 1

print(ans)


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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

vector<vector<string>> l(11);
void solve(int now,string s,char max_c){
    l[now].push_back(s);
    if(now==10){
        return;
    }

    
    for(char c = 'a'; c!=max_c+2;c++){
        if(c!=max_c+1){
            solve(now+1,s+c,max_c);
        }else{
            solve(now+1,s+c,max_c+1);
        }
    }
    return ;
}

int main(){

    int n;
    cin >> n;
    string s = "a";

    solve(1,s,'a');
    sort(l[n].begin(),l[n].end(),less<string>());
    rep(i,l[n].size()){
        cout << l[n][i] << endl;
    }

 

    return 0;
}  

Measured memory_bytes: 9588
import java.util.Scanner;


public class Main {

	public static void main(String[] args)  {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int[] cnt = new int[1000001];
		Long ans = 0l;
		
		for(int i = 0 ; i < n ; i++) {
			int a =Integer.parseInt(sc.next());
			cnt[a]++;
			ans += a;
		}
		
		int q = Integer.parseInt(sc.next());
		for(int i = 0 ; i < q ; i++) {
			int b = Integer.parseInt(sc.next());
			int c = Integer.parseInt(sc.next());
			cnt[c] += cnt[b];
			
			long tmp = (c- b);
			ans += tmp*cnt[b];
			cnt[b] = 0;
			System.out.println(ans);
		}

		
	}
}




Measured memory_bytes: 64832
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
int main(){
    int N,M;
    int check[10]={0};
    cin>>N>>M;
    for(int i=0;i<M;i++){
        int a;
        cin>>a;
        check[a]=1;
    }
    int ans;
    for(int i=N;;i++){
        int kari=i;
        while(1){
            if(kari==0){
                ans=i;
                goto exit;
            }
            else if(check[kari%10]){

                break;
            }
            else kari/=10;
        }
    }
exit:
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

#define int long long
#define tie() ios_base :: sync_with_stdio(false);cin.tie(0);cout.tie(0);

int32_t main()
{
    tie();
    int n;
    cin >> n;
    cout << (n + 1) / 2 << endl;
    return 0;
}


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

#define fori(i,a,b)    for(int i=a;i<=b;i++)
#define ford(i,a,b)   for(int i=a;i>=b;i--)
#define all(a)        a.begin(), a.end()
#define in(c,x)       ((c).find(x) != (c).end())
#define isp(c,x)      (find(all(c),x) != (c).end())
#define pb             push_back
#define ppb            pop_back
#define sz(x)          (int)x.size()
#define fill(a,v)      memset(a, v, sizeof a)
#define fs first
#define sc second
#define ub upper_bound
#define lb lower_bound
#define en '\n'

typedef long long int lli;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vlli;
typedef pair< int, int > pii;
typedef pair< lli, lli > plli;
typedef list<int> li;
typedef map<int, int> mi;
typedef map<lli, lli> mlli;
lli gcd(lli a,lli b){return (!b)?a:gcd(b,a%b);}
int t = 1; int ti;
lli md = 1e9 + 7;



const int N = 1e3 + 5;
int dp[N][N];
char a[N][N];
int dx[] = {-1, 0};
int dy[] = {0, -1};
int h, w;


int inR(int x, int y){
    return (1 <= x && x <= h && 1 <= y && y <= w);
}

void solve(){
    cin>>h>>w;

    fori(i, 1, h){
        fori(j, 1, w)
        cin>>a[i][j];
    }

    dp[1][1] = 1;

    fori(i, 1, h){
        fori(j, 1, w){
            fori(k, 0, 1){
                int xx = i + dx[k];
                int yy = j + dy[k];

                if(inR(xx, yy) && a[xx][yy] == '.'){
                    dp[i][j] += dp[xx][yy];
                    dp[i][j] %= md; 
                }
            }            
        }
    }

    cout<<dp[h][w];
}
//THINK OF SPECIAL CASES, ARRAY LIMITS, LLI vs INT, 1LL

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

    // cin>>t;

    // for(ti= 1; ti <= t; ti++)
    solve();

//    cout<<"\nTHINK OF SPECIAL CASES, ARRAY LIMITS, LLI vs INT, 1LL";
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;


int main() {
//    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


   int n, m;
   cin >> n >> m;
   map<int, int> d;
   ll modulo = 1000000007;
   for (int i = 0; i < m; i++) {
       int e;
       cin >> e;
       d[e] = 1;
   }


   ll a[n + 1];
   memset(a, 0, sizeof a);
   a[0] = 1;
   for (int i = 1; i <= n; i++) {
       if (i - 1 >= 0 && d[i - 1] == 0) {
           a[i] += a[i - 1];
           a[i] %= modulo;
       }

       if (i - 2 >= 0 && d[i - 2] == 0) {
           a[i] += a[i - 2];
           a[i] %= modulo;
       }
   }

   cout << a[n];



}




Measured memory_bytes: 5760
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	d := make([]int, n)
	m := map[int]int{}

	for i := range d {
		fmt.Scan(&d[i])
		m[d[i]]++
	}

	fmt.Println(len(m))
}


Measured memory_bytes: 512
import java.io.*;
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = Integer.parseInt(sc.next());
    int B = Integer.parseInt(sc.next());
    
    int ans = A - 2*B;
    
    if (ans > 0) {
      System.out.println(ans);
    } else {
      System.out.println(0);
    }
  }
}

Measured memory_bytes: 24148
a,b,c = gets.split(" ")

AB = a + b
BC = b + c
CA = c + a

ABtoi = AB.to_i
BCtoi = BC.to_i
CAtoi = CA.to_i

a = a.to_i
b = b.to_i
c = c.to_i

if ABtoi <= BCtoi then
 max = BCtoi + a
 elsif max=ABtoi + c
end

if max <= CAtoi then
 max = CAtoi + b
end

print max

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
  string s;
  cin>>s;
  int n =s.length();
  if(n==1 || n==0)
  {
    cout<<"No"<<endl;
    return 0;
  }
  for(int i =0;i<n-1;i++)
  {
      if(s[i]!=s[i+1])
      {
        cout<<"Yes"<<endl;
        return 0;
      }
  }
  cout<<"No"<<endl;
}


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

using namespace std;

/*

    bottom up

*/

const int N = 1e5 + 5;
const int INF = 2e9;

int n , k;
int h[N];
int dp[N];

main(){

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

    for(int i = 0 ; i < n ; i ++){
            scanf("%d" , &h[i]);
    }

    // initialize dp table
    for(int i = 0 ; i < n ; i ++){
            dp[i] = INF;
    }
    dp[0] = 0;

    for(int i = 0 ; i < n ; i ++){
            for(int j = 1 ; j <= k ; j ++){
                    if(i + j <= n-1){
                            dp[i + j] = min(dp[i + j] , abs(h[i] - h[i + j]) + dp[i]);
                    }
            }
    }

    printf("%d\n" , dp[n-1]);

    return 0;
}


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

signed main() {                                
	int N, K;
	cin >> N >> K;
	
	if (N > K) {
	      	int r = N % K;
		cout << min(r, abs(r - K));
	} else {
	 	cout << min(N, abs(N - K));
	}
	
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();
        long m = sc.nextInt();
        long N = (n == 1) ? 1 : n - 2;
        long M = (m == 1) ? 1 : m - 2;
        System.out.println(N * M);
    }
}

Measured memory_bytes: 23252
#include <stdio.h>
#include <time.h>

int main(){
	char a[100000];
	int x[100000];
	int count=0;
	
	scanf("%s",a);
	
	
	for(int i=0;i<strlen(a);i++){
		if(a[i]=='0'){
			count++;
		}
	}
	
	if(strlen(a)-count < count){
		count = strlen(a)-count;
	}
	
	printf("%d",count*2);
	
	return 0;
}

Measured memory_bytes: 256
from collections import deque
import sys
sys.setrecursionlimit(10**6)

def bfs1(c):
    visited[c]=1
    q=deque([c])
    while len(q)>0:
        p=q.popleft()
        for i in v[p]:
            if visited[i]==0:
                q.append(i)
                visited[i]=1
                d[c][i]=d[c][p]+1

def bfs2(c1,c2):
    visited[c2]=1
    bfs1(c1)
    bfs1(c2)

n,k=map(int,raw_input().split())
d=[[0]*n for _ in xrange(n)]
v=[[] for _ in xrange(n)]
e=[]
for i in xrange(n-1):
    a,b=map(int,raw_input().split())
    a-=1
    b-=1
    v[a].append(b)
    v[b].append(a)
    e.append([a,b])
if k%2==0:
    min_del=2005
    for i in xrange(n):
        cnt=0
        visited=[0]*n
        bfs1(i)
        for j in xrange(n):
            if d[i][j]>k/2:
                cnt+=1
        min_del=min(min_del,cnt)
    print(min_del)
else:
    min_del=2005
    for i,j in e:
        cnt=0
        visited=[0]*n
        bfs2(i,j)
        for l in xrange(n):
            if d[i][l]>(k-1)/2 or d[j][l]>(k-1)/2:
                cnt+=1
        min_del=min(min_del,cnt)
        d[i]=[0]*n
        d[j]=[0]*n
    print(min_del)

Measured memory_bytes: 104860
H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]

d = {}
for y in range(H):
    for x in range(W):
        d[A[y][x]] = (y, x)

t = [[0] * (H * W // D + 1) for _ in range(D)]
for i in range(D):
    j = 0
    if i == 0:
        j = 1
    while i + (j + 1) * D <= H * W:
        y1, x1 = d[i + j * D]
        y2, x2 = d[i + (j + 1) * D]
        t[i][j + 1] = abs(y1 - y2) + abs(x1 - x2)
        j += 1
    for j in range(H * W // D):
        t[i][j + 1] += t[i][j]

Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    i = L % D
    print(t[i][(R - i) // D] - t[i][(L - i) // D])


Measured memory_bytes: 28644
#include <stdio.h>

int main(void){

        int x, a, b;

        scanf("%d %d %d", &x, &a, &b);

        if((x >= 1 && x <= 1000) && (a >= 1 && a <= 1000) && (b >= 1 && b <= 1000)){
                if(abs(a-x) > abs(b-x)){
                        printf("B\n");
                }else if(abs(a-x) < abs(b-x)){
                        printf("A\n");
                }else if(a == b){
                        return 1;
                }
        }





return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#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(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



int main(){

  int n;
  cin >> n;
  vector<ll> a(n);
  REP(i,n) cin >> a[i];
  ll sum_0 = 0;
  ll sum_1 = 0;

  REP(i,n){
    if(i%2 == 0)sum_0 += a[i];
    else sum_0 -= a[i];
  }
  sum_1 += a[0];
  REP2(i,1,n){
    if(i%2 == 1)sum_1 += a[i];
    else sum_1 -= a[i];
  }

  vector<ll> m(n);
  m[0] = sum_0;
  m[1] = sum_1;

  REP2(i,2,n){
    if(i%2 == 0){
      sum_0 = sum_0 -2*a[i-2]+2*a[i-1];
      m[i] = sum_0;
    }

    else{
      sum_1 = sum_1 - 2*a[i-2]+2*a[i-1];
      m[i] = sum_1;
    }

  }

  for(auto x : m) cout << x << " ";
  cout <<  endl;


  return 0;
}


Measured memory_bytes: 4856
class UnionFind:
    def __init__(self, numV):
        self.pars = list(range(numV))
        self.ranks = [0] * numV
        self.sizes = [1] * numV
    def getRoot(self, x):
        par = self.pars[x]
        if par != x:
            self.pars[x] = par = self.getRoot(par)
        return par
    def merge(self, x, y):
        x, y = self.getRoot(x), self.getRoot(y)
        sx, sy = self.sizes[x], self.sizes[y]
        if x == y: return (0, 0)
        if self.ranks[x] < self.ranks[y]:
            self.pars[x] = y
            self.sizes[y] += sx
        else:
            self.pars[y] = x
            self.sizes[x] += sy
            if self.ranks[x] == self.ranks[y]:
                self.ranks[x] += 1
        return (sx, sy)
    def isSame(self, x, y):
        return self.getRoot(x) == self.getRoot(y)
    def updatePars(self):
        for v in range(len(self.pars)):
            self.getRoot(v)
    def getSize(self, x):
        return self.sizes[self.getRoot(x)]
      
n, m = map(int, input().split())
e = [list(map(int,input().split())) for i in range(m)]
e.reverse()

uf = UnionFind(n)
score = n*(n-1)//2 
ans = [score]
for ce in range(m-1):
    u, v = e[ce][0]-1, e[ce][1]-1
    if uf.getRoot(u) != uf.getRoot(v):
        xu = uf.getSize(u)
        xv = uf.getSize(v)
        uf.merge(u, v)
        score -= xu * xv
    ans.append(score)
ans.reverse()

for i in range(m):
    print(ans[i])

Measured memory_bytes: 99628
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define MAX 1000000007

using namespace std;
char *ret(char *t) {
	if (*t == 'A' || *t == 'T' || *t == 'G' || *t == 'C') {
		//cout << *t << 1 << endl;
		return ret(t+1);
	}
	else {
		//cout << *t << 2 << endl;
		return t;
		
	}
}


int main() {
	char s[10];
	int ans = 0;
	char *p, *q;
	cin >> s;
	int j,k=0;
	for (j = 0; s[j] != '\0'; j++);
	q = s;
	while(k<j){
		p = ret(q);
		//cout << (int)(p - q)<<endl;
		if (ans < (int)(p - q))ans = (int)(p - q);
		
		k += (int)(q- p)+1;
		q = p + 1;
		//cout << k << endl;
		
	}
	cout << ans;
}




Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from math import sqrt
from bisect import bisect_right

def main():
	n, m = map(int, input().strip().split())
	M = int(sqrt(m))
	ans = 1
	for i in range(1, M+1):
		if m % i == 0:
			if i*n <= m:
				ans = max(ans, i)
			if m//i * n <= m:
				ans = max(ans, m//i)
	print(ans)

if __name__ == '__main__':
	main()


Measured memory_bytes: 38512
#include <iostream>
#include <queue>
#include <algorithm>
#include <vector>
#define ll long long
using namespace std;

int main(void){
    long long n, a[300005];
    long long sum_front=0, sum_back=0;
    vector<ll> sf, sb;
    priority_queue<ll, vector<ll>, greater<ll> > que_front;
    priority_queue<ll> que_back;
    cin >> n;
    for( int i = 0; i< 3 * n; i++ ){
        cin >> a[i];
        if(i < n){
            sum_front += a[i];
            que_front.push(a[i]);
        }else if( 2*n <= i ){
            sum_back += a[i];
            que_back.push(a[i]);
        }
    }
    sf.push_back(sum_front);
    sb.push_back(sum_back);
    for( int i = n; i < 2*n ; i++ ){
        que_front.push(a[i]);
        sum_front += a[i];
        sum_front -= que_front.top();
        que_front.pop();
        sf.push_back(sum_front);
    }
    for( int i = 2*n-1; i >= n ; i-- ){
        que_back.push(a[i]);
        sum_back += a[i];
        sum_back -= que_back.top();
        que_back.pop();
        sb.push_back(sum_back);
    }
    reverse(sb.begin(), sb.end());
    long long ans = sf[0] - sb[0];
    for( int i = 0; i <= n; i++ ){
        ans = max(ans, sf[i] - sb[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6516
#include <iostream>
#include <vector>
#include <cmath>
#include <typeinfo>
#include <set>
#include <bitset>
#include <string>
#include <map>
using namespace std;
typedef long long ll;

int main(){
  long long x;
  cin >> x;
  long long n = 100;
  int count = 0;
  while(n < x){
    count += 1;
    n = floor(n * 1.01);
  }
  cout << count << endl;
}

Measured memory_bytes: 3744
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn gcd(a: i32, b: i32) -> i32 {
    fn gcd1(m: i32, n: i32) -> i32 {
        if n == 0 {
            m
        } else {
            gcd1(n, m % n)
        }
    }
    if a > b {
        gcd1(a, b)
    } else {
        gcd1(b, a)
    }
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut av = vec![0i32; n];
    for i in 0..n - 1 {
        av[i] = read(&mut stdin_lock, &mut buf, b' ');
    }
    av[n - 1] = read(&mut stdin_lock, &mut buf, b'\n');

    let mut ans = av[0];
    for i in 1..n {
        ans = gcd(ans, av[i]);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define llong long long
using namespace std;

void read(int &x)
{
    int f=1;x=0;char s=getchar();
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
    while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
    x*=f;
}

const int N = 3e5;
const int P = 998244353;
char a[N+3];
int num[4];
int n;

int decode(char x) {return x=='B'?0:(x=='R'?1:2);}

int main()
{
	scanf("%d",&n);
	scanf("%s",a+1); llong ans = 1ll; int n0=0,n1=0,n2=0;
	for(int i=1; i<=n*3; i++)
	{
		int x = decode(a[i]);
		num[x]++;
		int m0=max(max(num[0],num[1]),num[2]),m2=min(min(num[0],num[1]),num[2]),m1=i-m0-m2;
		if(m0!=n0) {ans = ans*(n-n0)%P;}
		else if(m1!=n1) {ans = ans*(n0-n1)%P;}
		else if(m2!=n2) {ans = ans*(n1-n2)%P;}
		n0=m0; n1=m1; n2=m2;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 512
# coding:utf-8

import sys
import math
import time
import numpy as np
import collections
from collections import deque
import queue
import copy

# 最大公約数
def gcd(m,n):
  x = max(m,n)
  y = min(m,n)
  if x%y == 0:
    return y
  else:
    while x%y != 0:
      z = x%y
      x = y
      y = z
    else:
      return z

# 幅優先探索(BFS)でスタート座標(x, y)からの最大距離返す
def bfs(SS, x, y, H, W):#入力(座標系(迷路), x, y, xの端, yの端)
  x_next = [0, 0, -1, 1]
  y_next = [1, -1, 0, 0]
  tempx = x
  tempy = y
  mlength = 0
  q = deque()
  xytuple = (x, y, 0)
  q.append(xytuple)


  while q:
    xytuple = q.popleft()
    SS[xytuple[0]][xytuple[1]] = "x" #探索した場所は探索できないようにする
    for i in range(4): #このforで上下左右を調べてる
      tempx = xytuple[0] + x_next[i]
      tempy = xytuple[1] + y_next[i]
      #print(tempx, tempy, xytuple[2])
      #print(S)
      if(0 <= tempx and tempx < H and 0 <= tempy and tempy < W and SS[tempx][tempy] == "."):
        temptuple = (tempx, tempy, xytuple[2]+1)
        SS[temptuple[0]][temptuple[1]] = "x" #探索した場所は探索できないようにする
        mlength = max(mlength, xytuple[2] +1)
        q.append(temptuple)
      #print(q)
  return mlength


#X = str(input()).split()
AB = str(input()).split()
A = int(AB[0])
B = int(AB[1])

ans = int(A * B /gcd(A,B))

print(ans)



Measured memory_bytes: 12484
n = gets.to_i
a = gets.split.map(&:to_i)
old_a = a[0]

ans = 0

1.upto(n-1) do |i|
  if !old_a.nil? && old_a == a[i]
    ans += 1
    old_a = nil
    next
  end
  old_a = a[i]
end

puts ans

Measured memory_bytes: 1788
import java.io.IOException;
import java.util.*;

public class Main {
    public static int map[]=new int[20001];
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int A=sc.nextInt()*N;
        int B=sc.nextInt();
        int ans=Math.min(A,B);
        System.out.println(ans);

    }


}

Measured memory_bytes: 22996
#include <stdio.h>
#include <stdlib.h>

int **G;
int *u, *k, **v;
int n;

void Input();
void CreateAdjacencyMatrix(int); 
void Output();


int main () {
  
  Input();
  Output();
  
  return 0;
}


void Input() {
  int i, j;
  
  scanf("%d", &n);
  
  k = (int *)malloc(sizeof(int) * (n + 1));
  u = (int *)malloc(sizeof(int) * (n + 1));
  G = (int **)malloc(sizeof(int *) * (n + 1));
  v = (int **)malloc(sizeof(int *) * (n + 1));
  
  for (i = 1; i <= n; i++) {
    scanf("%d%d", &u[i], &k[i]);
    G[i] = (int *)malloc(sizeof(int) * (n + 1));
    v[i] = (int *)malloc(sizeof(int) * (k[i] + 1));
    for (j = 1; j <= k[i]; j++) {
      scanf("%d", &v[i][j]);
    }
  }
  
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      G[i][j] = 0;
    }
  }
}

void CreateAdjacencyMatrix(int a) {
  int i, j;
  for (i = 1; i <= k[a]; i++) {
    for (j = 1; j <= n; j++) {
      if (u[j] == v[a][i])
	G[a][u[j]] = 1;
    }
  }
}

void Output() {
  int i, j;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      CreateAdjacencyMatrix(i);
      /*if (j != 1) printf(" ");*/
      printf("%d", G[i][j]);
      if(j==n) break;
      else printf(" ");
    }
    printf("\n");
    free(G[i]);
    free(v[i]);
  }
  free(u);
  free(k);
  free(G);
  free(v);
}

Measured memory_bytes: 644
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  int n, m;
  cin >> n >> m;
  int ans = 0;
  vector<int> k(m);
  vector<vector<int>> s(m);
  rep(i, m) {
    cin >> k[i];
    rep(j, k[i]) {
      int ss;
      cin >> ss;
      --ss;
      s[i].push_back(ss);
    }
  }
  vector<int> p(m);
  rep(i, m) cin >> p[i];

  rep(i, 1<<n) {
    vector<int> t(m);
    rep(j, m) {
      rep(l, k[j]) {
        int ns = s[j][l];
        if(i>>ns&1) t[j]++;
      }
    }
    bool ok = true;
    rep(j, m) {
      if(!(t[j] % 2 == p[j])) ok = false;
    }
    if(ok) ans++;
  }
  cout << ans << endl;
}

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

string s;
int k = 0;
bool f = 1;

int main()
{
	cin >> s;

	for (int i = 0; i < s.size(); i++) {
		if (f) {
			if (s[i] == s[i + 1]) {
				i++;
				f = 0;
			}
		}
		else
			f = 1;

		k++;
	}

	cout << k << endl;

	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int main(){
char a[3][4];
for(int k=0;k<3;k++){
for(int l=0;l<4;l++){
scanf("%c",&a[k][l]);
} 
}

printf("%c",a[0][0]);
printf("%c",a[1][1]);
printf("%c",a[2][2]);


return 0;
}


Measured memory_bytes: 128
#include <map>
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 1e5+55;
#define LL long long
map<int,int>num;
int main()
{
    int x,n,m;
    scanf("%d%d",&n,&m);
    int now = 0;
    LL ans=0;
    for(int i=1;i<=n;i++){
        scanf("%d",&x);
        now=(now+x)%m;
        if(now==0) ans++;
        ans+=num[now];
        num[now]++;
    }
    printf("%lld\n",ans);


}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;

ll gcd(ll a,ll b){
    while(b){
        ll c = a%b;
        a = b;
        b = c;
    }
    return a;
}

int main(){
    ll x,k,d;
    cin >> x >> k >> d;
    if(k < abs(x)/d){
        cout << abs(x)-k*d <<"\n";
    }
    else{
        ll cnt = abs(x)/d;
        ll p1 = abs(x)%d;
        if((k-cnt)&1) cout << abs(p1-d) <<"\n";
        else cout << p1 <<"\n";
    }
    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main()
{
    int n;
    scanf("%d", &n);
    int i,j;
    int count = 0;
    for(i=1;i<=n;i+=2){
        int temp = 0;
        for(j=1;j<=i;j++){
            if(i%j==0) temp++;
        }
        if(temp==8) count++;
    }
    
    printf("%d", count);

    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

const int MOD = 100000;

int n, m, s;
int dp[50][3005]; // dp[Iðµ½Â][Ýv]ð½·gÝí¹Ì

int main()
{
	while(cin >> n >> m >> s && n)
	{
		memset(dp,0,sizeof(dp));
		
        dp[0][0]=1;
		
        for(int i = 1; i <= m; i++)
		{
            for (int j = n * n; 0 < j; j--)
			{
                for(int k = s; i <= k; k--)
				{
                    (dp[j][k] += dp[j - 1][k - i]) %= MOD;
                }
            }
		}
		
		cout << dp[n * n][s] << endl;
	}
}

Measured memory_bytes: 1452
import math
def sieve_of_erastosthenes(num):
    input_list = [0 if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else 1 for i in range(num)]
    input_list[0] = input_list[1] = 0
    input_list[2] = input_list[3] = input_list[5] = 1
    sqrt = math.sqrt(num)
    for serial in range(3, num, 2):
        if serial >= sqrt:
            return input_list
        for s in range(serial ** 2, num, serial): 
            input_list[s] = 0
q = int(input())
l_list = []
r_list = []
for i in range(q):
    l, r = map(int, input().split())
    l_list.append(l)
    r_list.append(r)
minval = min(l_list)
maxval = max(r_list)
sieve = sieve_of_erastosthenes(maxval+1)
def is_prime(x):
    return sieve[x]
def is_like2017(x):
    return is_prime(x) * is_prime(int((x+1)/2))
like2017 = list(range(maxval+1))
for i in like2017:
    like2017[i] = is_like2017(i)

integral = like2017
for i in range(1, len(integral)):
    integral[i] = integral[i] + integral[i-1]
for l, r in zip(l_list, r_list):
    print(integral[r] - integral[l-1])

Measured memory_bytes: 15824
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n).map { sc.next().toLong() }
    println(problemddccb(n, a))
}

fun problemddccb(n: Int, a: List<Long>): Long {
    val dp = LongArray(n)
    var min = Long.MAX_VALUE
    var sum = a.takeLast(n - 1).sum()
    dp[0] = a[0]
    min = Math.min(min, Math.abs(dp[0] - sum))
    for (i in 1 until n) {
        val first = dp[i - 1] + a[i]
        dp[i] = first
        sum -= a[i]
        min = Math.min(min, Math.abs(sum - first))
    }
    return min
}

Measured memory_bytes: 59364
x, y = map(int, input().split())
A = [1,3,5,7,8,10,12]
B = [4,6,9,11]
if(x in A and y in A):
    print("Yes")
elif(x in B and y in B):
    print("Yes")
elif(x==y==2):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define D(a) cout<<#a<<": ";for(auto i:a)cout<<i<<' ';cout<<endl;
using namespace std;
int main()
{
    int N; cin >> N;
    vector<int> C(N + 1);
    for (int i = 0; i < N; i++) {
        int p; cin >> p; p--;
        C[p+1] = C[p] + 1;
        C[p] = 0;
    }
    cout << N - *max_element(C.begin(), C.end()) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    string ans = "APPROVED";
    for(int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if(x % 2 == 0) {
            if(x % 3 != 0 && x % 5 != 0) {
                ans = "DENIED";
                break;
            }
        }
    }
    cout << ans<< endl;
}

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

using namespace std;

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

	vector<int> p(N);
	vector<int> q(N);
	for (int i = 0; i < N; i++) {
		cin >> p.at(i);
		q.at(i) = p.at(i);
	}
	sort(q.begin(), q.end());

	int count = 0;
	for (int i = 0; i < N; i++) {
		if (p.at(i) != q.at(i)) {
			count++;
		}
	}

	if (count == 0 || count == 2) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

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

int main() {
    string str;
    cin >> str;
    int n = (int)str.length();
    long long int res = stoll(str);
    for (int bit = 0; bit < (1 << (n - 1)); bit++) {
        deque<int> split;
        for (int i = 0; i < (n - 1); i++) {
            if (bit & (1 << i)) {
                split.push_back(i);
            }
        }
        int prev = 0;
        while (!split.empty()) {
            res += stoll(str.substr(prev, split.front() + 1 - prev));
            prev = split.front() + 1;
            split.pop_front();
            if (split.empty()) {
                res += stoll(str.substr(prev));
                break;
            }
        }
    }
    cout << res << endl;
    return 0;
}

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

// マクロ //
#define rep(i,N) for(int i = 0; i < (int)(N); i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)
#define db(i) cout << #i << " = " << i;

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvli = vector<vli>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vvs = vector<vs>;
using mii = map<int, int>;
using mili = map<int, lint>;
using mci = map<char, int>;
using mcli = map<char, lint>;
using msi = map<string, int>;
using msli = map<string, lint>;


// 関数 //
template<class T, class Q> lint gcd_(T a, Q b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

template<class T, class Q> lint lcm_(T a, Q b) {
    return a * b / gcd(a, b);
}

double distance(pii a, pii b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint combination(int n, int m) {
    long double c = 1;
    for (int i = n, k = 1; i > m; i--, k++) {
        c *= i;
        c /= k;
    }
    return (lint)c;
}

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

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

// 定数 //
const double pi = acos(-1);
const int mod = 1000000007;
const int MOD = 998244353;
const int inf = 1045141919;
const lint linf = ((1LL << 62) - 1);


// キーワード //
#define elif else if

// End of Template //



int main() {

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

    double a, b, c, d;
    cin >> a >> b >> c >> d;
    int kaisuT = ceil(c / b);
    int kaisuA = ceil(a / d);
    kaisuT <= kaisuA ? y() : n();
}

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


input = sys.stdin.readline
def IS(cb): return cb(input().strip())
def IL(cb): return [cb(s) for s in input().strip().split()]
def IR(cb, rows): return [IS(cb) for _ in range(rows)]
def ILL(cb, rows): return [IL(cb) for _ in range(rows)]


def solve():
    N = IS(int)
    l = ['p', 'p', 'h', 'b', 'h', 'h', 'p', 'h', 'p', 'h']
    print(l[int(str(N)[-1])] + 'on')


solve()


Measured memory_bytes: 9204