akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
vector<pair<int,int> > e[101010];
map <pair<int,int>,vector<int> > mp;
queue <int> q; 
int dis[101010];
void work(int p,int c)
{
	vector<int> v=mp[make_pair(p,c)];
	mp[make_pair(p,c)].clear();
	for(int i=0;i<v.size();i++)
		if(dis[v[i]]==-1)
		{
			q.push(v[i]);
			dis[v[i]]=dis[p];
			work(v[i],c);
		}
		else if(dis[v[i]]==dis[p])
			work(v[i],c);
}
int main()
{
	int n,m,x,y,c,p;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d%d",&x,&y,&c);
		mp[make_pair(x,c)].push_back(y);
		mp[make_pair(y,c)].push_back(x);
		e[x].push_back(make_pair(y,c));
		e[y].push_back(make_pair(x,c));
	}
	memset(dis,-1,sizeof(dis));
	dis[1]=0;
	q.push(1);
	while(!q.empty())
	{
		p=q.front();
		q.pop();
		for(int i=0;i<e[p].size();i++)
			if(dis[e[p][i].first]==-1)
			{
				q.push(e[p][i].first);
				dis[e[p][i].first]=dis[p]+1;
				work(e[p][i].first,e[p][i].second);
			}
			else if(dis[e[p][i].first]==dis[p]+1)
				work(e[p][i].first,e[p][i].second);
	}
	printf("%d\n",dis[n]);
	return 0;
}

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

using namespace std;

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

  bool ok = false;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      ok |= i * m + j * n - 2 * i * j == k;
    }
  }

  cout << (ok ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

const ll MAX = 510010;
const ll mod = 1000000007;
vector<ll> fac(MAX), finv(MAX), inv(MAX);
bool init_called = false;
//=============modinv============================
void COMinit() {
  init_called = true;
  fac.at(0) = 1;
  fac.at(1) = 1;
  finv.at(0) = 1;
  finv.at(1) = 1;
  inv.at(1) = 1;
  for (ll i = 2; i < MAX; i++){
    fac.at(i) = fac.at(i - 1) * i % mod;
    inv.at(i) = mod - inv.at(mod % i) * (mod / i) % mod;
    finv.at(i) = finv.at(i - 1) * inv.at(i) % mod;
  }
}

ll COM(ll n, ll k){
  if (!init_called) {
    COMinit();
  }
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac.at(n) * (finv.at(k) * finv.at(n - k) % mod) % mod;
}
//=================================================

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll S;
  cin >> S;
  ll M_dig = S / 3;
  ll ans = 0;
  for (ll i = 1; i <= M_dig; ++i) {
    ll remain = S - i * 3;
    if (remain < 0) {
      continue;
    }
    ans += COM(i + remain - 1, i - 1);
    ans %= mod;
  }
  cout << ans << "\n";
}


Measured memory_bytes: 14984
n=int(input());l=[0,1];a=0;b=c=1;p=998244353
for i in range(2,n):
 l+=[l[p%i]*(p-int(p/i))%p]
for i in range(n,n//2,-1):
 a+=b*c%p;b+=b%p;c=c*i*l[n+1-i]%p
print((pow(3,n,p)-2*a)%p)

Measured memory_bytes: 226352
T1,T2 = map(int, input().split())
A1,A2 = map(int, input().split())
B1,B2 = map(int, input().split())
d1,d2 = (A1-B1)*T1,(A2-B2)*T2
if d1 < 0: d1,d2 = -d1,-d2
if d1+d2 == 0: print("infinity")
elif d1+d2>0: print(0)
elif d1 % (-(d1+d2)) == 0: print(d1//(-(d1+d2))*2)
else: print(d1//(-(d1+d2))*2+1)

Measured memory_bytes: 3064
s = input()

ans = 0

while s:

    # 先頭と末尾が同じ場合
    if s[0] == s[-1]:
        s = s[1:-1]

    ##### 以下、先頭と末尾が異なる場合の分類 #####

    # 先頭がxの場合
    elif s[0] == 'x':
        # 仮想的に末尾にxを足す
        s = s[1:]
        ans += 1

    # 末尾がxの場合
    elif s[-1] == 'x':
        # 仮想的に先頭にxを足す
        s = s[:-1]
        ans += 1

    # 先頭も末尾もxではない場合
    else:
        print(-1)
        exit()

print(ans)

Measured memory_bytes: 9168
#include <cstring>
#include <cmath>
#include <limits>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
#define reps(i, S, E) for (ll i = (S); i <= (E); i++)
#define rep(i, N) reps(i, 0, N-1)
#define deps(i, E, S) for (ll i = (E); i >= (S); i--)
#define dep(i, N) deps(i, N-1, 0)
void chmax(ll &a, ll b) { if (a < b) a = b; }
void chmin(ll &a, ll b) { if (a > b) a = b; }

const ll MOD = 1000000007;
const ll INF = 1LL << 60;

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

//E
int main() {
	ll N;
	scanf("%lld", &N);
	vector<ll> A(N);
	for (ll i = 0; i < N; i++) {
		scanf("%lld", &A[i]);
	}

	ll count[3] = { 0, 0, 0 };

	ll result = 1ll;

	rep(i, N) {
		if (count[0] == A[i] && count[1] == A[i] && count[2] == A[i]) {
			result *= 3ll;
			result %= MOD;
			count[0]++;
		}
		else if (count[0] == A[i] && count[1] == A[i] && count[2] != A[i]) {
			result *= 2ll;
			result %= MOD;
			count[0]++;
		}
		else if (count[0] != A[i] && count[1] == A[i] && count[2] == A[i]) {
			result *= 2ll;
			result %= MOD;
			count[1]++;
		}
		else if (count[0] == A[i] && count[1] != A[i] && count[2] == A[i]) { //�Ȃ��͂�
			result *= 2ll;
			result %= MOD;
			count[0]++;
		}
		else if (count[0] == A[i] && count[1] != A[i] && count[2] != A[i]) {
			count[0]++;
		}
		else if (count[0] != A[i] && count[1] == A[i] && count[2] != A[i]) {
			count[1]++;
		}
		else if (count[0] != A[i] && count[1] != A[i] && count[2] == A[i]) {
			count[2]++;
		}
		else {
			printf("0\n");
			return 0;
		}
	}

	printf("%lld\n", result);
}


//D
/*
int main() {
	ll N;
	scanf("%lld", &N);
	char s[101010];
	scanf("%s", s);
	ll len = strlen(s);

	//vector<vector<bool>> a(1000, vector<bool>(3, false));
	vector<bool> a1(10, false);
	vector<bool> a2(100, false);
	vector<bool> a3(1000, false);

	rep(i, N) {
		int num = s[i] - '0';

		rep(j, 100) {
			if (a2[j] == true) {
				a3[j + num * 100] = i;
			}
		}

		rep(j, 10) {
			if (a1[j] == true) {
				a2[j + num * 10] = i;
			}
		}

		a1[num] = true;
	}

	ll result = 0;

	rep(i, 1000) {
		if (a3[i] == true) {
			result++;
		}
	}

	printf("%lld\n", result);
}
*/

//C
/*
int main() {
	ll X;
	scanf("%lld", &X);

	ll div = X / 100;
	ll mod = X % 100;

	if (div * 5 >= mod) {
		printf("1\n");
	}
	else {
		printf("0\n");
	}
}
*/

//B
/*
int main() {
	ll N;
	scanf("%lld", &N);

	ll temp = (ll)((double)N / 1.08);

	ll result = 0;

	if ((ll)((double)temp * 1.08) == N) {
		result = temp;
	}
	else if ((ll)((double)(temp - 1) * 1.08) == N) {
		result = temp - 1;
	}
	else if ((ll)((double)(temp + 1) * 1.08) == N) {
		result = temp + 1;
	}
	else {
		printf(":(\n");
		return 0;
	}

	printf("%lld\n", result);
}
*/

//A
/*
int main() {
	ll M1;
	scanf("%lld", &M1);
	ll D1;
	scanf("%lld", &D1);
	ll M2;
	scanf("%lld", &M2);
	ll D2;
	scanf("%lld", &D2);

	ll result = 0;

	if (M1 != M2) {
		result = 1;
	}

	printf("%lld\n", result);
}
*/

Measured memory_bytes: 1024
using System.Linq;
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            string[] line = Console.ReadLine().Trim().Split(' ');
            var a = Array.ConvertAll(line, int.Parse);
            var b = a.Sum();
            Console.WriteLine(a.Count(x => x * n <= b));
        }
    }
}


Measured memory_bytes: 19220
from math import ceil
def main():
    N = int(input())
    P = list(map(float,input().split()))
    f = [[0]*(N + 1) for _ in range(N + 1)]
    f[0][0] = 1 - P[0]
    f[0][1] = P[0]
    for i in range(1,N):
        p = P[i]
        f[i][0] = f[i - 1][0]*(1 - p)
        for j in range(max(1,ceil((N + 1)/2) - N + i - 3),i + 2):
            f[i][j] += p*f[i - 1][j - 1] + (1 - p)*f[i - 1][j]
    print(sum(f[N - 1][N //2 + 1:]))
    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 154356
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, starter, n) for (int i = (starter); i < (int)(n); i++)

int main(){
    int H,W;
    cin >> H>> W;
    vector<vector<char>> data(H,vector<char>(W));
    rep(i,H){
        rep(j,W){
            cin >> data.at(i).at(j);
        }
    }
    //checking
    vector<int> showW;
    rep(i,H){
        int checkW=0;
        rep(j,W){
            if (data.at(i).at(j)=='.'){
                checkW++;
            }
        }
        
        if (checkW != W) showW.push_back(i);
    }
   
    vector<int> showH;
    rep(i,W){
        int checkH=0;
        rep(j,H){
            if (data.at(j).at(i)=='.') {
                checkH++;
            }
        }
        if (checkH != H) showH.push_back(i);
    }
    for(int i : showW){
        for(int j :showH){
            cout << data.at(i).at(j);
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
       Scanner scan= new Scanner(System.in);

       int n=scan.nextInt();
       int Array[] =new int[n];
       for(int i=0;i<n;i++){
           Array[i]=scan.nextInt();
           }
       for(int j=n-1;j>0;j--){
           System.out.print(Array[j]+" ");
       }
        System.out.println(Array[0]);
    }
}



Measured memory_bytes: 26320
#include <stdio.h>

int main( void ) {
	int i, n, sum, elmNum[ 9 ] = { 5, 3, 3, 3, 3, 3, 4, 3, 4 };
	char ch[ 9 ][ 6 ] = { ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" }, key, tmp;

	scanf( "%d%*c", &n );

	for ( i = 0; i < n; i++ ) {
		for ( ; scanf( "%c", &key ), key != '\n';  ) {
			if ( key == '0' )
				continue;

			for ( sum = 0; scanf( "%c", &tmp ), tmp != '0'; sum++ ) ;
			putchar( ch[ key - '1' ][ sum % elmNum[ key - '1' ] ] );
		}

		putchar( '\n' );
	}

	return 0;
}

Measured memory_bytes: 568
import java.util.*;

public class Main {

  static int N;
  static int M;
  static boolean[][] graph;
  static boolean[] visited;

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    N = sc.nextInt();
    M = sc.nextInt();
    graph = new boolean[N][N];

    for (int i = 0; i < M; i++) {
      int a = sc.nextInt() - 1;
      int b = sc.nextInt() - 1;
      graph[a][b] = true;
      graph[b][a] = true;
    }

    sc.close();

    visited = new boolean[N];

    visited[0] = true;

    int count = dfs(0);

    System.out.println(count);

  }

  public static int dfs(int v) {

    boolean all = true;

    for (int i = 0; i < N; i++) {
      if (visited[i] == false) {
        all = false;
        break;
      }
    }

    if (all) {
      return 1;
    }

    int count = 0;

    for (int i = 0; i < N; i++) {

      if (graph[v][i] == false) {
        continue;
      }

      if (visited[i]) {
        continue;
      }

      visited[i] = true;

      count += dfs(i);

      visited[i] = false;

    }

    return count;

  }

}

Measured memory_bytes: 25172
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(ll i=0;i<N;++i)
typedef long long int ll;
ll INF = 1LL<<30;
const ll mod = 1e9+7;

int main(){
    ll N; cin >> N;
    vector<vector<char> > S(N+1,vector<char> (N+1));
    string s1,s2; cin >> s1 >> s2;
    rep(i,N) S[i][0] = s1[i];
    rep(i,N) S[i][1] = s2[i];

    ll ans = 1;
    rep(i,N){
        if(S[i][0]!=S[i][1]){
            if(i==0) ans *= 6;
            else if(S[i-1][0]==S[i-1][1]) ans *= 2;
            else ans *= 3;
            ++i;
        }else{
            if(i==0) ans *= 3;
            else if(S[i-1][0]==S[i-1][1]) ans *= 2;
        }
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto n = readln.chomp.to!(char[]).array.count('9');
  writeln(n?"Yes":"No");
}


Measured memory_bytes: 256
n,m = map(int,input().split())
ans = ["-1"]*n
flag = False

for _ in range(m):
    s,c = input().split()
    s = int(s)-1
    if ans[s] != "-1" and ans[s] != c:
        flag = True
        break
    ans[s] = c
if n != 1 and ans[0] == "0": flag = True

if flag:
    print(-1)
    exit()

if ans[0] == "-1":
    ans[0] = "0" if n == 1 else "1"
for i in range(1,n):
    if ans[i] == "-1": ans[i] = "0"

print("".join(ans))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <list>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

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

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int m, k;
	cin >> m >> k;

	// xor は a^bでできる

	// 同じ数が必ず2つ
	// その距離の間のすべてのXORはkとなる(自身も含む)

	// kとのXORが0となればよい

	// 自分自身も含むので、始点と終点のXORは0

	// 2^mのすべてが正しくなければならない

	// kの値と等しいaの他のaを任意に使ってkを作れればよい

	if (m == 0) {
		if (k == 0) {
			cout << 0 << " " << 0 << endl;
		}
		else {
			cout << -1 << endl;
		}
		return 0;
	}

	if (m == 1) {
		if (k == 0) {
			cout << 0 << " " << 0 << " " << 1 << " " << 1 << endl;
		}
		else {
			cout << -1 << endl;
		}
		return 0;
	}

	if ((1 << m) <= k) {
		cout << -1 << endl;
		return 0;
	}

	if (k == 0) {
		rep(bit, 1 << m) {
			cout << bit << " " << bit << " ";
		}
		cout << endl;
		return 0;
	}

	vector<pair<int, int>> ans;
	// 全部入れてしまう
	rep(bit, 1 << m) {
		ans.push_back({ min(bit, bit ^ k), max(bit, bit ^ k) });
	}

	sort(allof(ans));
	// これにより、重複成分を削除して、削除されて余った長さ分を調整する
	ans.erase(unique(allof(ans)), ans.end());
	// 全ペアを2つ2組で作って並べる
	// ex) (0 5) (1 4) (5 0) (4 1)

	for (int i = 0; i < ans.size(); i += 2) {
		cout << ans[i].first << " " << ans[i].second << " ";
		cout << ans[i + 1].first << " " << ans[i + 1].second << " ";
		cout << ans[i].second << " " << ans[i].first << " ";
		cout << ans[i + 1].second << " " << ans[i + 1].first << " ";
	}
	cout << endl;

	return 0;
}


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

using namespace std;

using ll = long long;

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

    string s;
    cin >> s;

    ll total = 0;
    ll w_num = 0;
    for (ll i = 0; i < s.length(); ++i) {
        if (s[i] == 'W') {
            total += i - w_num++;
        }    
    }

    cout << total << '\n';

    return 0;
}


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

void show(int A[],int N){
    for(int i = 0; i < N;i++){
        if(i > 0) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}

int selection(int A[],int N){
    int count = 0;
    for(int i=0; i < N-1; i++){
        int min = A[i];
        int index = i;
        for(int j = i+1; j < N; j++){
            if(A[j] < min){
                min = A[j];
                index = j;
            }
        }
        if(i != index){
            swap(A[i],A[index]);
            count++;
        }
    }
    return count;
}

int main(){
    int N;
    cin >> N;
    int A[N];
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    int ans = selection(A,N);
    show(A,N);
    cout << ans << endl;
}


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

#define ll long long
#define pb push_back
#define all(x) x.begin(), x.end()

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n, l;
	cin >> n >> l;
	string s[n];
	for(int i = 0; i < n; i++) {
		cin >> s[i];
	}
	sort(s, s + n);
	string ans;
	for(int i = 0; i < n; i++) {
		ans += s[i];
	}
	cout << ans;
}


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

int ctoi(char c) {
	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}

int main()
{

    int N, A, B;
    cin >> N >> A >> B;
    int sum = 0;
    int i = 1;
    while (i <= N) {
	    int tmp_sum = 0;
	    string i_str = std::to_string(i);
	    int keta = std::to_string(i).length();
	    for (int j=0; j < keta; j++) {
		tmp_sum += ctoi(i_str[j]);
	    }

	    if (A <= tmp_sum && tmp_sum <= B) {
		sum += i;
	    }

	    i += 1;
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
from sys import stdin


year, month, date = stdin.readline().rstrip().split(sep='/')

y = int(year)
m = int(month)
d = int(date)

heisei_y = 2019
heisei_m = 4
heisei_d = 30

if y < heisei_y:
  print('Heisei')
elif  (y == heisei_y) and (m < heisei_m):
  print('Heisei')
elif  ((y == heisei_y) and m == heisei_m) and (d <= heisei_d):
  print('Heisei')
else:
  print('TBD')



Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	final int MAX_V = 10;
	final int MAX_C = 100000;

	void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			int n = scan.nextInt();
			if (n == 0)
				break;
			int[][] d = new int[MAX_V][MAX_V];
			boolean[] v = new boolean[MAX_C];

			for (int i = 0; i < MAX_V; i++)
				for (int j = 0; j < MAX_V; j++)
					d[i][j] = MAX_C;
			for (int i = 0; i < MAX_V; i++)
				d[i][i] = 0;

			for (int i = 0; i < n; i++) {
				int a = scan.nextInt();
				int b = scan.nextInt();
				int c = scan.nextInt();
				d[a][b] = c;
				d[b][a] = c;
				v[a] = v[b] = true;
			}
			for (int k = 0; k < MAX_V; k++)
				for (int i = 0; i < MAX_V; i++)
					for (int j = 0; j < MAX_V; j++)
						d[i][j] = Math.min(d[i][j], d[i][k] + d[k][j]);

//			for (int i = 0; i < 5; i++) {
//				for (int j = 0; j < 5; j++)
//					System.out.print((d[i][j] != MAX_C ? d[i][j] : "X") + " ");
//				System.out.println();
//			}
			int ans_v = 0;
			int ans_c = MAX_C;
			for (int i = 0; i < MAX_V; i++) {
				int sum = 0;
				if (!v[i]) continue;
				for (int j = 0; j < MAX_V; j++) {
					if (d[i][j] != MAX_C)
						sum += d[i][j];
//					System.out.print((d[i][j] != MAX_C? d[i][j]:"X") + " ");
				}
//				System.out.println(": " + sum);
				if (ans_c > sum) {
					ans_c = sum;
					ans_v = i;
				}
			}
			System.out.println(ans_v + " " + ans_c);
		}
	}

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



Measured memory_bytes: 26692
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int R,G,B,N;
    cin>>R>>G>>B>>N;
    int ans=0;
    for(int i=0;i<=N;i+=R){
        for(int j=0;i+j<=N;j+=G){
            if((N-i-j)%B==0)ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3600
#include <stdio.h>

int main(int argc, char *args[])
{
	int a,b,c=0;

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

	if( (a < b) && (b < c) ) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 580
import math
import sys
from operator import itemgetter

# N, K = map(int, input().split())
# h = list(map(int, input().split()))
# S = [input() for _ in range(H)]
# X = [[0 for j in range(100)] for i in range(200)]


### input
N = int(input())
a = [0]*100001
b = [0]*100001
c = [0]*100001

for i in range(N):
	a[i], b[i], c[i] = map(int, input().split())


### solve
hpns = [[0 for j in range(100001)] for i in range(3)]

for i in range(1, N+1):
	hpns[0][i] = max(hpns[1][i-1], hpns[2][i-1]) + a[i-1]
	hpns[1][i] = max(hpns[2][i-1], hpns[0][i-1]) + b[i-1]
	hpns[2][i] = max(hpns[0][i-1], hpns[1][i-1]) + c[i-1]
	
print(max(hpns[0][N], hpns[1][N], hpns[2][N]))

Measured memory_bytes: 26908
from math import gcd

def lcm(a, b):
    return a // gcd(a, b) * b 

N, M = map(int, input().split())
As = list(map(int, input().split()))

rightmostbit = As[0] & -As[0]
for A in As[1:]:
    if rightmostbit != A & -A:
        print(0)
        exit() 


lcm_of_half_As = 1
for A in As:
    lcm_of_half_As = lcm(lcm_of_half_As, A //  2)
    if lcm_of_half_As > M:
        break

print((M // lcm_of_half_As + 1) // 2)

Measured memory_bytes: 20156
s = list(input())
ans = 0
cnt = 0
if len(s) % 2 != 0:
    print("No")
else:
    for i in range(int(len(s)/2)):
        if s[2*i] == "h" and s[2*i+1] == "i":
            cnt += 1
        #print(cnt)
    if cnt == int(len(s)/2):
        print("Yes")
    else:
        print("No")

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

/*----------------------------------------------*/

signed main(){
  int x;
  cin>>x;
  int ans=x/500*1000;
  x%=500;
  ans+=x/5*5;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <bitset>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)

int main(){
	int n,a,b,c,d;
	string str;
	cin >>  a>>b>>c>>d;
	cout <<min(a, b) + min(c, d);
}

Measured memory_bytes: 764
#include <iostream>
#include <bitset>
#include <string>

class Baseball {
    // 各ビットがそれぞれの塁のランナーの有無を表現する
    std::bitset<4> runners;
    u_int _out, _score;
public:
    Baseball() :_out(0), _score(0) {};
    ~Baseball() = default;
    void hit();
    void homerun();
    void out() { ++_out; }
    void change();
    bool is_change() { return _out == 3; }
    u_int score() { return _score; }
};

void Baseball::hit() {
    runners <<= 1;  // ランナーを1つずつ進める
    runners.set(0); // 一塁にランナーを置く
    // ホームインしたかどうか
    if (runners.test(3)) {
        ++_score;
        runners.reset(3);
    }
}

void Baseball::homerun() {
    _score += runners.count() + 1;
    runners.reset(); // ランナーをリセット
}

void Baseball::change() {
    _out = _score = 0;
    runners.reset();
}

int main(void) {
    u_int n;
    std::string event;
    Baseball game;

    std::cin >> n;
    for (u_int i = 0; i < n; ++i) {
        do {
            std::cin >> event;
            if ("HIT" == event) {
                game.hit();
            } else if ("HOMERUN" == event) {
                game.homerun();
            } else if ("OUT" == event) {
                game.out();
            }
        } while (!game.is_change());

        std::cout << game.score() << std::endl;
        game.change();
    }

    return 0;
}

Measured memory_bytes: 1208
def main35():
    num = int(input())
    if num == 98:
        print("Yes")
    for i in range(14):
        kazu = i*7
        while(kazu<=100):
            if kazu == num:
                print("Yes")
                return
            kazu = kazu + 4
    print("No")

if __name__ == "__main__":
    main35()

Measured memory_bytes: 3060
n, k = [int(i) for i in input().split()]

mod = 10 ** 9 + 7

ksum = 0
ans = 0

isum = 0
sum_list = [0 for _ in range(n+2)]
for i in range(n+2):
	isum += i  
	sum_list[i] = isum % mod


for i in range(k, n+2):
	vmax = (n * i - sum_list[i-1]) % mod
	vmin = sum_list[i-1] 
	ans += vmax - vmin + 1
	ans %= mod

print(ans)


Measured memory_bytes: 16916
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

//# include <ext/pb_ds/assoc_container.hpp>
//# include <ext/pb_ds/tree_policy.hpp>

//using namespace __gnu_pbds;
using namespace std;
 
//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 323;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int a[N];
vector < int > g[N];
int e[N][N];
int dp[N][N];
int ans[N];

int main () {
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= n; ++j)
		    if(i != j)
				e[i][j] = k + 1;
	for (int i = 1; i <= m; ++i) {
		int x, y, z;
		scanf("%d%d%d", &x, &y, &z);
		e[x][y] = e[y][x] = min(z, e[x][y]);
	}

	for (int k = 1; k <= n; ++k)
		for (int i = 1; i <= n; ++i) {
			for (int j = 1; j <= n; ++j)
				e[i][j] = min(e[i][j], e[i][k] + e[k][j]);
		}


	for (int s = 1; s <= n; ++s) {
		for (int i = 1; i <= n; ++i)
			dp[s][i] = (i!=s ? inf : 0);
		deque < pair<int,int> > dq;
		dq.pb({k, s});
		while(dq.size()) {
			int v = dq.front().second;
			int L = dq.front().first;

			dq.pop_front();

			for (int i = 1; i <= n; ++i) if (e[v][i] <= L) {
				if(dp[s][i] > dp[s][v]) {
					dp[s][i] = dp[s][v];
					dq.push_front({L - e[v][i], i});
				}
			}

			L = k;
			for (int i = 1; i <= n; ++i) if (e[v][i] <= L) {
				if(dp[s][i] > dp[s][v] + 1) {
					dp[s][i] = dp[s][v] + 1;
					dq.pb({L-e[v][i], i});
				}
			}
		}
	}

	int q;
	scanf("%d", &q);

	while(q--) {
		int s, t;
		scanf("%d%d", &s, &t);
		int &ans = dp[s][t];
		if(ans ==inf) ans = -1;
		printf("%d\n", ans);
	}

	       
	return Accepted;
}

// B...a

Measured memory_bytes: 1280
import sys
sys.setrecursionlimit(10**9)

def f(X):
    if X not in memo:
        if X == 1:
            memo[X] = 1
        else:
            memo[X] = 2 * f(X//2)
    return memo[X]

H = int(input())

memo = {}
ans = f(H)

print(ans*2-1)


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

int main() {
	int N, M, X, Y;
	cin >> N >> M >> X >> Y;

	int x_max = -101;
	int y_min = 101;

	for (int i = 0; i < N; i++) {
		int x_tmp;
		cin >> x_tmp;
		if (x_tmp > x_max)
			x_max = x_tmp;
	}

	for (int i = 0; i < M; i++) {
		int y_tmp;
		cin >> y_tmp;
		if (y_tmp < y_min)
			y_min = y_tmp;
	}

	if (y_min > x_max) {
		if (y_min > X && y_min <= Y)
			cout << "No War" << endl;
		else
			cout << "War" << endl;
	} else
		cout << "War" << endl;

	return 0;
		
}

Measured memory_bytes: 256
/*     *******************Bismillahir Rahmanir Rahim************************
                          MD. ASFAKUL GHANI!
                          *ProMAGFAT*!
 SECRET_warning :)->FAT   CSE-25!
                          JAHANGIRNAGAR UNIVERSITY!
                          Dhaka,Bangladesh!
*/

#include <bits/stdc++.h>
using namespace std;

#define           fasterIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#define           Im int main()
#define           ll long long
#define           sc scanf
#define           pf printf
#define           rn0 return 0
#define           rn return
#define           f0(i,n) for(ll i=0;i<n;i++)
#define           f1(i,n) for(ll i=1;i<=n;i++)
#define           f2(i,n) for(ll i=n-1;i>=0;i--)
#define           pi 2*acos(0.0)
#define           modulo 1000003
#define           dd double
#define           PI 3.14159265358979
#define           pi 2*acos(0.0)
#define           p_b push_back
#define           ps push


ll for_binarySearch(ll a,ll b,ll aa[],ll x){while(a<=b){ll mid=(a+b)/2;if(aa[mid]==x) return 1;else if(aa[mid] > x) b=mid-1;else a=mid+1;}return -1;}
ll for_gcd(ll a,ll b){if(a==0) return b;else return for_gcd(b%a,a);}
ll for_prime(ll x){for (ll i=2;i*i<=x;i++){if(x%i==0) return 0;}return 1;}
void for_swap(char *x,char *y){char temp;temp=*x;*x=*y;*y=temp;}
ll for_big_mod(ll b,ll p,ll m){if(p==0) return 1;else if(p%2==0){ll k=for_big_mod(b,p/2,m);return (k*k)%m;}else return ((b%m)*(for_big_mod(b,p-1,m)))%m;}
ll for_josephus(ll n,ll k){if(n==1) return 1;return (for_josephus(n-1,k)+k-1)%n+1;}
ll for_gcdExtended(ll a,ll b,ll *x,ll *y){if(a==0){*x=0;*y=1;return b;}ll x1,y1;ll gcd=for_gcdExtended(b%a,a,&x1,&y1);*x=y1-(b/a)*x1;*y=x1;return gcd;}

/*
void debug1()
{
    cout << "***" << endl;
}

void debug11(ll n)
{
    cout << n << endl;
}
*/

bool vis[1010];
ll prime[1010];
ll c;
void FAT_fp()
{
    vis[0] = vis[1] = 1;
    for (ll i = 4; i < 1010; i += 2) vis[i] = 1;
    prime[c++] = 2;
    for (ll i = 3; i < 1010; i += 2){
        if (!vis[i]){
            prime[c++] = i;
            for (ll j = (i*i); j < 1010; j += (i+i)) vis[j] = 1;
        }
    }
}

Im
{
    /*#ifdef FAT
       freopen("input.txt","w",stdin);
    #endif // FAT*/

    fasterIO;

    FAT_fp();

    ll n;
    cin>>n;
    ll a1[n+2];
    ll mx = 0;
    for (ll i = 0; i < n; i += 1){
        cin>>a1[i];
        mx = max(mx,a1[i]);
    }
    ll p = 1;
    for (ll i = 0; i < c; ){
        ll c1 = 0;
        for (ll j = 0; j < n; j += 1){
            if (a1[j] % prime[i] == 0){
                c1 += 1;
            }
        }
       if (c1>1){
        p *= prime[i];
         for (ll j = 0; j < n; j += 1){
            if (a1[j]%prime[i] == 0){
                a1[j] /= prime[i];
            }
         }
       }
       else i+=1;
    }

    for (ll i = 0; i < n; i += 1){
        if (a1[i] > 1) p *= a1[i];
    }

    cout << p << endl;

    //main();

    rn0;
}

Measured memory_bytes: 3144
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

int c;
int n,s;

void dfs(int flor,bool used[10],int sum,int bef){
    if(flor>=n){
        if(sum==s)c++;
    }
    else{
        for(int i=bef+1;i<10;i++){
            if(used[i]==false){
                used[i]=true;
                dfs(flor+1,used,sum+i,i);
                used[i]=false;
            }
        }
    }
}


int main() {
    while(cin>>n>>s){
        if(n==0 && s==0)break;
        
        c=0;
        bool a[10]={};
        dfs(0,a,0,-1);
        cout<<c<<endl;
    }
    
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    while (n != 0) {
        int sum = n;
        for (int i = 0; i < 9; i++) {
            int t;
            cin >> t;
            sum -= t;
        }
        cout << sum << "\n";
        cin >> n;
    }
    return 0;
}


Measured memory_bytes: 3076
#include <stdio.h>

int main(void) {
	int H, W, i, j;
	
	while(1){
		scanf("%d %d", &H, &W);
		
		if(H==0 && W==0)
		break;
		
		for(i=1;i<=W;i++)
		{
		printf("#");
		}
		
		putchar('\n');
		
		for(j=1;j<=H-2;j++)
		{
		 putchar('#');
		 
		 for(i=2;i<=W-1;i++)
		 printf(".");
		 
		 putchar('#');
		 
		 putchar('\n');
		}
		 
		 for(i=1;i<=W;i++)
		 {
		 	printf("#");
		 }
		 
		 putchar('\n');
		 putchar('\n');
		
	}
	
	return 0;
}

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

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

int main(){
  int64_t x;
  cin >> x;

  vector<int64_t> gojou(1000);
  for(int i=0; i<1000; i++){
    gojou.at(i) = pow(i, 5);
  }

  //cout << sosuu.at(1);

  int64_t a, b;

  for(int i=0; i<1000; i++){
    for(int j=0; j<1000; j++){
      int64_t sa = gojou.at(i) - gojou.at(j);
      int64_t wa = gojou.at(i) + gojou.at(j);

      if(sa!=0&&x%sa == 0){
        a = i;
        b = j;
        break;
      }
      if(wa!=0&&x%wa == 0){
        a = i;
        b = (-1) * j;
        break;
      }
    }
  }

  cout << a << " " << b;
}


Measured memory_bytes: 4108
A, V = list(map(int, input().split()))
B, W = list(map(int, input().split()))
T = int(input())

abs_BA = abs(B-A)
sub_VW = V - W

if sub_VW <= 0:
  print("NO")
elif abs_BA <= T * sub_VW:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 9160
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

func main() {
	prices := readPrices()

	n := len(prices)

	margin := -int(math.Pow(10, 9))
	//minv := prices[0]
	minv := prices[1]

	//for j := 1; j < n; j++ {
	for j := 2; j < n; j++ {
		if prices[j]-minv > margin {
			margin = prices[j] - minv
		}
		if prices[j] < minv {
			minv = prices[j]
		}
	}

	fmt.Println(margin)
}

func readPrices() []int {
	var prices []int

	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		text := scanner.Text()
		if text == "" {
			break
		}
		i, err := strconv.Atoi(text)
		checkErr(err)
		prices = append(prices, i)
	}

	err := scanner.Err()
	checkErr(err)

	return prices
}

func checkErr(e error) {
	if e != nil {
		log.Fatalln(e)
	}
}



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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

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

  for (int i = 0; i < s.length(); i = i + 2) cout << s[i];

  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>

void boubleSort(long int x[4]) {
  for (int i = 0; i < 3; i++) {
    for ( int j = 0; j < 3-i; j++) {
      if (x[j] > x[j+1]) {
        int tmp = x[j];
        x[j] = x[j+1];
        x[j+1] = tmp;
      }
    }
  }
}

int main(void) {
  long int Q, H, S, D, N;
  scanf("%ld %ld %ld %ld", &Q, &H, &S, &D);
  scanf("%ld", &N);
  
  long int values[4] = {8*Q, 4*H, 2*S, D};
  boubleSort(values);
  long int a, b, c, d;   //a<b<c<d 2L単位の値段
  a = values[0];
  b = values[1];
  c = values[2];
  d = values[3];
  
  //8Q, 4H, 2Sが最安値なら全てそれで購入できる
  if (a != D) printf("%ld", (N*a)/2);
  else {
    //Dが最安値ならできるだけDで買い、最後の1Lのみどれかで買う
    printf("%ld", (N/2)*a+(N%2)*b/2);
  }
  
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(){
  int k, a, b, i=1;
  scanf("%d", &k);
  scanf("%d %d", &a, &b);
  
  do {
    if ((a <= i*k) && (i*k <= b)){
      printf("OK\n");
      return 0;
    }
    i++;
  } while (i*k <= b);
    
  printf("NG\n");
  return 0;
}


Measured memory_bytes: 1644
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
def LILI(n): return [LI() for _ in range(n)]
INF = 10 ** 18
MOD = 10 ** 9 + 7

'''MEMO:

'''

def main(): 
    N = II()
    K = II()

    keta_N = len(str(N))

    ans = 0

    # 1桁の数
    if K == 1: ans += min(9, N)
    else: pass
    if N < 10:
        print(ans)
        return

    # 2桁の数
    if K == 1:
        for i in range(10, 100, 10):
            if i <= N:
                ans += 1
    elif K == 2:
        for i in range(10, 100, 1):
            if i%10 == 0:
                continue
            elif i <= N:
                ans += 1
    else: pass
    if N < 100:
        print(ans)
        return

    # 3桁以上, keta_N桁未満
    if K == 1:
        ans += 9 * (keta_N - 3)
    else:
        for keta in range(3, keta_N):
            if K == 2:
                ans += 9 * (keta-1) * 9
            else:
                ans += (9 * (keta-1) * (keta-2) * 9 * 9)//2

    # keta_N桁の数
    # すべて生成しても 10**5 個程度なので、すべて生成して N と比較してみる。
    if K == 1:
        for i in range(1, 10):
            if i * 10**(keta_N - 1) <= N:
                ans += 1

    elif K == 2:
        for i in range(1, 10):
            for j in range(1, 10):
                for k in range(0, keta_N-1):
                    if i * 10**(keta_N - 1) + j * 10**k <= N:
                        ans += 1

    elif K == 3:
        for i in range(1, 10):
            if i < int(str(N)[0]):  # 10**7 のループなので愚直で回るはずだけれど、ちょっと高速化。
                ans += ((keta_N - 1) * (keta_N - 2) * 9 * 9)//2
                continue
            elif i > int(str(N)[0]):
                break
            for j in range(1, 10):
                for k in range(0, keta_N-1):
                    for l in range(1, 10):
                        for m in range(0, keta_N-1):
                            if k <= m: continue
                            if i * 10**(keta_N - 1) + j * 10**k + l * 10**m <= N:
                                ans += 1

    print(ans)

main()

Measured memory_bytes: 42716
def main():
    h, w = map(int, input().split())
    s = [list(input()) for _ in range(h)]
    delta = [[0, 1], [1, 0], [0, -1], [-1, 0]]
    black_count = 0
    for i in range(h):
        for j in range(w):
            if s[i][j] == "#":
                black_count += 1
                tmp = 0
                for dy, dx in delta:
                    new_y = dy + i
                    new_x = dx + j
                    if 0 <= new_y < h and 0 <= new_x < w:
                        if s[new_y][new_x] == "#":
                            tmp += 1
                if tmp > 0:
                    black_count -= 1
    print("Yes" if black_count == 0 else "No")


if __name__ == '__main__':
    main()



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

void solve() {
  string s; cin >> s;
  int now = 0, ans = 0;
  for(auto &c : s) {
    if(c == 'R') ans = max(ans, ++now);
    else now = 0;
  }
  cout << ans << endl;
}

signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  solve();
  return 0;
}


Measured memory_bytes: 3676
using System;

public class Program{
    public static void Main(){
      string[] a = Console.ReadLine().Split(' ');
      var takHP = int.Parse(a[0]);
      var takAt = int.Parse(a[1]);
      var aoHP = int.Parse(a[2]);
      var aoAt = int.Parse(a[3]);
      //System.Console.WriteLine(a[0]);
      
      while(takHP > 0 && aoHP > 0)
      {
        aoHP -= takAt;
        if(aoHP <= 0)
        {
          System.Console.WriteLine("Yes");
          break;
        }
        
        takHP -= aoAt;
        if(takHP <= 0)
        {
          System.Console.WriteLine("No");
          break;
        }    
      }
    }
}




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

using namespace std;

int n;
int pri[101][101], p[101] = {};

int creat(int t)
{
	int p = 2, i = t;
	while (i >= p * p)
		if (i % p == 0)
		{
			pri[t][p]++;
			i /= p;
		}
		else
			p++;
	pri[t][i]++;
	return 0;
}

int cnt(int t)
{
	int ret = 0;
	for (int i = 0; i <= 100; i++)
		if (t - 1 <= p[i])
			ret++;
	return ret;
}

int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
		creat(i);
	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= 100; j++)
			p[j] += pri[i][j];
	cout << cnt(75) + cnt(25) * (cnt(3) - 1) + cnt(15) * (cnt(5) - 1) + cnt(5) * (cnt(5) - 1) * (cnt(3) - 2) / 2 << endl;

	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);
		
		while(true){
			String str = sc.nextLine();
			String[] nums = str.split(" ");
			int[] a = new int[nums.length];
			int ace=0, score=0;
			boolean flag = true;
			
			if(nums[0].equals("0")) break;
			
			for(int i=0; i<nums.length; i++) {
				a[i] = Integer.parseInt(nums[i]);
				if(a[i] == 1) ace++;
				else if(a[i]>9 && a[i]<14) score+=10;
				else score+=a[i];
				
				if(score>21) {
					score=0;
					flag = false;
					break;
				}
			}
			
			if(score +1*ace > 21) {
				flag = false;
				score=0;
			}
			
			int tt = score;
					
			if(flag){
				for(int i=0; i<=ace; i++){
					if(tt + 1*i + 11*(ace-i) <= 21) {
						score = tt + 1*i + 11*(ace-i);
						break;
					} 	
				}
			}
		
			System.out.println(score);
		}	

	}
}

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

int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  vector<int>sumW(n+1,0);
  for(int i=0;i<n;i++){
    if(s[i]=='W'){
      sumW[i+1]=sumW[i]+1;
    }
    else{
      sumW[i+1]=sumW[i];
    }
  }
  vector<int>sumE(n+1,0);
  for(int i=0;i<n;i++){
    if(s[i]=='E'){
      sumE[i+1]=sumE[i]+1;
    }
    else{
      sumE[i+1]=sumE[i];
    }
  }
  int minn=1e9;
  for(int i=0;i<n+1;i++){
    minn=min(minn,(sumW[i]+sumE[n]-sumE[i]));
  }
  cout<<minn<<endl;
  
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
 
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; }
 
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;
 
const vector<int> dx = {1, 1,  1, 0,  0, 0, -1, -1, -1};
const vector<int> dy = {1, 0, -1, 1, -1, 0,  1,  0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;
 
const int MAX = 1000000;
const int MOD = 1000000007;
 
int main(){
 int n, m;
 cin >> n >> m;
 set<int>st;
 dsu d(n);
 rep(i, 0, m){
     int p, q;
     cin >> p >> q;
     d.merge(p-1,q-1);
 }
 rep(i, 0, n){
     int r = d.leader(i);
     st.insert(r);
 }
 cout << (int)st.size()-1 << endl;
}

Measured memory_bytes: 7780
import sys
input = sys.stdin.readline

N = int(input())
a = list(map(int, input().split()))
a.sort()
m, n = max(a), min(a)
if n * 2 == m:
    cnt = [0] * (m - n + 1)
    for i in range(N):
        cnt[a[i] - n] += 1
    if cnt[0] == 1 and all(c >= 2 for c in cnt[1:]):
        print('Possible')
    else:
        print('Impossible')
elif n * 2 - 1 == m:
    cnt = [0] * (m - n + 1)
    for i in range(N):
        cnt[a[i] - n] += 1
    if cnt[0] == 2 and all(c >= 2 for c in cnt[1:]):
        print('Possible')
    else:
        print('Impossible')
else:
    print('Impossible')


Measured memory_bytes: 38256
#include <iostream>
#include <vector>

using namespace std;

int main() {
    while(true) {
        int N, M;
        cin >> N >> M;
        if(!N && !M) break;

        vector<int> v(N);
        int pos = 0;
        for(int i = 0; i < N; ++i) {
            cin >> v[i];
        }
        vector<int> m(M);
        for(int i = 0; i < M; ++i) {
            cin >> m[i];
        }
        for(int i = 0; i < M; ++i) {
            pos += m[i];
            if(pos >= N-1) {
                cout << (i+1) << endl;
                break;
            }
            pos += v[pos];
            if(pos >= N-1) {
                cout << (i+1) << endl;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>

int main(int argc, const char * argv[]) {
    char str[1001],cmd[10],c,s[1001];
    int i,j,q,a,b;
    
    scanf("%s",str);
    scanf("%d",&q);
    
    for(i=0;i<q;i++){
        scanf("%s",cmd);
        //print??¨??\????????????
        if(strcmp(cmd,"print") == 0){
            scanf("%d %d",&a,&b);
            for(j=a;j<=b;j++){
                printf("%c",str[j]);
            }
            printf("\n");
        }
        //reverse??¨??\????????????
        else if(strcmp(cmd,"reverse") == 0){
            scanf("%d %d",&a,&b);
            while(a<b){
                c = str[a];
                str[a] = str[b];
                str[b] = c;
                a++;
                b--;
            }
        }
        //replace??¨??\????????????
        else if(strcmp(cmd,"replace") == 0){
            scanf("%d %d %s",&a,&b,s);
            for(j=0;j<b-a+1;j++){
                str[j+a] = s[j];
            }
        }
    }
    return 0;
}

Measured memory_bytes: 576
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (ql:quickload '(:cl-debug-print :fiveam))
  #-swank (set-dispatch-macro-character #\# #\> (lambda (s c p) (declare (ignore c p)) (read s nil (values) t))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)
#-swank (disable-debugger) ; for CS Academy

;; BEGIN_INSERTED_CONTENTS
(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body
;;;
;;; Arithmetic operations with static modulus
;;;

(defmacro define-mod-operations (&optional (divisor 1000000007))
  `(progn
     (defun mod* (&rest args)
       (reduce (lambda (x y) (mod (* x y) ,divisor)) args))

     (sb-c:define-source-transform mod* (&rest args)
       (if (null args)
           1
           (reduce (lambda (x y) `(mod (* ,x ,y) ,',divisor)) args)))

     (defun mod+ (&rest args)
       (reduce (lambda (x y) (mod (+ x y) ,divisor)) args))

     (sb-c:define-source-transform mod+ (&rest args)
       (if (null args)
           0
           (reduce (lambda (x y) `(mod (+ ,x ,y) ,',divisor)) args)))

     (define-modify-macro incfmod (delta divisor)
       (lambda (x y divisor) (mod (+ x y) divisor)))

     (define-modify-macro decfmod (delta divisor)
       (lambda (x y divisor) (mod (- x y) divisor)))))

(define-mod-operations)

(defun main ()
  (declare #.OPT
           (inline digit-char-p))
  (let* ((s (coerce (read-line) 'simple-base-string))
         (n (length s))
         (dp (make-array (list (+ n 1) 13) :element-type 'uint32 :initial-element 0)))
    (declare (simple-base-string s)
             (uint31 n))
    (setf (aref dp 0 0) 1)
    (do ((pos 0 (+ pos 1))
         (base 1 (mod (* base 10) 13)))
        ((= pos n))
      (declare (uint32 pos base))
      (if (char= #\? (aref s (- n pos 1)))
          (dotimes (d 10)
            (let ((num (mod (* d base) 13)))
              (dotimes (m 13)
                (incfmod (aref dp (+ pos 1) (mod (+ m num) 13))
                         (aref dp pos m)
                         +mod+))))
          (let* ((d (digit-char-p (aref s (- n pos 1))))
                 (num (mod (* d base) 13)))
            (dotimes (m 13)
              (setf (aref dp (+ pos 1) (mod (+ m num) 13))
                    (aref dp pos m))))))
    (println (aref dp n 5))))

#-swank (main)


Measured memory_bytes: 23012