akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
 
        int i = 1;
        int n = sc.nextInt();
         
        while(i <= n){
            int x = i;
             
            if(x % 3 == 0){
                System.out.print(" " + i);
            }else{ 
                while(x >=1){
                    if(x % 10 == 3){
                        System.out.print(" " + i);
                        break;
                    }
                    x /= 10;
                }
            }
            i++;
        }
        System.out.println("");
        sc.close();
    }
}


Measured memory_bytes: 28596
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

int INF = 1e9 + 7;

int main() {
	int n;
	ll k;
	cin >> n >> k;
	vector<int> to(n);
	rep(i, n) {
		int a;
		cin >> a;
		a--;
		to[i] = a;
	}
	vector<int> firstvisit(n, INF);
	int from = 0;
	int cnt = 0;
	while (true) {
		if (firstvisit[from] != INF) break;
		else {
            if(cnt==k){
              cout<<from+1<<endl;
              return 0;
            }
			firstvisit[from] = cnt;
			from = to[from];
			cnt++;
		}
	}
	k -= (ll)firstvisit[from];
	cnt -= firstvisit[from];
	ll kk = k % (ll)cnt;
	rep(i, n) {
		if (firstvisit[i] == firstvisit[from] + kk) {
			cout << i + 1 << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 4844
#include "bits/stdc++.h"
using namespace std;

char S[2010][2010];
int yoko[2010][2010];
int tate[2010][2010];

int main() {
    int H, W;
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) cin >> S[i][j];
    }

    for (int i = 0; i < H; i++) {
        int tmp = 0;
        for (int j = 0; j < W; j++) {
            if (S[i][j] == '#') {
                yoko[i][j] = tmp;
                tmp = 0;
            }
            else tmp++;
        }
        yoko[i][W] = tmp;
    }
    for (int i = 0; i < W; i++) {
        int tmp = 0;
        for (int j = 0; j < H; j++) {
            if (S[j][i] == '#') {
                tate[j][i] = tmp;
                tmp = 0;
            }
            else tmp++;
        }
        tate[H][i] = tmp;
    }

    for (int i = H - 1; i >= 0; i--) {
        int tmp = 0;
        for (int j = W; j >= 0; j--) {
            if (S[i][j] == '#' || j == W) {
                tmp = yoko[i][j];
                yoko[i][j] = 0;
            }
            else yoko[i][j] = tmp;
        }
    }
    for (int i = W - 1; i >= 0; i--) {
        int tmp = 0;
        for (int j = H; j >= 0; j--) {
            if (S[j][i] == '#' || j == H) {
                tmp = tate[j][i];
                tate[j][i] = 0;
            }
            else tate[j][i] = tmp;
        }
    }
    
    int ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) ans = max(ans, yoko[i][j] + tate[i][j]);
    }
    cout << ans - 1 << endl;
}

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

int main() {
  string S;
  cin >> S;
  
  vector<bool> vec(26);
  for(int i = 0; i < 26; i++) {
    vec.at(i) = false;
  }
  
  for(int i = 0; i < S.size(); i++) {
    vec.at(S.at(i) - 'a') = true;
  }
  
  for(int i = 0; i < 26; i++) {
    if(!(vec.at(i))) {
      cout << (char) (i + 'a') << endl;
      break;
    }
    else if(i == 25) {
      if(vec.at(i) == true) {
        cout << "None" << endl;
      }
    }
  }
  
   
  
  return 0;
  
    
}
    

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cstdio>
using namespace std;
int main()
{
	string str;
	cin>>str;
	if(str.size()==2)
	{
		cout<<str<<endl;
	}
	else if(str.size()==3)
	{
		for(int i=str.size()-1;i>=0;i--)
		{
			cout<<str[i];
		}
		cout<<endl;
	}
	
	return 0;
 } 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  string s;
  cin >> s;
  vector<int> r(s.size(),0);

  int a=0,b=0;
  for(int i=0;i<s.size()-1;i++){
    if(s[i]=='R'){
      if(i%2==0) a++;
      else b++;
      
      if(s[i+1]=='L'){
        if(i%2==0){ r[i]+=a; r[i+1]+=b;}
        else {r[i]+=b; r[i+1]+=a;}
        a=0; b=0;
      }
    }
  }

  for(int i=s.size()-1;0<i;i--){
    if(s[i]=='L'){
      if(i%2==0) a++;
      else b++;
      
      if(s[i-1]=='R'){
        if(i%2==0){ r[i]+=a; r[i-1]+=b;}
        else {r[i]+=b; r[i-1]+=a;}
        a=0; b=0;
      }
    }
  }

  for(int ri:r) cout << ri << " "; cout << endl;

  return 0;
}


Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    from itertools import groupby
    s=input()
    k=int(input())
    t=groupby(s)
    S=[]
    for tup in t: S.append((tup[0],len(list(tup[1]))))
    if len(S)==1:
        print(len(s)*k//2)
        return
    if s[0]==s[-1]:
        p=0 # s自体で変更する数
        for a,b in S[1:-1]:
            p+=b//2
        q=(S[0][1]+S[-1][1])//2
        ans=p*k+q*(k-1)
        ans+=S[0][1]//2+S[-1][1]//2
        print(ans)
    else:
        p=0
        for a,b in S:
            p+=b//2
        ans=p*k
        print(ans)
resolve()

Measured memory_bytes: 38256
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
using namespace std;
int main()
{
	int i,j,k,n,m;
	ll x,y;
	cin>>x>>y;
	if(y-x>3000)
	{
		printf("0");
		return 0;
	}
	ll ans=2020;
	for(i=x;i<=y;i++)
	{
		for(j=i+1;j<=y;j++)
		{
			ans=min(ans,1ll*(i%2019ll)*(j%2019ll)%2019ll);
		}
	}
	printf("%d",ans);
}


Measured memory_bytes: 256
import math

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

sort_x = sorted(origin_x)

medians = [sort_x[math.floor((n-1)/2)],sort_x[math.floor((n)/2)]]

for num in origin_x:
    if num < medians[1]:
        print(medians[1])
    else:
        print(medians[0])

Measured memory_bytes: 25220
#include "bits/stdc++.h"
#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)

using namespace std;
int main() {
	string S;
	cin >> S;
	if (S.at(0) == '7' || S.at(1) == '7' || S.at(2) == '7') {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
 }

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

bool check(string s){
    if (s.size() % 2 != 0) return false;
    int n = s.size();
    string t = s.substr(0, n/2);
    string u = s.substr(n/2);
    if (t == u) return true;
    else return false;
}


int main(){
    string s;
    cin >> s;
    int m = s.size();
    int ans = 0;
    for(int i = 1; i < m; i++){
        string t = s.substr(0, m-i);
        if (check(t)) ans = max(ans, m-i);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3596
R, G, B, n = list(map(int, input().split()))
ans = 0
mr = n // R
for i in range(mr + 1):
    m = n - i * R
    mg = m // G
    for j in range(mg + 1):
        l = m - j * G
        if l % B == 0:
            ans += 1
print(ans)


Measured memory_bytes: 2940
#include<stdio.h>
#define n_max 1000000

typedef struct{
  char name[10];
  int time;
}input;

int main(){
  int i=0,j=0,x,n,de,sum=0;
  input in[n_max];

  scanf("%d%d",&n,&de);
  for(i=0;i<n;i++){
    scanf("%s%d",&in[i].name,&in[i].time);
  }

  while(n>0){
    if((x=in[j].time-de)>0){
      in[j].time=x;
      in[i]=in[j];
      sum+=de;
      i++;
      j++;
    }
    
    else if(in[j].time-de<=0){
      sum+=in[j].time;
      printf("%s %d\n",in[j].name,sum);
      j++;
      n--;
    }
  }
  
  return 0;
}



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

int main(){
    int N;
    cin >> N;
    vector<ll> mcnt(N,0);
    vector<ll> pcnt(N,0);
    ll A;
    for(int i=0;i < N;i++){
        cin >> A;
        if(A + i + 1 < N){
            pcnt[A + i + 1]++;
        }
        if(i - A + 1 > 0){
            mcnt[i - A + 1]++;
        }
    }
    ll ans = 0;
    for(int i=0;i < N;i++){
        ans += pcnt[i] * mcnt[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 6428
import copy
import math
import time
import statistics
import math
import itertools
import bisect

# a = get_int()
def get_int():
    return int(input())
# a = get_string()
def get_string():
    return input()
# a_list = get_int_list()
def get_int_list():
    return [int(x) for x in input().split()]
# a_list = get_string_list():
def get_string_list():
    return input().split()
# a, b = get_int_multi()
def get_int_multi():
    return map(int, input().split())
# a_list = get_string_char_list()
def get_string_char_list():
    return list(str(input()))
# print("{} {}".format(a, b))
# for num in range(0, a):
# a_list[idx]
# a_list = [0] * a
'''
while (idx < n) and ():

    idx += 1
'''

def main():
    start = time.time()
    n = get_int()

    a_list = get_int_list()
    b_list = get_int_list()
    c_list = get_int_list()

    a_list.sort()
    b_list.sort()
    c_list.sort()

    a_count = []
    b_count = []
    b_count2 = []

    idx = 0
    for a in a_list:
        idx = bisect.bisect_right(b_list, a, idx)
        a_count.append(idx)

    idx = 0
    for b in b_list:
        idx = bisect.bisect_right(c_list, b, idx)
        b_count.append(idx)

    ruikei = 0
    for i in range(n-1, -1, -1):
        ruikei += n - b_count[i]
        b_count2.append(ruikei)

    b_count2.sort(reverse=True)

    ans = 0
    for a in a_count:
        if a == n:
            continue
        ans += b_count2[a]

    print(ans)
    #print(time.time() - start)

if __name__ == '__main__':
    main()




Measured memory_bytes: 35824
def lscan; gets.split.map(&:to_i); end
def dist(u,v)
  Math::hypot(u[0]-v[0], u[1]-v[1])
end
pts = gets.to_i.times.map{ gets.split.map(&:to_f) }

sum = 0
m = 0
pts[0..-1].permutation do |ppts|
  l = ppts.shift
  t = 0
  ppts.each do |pt|
    t += dist(l, pt)
    l = pt
  end
  sum += t
  m += 1
end

p sum/m


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


int main(){
    int n,wMax;
    cin >> n >> wMax;
    int v[n],w[n];

    for (int i = 0;i<n;i++)
        cin >> w[i] >> v[i];

    long long dp[n+1][wMax+1];
    for (int i = 0;i<wMax+1;i++)
        dp[0][i]=0;
    for (int i = 0;i<n+1;i++)
        dp[i][0]=0;


    for (int i=1; i<n+1; i++){
        for (int j=1; j<wMax+1; j++){
            if (w[i-1]<=j)
                dp[i][j]=max( dp[i-1][j], v[i-1]+dp[i-1][j-w[i-1]]);
            else
                dp[i][j]=dp[i-1][j];
        }
    }
    cout << dp[n][wMax];
}


Measured memory_bytes: 79104
#include <iostream>
#include <cstring>
using namespace std;
int main(void){
    int N;
    cin>>N;
    int a[N];
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    int next;
    for(int i=1;i<=N;i++){
        if(i==1) next=a[0];
        else next=a[next-1];
        if(next==2) {cout<<i; break;}
        if(i==N) cout<<-1;
    }
    return 0;
}


Measured memory_bytes: 640
import scala.io.StdIn.readLine

object Main {

  def d(i:Int) = if(i<0) 15+i else i

  def getIndex(s:String) = s match {
    case "Rock" => 0 case "Fire" => 1 case "Scissors" => 2 case "Snake" => 3
    case "Human" => 4 case "Tree" => 5 case "Wolf" => 6 case "Sponge" => 7
    case "Paper" => 8 case "Air" => 9 case "Water" => 10 case "Dragon" => 11
    case "Devil" => 12 case "Lightning" => 13 case "Gun" => 14
  }

  val gestures = Array("Rock", "Fire", "Scissors", "Snake", "Human", "Tree", "Wolf", "Sponge", "Paper", "Air", "Water", "Dragon", "Devil", "Lightning", "Gun")

  def scan(list:Array[Int],i:Int,n:Int):String = {
    if(i==n) "Draw"
    else {
      val win = d(list((i+1)%n)-list(i))
      val j = if(i>0) i-1 else n-1
      val lose = d(list(i)-list(j))
      if(win<=7 && lose>7) gestures(list(i))
      else scan(list,i+1,n)
    }
  }

  def main(args:Array[String]) = {
    var n = 0
    while({n=readLine.trim.toInt;n}!=0) {
      val list = {for(i<-1 to n) yield getIndex(readLine.trim)}.toArray.sorted
      println(scan(list,0,list.length))
    }
  }
}

Measured memory_bytes: 56360
from sys import stdin
N,M=list(map(int,(stdin.readline().strip().split())))
A=list(map(int,(stdin.readline().strip().split())))
hyou=(sum(A)/(4*M))
count=0
for i in range(N):
    if (A[i])<hyou:continue
    count+=1
if count>=M:print("Yes")
else:print("No")

Measured memory_bytes: 3064
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 2000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144
#define REP(a,b) for(long long a = 0;a < b;++a)
int main(){
#define int long long
	long long t[2], a[2], b[2];
	REP(i, 2) {
		cin >> t[i];
	}
	REP(i, 2) {
		cin >> a[i];
	}
	REP(i, 2) {
		cin >> b[i];
	}
	if (t[0] * a[0] + t[1] * a[1] == t[0] * b[0] + t[1] * b[1]) {
		cout << "infinity" << endl;
		return 0;
	}
	if (t[0] * a[0] + t[1] * a[1] > t[0] * b[0] + t[1] * b[1]) {
		swap(a, b);
	}
	if (a[0] <b[0] && a[1] < b[1]) {
		cout << 0 << endl;
		return 0;
	}
	long long ans = 0;
	long long diff = t[0] * b[0] + t[1] * b[1] - (t[0] * a[0] + t[1] * a[1]);
	if (a[0] > b[0]) {
		long long tmp = t[0] * (a[0] - b[0]);
		ans += tmp / diff;
		ans *= 2LL;
		if (tmp % diff != 0) {
			ans++;
		}
	}
	else {
		ans = 0;
	}
	cout << ans << endl;
}

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

int main() {
    int x, y; cin >> x >> y;
    int a, b, c; cin >> a >> b >> c;
    vector<int> p(a), q(b), r(c);
    for (int i = 0; i < a; i++) cin >> p[i];
    for (int i = 0; i < b; i++) cin >> q[i];
    for (int i = 0; i < c; i++) cin >> r[i];
    sort(p.rbegin(), p.rend());
    sort(q.rbegin(), q.rend());
    vector<int> d;
    for (int i = 0; i < x; i++) d.push_back(p[i]);
    for (int i = 0; i < y; i++) d.push_back(q[i]);
    for (int i = 0; i < c; i++) d.push_back(r[i]);
    sort(d.rbegin(), d.rend());
    ll ans = 0;
    for (int i = 0; i < x+y; i++) ans += d[i];
    cout << ans << endl;
    return 0;
}

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

vector<ll> divisor(ll n){
    vector<ll> vec;
    for(ll i=1;i*i<= n;i++){
        if(n%i==0){
            vec.push_back(i);
            if(i*i!=n) vec.push_back(n/i);
        }
    }
    sort(vec.begin(), vec.end());
    return vec;
}

int main(void){
    int n;
    cin >> n;
    
    ll ans = 0;
    for(int a=1;a<=n;a++){
        ans += (n-1)/a;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<stack>/*** LIFO *** stack<type> var;
push(), top():to get data, pop():to remove, size(), empty() ***/
using namespace std;

#define Fp(I, STAT, END) for(int I = STAT; I < END; I++)
#define Fm(I, STAT, END) for(int I = STAT; I > END; I--)

int main(){
    string S;
    cin >> S;
    Fp(i, 0, 3){
        if(S[i] == S[i + 1]){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int num = Integer.parseInt(sc.next());
        int sum = Integer.parseInt(sc.next());

        boolean isYes = false;
        for (int i = 0; i <= num; i++) {
            if (sum == (2 * i) + (4 * (num - i))) {
                System.out.println("Yes");
                isYes = true;
            }
        }
        if (!isYes) {
            System.out.println("No");
        }

        sc.close();
    }
}


Measured memory_bytes: 35540
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
b_a = [0] * n
for i in range(n):
    b_a[i] = a[i] - b[i]
b_a.sort()
total = sum([-1 * i for i in b_a if i < 0])  # 負の要素のsum * -1
lim = len([-1 * i for i in b_a if i < 0])  # 負の個数 3　なら0,1,2 が負
#print(b_a, total, lim)
num = 0
if total == 0:
    print(0)
    exit()
while total > 0:  # 全部正の時にtotal=0でここには入らなくて良い。
    total -= b_a[-num - 1]
    num += 1
    if num == n - 1:  # 無限るーぷしないように、n-num-1 がlim-1まできたらbreak
        print(-1)
        exit()
print(num + lim)


Measured memory_bytes: 18356
//
// Created by yamunaku on 2020/04/19.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    //CFS;
    double r;
    cin >> r;
    CST(10);
    cout << 2 * 3.1415926535 * r << endl;
    return 0;
}

Measured memory_bytes: 3772
#include <iostream>//約数だけ考えればよいですね。O(sqrt(n))で解けます。
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <complex>
#define MX 100000
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;
vector<int>par;
vector<int>fac;
vector<int>ran;
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	return find(par[x]);
}
void unit (int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (ran[x] < ran[y]) {
		par[x] = y;
		fac[y] += fac[x];
	}
	else {
		par[y] = x;
		fac[x] += fac[y];
	}
	if (ran[x] == ran[y])ran[x]++;
}
int main() {
	int n, m, k;
	cin >> n >> m >> k;

	rep(i, n) {
		par.push_back(i);
		fac.push_back(1);
		ran.push_back(1);
	}
	
	vector<vector<int>>dt(n);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		--a;
		--b;
		unit(a, b);
		dt[a].push_back(b);
		dt[b].push_back(a);
	}
	vector<int>ans(n,0);
	rep(i, k) {
		int c, d;
		cin >> c >> d;
		--c;
		--d;
		if (find(c) == find(d)) {
			ans[c]--;
			ans[d]--;
		}
	}
	
	rep(i, n) {
		int tmp = find(i);
		ans[i] += fac[tmp] - dt[i].size()-1;
		cout << ans[i] << " ";
	}
	return 0;
}

Measured memory_bytes: 8300
import java.util.*;
import java.io.*;
class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        long n = Long.parseLong(st.nextToken());
        long x = Long.parseLong(st.nextToken());
        st = new StringTokenizer(br.readLine());
        long[] arr = new long[(int)n];
        for (int i=0; i<n; i++) {
            arr[i]=Long.parseLong(st.nextToken());
        }
        long ans = 0;
        if(arr[0]>x){
            ans+=arr[0]-x;
            arr[0]=x;
        }
        for (int i=1; i<n; i++) {
            if(arr[i-1]+arr[i]>x){
                ans+=arr[i-1]+arr[i]-x;
                arr[i]=arr[i]-(arr[i-1]+arr[i]-x);
            }
        }
        // for (int i=0; i<n; i++) {
        //     System.out.print(arr[i]+",");
        // }
        // System.out.println();

        System.out.println(ans);

        
    }
}


Measured memory_bytes: 43660
from scipy.sparse.csgraph import dijkstra
import numpy as np
N, X, Y = map(int, input().split())
X -= 1
Y -= 1

g = np.zeros((N, N), dtype=int)
a = np.arange(N - 1)
np.add.at(g, (a, a + 1), 1)
np.add.at(g, (a + 1, a), 1)
np.add.at(g, (X, Y), 1)
np.add.at(g, (Y, X), 1)
fw = dijkstra(g, directed=False)
fw = (fw + 0.5).astype(int)
fw = np.tril(fw).ravel()
fw = fw[fw > 0]

cnt = np.bincount(fw).tolist()
ans = [0] * (N - 1)
for i, c in enumerate(cnt[1:]):
    ans[i] = c

print(*ans, sep="\n")

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

public class Main{
	final static int MOD = 1000000007;
	final static int INF = 1000000000;

	public static void main(String[] args) throws IOException{
		NScanner sc = new NScanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int C = sc.nextInt();
		double S = a * b * Math.sin(Math.toRadians(C)) / 2.0;
		double c = Math.sqrt(a*a + b*b - 2*a*b*Math.cos(Math.toRadians(C)));
		System.out.printf("%.6f %.6f %.6f\n", S, a+b+c, 2*S/a);
	}

}

class NScanner{

	private BufferedReader br;
	private StringTokenizer tok;

	public NScanner(InputStream is) throws IOException{
		br = new BufferedReader(new InputStreamReader(is));
		getLine();
	}

	private void getLine() throws IOException{
		while(tok == null || !hasNext()){
			tok = new StringTokenizer(br.readLine());
		}
	}

	public boolean hasNext(){
		return tok.hasMoreTokens();
	}

	public String next() throws IOException{
		if(hasNext()){
			return tok.nextToken();
		}else{
			getLine();
			return tok.nextToken();
		}
	}

	public int nextInt() throws IOException{
		if(hasNext()){
			return Integer.parseInt(tok.nextToken());
		}else{
			getLine();
			return Integer.parseInt(tok.nextToken());
		}
	}

	public long nextLong() throws IOException{
		if(hasNext()){
			return Long.parseLong(tok.nextToken());
		}else{
			getLine();
			return Long.parseLong(tok.nextToken());
		}
	}

	public double nextDouble() throws IOException{
		if(hasNext()){
			return Double.parseDouble(tok.nextToken());
		}else{
			getLine();
			return Double.parseDouble(tok.nextToken());
		}
	}
}


Measured memory_bytes: 24620
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

ll memo[90];
long long func(int n){
	if(n==0)return 2;
	if(n==1)return 1;
	if(memo[n] !=0) return memo[n];
	return memo[n]=(func(n-1)+func(n-2));
}
int main(){
	
	int n; cin >>n;
	cout << func(n)<< endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
  
int gcd(int a, int b) {
  if(a > b) swap(a,b);
  if( a == 0) return b;
  else return gcd(b%a,a);
}

int main () {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> r(n+1);
  vector<int> l(n+1);
  rep(i,n) cin >> a.at(i);
  for(int i=1;i<=n;i++)
    r.at(i) = gcd(r.at(i-1),a.at(i-1));
  for(int i=n-1;i>=0;i--) 
    l.at(i) = gcd(l.at(i+1),a.at(i));
  int ans;
  rep(i,n) ans = max(ans,gcd(r.at(i),l.at(i+1)));
  cout << ans;
}


Measured memory_bytes: 1408
/***********************************
*******AUTHOR SHASHI KANT **********         
****GMAIL Shshiksnt140895@gmail.com*
************************************                                  
***********************************/
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
/*class graph
{
	map<int,list<int>>adj;
	public :
	       void addedge(int a, int b)
	       {
	           adj[a].push_back(b);
	           adj[b].push_back(a);
	       }

}*/
string win_game(ll n, ll k, vector<int>vect)
{
    vector<bool>dp(k+1,0);
    for(int i=1; i<=k; i++)
    {
    	for(int j=0; j<n; j++)
    	{
    		if(vect[j]> i)
    		   continue;
    		if(dp[i-vect[j]] == 0)
    			dp[i] = 1;
        }
    } 

    if(dp[k] == 1)
        return "First";
        else
        return "Second";   
   
}
int main(){
          ll n, k;
             cin>>n>>k;
             vector<int>vect(n);
             for(int i=0; i<n; i++)
             cin>>vect[i];
             cout<<win_game(n, k, vect)<< endl;
       	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define em3 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define X real()
#define Y imag()
#define cross(a, b) ((conj(a) * (b)).Y)
#define dot(a, b) ((conj(a) * (b)).X)
#define EPS 1e-7
long long mod = 1e9 +7;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const double pi = acos(-1);
typedef complex <double> point;
typedef tuple<int, int, int> line;
typedef vector<point> polygon;
ll n , x , h[100005] , arr[100005];
ll solve(int ind)
{
    if(ind >= n)
        return 2e9;
    if(ind == n - 1)
        return 0;
    if(arr[ind] != -1)
        return arr[ind];
    ll ans = 2e9;
    for(int i = ind + 1; i < n && i <= ind + x ; i++)
        ans = min(ans , abs(h[ind] - h[i]) + solve(i));
    arr[ind] = ans;
    return ans;
}

int main()
{
    cin >> n >> x;
    memset(arr , -1 , sizeof arr);
    for(int i = 0 ; i < n ; i++)
        cin >> h[i];
    cout << solve(0);

    return 0;
}



Measured memory_bytes: 6528
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3
#define MOD 1000000007LL

ll fact[100002], factInv[100002];

ll power(ll x) {
    ll res = 1, n = MOD - 2;
    while(n > 0) {
        if (n & 1) res = (res * x) % MOD;
        x = (x * x) % MOD;
        n >>= 1;
    }
    return res;
}

void factrial() {
    fact[0] = factInv[0] = 1;
    repl(i, 1, 100002) {
        fact[i] = (fact[i - 1] * i) % MOD;
        factInv[i] = power(fact[i]);
    }
}

int main(){
    cin.sync_with_stdio(false);
    ll n;
    cin >> n;
    int a, b[n] = {};
    rep(i, n) b[i] = -1;
    int l, r;
    rep(i, n + 1) {
        cin >> a;
        if (b[a - 1] != -1) l = b[a - 1], r = i;
        else b[a - 1] = i;
    }
    factrial();
    int p = n + 1 - (r - l + 1);
    repl(i, 1, n + 2) {
        ll g = (((fact[n + 1] * factInv[i]) % MOD) * factInv[n + 1 - i]) % MOD;
        ll h = (p < i - 1) ? 0 : (((fact[p] * factInv[i - 1]) % MOD) * factInv[p - i + 1]) % MOD;
        cout << (g - h + MOD) % MOD << endl;
    }
    return 0;
}


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

int main() {
  long long int n, a, b, c, d, e;
  cin >> n >> a >> b >> c >> d >> e;
  
  vector<long long int> array;
  array.push_back(a);
  array.push_back(b);
  array.push_back(c);
  array.push_back(d);
  array.push_back(e);

  long long int max_t = 0;
  for (int i = 0; i < array.size(); i++) {
    long long int time = 0;
    time += n / array[i];
    
    if (n % array[i] != 0) {
      time += 1;
    }
    if (max_t < time) {
       max_t = time;
    }
  }
  max_t += 4;
  cout << max_t << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVETSE(c) reverse((c).begin(),(c).end())
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define ALL(a)  (a).begin(),(a).end()

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> T maxt(T x,T y) {
    if (x>y) return x;
    else return y;
}
template<class T> T mint(T x,T y) {
    if (x>y) return y;
    else return x;
}
//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
//cout << fixed << setprecision(10) << ans << defaultfloat << endl;
typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<double> Vd;
typedef vector<string> Vs;

/* //約数列挙
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}*/

int main() {
    int N,h;
    cin >> N;
    Vi v;
    REP(i,N){
      cin >> h;
      v.push_back(h);
    }
    reverse(ALL(v));
    
    int ans=0,c=0;
    FOR(i,1,N){
      // cout << c << ' ' << v[i] << ' ' << v[i-1] << endl;
      if (v[i] >= v[i-1]) {
        c++;
      }
      else {
        ans = max(ans,c);
        c = 0;
      }
    }
    ans = max(ans,c);
    cout << ans << endl;
    }

Measured memory_bytes: 892
import sys

stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces


N = ni()
arr = ["hon", "pon", "bon"]
arr2 = [1, 1, 0, 2, 0, 0, 1, 0, 1, 0]
print(arr[arr2[N % 10]])


Measured memory_bytes: 61300
#include <iostream>
#include <string>

using namespace std;

int main(){
	int bill_num = 0, money_sum = 0;
	cin >> bill_num >> money_sum;
	int sum, num;
	for (int yukichi = 0; yukichi <= bill_num; ++yukichi){
		for (int ichiyo = 0; ichiyo <= bill_num - yukichi; ++ichiyo){
			int hideyo = bill_num - yukichi - ichiyo;
			sum = yukichi * 10000 + ichiyo * 5000 + hideyo * 1000;
			num = yukichi + ichiyo + hideyo;
			if (sum == money_sum) {
				string str = to_string(yukichi) + ' ' + to_string(ichiyo) + ' ' + to_string(hideyo);
				cout << str << endl;
				goto END;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
END:
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys

def solve(bigN, bigX, xs):
    ys = [abs(x - bigX) for x in xs]
    g = ys[0]
    for y in ys[1:]:
        g = gcd(g, y)
    return g

def gcd(a, b):
    '''The greatest common divisor of a and b'''
    if b < a:
        (a, b) = (b, a)
    while True:
        x = a % b
        if x == 0:
            return b
        (a, b) = (b, x)

def readQuestion():
    [line1, line2] = list(sys.stdin)
    [bigN, bigX] = [int(s) for s in line1.split(' ')]
    xs           = [int(s) for s in line2.split(' ')]
    return (bigN, bigX, xs)

def main():
    bigN, bigX, xs = readQuestion()
    answer = solve(bigN, bigX, xs)
    print(answer)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 15140
mod = 10 ** 9 + 7

def naive_main(nums):
    n = len(nums)
    ans = 0
    for i in range(n - 1):
        for j in range(i + 1, n):
            ans += nums[i] ^ nums[j]
    return ans

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

# s

"""
0 0 0 1
0 0 1 0
0 0 1 0
0 1 0 0
1 0 0 0

4, 4, 6, 4

32 16 12 4
"""

max_len = len(bin(max(nums))) - 2

counter = [0 for _ in range(max_len)]
for i in range(n):
    ss = bin(nums[i])[2:]
    ss = "0" * (max_len - len(ss)) + ss
    for j in range(len(ss)):
        if ss[j] == "1":
            counter[j] += 1

# print(n)
# print(counter)
ans = 0
for i in range(max_len):
    c = counter[max_len - 1 - i]
    ans += (c * (n - c) * (2 ** i)) % mod

print(int(ans) % mod)
#print(naive_main(nums))



Measured memory_bytes: 123056
s = input()

c1= c2 = 0
for i in s[2:]:
    if i == 'C':
        c1 += 1
    else:
        if i!=i.lower():
            c2 +=1
if s[0] == 'A' and s[1] == s[1].lower() and c1==1 and c2==0 and s[-1] != 'C':
    print('AC')
else:
    print('WA')

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

int main(){
  int n;
  cin >> n;
  char a;
  bool flag = true;
  r(i,n){
    cin >> a;
    if(a=='Y')flag=false;
  }
  if(flag)cout << "Three"<<endl;
  else cout << "Four"<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
int w, h;
int memo[128][128][2][3];
//dir 1:x, 2:y
int solve(int x, int y, int prev, int dir){
  if(x > w || y > h) return 0;
  if(x == w && y == h) return 1;
  if(memo[x][y][prev][dir]) return memo[x][y][prev][dir];
  if(!prev)
    return memo[x][y][prev][dir] = (solve(x + 1, y, dir == 1? 0 : 1, 1) + solve(x, y + 1, dir == 2? 0 : 1, 2)) % 100000;
  else
    return memo[x][y][prev][dir] = ((dir == 1)? solve(x + 1, y, 0, 1) : solve(x, y + 1, 0, 2)) % 100000;
}
int main(void){
  for( ; ; ){
    scanf("%d %d", &w, &h);
    if(!(w + h)) break;
    memset(memo, 0, sizeof(memo));
    printf("%d\n", (solve(2, 1, 0, 1) + solve(1, 2 , 0, 2)) % 100000);
  }
}


Measured memory_bytes: 1432
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

n = int(input())

divisors = make_divisors(n)

l = len(divisors)
#print(divisors)

ans = float('inf')
for i in range(l):
    a = divisors[i]
    b = int(n/a)
    m = max([a,b])
    keta = 1
    while m > 9:
        m = int(m/10)
        keta += 1
    ans = min([ans, keta])

print(ans)

Measured memory_bytes: 3188
def solve( s , c ):
    cnt = int(0)
    while 1 :

        if len(s) == 0 :
            return cnt

        f = True

        for i in range(len(s)):
            if s[i] != c:
                f = False
                break
        
        if f :
            return cnt


        s2 = ""
        for i in range(len(s)-1):
            if s[i] == c or s[i+1] == c:
                s2 += c
            else:
                s2 += s[i]
         
        s = s2
        cnt += 1

    return cnt;



s = input()
a = [0 for i in range(26)]

for i in range(len(s)):
    a[ord(s[i])-ord('a')] += 1

ans = 0x7FFFFFFF
for i in range(26):
    if(a[i] > 0 ):
        ans = min( ans , solve(s, chr( i + ord('a') ) ) )

print(ans)


Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
//    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

long long  factorial(long long n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}

int min(int a, int b) {
    if (a > b)
        return b;
    else
        return a;
}

int distance(int a, int b) {
  return abs(a-b)*abs(a-b);
}

//int ()



int main()
{
  long long  a ,b, c, d, e, X, Y ,r;
//  long long  a, b, c, d, e, X, Y;
  //  double  c;
//  int  A[200003]={};
  int  A[100003]={};
  int  B[100003]={};
  int  C[100003][11]={};

  int  flg=0;

//  long long  a, b, c, d, X, Y;
  char s[101][101]={};
  char t[101]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  long long p,q;
//  int flag=0;
//  int tmp=0;
//  char tmp[101]={};
//  long long min=10000000000;
//  long long min=100000001;
  int len=0;
  int l=0;
//  int r=1000001;
  int cnt=0;
  int num=0;
  int num1=0;
  int num2=0;
  int ans=0;
  int max=0;
  int sum=0;
  int addr=0;
  int ptn=0;
  long long  tmp=0;
//  bool on_off[100]={};
  
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
  scanf("%lld %lld", &a, &b);
//  scanf("%d%d", &a, &b);

   if(a<=b*2)  printf("0\n");
   else printf("%lld\n", a-(b*2));
  
return 0;
}


Measured memory_bytes: 128
from collections import Counter
n=int(input())
L=[input() for i in range(n)]
LC=Counter(L)

A=['AC', 'WA', 'TLE', 'RE']
for a in A:
    if a in LC.keys():
        print(a+' x '+str(LC[a]))
    else:
        print(a+' x '+'0')

Measured memory_bytes: 16496
#include <stdio.h>
#include <stdlib.h>
#define MAX_NUM 100

int main(void){
	int i, sequence_num;
	int *sequence, *reverse;
	
	scanf("%d", &sequence_num);
	
	// ????????????????´??????????(malloc)
	sequence = (int *)malloc(sizeof(int) * sequence_num);
	reverse = (int *)malloc(sizeof(int) * sequence_num);
	
	// ????????°???100????¶?????????¨??¨??????
	if(sequence_num > MAX_NUM){
		puts("Array Number is Over.");
		return 0;
	}
	
	// ???????????\????????????????????\???
	for(i = 0; i < sequence_num; i++){
		scanf("%d", &sequence[i]);
		reverse[sequence_num - (i + 1)] = sequence[i];
	}
	
	// ??????????????¨???
	for(i = 0; i < sequence_num; i++){
		printf("%d", reverse[i]);
		if(i != (sequence_num - 1)){
			putchar(' ');
		}
	}
	putchar('\n');
	
	// malloc?????????
	free(sequence);
	free(reverse);
	
	return 0;
}

Measured memory_bytes: 600
<?php
# 文字列の入力
fscanf(STDIN, "%s", $data1);
# 文字列の入力
fscanf(STDIN, "%s", $data2);
$anser = 0;
$WetherForecast = str_split($data1);
$fact = str_split($data2);
for($i=0; $i < 3; $i++){
    if($WetherForecast[$i] == $fact[$i]){
        $anser += 1;
    }
}

echo $anser."\n";

?>

Measured memory_bytes: 3828
import java.util.Arrays;
import java.util.Scanner;

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

        int points[] = new int[sc.nextInt()];
        int startPoint = sc.nextInt();
        int correctNum = sc.nextInt();

        Arrays.fill(points, startPoint);

        for(int i = 0; i < correctNum; i++){
            int answer = sc.nextInt() - 1 ;
                points[answer] += 1;
        }

        for(int i = 0;  i< points.length; i++){
            if(points[i] - correctNum > 0){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }

    }
}


Measured memory_bytes: 57284
#include<stdio.h>

#define MAX 200001

int main(void){

    int N,i;
    long int A[MAX],ans = 0;

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

    for(i = 1;i < N;i++){
        if(A[i-1] > A[i]){
            ans += A[i-1] - A[i];
            A[i] += A[i-1] - A[i];
        }
    }

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

Measured memory_bytes: 3292
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		string[] str2 = Console.ReadLine().Split();
		string[] str3 = Console.ReadLine().Split();
		long[]C = new long[6];
		C[0] = long.Parse(str[0]);
		C[1] = long.Parse(str[1]);
		C[2] = long.Parse(str2[0]);
		C[3] = long.Parse(str2[1]);
		C[4] = long.Parse(str3[0]);
		C[5] = long.Parse(str3[1]);
		long[]D = new long[4];
		for(var i=0;i<6;i++){
			D[C[i]-1]++;
		}
		long[]E = new long[6];
		for(var i=0;i<4;i++){
			E[D[i]]++;
		}
		string ans = "NO";
		if(E[1]==2 && E[2]==2){
			ans = "YES";
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13140
from collections import deque
import copy
import sys
sys.setrecursionlimit(1000)
a,b=map(int,input().split())
maze=[list(input()) for i in range(a)]
ans=0
for i in range(a):
  for j in range(b):
    l=copy.deepcopy(maze)
    if l[i][j]!="#":
      l[i][j]=0
      q=deque([[i,j]])
      while q:
        h,w=q.popleft()
        if 0<=h-1<a and 0<=w<b:
          if l[h-1][w]==".":
            l[h-1][w]=l[h][w]+1
            q.append([h-1,w])
        if 0<=h+1<a and 0<=w<b:
          if l[h+1][w]==".":
            l[h+1][w]=l[h][w]+1
            q.append([h+1,w])
        if 0<=h<a and 0<=w-1<b:
          if l[h][w-1]==".":
            l[h][w-1]=l[h][w]+1
            q.append([h,w-1])
        if 0<=h<a and 0<=w+1<b:
          if l[h][w+1]==".":
            l[h][w+1]=l[h][w]+1
            q.append([h,w+1])
      s=0
      for x in l:
        for y in x:
          if type(y)==int:
            if y>s:
              s=y
      if ans<s:
        ans=s
print(ans)

Measured memory_bytes: 3564
#!/usr/bin/env python3
#ABC94 C

from copy import deepcopy
from operator import itemgetter
n = int(input())
x = list(map(int,input().split()))
y = sorted(x)
c1 = y[n//2-1]
c2 = y[n//2]
for i in x:
    if i < c2:
        print(c2)
    elif i >= c2:
        print(c1)


Measured memory_bytes: 93128
#include <stdio.h>
#include <string.h>
#define rep(i, a) for(int i = 0; i < a; ++i)

int main(void) {
  char s[250], t[250];
  int m, i, j, n, a;
  while( 1 ) {
    scanf("%s", s);
    n = strlen(s);
    if(n == 1 && s[0] == '-') break;
    scanf("%d", &m);
    rep(i, m) {
      scanf("%d", &a);
      rep(j, a) t[j] = s[j];
      t[a] = 0;
      rep(j, (n - a)) s[j] = s[j + a];
      rep(j, a) s[j + n - a] = t[j];
    }
    printf("%s\n", s);
  }
  return 0;
}


Measured memory_bytes: 2580
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <cassert>
#include <unordered_map>

#define _(x) { cout << #x << " = " << x << " "; }

const double E = 1e-8;
const double PI = acos(-1);

using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> v(n+1);
    vector<bool> tr(n+1, true);
    for (int i = 0; i < n; ++i) cin >> v[i+1];
    while (m--) {
        int a, b;
        cin >> a >> b;
        if (v[a] < v[b]) tr[a] = false;
        else if (v[b] < v[a]) tr[b] = false;
        else {
            tr[a] = false; tr[b] = false;
        }
    }
    int ans = 0;
    /*
    for (int i = 0; i < n; ++i) {
        cout << i+1 << " " << tr[i+1] << '\n';
    }
    */
    for (int i = 0; i < n; ++i) if (tr[i+1]) ++ans;
    cout << ans << '\n';
    return 0;
}



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

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__() for(long blockTime=NULL;(blockTime==NULL?(blockTime=clock())!=NULL:false); debug("Time:%.4fs\n",(double)(clock()-blockTime)/CLOCKS_PER_SEC))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.14159265358979323846264338327
#define INF 2e9
#define MOD 998244353
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef unsigned long long ull;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	bool a[10];
	memset(a,0,sizeof(a));
	for(int i=0;i<4;i++){
		int x;	cin>>x;
		a[x]=true;
	}
	
	if(a[1]&&a[7]&&a[9]&&a[4])	cout<<"YES"<<'\n';
	else cout<<"NO\n";
	
	return 0;
}


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

using namespace std;

template<class INT>
std::vector<INT> get_min_prime_fact_table(INT n){
    std::vector<INT> lp(n + 1), P;
    for (INT i = 2; i <= n; i++){
        if (lp[i] == 0){
            lp[i] = i;
            P.push_back(i);
        }
        for (INT j = 0; j <= P.size() and P[j] <= lp[i] and i * P[j] <= n; j++)
            lp[i * P[j]] = P[j];
    }

    return lp;
}

template<class INT>
std::vector<int> prime_factorize(INT n, std::vector<INT> &lp){
    vector<int> res(1, 1);
    int last = 2;
    while (n != 1){
        if (last != lp[n]){
            res.push_back(1);
            last = lp[n];
        }
        n /= lp[n];
        res[res.size() - 1]++;
    }

    return res;
}

int main(){
    int n;
    cin >> n;
    auto lp = get_min_prime_fact_table(n);
    int64_t ans = 0;
    for (int i = 1; i <= n; i++){
        auto P = prime_factorize(i, lp);
        ans += int64_t(i) * accumulate(P.begin(), P.end(), 1, [](auto &l, auto &r){return l * r;});
    }

    cout << ans << endl;
}

Measured memory_bytes: 46512
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <deque>
#include <utility>
#include <algorithm>
using namespace std;

int main(void){
   
    string o, e;
    
    cin>>o;
    cin>>e;
    
    int idx=o.size()+e.size();
    
    for(int i=0; i<idx; i++){
        if(i%2==0){
            cout<<o[i/2];
        }else{
            cout<<e[(i-1)/2];
        }
    }
    cout<<endl;
    
}


Measured memory_bytes: 256
//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
        if (i == 0 || h[i] - 1 >= h[i - 1]) {
            h[i]--;
        }
    }
    for (int i = 0; i + 1 < n; i++) {
        if (h[i] > h[i + 1]) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 640