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

int main() {

  int N;
  cin >> N;

  vector<vector<pair<int,int>>> xy(N);
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    for (int j = 0; j < A; j++) {
      int x, y;
      cin >> x >> y;
      xy[i].push_back(make_pair(x,y));
    }
  }


  int answer = 0;

  for(int bits = 1; bits < (1 << N); bits++) {
  
    // bit全探索を文字列で作る
    string bit = "";
    
    int count = 0;

    for (int i = 0; i < N; i++) {
      if (bits & (1 << i)) {
        bit += '1';
        count++;
      } else {
        bit += '0';
      }
    }

    bool flg = true;

    for (int i = 0; i < N; i++) {
      
      if (bit[i] - '0' == 1) {
        for (int j = 0; j < xy[i].size(); j++) {
          if (bit[xy[i][j].first - 1] - '0' != xy[i][j].second) {
            flg = false;
            break;
          }
        }
      } 

      if (!flg) {
        break;
      }

    }

    if (flg) {
      answer = max(count, answer);
    }

  }

  cout << answer << endl;
  
}


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

using namespace std;

int main(){
  int h,w; cin >> h >> w;
  unsigned long long int ans=0;
  for(int i=0;i<h;++i){
    for(int j=0;j<w;++j){
      long long a; cin >> a;
      ans+=a*(i+1)*(j+1)*(h-i)*(w-j); //左上のどれかが右下のどれかを選ぶ個数
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3076
y, m, d = map( int, input().split("/"))
ans = "TBD"
if y <= 2018:
    ans = "Heisei"
elif y == 2019:
    if m <= 3:
        ans = "Heisei"
    elif m == 4:
        if d <= 30:
            ans = "Heisei"
print( ans)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
#define task "tst"
using namespace std;
const ll N = 3e3 + 9;
const ll mod = 1e9 + 7;
typedef pair<ll,ll> LL;
ll x,y;
ll n,d;
ll cal(ll x,ll y){
    ll t = x*x + y*y;
    ll p = sqrt(x*x + y*y);
    if (p*p == t) return p;
    return p + 1;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if (fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        //freopen(task".out", "w", stdout);
    }
    ll cnt = 0;
    cin>>n>>d;
    while(n--){
        cin>>x>>y;
        if (cal(x,y) <= d) cnt++;
    }
    cout<<cnt;
}



Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <vector>
#include <ios>
#include <iomanip>
#include <stack>
#include <queue>
#include <algorithm>

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

using namespace std;

const int INF = 100000000;

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

  int num = 1;
  for (int i = 0; i < n; i++) {
    num += (num >= k) ? k : num;
  }
  cout << num << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

long min(long *a, int n) {
    long min = a[0];
    for (int i = 1; i < n; i++) {
        if (min > a[i]) {
            min = a[i];
        }
    }
    return min;
}

long max(long *a, int n) {
    long max = a[0];
    for (int i = 1; i < n; i++) {
        if (max < a[i]) {
            max = a[i];
        }
    }
    return max;
}

int main(void) {
    int n;
    long a[100];

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

    printf("%ld\n", max(a, n) - min(a, n));
    return 0;
}

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

#define PI 3.14159265358979323846264338327950L

using namespace std;

int main() {
	int a,b,h,m;
	cin>>a>>b>>h>>m;

	double angle = 6.0 * (5.0 * h + m / 12.0 - m);
	double c2 = a*a + b*b - 2*a*b*cos(PI * angle / 180);

	printf("%.12lf\n", sqrt(c2));
	
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end(), greater<int>());

    int alice = 0, bob = 0;
    for(int i = 0; i < a.size(); i++){
        if(i%2 == 0){
            alice += a[i];
        }else{
            bob += a[i];
        }
    }
    cout << alice - bob << endl;
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
using namespace std;
int main()
{
  int H, W;
  cin >> H >> W;
  char S[H][W];
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
      cin >> S[i][j];
  }
  int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
  int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      if (S[i][j] == '.')
      {
        int count = 0;
        for (int d = 0; d < 8; d++)
        {
          int ny = i + dy[d];
          int nx = j + dx[d];
          if (0 <= ny && ny < H && 0 <= nx && nx < W && S[ny][nx] == '#')
            count++;
        }
        cout << count;
      }
      else
        cout << S[i][j];
    }
    cout << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>

using namespace std;

int main(void) {
	
	int n;
	cin >>n;
	int a[n],i;
	for (i=0 ; i<n ; i++) {
		cin >>a[i];
	}
	
	sort(a,a+n);
	int p,q=a[0],r;
	for (i=1 ; i<n ; i++) {
		p=a[i];
		while (1) {
			r=p%q;
			if (r==0) break;
			p=q;
			q=r;
		}
	}
	
	cout <<q <<endl;
	
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
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; }
//constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;
const long double PI = acos((long double)(-1));

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

void solve() {
    int n, l; cin >> n >> l; if (n == 0) exit(0);
    vector<int> d(n), p(n);
    for (int i = 0; i < n; i++) {
        char c; cin >> c >> p[i];
        if (c == 'R') d[i] = 1;
        else d[i] = -1;
    }
    int lv = 0;
    int lp = p[0];
    for (int t = 1;; t++) {
        for (int i = 0; i < n; i++) {
            p[i] += d[i];
        }
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                if (p[i] == p[j]) {
                    d[i] *= -1;
                    d[j] *= -1;
                }
            }
        }

        bool ok = true;
        for (int i = 0; i < n; i++) {
            if (p[i] > 0 and p[i] < l) {
                ok = false;

            }
        }
        if (ok) {
            cout << t << " "<< lv + 1 <<"\n";
            return;
        }
        else {
            lv = -1;
            lp = inf;
            for (int i = 0; i < n; i++) {
                if (p[i] > 0 and p[i] < l) {
                    if (chmin(lp, p[i])) {
                        lv = i;
                    }
                    else if (lp == p[i] and d[i] == -1) lv = i;
                }
            }
        }
       
    }
}

int main()
{

    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    

	int kkt = 89;
	while (kkt) {
		solve();
	}
    return 0;
}


Measured memory_bytes: 3224
// 隣り合うのをL以上になるようにくっつけていきたいね 一箇所でもみつければあとは隣接してるのをくっつけていきたいね
// -> てんでダメでした
// よくよくみたらおかしいところ 端から切り離す感じにするようにした
// -> なぜかWA
// 3つ並んでる総和がL未満なら見込み0ってことか
// -> そういうことではない

package main

import "fmt"

func main() {
	var N, L int
	fmt.Scan(&N, &L)
	A := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&A[i])
	}

	idx := -1
	for i := 1; i < N; i++ {
		if A[i-1]+A[i] >= L {
			idx = i
			break
		}
	}

	if idx == -1 {
		fmt.Println("Impossible")
		return
	}
	P := []int{}
	for i := N - 1; i > idx; i-- {
		P = append(P, i)
	}
	for i := 1; i < idx; i++ {
		P = append(P, i)
	}
	P = append(P, idx)
	fmt.Println("Possible")
	for _, p := range P {
		fmt.Println(p)
	}
}

// 10 4
// 2 1 1 4 2 3 1 2 1 2

// 5 3
// 1 1 3 1 1

// 5 5
// 1 1 3 2 1


Measured memory_bytes: 8000
##B
S = str(input())
N = int(len(S))
##print(N)
S1 = S[0:(N-1)//2]
N1 = len(S1)
S2 = S[(N+3)//2-1:N]
N2 = len(S2)

if S1 == S2:
    if S1 == S1[::-1]:
        if S2 == S2[::-1]:
            print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
package main

import (
	"fmt"
	"strings"
)

func main() {
	var N, K int
	fmt.Scan(&N, &K)
	var S string
	fmt.Scan(&S)
	fmt.Println(S[:K-1] + strings.ToLower(string(S[K-1])) + S[K:])
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		char[] str = scn.nextLine().toCharArray();
		boolean a=false,b=false,c=false;
		for(int i = 0;i < 3;i++) {
			if(str[i] == 'a')a = true;
			if(str[i] == 'b')b = true;
			if(str[i] == 'c')c = true;
		}
		System.out.println(a&&b&&c?"Yes":"No");
	}

}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define per(i,s,n) for(int i=n-1;i>=s;i--)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  int n,k;
  cin>>n>>k;
  int a;
  int c=0;
  rep(i,n){
    cin>>a;
    if(a>=k) c++;
  }
  
  cout<<c<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#define llong long long
#define ldouble long double
#define uint unsigned int
#define ullong unsigned long long
#define udouble unsigned double
#define uldouble unsigned long double
#define modinc(x) {if(x>=P) x-=P;}
#define pii pair<int,int>
#define piii pair<pair<int,int>,int>
#define piiii pair<pair<int,int>,pair<int,int> >
#define pli pair<llong,int>
#define pll pair<llong,llong>
#define Memset(a,x) {memset(a,x,sizeof(a));}
using namespace std;

const int N = 500;
int a[N+2][N+2];
int n,m,nn,mm;

int main()
{
	scanf("%d%d%d%d",&n,&m,&nn,&mm);
	llong s = 0ll;
	for(int i=1; i<=n; i++)
	{
		for(int j=1; j<=m; j++)
		{
			if(i%nn==0 && j%mm==0)
			{
				a[i][j] = -nn*mm*1000+999;
			}
			else a[i][j] = 1000;
			s += (llong)a[i][j];
		}
	}
	if(s<=0) printf("No");
	else
	{
		puts("Yes");
		for(int i=1; i<=n; i++)
		{
			for(int j=1; j<=m; j++)
			{
				printf("%d ",a[i][j]);
			}
			if(i!=n) puts("");
		}
	}
	return 0;
}

Measured memory_bytes: 2432
import java.util.*;
import java.math.*;

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

class Solver {

    private int digitSum(int v) {
        int sum = 0;
        while (v > 0) {
            sum += (v % 10);
            v /= 10;
        }
        return sum;
    }

    public void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();

        int sum = 0;
        for (int i = 1; i <= N; i++) {
            int s = digitSum(i);
            if (s >= A && s <= B) {
                sum+=i;
            }
        }
        System.out.println(sum);

        return;
    }

}

Measured memory_bytes: 21972
N = int(input())
B = list(map(int, input().split()))
A = []
A.append(B[N-2])
for i in reversed(range(1, len(B))):
    if B[i]>=B[i-1]:
        A.append(B[i-1])
    else:
        A.append(B[i])

A.append(B[0])

print(sum(A))


Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections.Generic;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var rdx = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var r = rdx[0];
            var d = rdx[1];
            var x = rdx[2];
            var xLast = x;

            Func<int, int> F = item=>r*item-d;

            for(int i=1;i<=10;i++)
            {
                xLast = F(xLast);
                Console.WriteLine(xLast);
            }
        }
    }
}


Measured memory_bytes: 11220
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(m)]

for i in range(10 ** (n - 1) - (n == 1), 10 ** n):
    is_ok = True
    for s, c in sc:
        s -= 1
        if int(str(i)[s]) != c:
            is_ok = False
    if is_ok:
        print(i)
        exit()
print(-1)

Measured memory_bytes: 9112
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>

#define bigone t.size() + 1
#define bangone b.size() + 1
#define big t.size()
#define bang b.size()
#define USA 1000000007

using namespace std;

long long P[10000][10000];

int main() {
	string t, b;
	cin >> t >> b;
	//P=プロフェッショナル

	for (int i = 0; i < bang + 1; i++) {
		P[0][i] = 0;
	}

	for (int i = 0; i < big + 1; i++) {
		P[i][0] = 1;
	}

	for (int i = 1; i < big + 1; i++) {
		char ti = t.at(i - 1);
		for (int j = 1; j < bang + 1; j++) {
			char bj = b.at(j - 1);
			if (j <= i) {
				if (ti == bj) {
					P[i][j] = (P[i - 1][j - 1] + P[i - 1][j]) % USA;
				}
				else {
					P[i][j] = P[i - 1][j];
				}
			}
			else {
				P[i][j] = 0;
			}
		}
	}
	cout << P[big][bang] << endl;
}


Measured memory_bytes: 14896
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    vector<int> b(m); rep(i,m) cin >> b[i];

    vector<vector<int>> a(n, vector<int> (m,0));

    rep(i,n){
        rep(j,m){
            cin >> a[i][j];
        }
    }

    ll ans = 0;

    rep(i,n){
        ll jud = c;
        rep(j,m){
            jud += a[i][j]*b[j];
        }
        if(jud >0) ans++;
    }

    dunk(ans);
}


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

using namespace std;

int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;

    int select=0;
    while(a>0 && c>0){
        if(select == 0){
            select=1;
            c-=b;
        }
        else{
            select=0;
            a-=d;
        }
    }
    if(a<=0) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 3508
#include<iostream>
using namespace std;
int main(){
  int i,m=0;
  int d[100]={};
  while(cin >> i) d[i-1]++;
  for(i=0;i<100;i++) m=max(m,d[i]);
  for(i=0;i<100;i++) if(d[i]==m) cout << (i+1) << endl; 
}


Measured memory_bytes: 3084
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

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

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)

#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int N, A, B, C, D;

const int MAX_N = 10000;
ll fact[MAX_N + 1], fact_inv[MAX_N + 1];

ll mod_pow(ll x, ll n, ll p) {
  if(n == 0) return 1;
  ll res = mod_pow(x * x % p, n / 2, p);
  if(n & 1) res = res * x % p;
  return res;
}

void init(ll n, ll p) {
  fact[0] = 1;
  for(int i = 0; i < n; i++) {
    fact[i + 1] = fact[i] * (i + 1) % p;
  }
  fact_inv[n] = mod_pow(fact[n], p - 2, p);
  for(int i = n - 1; i >= 0; i--) {
    fact_inv[i] = fact_inv[i + 1] * (i + 1) % p;
  }
}


int main(){
  cin >> N >> A >> B >> C >> D;

  init(10000, MOD);

  ll dp[B + 1][N + 1];
  REP(i, A) REP(j, N + 1) dp[i][j] = 0;
  REP(i, B) dp[i][0] = 1;
  for(int i = A; i <= B; i++) {
    REP(j, N + 1) {
      dp[i][j] = dp[i - 1][j];
      for(int k = C; k <= min(j / i, D); k++) {
        dp[i][j] += dp[i - 1][j - i * k] * fact[N - j + i * k] % MOD * fact_inv[N - j] % MOD * mod_pow(fact_inv[i], k, MOD) % MOD * fact_inv[k] % MOD;
        dp[i][j] %= MOD;
      }
    }
  }

  cout << dp[B][N] << endl;

  return 0;
}


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

int main(){
	int n;	cin >> n;
	while(n--){
		int i,eq1,eq2;
		string ret = "NA";
		
		string s; cin >> s;
		if(s.substr(0,3) == ">'="){
			i = 2;
			
			eq1 = 0;
			while(s[i] == '=' && i < s.length() )i++,eq1++;
			if(s[i] != '#')goto label;
			
			i++; eq2 = 0;
			while(s[i] == '=' && i < s.length() )i++,eq2++;
			
			if(i == s.length()-1 && s[i] == '~' && eq1 == eq2)
				ret = "A"; 
		}else if(s.substr(0,4) == ">^Q="){
			for(i=2;i+1<s.length()-2;i+=2){
				if(s[i] == 'Q' && s[i+1] == '='){}
				else goto label;
			}
			if(s[s.length()-1] == '~' && s[s.length()-2] == '~' && s[s.length()-3] == '=' && s[s.length()-4] == 'Q')
				ret = "B";
			
		}
		label:;
		cout << ret << endl;
		
		
	}
}

Measured memory_bytes: 0
module Main where

import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
    [n, m] <- fmap read . words <$> getLine :: IO [Int]
    let ans = case sort [n, m] of
            [1, 1] -> 1
            [1, 2] -> 0
            [1, b] -> b - 2
            [2, _] -> 0
            [s, t] -> (s - 2) * (t - 2)
    print ans

Measured memory_bytes: 508
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n)cin >> a[i];
    sort(ALL(a));
    ll ans = 1;
    rep(i,n){
        if(a[i] != 0 && a[i]<=(ll)1e18/ans){
            ans *= a[i];
        }else if(a[i] == 0){
            cout << 0 << endl;
            return 0;
        }else{
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}

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

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

		if((a+b) < 10)
			System.out.println(a+b);
		else
			System.out.println("error");
	}
}

Measured memory_bytes: 21844
def dfs(x, y):
    for dx in [-1, 0, 1]:
        for dy in [-1, 0, 1]:
            if abs(dx) + abs(dy) == 2 or abs(dx) + abs(dy) == 2:
                continue
            next_x, next_y = x + dx, y + dy
            if 0 <= next_x < H and 0 <= next_y < W and isVisited[next_x][next_y] == 0 and tile[next_x][next_y] == '.':
                isVisited[next_x][next_y] = 1
                dfs(next_x, next_y)
                
                

while True:
    W, H = map(int, raw_input().split())
    if W == 0 and H == 0: break
    tile = [raw_input() for _ in range(H)]
    ans = 0
    isVisited = [[0]*W for _ in range(H)]
    for cnt, t in enumerate(tile):
        if '@' in t:
            sx = cnt
            sy = t.index('@')
            break
    isVisited[sx][sy] = 1
    dfs(sx, sy)
    print sum([sum(v) for v in isVisited])

Measured memory_bytes: 4500
from collections import defaultdict
from bisect import bisect_left

s = input()
t = input()

if set(s) >= set(t):
    d = defaultdict(list)
    for i, x in enumerate(s * 2):
        d[x].append(i)
    
    ans = 0
    cur = 0
    N = len(s)
    for x in t:
        cur_new = d[x][bisect_left(d[x], cur)]
        ans += cur_new - cur + 1
        cur = (cur_new + 1) % N

    print(ans)
else:
    print(-1)


Measured memory_bytes: 53360
n=input()
a=n[0]
b=n[1]
c=n[2]
d=n[3]
e="=7"


for i in ["+","-"]:
    if i !="/" or i =="/" and int(b)!=0:
        for j in ["+","-"]:
            if j=="/" and int(c)==0:
                break
            for k in ["+","-"]:
                if k=="/" and int(d)==0:
                    break
                if eval(a+i+b+j+c+k+d)==7:
                    print(a+i+b+j+c+k+d+e)
                    exit()

Measured memory_bytes: 38256
# Segment Tree
class Segment:
    def __init__(self, N, init_val):
        self.N0 = 2**(N-1).bit_length()
        # 0-indexedで管理
        self.dat = [identity_element]*(2*self.N0)
        # 値を代入
        for i in range(N):
            self.dat[i+self.N0-1]=init_val[i]    
        # 構築
        for i in range(self.N0-2,-1,-1) :
            self.dat[i]=segfunc(self.dat[2*i+1],self.dat[2*i+2]) 

    # k番目の要素の値をxに変更
    def update(self, k, x):
        k += self.N0-1
        self.dat[k] = x
        while k >= 0:
            k = (k-1)//2
            self.dat[k] = segfunc(self.dat[2*k+1], self.dat[2*k+2])

    # 区間[l, r)のsegfuncを求める
    def query(self, l, r):
        L = l + self.N0
        R = r + self.N0
        s = identity_element
        # 区間を列挙しながらsegfuncを求める
        while L < R:
            if R & 1:
                R -= 1
                s = segfunc(s, self.dat[R-1])
            if L & 1:
                s = segfunc(s, self.dat[L-1])
                L += 1
            L >>= 1
            R >>= 1
        return s

# segfunc : min, +, *, xor, gcd
# identity_element : 単位元(min:inf, 和:0, 積:1, xor:0, gcd:0)

from fractions import gcd
def segfunc(x,y):
    return gcd(x,y) # 変える
identity_element = 0 # 変える

n = int(input())
a = list(map(int,input().split()))

h = Segment(n, a)
ans = 0
for i in range(n):
    ans=max(ans,gcd(h.query(0,i), h.query(i+1,n)))
print(ans)

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
  st s;
  cin >> s;
  st ans = "";
  rep(i, 0, (s.size() + 1)/ 2) ans += s.at(i * 2);
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <stdio.h>

#define N      10000
#define P10000 104743

static
int p[ N ];
static
int q[ P10000 + 1 ] = { 0 };

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i, j, k;

  k = 0;
  for ( i = 2; i <= P10000; ++i )
  {
    if ( q[ i ] ) continue ;

    p[ k++ ] = i;
    for ( j = i; j <= P10000; j += i )
    {
      q[ j ] = 1;
    }
  }

  for ( ; ; )
  {
    int res = 0;
    int n;

    scanf ( "%d", &n );
    if ( !n ) break ;

    for ( i = 0; i < n; ++i )
    {
      res += p[ i ];
    }

    printf ( "%d\n", res );
  }

  return ( 0 );
}

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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        string a = sc.Next();
        string b = sc.Next();

        string answer = (a + b == "HH" || a + b == "DD") ? "H" : "D";

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 9044
#include<iostream>
#include<cstdio>
#include<fstream>
	using namespace std;
	int a[500005],g[200005],ans[200005];
	long long f[200005][70];
int main()
{
	int n=0;
	long long k=0;
	scanf("%d%lld",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]),a[n+i]=a[i];
	for(int i=1;i<=n+n;i++)
	{
		if(0<g[a[i]]&&g[a[i]]<=n)
			f[g[a[i]]][0]=i-g[a[i]]+1;
		g[a[i]]=i;
	}
	for(int j=1;j<=65;j++)
		for(int i=1;i<=n;i++)
		{
			int s=((i+f[i][j-1])%n==0)?n:(i+f[i][j-1])%n;
			if(f[i][j-1]==-1||f[s][j-1]==-1) f[i][j]=-1;
			else f[i][j]=f[i][j-1]+f[s][j-1];
			if(f[i][j]<0) f[i][j]=-1;
		}
	long long c=1;
	for(int i=65;i>=0;i--)
	{
		int s=(c%n==0)?n:c%n;
		long long h=c+f[s][i];
		if(h<0||h>n*k) h=-1;
		if(f[s][i]!=-1&&h!=-1) c+=f[s][i];
	}
	int cnt=0; c=n*k-c+1;
	if(c>n) c=0;
	for(int i=1;i<=n;i++) g[a[i]]=0;
	for(int i=n-c+1;i<=n;i++)
		if(g[a[i]])
			while(g[a[i]])
				g[ans[cnt--]]=0;
		else g[a[i]]=1,ans[++cnt]=a[i];
	for(int i=1;i<=cnt;i++) printf("%d ",ans[i]);
	return 0;
}

Measured memory_bytes: 114176
N = int(input())
s = [-1] * N
imos = [0]*(N+1)
for i in range(N):
    s[i] = int(input())


def wa_solver():
    s.sort(reverse=True)
    ans = 0
    for i in range(N):
        imos[i+1] = imos[i] + s[i]

    for ele in imos[::-1]:
        if ele % 10 != 0:
            ans = ele
            break

    print(ans)


def ac_solver():
    s.sort(reverse=True)
    ans = sum(s)
    if ans % 10 == 0:
        while s:
            a = s.pop()
            if a % 10 != 0:
                ans -= a
                break
        else:
            ans = 0

    print(ans)


if __name__ == "__main__":
    # wa_solver()
    ac_solver()


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

int a, b;
int main() {
    scanf("%d%d", &a, &b);
    if (a > 0) printf("Positive");
    else if (b >= 0) printf("Zero");
    else if ((b - a) & 1) printf("Positive");
    else printf("Negative");
    return 0;
}

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

namespace ABC173_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            Dictionary<string, int> dic = new Dictionary<string, int>();
            dic.Add("AC", 0);
            dic.Add("WA", 0);
            dic.Add("TLE", 0);
            dic.Add("RE", 0);

            for (int i = 0; i < N; i++)
            {
                string s = Console.ReadLine();
                dic[s]++;
            }

            foreach (var v in dic)
            {
                Console.WriteLine("{0} x {1}", v.Key, v.Value );
            }
        }
    }
}


Measured memory_bytes: 30960
import math

a, b, c, d = (int(i) for i in input().split())

dab = math.sqrt((a-b)**2)
dac = math.sqrt((a-c)**2)
dbc = math.sqrt((b-c)**2)

if dac <= d:
    print("Yes")
elif dab <= d and dbc <= d:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

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

    long int min = 10000000;
    long int max = -10000000;
    long int sum = 0;

    for (int i = 0; i < n; i ++) { 
        long int t;
        cin >> t;
        if (t < min) {
            min = t;
        }
        if (t > max) {
            max = t;
        }
        sum += t;
    }
    cout << min << ' ' << max << ' ' << sum << '\n';
    return 0;
}



Measured memory_bytes: 3116
n,l = map(int,input().split())
ans = 0 
for i in range(l,n+l):
    ans += i
if l <= 0 and n+l > 0:
    print(ans)
elif l <= 0 and n+l <= 0:
    print(ans - (n+l)+1)
else:
    print(ans-l)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
 
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

int main() {
    int a, b;
    cin >> a >> b;
    cout << 6 - (a + b);
    return 0;
}

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

ll INF = 1000000000000000000;

struct edge{
    ll to ,cost;
};

vector<vector<edge>> g(100005);
vector<ll> depth(100005);

void dfs(int v ,int p ,ll d){
    depth[v] = d;
    for(auto &e : g[v]){
        if(e.to == p) continue;
        dfs(e.to ,v ,d + e.cost);
    }
}

int main(){
    ll n;
    cin >> n;
    for(int i=0;i<(n-1);i++) {
        ll a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        g[a].push_back(edge{b ,c});
        g[b].push_back(edge{a ,c});
    }
    ll q ,k;
    cin >> q >> k;
    k--;

   /* queue<edge> que;
    vector<ll> d(n ,INF);
    que.push(edge{k ,0});
    d[k] = 0;
    while(!que.empty()){
        edge e = que.front();
        que.pop();
        for(int i=0;i<g[e.to].size() ;i++){
            ll ne = g[e.to][i].to ,nc = g[e.to][i].cost;
            if(d[ne] > d[e.to] + nc){
                d[ne] = d[e.to] + nc;
                que.push(edge{ne ,nc});
            }
        }
    }*/
    dfs(k ,-1 ,0);

    for(int i=0;i<q;i++){
        int x ,y;
        cin >> x >> y;
        x--; y--;
        cout << depth[x] + depth[y] << endl;
    }
}


Measured memory_bytes: 14336
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 1e18;

long long int N,M,s,w;

int main()
{
    cout << fixed << setprecision(18);
    cin>>N;
    string S=to_string(N);
    for(long long int i = 0; i < S.size(); i++){
        if(S[i]=='7'){
            SAY_Yes;
            return 0;
        }
    }
    SAY_No;
}


Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
int main()
{
	int a; cin >> a;
	pair<lli, lli> arr[a + 50];
	for(int i=0; i<a; i++)
		cin >> arr[i].first >> arr[i].second;
	sort(arr, arr + a);
	lli mx = arr[0].second, mi = arr[0].second, ans = 0;
	for(int i=1; i<a; i++)
	{
		mx += arr[i].first - arr[i - 1].first;
		mi -= arr[i].first - arr[i - 1].first;
		ans = max(ans, max(abs(arr[i].second - mx), abs(arr[i].second - mi)));
		mx = max(mx, arr[i].second);
		mi = min(mi, arr[i].second);
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 6712
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const long long INF = 1LL << 60;
const ll C = 1000000000+7;

int main() {
    int N;
    cin >> N;
    vector<int> odd(100005), even(100005);
    for(int i=1; i<=N; i++) {
        int v;
        cin >> v;
        if(i%2 == 0) {
            odd[v]++;
        }
        else {
            even[v]++;
        }
    }

    vector<int>::iterator iter = max_element(odd.begin(), odd.end());
    int oindex = distance(odd.begin(), iter);
    vector<int>::iterator e_iter = max_element(even.begin(), even.end());
    int eindex = distance(even.begin(), e_iter);

    sort(odd.begin(), odd.end());
    reverse(odd.begin(), odd.end());
    sort(even.begin(), even.end());
    reverse(even.begin(), even.end());

    if(oindex == eindex) {
        if(odd[1] >= even[1]) {
            cout << (N/2) - odd[1] + (N/2) - even[0] << endl;
            return 0;
        }
        else {
            cout << (N/2) - odd[0] + (N/2) - even[1] << endl;
            return 0;
        }
    }
    cout << (N/2) - odd[0] + (N/2) - even[0];
}

Measured memory_bytes: 3996
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0); cin.tie(0)
#define int int64_t
#define ii pair<int, int>
#define endl '\n'
#define vi vector<int>
#define vii vector<ii>
#define vvii vector<vii>
#define F first
#define S second
#define pb push_back
#define FOR(i,l,r) for(int i=l; i<r; ++i)
#define ROF(i,r,l) for(int i=r; i>l; --i)
#define all(x) x.begin(), x.end()
#define amin(a,b) a = min(a,b)
#define amax(a,b) a = max(a,b)
#define test int t; cin >> t; while(t--) solve();

using namespace std;

typedef long long ll;

const int MAXN = 2e5+73;
const int MAXINT = 2147483098;
const int MAXLL = 9223372036854775258LL;
const int MOD = 998244353;




void solve(){
    string s;
    cin >> s;
    int cur = 0;
    FOR(i,0,s.size()){
    cur+=s[i]-'0';
    cur%=9;
    }
    if (cur) cout << "No";
    else cout << "Yes";

}





int32_t main()
{
    fast;
    //test;
    solve();
    //freopen("kotlin.in", "r", stdin);
    //freopen("kotlin.out","w", stdout);



    return 0;
}


Measured memory_bytes: 3768
N = 4

def hit(arr1, arr2)
  n = 0
  
  N.times do |i|
    n += 1 if arr1[i] == arr2[i]
  end
  
  return n
end

def blow(arr1, arr2)
  n = 0
  
  N.times do |i|
    N.times do |j|
      n += 1 if i != j && arr1[i] == arr2[j] 
    end
  end
  
  return n
end

while line1 = gets
  arr1 = line1.split.map(&:to_i)
  arr2 = gets.split.map(&:to_i)
  puts "#{hit(arr1, arr2)} #{blow(arr1, arr2)}"
end

Measured memory_bytes: 6104
#include <iostream>
#include <cstring>
#include <climits>
using namespace std;

int** memoTable;
int* swim; //[100000];
int* bugs;//[100000];
int* HW;//[100000];
int minCost(int index, int lastActivity, int* swim, int* bugs, int* HW, int nDays){

    if(index == nDays){
        return 0;
    }

    if(lastActivity != -1 && memoTable[index][lastActivity] != -1){
        return memoTable[index][lastActivity];
    }

    int op1 = INT_MIN;
    int op2 = INT_MIN;
    int op3 = INT_MIN;

    if(lastActivity != 0){
        op1 = minCost(index+1, 0, swim, bugs, HW, nDays) + swim[index];
    }
    

    if(lastActivity != 1){
        op2 = minCost(index+1, 1, swim, bugs, HW, nDays) + bugs[index];
    }

    if(lastActivity != 2){
        op3 = minCost(index+1, 2, swim, bugs, HW, nDays) + HW[index];
    }

    memoTable[index][lastActivity] = max(op1, max(op2, op3));
    return memoTable[index][lastActivity];

}

int main(){

    int nDays;
    cin >> nDays;

    swim = new int[100000];
    bugs = new int[100000];
    HW = new int[100000];

    for(int i=0; i<nDays; ++i){
        cin >> swim[i] >> bugs[i] >> HW[i];
    }

    memoTable = new int*[100000];
    for(int i=0; i<100000; ++i){
        memoTable[i] = new int[3];
        memset(memoTable[i], -1, sizeof(int)* 3);
    }

    cout << minCost(0, -1, swim, bugs, HW, nDays);
    return 0;
}

Measured memory_bytes: 13184
from collections import Counter

h, w = map(int, input().split())
a = Counter(''.join(input() for _ in range(h)))

center = h * w % 2
side = (h // 2) * (w % 2) + (w // 2) * (h % 2)

cnt = 0
for i in a:
    if a[i] % 2 == 1:
        a[i] -= 1
        cnt += 1
if cnt != center:
    print('No')
    exit()
cnt = 0
for i in a:
    if cnt == side:
        break
    if a[i] % 4 == 2:
        a[i] -= 2
        cnt += 1

print('Yes' if sum(a[i] % 4 for i in a) == 0 else 'No')


Measured memory_bytes: 9464
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>
using namespace std;
typedef long long LL;

const int L=3e5+1;
LL D[L];
LL U[L];
LL V[L];

void solve(long long N, std::vector<long long> A){
	sort(A.begin(),A.end());
	int k=1;
	vector<int> cs,ds;
	for(int i=1;i<N;i++){
		if(A[i]==A[i-1]){
			k++;
		}
		else{
			D[k]++;
			k=1;
		}
	}
	D[k]++;
	for(int i=1;i<=N;i++){
		//cerr << i << ", " << D[i] << endl;
		U[i]=U[i-1]+i*D[i];
		V[i]=V[i-1]+D[i];
	}
	vector<LL> r;
	r.push_back(N+1);
	for(int i=1;i<=N;i++){
		r.push_back((U[i]+i*(V[N]-V[i]))/i);
		//cerr << i << ": " << r.back() << endl;
	}
	int v=N;
	for(int i=1;i<=N;i++){
		while(i>r[v])
		{
			v--;
		}
		printf("%d\n",v);
	}
}


int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}




Measured memory_bytes: 14472
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main() {
	char buf[82];
	int i, j;

	while (fgets(buf, 82, stdin) != NULL) {
		for (i = 0; i < 26; i++) {
			for (j = 0; j < strlen(buf); j++) {
				if (buf[j] == 'z') buf[j] = 'a';
				else if (isalpha(buf[j])) buf[j]++;
			}
			if (strstr(buf, "the") != NULL ||
				strstr(buf, "this") != NULL ||
				strstr(buf, "that") != NULL)
				printf("%s", buf);
		}
	}
	return 0;
}

Measured memory_bytes: 528
#include <bits/stdc++.h>
using namespace std;
int main(){
  	string a,b,c;
  	char d,e,f;
  	cin >> a >> b >> c;
    d = a.at(0)-32;
    e= b.at(0)-32;
   f = c.at(0)-32; 
  	cout <<d <<e <<f << endl;
}

Measured memory_bytes: 256
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_A&lang=jp
#??????????????????
#?????????????´?????¢????????????£????????????????????????????????¨???????¢?????????¨
#?????°??¢??°???????¨???????????¢????????????????

def bubble_sort(target_list):
    list_length = len(target_list)
    
    flag = True
    change_count = 0
    top_index = 1
    while flag:
        flag = False
        for i in range(top_index, list_length)[::-1]:
            if target_list[i] < target_list[i - 1]:
                tmp = target_list[i]
                target_list[i] = target_list[i - 1]
                target_list[i - 1] = tmp
                change_count += 1
                flag = True
        top_index += 1
        
    return change_count

def main():
    n_list = int(input())
    target_list = [int(n) for n in input().split()]
    cc = bubble_sort(target_list)
    print(*target_list)
    print(cc)
if __name__ == "__main__":
    main()

Measured memory_bytes: 7716
from collections import deque
from collections import defaultdict


def p_e():
    n, k = map(int, input().split())
    a = [0] + list(map(int, input().split()))
    for i in range(n):
        a[i + 1] = (a[i + 1] + a[i] - 1) % k
    d = defaultdict(int)
    d[0] = 1
    q = deque()
    ans = 0
    for i in range(1, n + 1):
        if i - k >= 0:
            d[a[i - k]] -= 1
        ans += d[a[i]]
        d[a[i]] += 1
    print(ans)
    
p_e()

Measured memory_bytes: 111692
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		ArrayList<String> w = new ArrayList<>();
		String s = saori.nextHayami();
		w.add(s);
		boolean flg = true;
		for(int i = 0;i < n-1;i++){
			s = saori.nextHayami();			
			if(w.contains(s)){
				flg = false;
			}
			w.add(s);
			String str = w.get(i);
			if(str.endsWith(s.substring(0, 1))){

			} else {
				flg = false;
			}
		}
		if(flg){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21204
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)

int main() {
  int n;
  cin >> n;
  bool flag = false;
  FOR(i, 1, 10) FOR(j, 1, 10) {
    if (i * j == n) flag = true;
  }
  cout << (flag ? "Yes" : "No") << endl;
}

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

int main() {
    int n;cin>>n;
    const int INF = 1000000007;
    long long ans=1;
    for(int i=1;i<=n;++i){
        ans*=i;
        ans%=INF;
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>
#include <cstdint>

void solve(void){
  std::string n;
  std::cin >> n;

  int cnt = 0;
  for(int i=0; i<n.size(); i++){
    cnt += (n[i] - '0');
  }

  if(cnt % 9 == 0) std::cout << "Yes" << std::endl;
  else             std::cout << "No"  << std::endl;
  return;
}
int main(void){
  solve();
  return 0;
}





Measured memory_bytes: 3752
#include<iostream>

using namespace std;

int main() {
	int n;
	cin >> n;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		sum += b - a + 1;
	}
	cout << sum << endl;
	return 0;

}

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

const ll MAXN = 100000;
const ll MOD = 1000000007;
vector<ll> prime;
bool sieve[MAXN];
void linear_sieve(){
	for(ll i=2;i<MAXN;i++){
		if(!sieve[i])prime.emplace_back(i);
		for(ll j=0;j<ll(prime.size())&&i*prime[j]<MAXN;j++){
			sieve[prime[j]*i] = 1;
			if(i%prime[j]==0)break;
		}
	}
}


ll myexp(ll b,ll p){
  if(p==1)return b;
  ll tmp = myexp(b,p/2);
  tmp = tmp*tmp%MOD;
  return p&1?tmp*b%MOD:tmp%MOD;
}
ll inv(ll a){
  return myexp(a,MOD-2);
}

ll c(ll cn,ll cm){
	
	ll ret = 1;
	for(ll i=1;i<=cm;i++){
		ret = (ret*(cn-i+1))%MOD;
		ret = ret*inv(i)%MOD;
	}
	return ret;
}
ll n,m,ans;
int main(){
	cin>>n>>m;
	linear_sieve();
	ll pidx = 0;
	ans = 1;
	while(m!=1){
		ll cnt = 0;
		while(m%prime[pidx]==0)m/=prime[pidx],cnt++;
		ans = ans*c(n+cnt-1,cnt)%MOD;
		if(++pidx >= prime.size()-1)break;
	}
	if(m!=1)ans = ans*n%MOD;

	cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>

using namespace std;

int main()
{
	string s;
	cin >> s;
	bool f = true;
	if (s[0] == s[1] &&s[1]==s[2]) {
		f = false;
	}
	if (f) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]
N,A,B=map(int,input().split())
h=[int(input()) for i in range(N)]
h.sort(reverse=1)
l,r=0,10**9
k=A-B
while l+2<r:
    m=(r-l)//2+l
    t=m*B
    c=0
    for i in h:
        if i>t:
            c+=-((-i+t)//k)
        else:
            break
    if c>m:
        l=m
    else:
        r=m+1
print(r-1)

Measured memory_bytes: 44508