akhauriyash/Code-Regression huggingface dataset:
program main
    implicit none
    integer n
    character(len=10),allocatable, dimension(:) :: s
    integer i,j,k,l,sum,minus,up

    type mytype
        integer :: number
        character(len=10),dimension(200000) :: word
    end type mytype

    type(mytype) :: alpha(26,10)

    read(*,*) n
    allocate(s(n))

    do i = 1,26
        do j = 1,10
            alpha(i,j)%number = 0
        end do
    end do

    do i = 1,n
        read(*,*) s(i)
        if (s(i)(1:1) == "a") then
            k = 1
        else if (s(i)(1:1) == "b") then
            k = 2
        else if (s(i)(1:1) == "c") then
            k = 3
        else if (s(i)(1:1) == "d") then
            k = 4
        else if (s(i)(1:1) == "e") then
            k = 5
        else if (s(i)(1:1) == "f") then
            k = 6
        else if (s(i)(1:1) == "g") then
            k = 7
        else if (s(i)(1:1) == "h") then
            k = 8
        else if (s(i)(1:1) == "i") then
            k = 9
        else if (s(i)(1:1) == "j") then
            k = 10
        else if (s(i)(1:1) == "k") then
            k = 11
        else if (s(i)(1:1) == "l") then
            k = 12
        else if (s(i)(1:1) == "m") then
            k = 13
        else if (s(i)(1:1) == "n") then
            k = 14
        else if (s(i)(1:1) == "o") then
            k = 15
        else if (s(i)(1:1) == "p") then
            k = 16
        else if (s(i)(1:1) == "q") then
            k = 17
        else if (s(i)(1:1) == "r") then
            k = 18
        else if (s(i)(1:1) == "s") then
            k = 19
        else if (s(i)(1:1) == "t") then
            k = 20
        else if (s(i)(1:1) == "u") then
            k = 21
        else if (s(i)(1:1) == "v") then
            k = 22
        else if (s(i)(1:1) == "w") then
            k = 23
        else if (s(i)(1:1) == "x") then
            k = 24
        else if (s(i)(1:1) == "y") then
            k = 25
        else if (s(i)(1:1) == "z") then
            k = 26
        end if
        l = len_trim(s(i))
        alpha(k,l)%number = alpha(k,l)%number + 1
        alpha(k,l)%word(alpha(k,l)%number) = s(i)
    end do

    sum = n

    do i = 1,26
        do j = 1,10

            minus = 0
            up = alpha(i,j)%number
            if (up <= 1) then
                go to 20
            end if
            do k = 1,up
                if (alpha(i,j)%word(k) == "0") then
                    go to 10
                end if
                do l = k + 1, up
                    if(alpha(i,j)%word(k) == alpha(i,j)%word(l)) then
                        minus = minus + 1
                        alpha(i,j)%word(l) = "0"
                    end if
                end do
                10 continue
            end do
            20 continue

            sum = sum - minus

        end do
    end do

    write(*,*) sum


end program

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

using namespace std;
typedef long long ll;

ll X,sum[2][200004];
int now = 0,rev = 1;

ll x(int now,int ind){
    if(ind==0){return sum[now][0];}
    return sum[now][ind]-sum[now][ind-1];
}

int main(){
    int N;
    ll L;
    cin>>L>>N;
    
    for(int i = 0;i < N;i++){
        cin>>X;
        sum[0][i]=X;
        sum[1][N-1-i]=L-X;}
    for(int i = 1;i < N;i++){
        sum[0][i]+=sum[0][i-1];
        sum[1][i]+=sum[1][i-1];
    }
    ll ans = 0;
    for(int xxxx = 0;xxxx < 2;xxxx++){
        for(int i = 0;i < N;i++){
            ll temp = 0;
            if((N-i)%2==1){
                int j = (N-1-i)/2;
                temp = 2*sum[rev][j-1]+2*sum[now][j+i]-x(now,j+i);
                if(i>0){temp -= 2*sum[now][i-1];}
            }else{
                int j = (N-i)/2;
                temp = 2*sum[rev][j-1]+2*sum[now][j+i-1]-x(rev,j-1);
                if(i>0){temp -= 2*sum[now][i-1];}
            }
            ans = max(ans,temp);
        }
        now = 1,rev = 0;
    }
    cout<<ans<<endl;
    
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int sum[90005];
int ii[90005];
int jj[90005];

int main() {
    std::ios::sync_with_stdio(false);
    int h, w, d;cin >> h >> w >> d;
    inc(i, 0, h){
        inc(j, 0, w){
            int a;cin >> a;
            ii[a] = i;
            jj[a] = j;
        }
    }
    inc(k, 1, h*w+1){
        if(k+d <= h*w){
            int dist = abs(ii[k+d]-ii[k]) + abs(jj[k+d]-jj[k]);
            sum[k+d] = sum[k] + dist;
        }
    }

    int q;cin >> q;
    inc(i, 0, q){
        int l, r;cin >> l >> r;
        cout << sum[r]-sum[l] << endl;
    }
    return 0;
}


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

#define FOR(n)          for(int i=0; i<(int)(n); ++i)
#define FORI(i, s, n)   for(int i=(int)(s); i<(int)(n); ++i)
#define F0RIJ(i, a)     for(int i=0; i<(int)(a); i++)
#define FORP(x)         for(__typeof__((x).begin()) it=(x).begin(); it!=(x).end(); ++it)

#define all(V)          V.begin(),V.end()
#define FF              first
#define SS              second
//#define sz(V)           ((int) (V).size())
#define pb              push_back
#define pii             pair<int, int>
#define ll              long long
#define sz              size()
#define ull             unsigned long long
#define mem(A)          memset(A, 0, sizeof(A))
#define lg              length()

#define all(V)          V.begin(),V.end()
#define clr(A,B)        memset(A,B,sizeof A)

#define input           freopen("input.txt", "r", stdin);
#define output          freopen("output.txt", "w", stdout);
#define sync            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define dbg(args...)    {string sss(#args);sss+=',';cout<<"-->";debugger::call(all(sss), args);cout<<"\n";}
#define dbgA(A, n)      {cout<<"-->"<<#A<<"=(";FOR(n)cout<<A[i]<<" ";cout<<")\n";}
#define dbgA2(A, n, m)  {cout<<"-->"<<#A<<"=\n";FOR(n){FORI(j, 0, m){cout<<A[i][j]<<" ";}cout<<"\n";}cout<<"\n";}

#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl

#define dt ll

struct debugger {
    typedef string::iterator si;
    static void call(si it, si ed) {}
    template<typename T, typename ... aT>
    static void call(si it, si ed, T a, aT... rest) {
        string b;
        for(; *it!=','; ++it) if(*it!=' ')b+=*it;
        cout << b << "=" << a << " ";
        call(++it, ed, rest...);
    }
};

vector<dt> takeInput(dt n){
    vector<dt> v;
    for(dt i=0;i<n;i++){
        dt temp;
        cin >> temp;
        v.push_back(temp);
    }
    return v;
}


int main()
{

    dt n;
    cin >> n;
    vector<dt> v = takeInput(n);

    dt odd,even,evenNeed;
    odd=even=evenNeed=0;

    for(dt i=0;i<n;i++){
        if(v[i]%2==1){
            odd++;
        }
    }
    if(odd%2==0){
        yes;
    }else  {
        no;
    }

    return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100010;
const int inf=1e9;
int dp[N];
int main(){
    int n,k;
    cin>>n>>k;
    int a[n+5];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++) dp[i]=inf;
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<=k;j++){
        if(i-j>=0) dp[i]=min(dp[i],dp[i-j] + abs(a[i]-a[i-j]));
        }
    }
    cout<<dp[n-1]<<'\n';
    
}
  


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

using namespace std;

#define PB push_back
#define ALL(v) (v).begin(), (v).end()
#define SZ size()
#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define REP(i, n) FOR((i), 0, (n))
#define GET(a) cin >> (a)
#define GET2(a, b) cin >> (a) >> (b)
#define GET3(a, b, c) cin >> (a) >> (b) >> (c)
#define SHOW(v) cout << (v) << endl
#define SHOW2(a, b) cout << (a) << " " << (b) << endl
#define SHOW3(a, b, c) cout << (a) << " " << (b) << " " << (c) << endl
#define MOD 1000000007
template<class T> void GETV(T &v) { REP(i, v.size()) { GET(v[i]); } }
template<class T> void SHOWV(T &v) { REP(i, v.size()) { SHOW(v[i]); } }

typedef long long ll;

int main() {
	int n;
	cin >> n;
	
	vector<int> v(n);
	for(int i = 0; i < n; i++) {
		cin >> v[i];
	}
	
	vector<int> c(n);
	for(int i = 0; i < n; i++) {
		cin >> c[i];
	}
	
	int ans = 0;
	for(int i = 0; i < n; i++) {
		if(v[i] - c[i] > 0) {
			ans += v[i] - c[i];
		}
	}
	
	cout << ans << endl;
	
    return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n;
  cin >> n;
  vector<int32> a(n),b(n);
  REP(i,n)cin >> a[i] >> b[i];
  sort(ALL(a));
  sort(ALL(b));
  int32 x = (n+1)/2-1;
  int32 l1 = a[x];
  int32 l2 = a[x+1];
  int32 r1 = b[n-1-x];
  int32 r2 = b[n-1-x-1];
  if(n % 2 == 0){
    ANS((r1+r2 - l1-l2) + 1);
  }else{
    ANS((r1-l1) + 1);
  }

  return 0;
}

Measured memory_bytes: 6368
N=int(input())
count=0
a=list(map(int,input().split()))
w=[]
s=[]
num=[0]*N
maxi=max(a)
for i in range(N):
  s.append(i-a[i])
  if i+a[i]<N:
    num[i+a[i]]+=1
for i in range(N):
  if s[i]>=0:
    count+=num[s[i]]
print(count)

Measured memory_bytes: 32240
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long q, h, s, d; cin >> q >> h >> s >> d;
    long long n; cin >> n; n *= 4;
    h = min(q*2, h);
    s = min(h*2, s);
    d = min(s*2, d);
    long long ans = 0;
    ans += (n / 8) * d;
    n %= 8;
    ans += (n / 4) * s;
    n %= 4;
    ans += (n / 2) * h;
    n %= 2;
    ans += n * q;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
for i in range(1,10):
    print(f"{i}x1={i}")
    print(f"{i}x2={i*2}")
    print(f"{i}x3={i*3}")
    print(f"{i}x4={i*4}")
    print(f"{i}x5={i*5}")
    print(f"{i}x6={i*6}")
    print(f"{i}x7={i*7}")
    print(f"{i}x8={i*8}")
    print(f"{i}x9={i*9}")


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

// data types
#define ll long long int
#define ld long double

//funtion macros


// stl
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define ilp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll> 
#define pld pair<ld,ld> 
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define sz(x) ((ll)((x).size()))

#define mod 1000000007

// utility functions
ll max(ll a, ll b)
{
    if(a>b)return a;
    return b;
}

ll min(ll a, ll b)
{
	if(a<b)return a;
    return b;
}

ll power(ll x, ll y, ll m=mod)
{
	if(y<0)
    {
		x = power(x,m-2);
		y = -y;
	}
	ll ans=1;
	x = x % m;
	while(y)
    {
		if(y&1) ans = (ans*x)%m;
		y=y/2;
		x=(x*x)%m;
	}
	return ans;
}


int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int a,b;
    cin >> a >> b;
    cout << a*b << "\n";
	return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>
int mountain[10];
int main(){
	int n,temp;
	for (int i = 0;i < 10;i++) {
		scanf("%d",&n);
		mountain[i] = n;
	}
	for (int i = 0;i < 10;i++) {
		for (int j = 0;j < 9-i;j++) {
			if (mountain[j] > mountain[j+1]) {
				temp = mountain[j+1];
				mountain[j + 1] = mountain[j];
				mountain[j] = temp;
			}
		}
	}
	printf("%d\n", mountain[9]);
	printf("%d\n", mountain[8]);
	printf("%d\n", mountain[7]);
	
}

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

from collections import Counter

c = Counter(A)

odd = 0
even = 0
for v in c.values():
    if v % 2 == 0:
        even += 1
    else:
        odd += 1

if even % 2 == 0:
    ans = odd + even
else:
    ans = odd + even - 1

print(ans)

Measured memory_bytes: 18528
s = input()
t = input()


# 後ろから見ていって、はまったらa埋めする
def check_embed(s, t, ind):
    use_s = s[ind:ind+len(t)]
    for i in range(len(t)):
        if use_s[i] != "?" and use_s[i] != t[i]:
            return False
    return True

def check_a(s, t, ind):
    use_s = s[ind:ind+len(t)]
    for i in range(len(t)):
        if not ((use_s[i] == "?" and t[i] == "a") or use_s[i] == t[i]):
            return False
    return True

"""
flag = 0
for i in range(len(s) - len(t) + 1):
    if check_a(s, t, i):
        print(i)
        flag = 1
        s = (s[:i] + t + s[i + len(t):]).replace("?", "a")
        break
if flag:
    print(s)
else:
"""
ans = []
flag = 0
for i in range(len(s) - len(t) + 1):
    if check_embed(s, t, len(s) - len(t) - i):
        flag = 1
        ans.append((s[:len(s) - len(t) - i] + t + s[len(s) - i:]).replace("?", "a"))
if flag:
    ans.sort()
    print(ans[0])
else:
    print("UNRESTORABLE")


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


int main (void)
{
    int N;
    int L_i[2000];
    int ans=0;
    std::cin >> N;
    for(int i=0;i<N;i++){
        std::cin >> L_i[i];
    }
    std::sort(L_i, L_i+N, std::greater<int>());
    for(int i=0;i<N-2;i++)
    {
        for(int j=i+1;j<N-1;j++)
        {
            for(int k=j+1;k<N;k++)
            {
                if (L_i[i] < L_i[j] + L_i[k])
                {
                    ans++;
                }
            }
        }
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 256
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}
 
let today=readLine()!
if today=="Sunny"{
  print("Cloudy")
}else if today=="Cloudy"{
  print("Rainy")
}else if today=="Rainy"{
  print("Sunny")
}

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

int main(){
  string str;
  cin >> str;
  int type = 1;
  char c = str[0];
  for(int i=0; i<str.length(); i++){
    if(str[i] != c){
      type++;
      c = str[i];
    }
  }
  cout << type-1 << endl;
  return 0;
}
  
  

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

bool compare(pair<ll, ll> a, pair<ll, ll> b) {
    return a.second < b.second;
}

int main(void) {
    ll N;
    map<ll, ll> Am, Bm;
    vector<pair<ll, ll>> A, B;
    ll a, b;
    cin >> N;
    rep(i, N) {
        ll temp;
        cin >> temp;
        if(i % 2) Am[temp]++;
        else Bm[temp]++;
    }
    A = vector<pair<ll, ll>>(Am.begin(), Am.end());
    B = vector<pair<ll, ll>>(Bm.begin(), Bm.end());
    A.push_back({0, 0});
    B.push_back({0, 0});
    sort(A.begin(), A.end(), compare);
    sort(B.begin(), B.end(), compare);
    if(A.back().first == B.back().first) {
        a = N / 2 - A[A.size() - 2].second;
        b = N / 2 - B[B.size() - 2].second;
        if(a > b) a = N / 2 - A.back().second;
        else b = N / 2 - B.back().second;
    } else {
        a = N / 2 - A.back().second;
        b = N / 2 - B.back().second;
    }
    cout << a + b << endl;
    return 0;
}


Measured memory_bytes: 8832
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    H=LI()[::-1]
    for i,h in enumerate(H):
        if i == 0:
            pass
        else:
            if h <= H[i-1]:
                continue
            else:
                H[i]-=1
                if H[i] > H[i-1]:
                    print("No")
                    exit()
            

    print("Yes")
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 59632
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
using namespace std;
typedef pair<int, int> pii;
#define MAX 99999999
int main(){
    int n;
    while(cin>>n,n){
        vvi d(1040,vi(1040,0));
        vvi dp(1040,vi(1040,0));
        rep(i,n){
            pii temp; cin>>temp.first>>temp.second;
            d[temp.first][temp.second]++;
        }
        int m;
        cin>>m;
        rep(i,m){
            pii temp;
            cin>>temp.first>>temp.second;
            d[temp.first][temp.second]++;
        }
        loop(i,1,1001){
            loop(j,1,1001){
                dp[i][j]=max(max(dp[i-1][j],dp[i][j-1]),dp[i-1][j-1]+d[i][j]);
        
            }
        }
        cout<<dp[999][999]<<endl;
    }
    
}

Measured memory_bytes: 11268
//ID:computerbox --> Hajiyev Huseyn
#include <bits/stdc++.h>
#define FAST_READ ios_base::sync_with_stdio(false);
#define in freopen("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define COUT(n, a) cout<< fixed << setprecision(a) << n<<endl
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";
#define CURTIME() cerr << clock() * 1.0 / CLOCKS_PER_SEC << endl
#define DTIME(ccc) __begin = clock(); ccc; cerr<<"Time of work = "<<(clock()-__begin)/CLOCKS_PER_SEC<<endl;
#define MAXN 200010

using namespace std;

ll N;
vector<ll>massiv;

map<ll,ll>used;

int main(){
FAST_READ;
cin>>N;
massiv.resize(N+1);
for(ll i=1;i<=N;i++)
{
	cin>>massiv[i];
	used[massiv[i]]++;
}
ll maxa=-123123123123;
for(ll i=1;i<=N;i++)
{
	//debt(used[massiv[i]-2]+used[massiv[i]-1]+used[massiv[i]],used[massiv[i]+2]+used[massiv[i]+1]+used[massiv[i]]);
 maxa=max(maxa,max(used[massiv[i]-2]+used[massiv[i]-1]+used[massiv[i]],max(used[massiv[i]],used[massiv[i]+2]+used[massiv[i]+1]+used[massiv[i]])));
}


cout<<maxa<<endl;


return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pllll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  pii p[n];
  fi(0, n)
    cin >> p[i].first >> p[i].second;
  // sort(p, p + n);
  map<pii, int> m;
  fi(0, n)
    fj(0, n) {
      if(i == j) continue;
      int a = p[i].first - p[j].first;
      int b = p[i].second - p[j].second;
      if(a == 0 && b == 0) continue;
      m[pii{a, b}]++;
    }
    // m[pii{ p[i].first - p[i - 1].first, p[i].second - p[i - 1].second }]++;
  for(auto x: m) {
    if(x.first.first == 0 && x.first.second == 0) continue;
    chmax(ans, (ll)x.second);
  }
  // cout << ans << endl;
  cout << n - ans << endl;
  return 0;
}



Measured memory_bytes: 384
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
ans = 0
skw1 = [0]*3
skw2 = [0]*3
for _ in range(N):
  b = int(input())
  for i in range(3):
    if b in A[i]:
      A[i][A[i].index(b)]=0
for i in range(3):
  if all([a==0 for a in A[i]]):
    ans = 1
  if all([a[i]==0 for a in A]):
    ans = 1
  if A[i][i]==0:
    skw1[i] = 1
  for j in range(3):
    if i+j == 2:
      if A[i][j]==0:
        skw2[i] = 1

print('Yes' if ans or all(skw1) or all(skw2) else 'No')

Measured memory_bytes: 3064
// B.

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

using namespace std;

typedef long long LL;

int main(int argc, char *argv[]) {
	LL n, a, b;
	cin >> n >> a >> b;
	LL c = n / (a + b);
	LL r = n - (a + b) * c;
	LL ans = a * c + min(a, r);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
def comb_mod(a: int, b: int, mod: int = 10**9+7) -> int:
    """Returns Comb(a, b) % mod
    Precondition: mod is prime
    Complexity: O(min(a-b, b))
    :param a:
    :param b:
    :param mod: a prime number
    :return:
    """
    b = min(b, a-b)

    res = 1
    for x in range(a-b+1, a+1):
        res = res * x % mod

    # Using Fermat's little theorem
    # a^{p-1} = 1 mod p
    # a^{p-2} = a^{-1} mod p
    for x in range(1, b+1):
        res = res * pow(x, mod-2, mod) % mod

    return res


def main():
    n, a, b = map(int, input().split())
    MOD = 10**9+7
    ans = pow(2, n, MOD)
    ans = (ans - comb_mod(n, a, MOD)) % MOD
    ans = (ans - comb_mod(n, b, MOD)) % MOD
    ans = (ans - 1) % MOD
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<int> p(n),q(n);
    rep(i,n)cin>>p[i],--p[i];
    rep(i,n)cin>>q[i],--q[i];
    vector<int> s(n);
    rep(i,n)s[i]=i;
    map<vector<int>,int> ord;
    int itr=0;
    do{
        ord[s]=itr++;
    } while(next_permutation(s.begin(),s.end()));
    cout<<abs(ord[p]-ord[q])<<endl;   
    return 0;
}


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

using namespace std;


uintmax_t combination(unsigned int n, unsigned int r) {
    if ( r * 2 > n ) r = n - r;
    uintmax_t dividend = 1;
    uintmax_t divisor  = 1;
    for ( unsigned int i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return dividend / divisor;
}

int main() {
    int n;
    cin>>n;
    vector<int> x(n,-1);
    for(int i=0;i<n;i++)cin>>x[i];
    int an=*max_element(x.begin(),x.end());
    int mi=distance(x.begin(),max_element(x.begin(),x.end()));
    x[mi]=*min_element(x.begin(),x.end());
    int med[2];
    if(an%2==0){med[0]=an/2;med[1]=an/2;}
    else {med[0]=(an-1)/2;med[1]=(an+1)/2;}
    int diff=1000000000,ans;
    for(int i=0;i<n;i++) {
        if(diff>min(abs(x[i] - med[0]), abs(x[i] - med[1]))){
            ans=x[i];
            diff=min(abs(x[i] - med[0]), abs(x[i] - med[1]));
        }
    }
/*
    int aan=*max_element(x.begin(),x.end());
    if(aan%2==0){med[0]=aan/2;med[1]=aan/2;}
    else {med[0]=(aan-1)/2;med[1]=(aan+1)/2;}
    int ddiff=1000000000,aans;
    for(int i=0;i<n;i++) {
        if(ddiff>min(abs(x[i] - med[0]), abs(x[i] - med[1]))){
            aans=x[i];
            ddiff=min(abs(x[i] - med[0]), abs(x[i] - med[1]));
        }
    }
    if(combination(an,ans)<combination(aan,aans)){an=aan;ans=aans;}
    */
    cout<<an<<" "<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define double long double
#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,sse")
using namespace std;

int n, k, ans = 0;
vector<int> arr;

int ind(int x, vector<int> &arr) {
    if (arr.empty() || arr[0] >= x) {
        return 0;
    } else if (arr.back() < x) {
        return arr.size();
    } else {
        int l = 0;
        int r = arr.size() - 1;
        while (r - l > 1) {
            int m = (l + r) >> 1;
            if (arr[m] < x) {
                l = m;
            } else {
                r = m;
            }
        }
        return r;
    }
}

void go(int l, int r) {
    if (l == r) {
        if (arr[l] == 1) {
            ans++;
        }
    } else {
        int m = (l + r) >> 1;
        map<int, vector<int>> delta;
        for (int i = m + 1, curr = 0, len = 1; i <= r; i++, len++) {
            curr = (curr + arr[i]) % k;
            int d = (curr - len + k) % k;
            delta[d].push_back(len);
        }
        for (auto pr : delta) {
            int x = pr.first;
            sort(delta[x].begin(), delta[x].end());
        }
        for (int i = m, curr = 0, len = 1; i >= l; i--, len++) {
            curr = (curr + arr[i] % k);
            int d = (curr - len + k) % k;
            ans += ind(k - len, delta[(k - d) % k]);
        }
        go(l, m);
        go(m + 1, r);
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> k;
    arr.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
        arr[i] %= k;
    }
    go(0, n - 1);
    cout << ans << '\n';

    fflush(stdout);
    return 0;
}


Measured memory_bytes: 42248
import sys, math
from functools import lru_cache
import numpy as np
import heapq
from collections import defaultdict
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


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


def main():
    N, A, B, C = [ii(), input(), input(), input()]
    cnt = 0

    for i in range(N):
        k = len(set([A[i], B[i], C[i]]))
        if k == 2:
            cnt += 1
        if k == 3:
            cnt += 2
    print(cnt)

if __name__ == '__main__':
    main()


Measured memory_bytes: 26996
import java.util.ArrayList;
import java.util.Collections;

public class Main {
	public static void main(String[] args) {
		var sc = new java.util.Scanner(System.in);
		var n = sc.nextInt();
		var k = sc.nextInt();
		var p = new ArrayList<Integer>();
		for(int i=0;i<n;i++) {
			p.add(sc.nextInt());
		}
		Collections.sort(p);

		int count = 0;
		for(int i=0;i<k;i++) {
			count+=p.get(i);
		}

		System.out.println(count);
	}
}

Measured memory_bytes: 38956
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    vint A(N);
    rep(i, N - 1) cin >> A[i];
    unordered_map<int, int> ans;
    rep(i, N - 1) {
        ans[A[i]]++;
    }
    REP(i, 1, N + 1) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 12216
#!/usr/bin/env python
# -*- coding:utf-8 -*-
#from __future__ import print_function
import time
import sys
import io
import re
import math
start = time.clock()
i = 0
n=int(raw_input())
A=map(int, raw_input().split())
A.sort()
print ' '.join(map(str,A))

Measured memory_bytes: 186476
from itertools import accumulate


def get_primes_til(n):
    primes = [True] * (n + 1)
    primes[0] = False
    primes[1] = False
    for i in range(2, int(n ** .5) + 1):
        for j in range(2 * i, n + 1, i):
            primes[j] = False
    return primes


N_MAX = 10 ** 5
is_prime = get_primes_til(N_MAX)
is_2017_like = list(accumulate([1 if is_prime[i] and is_prime[(i + 1) // 2] else 0 for i in range(N_MAX + 1)]))
for _ in range(int(input())):
    l, r = map(int, input().split())
    print(is_2017_like[r] - is_2017_like[l - 1])


Measured memory_bytes: 7704
#include<cstdio>
#include<algorithm>

using namespace std;

int a, b, c, d, e, f, g;

long long calc1(int a, int b, int c, int d, int e, int f, int g){
	if(a < 0 || d < 0 || e < 0) return -100;
	long long res = 0;
	res += (a / 2) * 2;
	a %= 2;
	res += b;
	res += (d / 2) * 2;
	d %= 2;
	res += (e / 2) * 2;
	e %= 2;
	return res;
}

long long calc2(int a, int b, int c, int d, int e, int f, int g){
	long long x = calc1(a - 1, b, c, d - 1, e - 1, f, g);
	return x + 3;
}

long long solve(){
	long long x = calc1(a, b, c, d, e, f, g);
	long long y = calc2(a, b, c, d, e, f, g);
	return max(x, y);
}

void input(){
	scanf("%d%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f, &g);
}

int main(){
	input();
	long long ans = solve();
	printf("%lld\n", ans);
	return 0;
}


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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n = in();
    vint a = in(n);
    auto ma = max_element(ALL(a));
    auto mi = min_element(ALL(a));
    vector<pint> ans;
    if (*ma >= 0 && *mi < 0)
    {
        if (abs(*ma) >= abs(*mi))
        {
            rep(i, n)
            {
                a[i] += *ma;
                ans.emplace_back((ma - a.begin()), i);
            }
        }
        else
        {
            rep(i, n)
            {
                a[i] += *mi;
                ans.emplace_back((mi - a.begin()), i);
            }
        }
    }

    auto ma2 = max_element(ALL(a));
    auto mi2 = min_element(ALL(a));
    if (*mi2 >= 0)
    {
        rep(i, n - 1)
        {
            if (a[i] <= a[i + 1])
                continue;
            ans.emplace_back(i, i + 1);
            a[i + 1] += a[i];
        }
    }
    else
    {
        for (int i = n - 1; i >= 1; --i)
        {
            if (a[i - 1] <= a[i])
                continue;
            ans.emplace_back(i, i - 1);
            a[i - 1] += a[i];
        }
    }

    cout << ans.size() << endl;
    rep(i, ans.size()) cout << ans[i].first + 1 << " " << ans[i].second + 1 << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

class Main {

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] A = new long[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextLong();
		}
		solve(N, A);
	}

	static void solve(int N, long[] A) {
		long[] sum = new long[N + 1];
		for (int i = 0; i < N; i++) {
			sum[i + 1] = sum[i] + A[i];
		}

		int l = 1;
		int r = 3;
		long answer = Long.MAX_VALUE;
		for (int i = 2; i < N - 1; i++) {
			while (l < i - 1 && Math.abs(sum[i] - sum[l] * 2) >
					Math.abs(sum[i] - sum[l + 1] * 2)) {
				l++;
			}

			while (r < N - 1 && Math.abs(sum[N] - sum[i] - (sum[r] - sum[i]) * 2) >
					Math.abs(sum[N] - sum[i] - (sum[r + 1] - sum[i]) * 2)) {
				r++;
			}

			long[] a = new long[]{sum[l], sum[i] - sum[l], sum[r] - sum[i], sum[N] - sum[r]};
			Arrays.sort(a);

			answer = Math.min(answer, Math.abs(a[3] - a[0]));
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 85620
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <map>
#include <iomanip>

using namespace std;

void solve(){
    int a, b;
    cin >> a >> b;
    string ans(max(a, b), '0' + min(a, b));
    cout << ans << endl;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(16);
    
    solve();

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    string s, t;
    cin >> s >> t;

    ll ans = 0;

    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] != t[i])
        {
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3812
#include<iostream>
#include<vector>
#include <algorithm>
#include <cstdio>
using namespace std;
int main(){
    int N,h,m;
    int M,k,g;
    vector<int> time;
    cin>>N;
    for (int i=0; i<N; i++) {
        cin>>h>>m;
        time.push_back(h*60+m);
    }
    cin>>M;
    for (int i=0; i<M; i++) {
        cin>>k>>g;
        time.push_back(k*60+g);
    }
    sort(time.begin(), time.end());
    for (int i=0; i<time.size()-1; i++) {
        if (time[i]==time[i+1]) {
            time.erase(time.begin()+i);
        }
    }
    for (int i=0; i<time.size()-1; i++) {
        printf("%d:%02d ",time[i]/60,time[i]%60);
    }
    printf("%d:%02d\n",time[time.size()-1]/60,time[time.size()-1]%60);
    return 0;
}

Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
int main(){
    int A,B,K;
    cin >> A >> B >> K;
    if(B-A+1 <= 2*K) for(int i = 0;i < B-A+1;i ++) cout << A+i << endl;
    else {
        for(int i = 0;i < K;i ++) cout << A+i << endl;
        for(int i = 0;i < K;i ++) cout << B-K+1+i << endl;
    } 
    return 0;
}

Measured memory_bytes: 384
n = int(input())
h = list(map(int,input().split()))
count = 0
for i in range(n-1):
  if h[i]-h[i+1]>=2:
    print("No")
    exit()
  elif h[i]-h[i+1]==1:
    count+=1
    if count >= 2:
      print("No")
      exit()
  elif h[i]-h[i+1]<=-1:
    count = 0
print("Yes")
  
  
  
    
    
  

Measured memory_bytes: 14396
H,W=map(int,input().split())
 
S=[input() for i in range(H)]
R=['' for i in range(H)]

for i in range(H):
  for j in range(W):
    sum=0
    if i!=0:
      sum+=S[i-1][max(0,j-1):min(W,j+2)].count('#')
    sum+=S[i][max(0,j-1):min(W,j+2)].count('#')
    if i!=H-1:
      sum+=S[i+1][max(0,j-1):min(W,j+2)].count('#') 
    if S[i][j]=='.':
      R[i]+=str(sum)
    else:      
      R[i]+='#'
    
print(*R,sep='\n')

Measured memory_bytes: 3064
N = int(input().strip())
T,A = map(int,input().strip().split())
Hs = [int(x) for x in input().strip().split()]
posTemp = 10000000
posId = 0
for i in range(N):
    if posTemp > abs(A - (T - Hs[i] * 0.006)):
        posTemp = abs(A - (T - Hs[i] * 0.006))
        posId = i + 1
print(posId)

Measured memory_bytes: 3060
/* include c++ libraries */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>

/* include c-lang libraries */
#include <climits>
#include <cmath>

/* include my libraries */
//#include <show_vec.hh>

using namespace std;

#define LINE DEBUG{ printf("LINE : %d\n", __LINE__); }
#define DEBUG if(false)

using ll = long long;
template<class T> using vec = vector<T>;

const int MOD = 1000000007;

int main(){
  int N;
  cin >> N;
  ll Ans = 0;
  for(int a = 1; a < N; a++){
    int b_max = N / a;
    if(a * b_max == N){
      Ans += (b_max-1);
    }else{
      Ans += b_max;
    }
  }
  cout << Ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
using namespace std;
int main(void)
{
  int n;
  double x[4],y[4];
  double degree[2];
  
  cin >> n;

  for(int i = n ; i > 0 ; i--){
    cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3];
    degree[0] = (y[1] - y[0]) / (x[1] - x[0]);
    degree[1] = (y[3] - y[2]) / (x[3] - x[2]);

    if(degree[0] == degree[1]) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
//#include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>

using namespace std;
using ll=long long;
using intpair=pair<int,int>;
using intpv=vector<intpair>;
using llpair=pair<ll,ll>;
using llpv=vector<llpair>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;
using pairmat=vector<llpv>;

template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

#define PI 3.141592653589793
#define INTINF 1<<30
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353

#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define iter(name) decltype(name)::iterator
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())
#define init(v,size) v.resize(size); for(auto &a__: v) cin>>a__
#define matin(mat,H,W) for(int i__=0; i__<H; i__++)for(int j__=0; j__<W; j__++) cin>>mat[i__][j__]
#define out(n) cout<<n<<endl

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

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

template<class T> inline void outmat(T& a, int y, int x) {
	for(int i=0; i<y; i++) {
		for(int j=0; j<x; j++) cout<<a[i][j]<<" ";
		cout<<endl;
	}
}

ll GCD(ll a, ll b) { //最大公約数
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll binpow(ll a, ll ex, ll p) { //繰り返し二乗法
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}

ll Fact(ll x, ll p) { //階乗
	ll f=1;
	for(ll i=2; i<=x; i++) {
		f*=i;
		f%=p;
	}
	return f;
}

int DigitNum(ll n) { //桁数
	int digit=0;
	ll div=1LL;
	while(n/div) {
		digit++;
		div*=10;
	}
	return digit;
}


struct Room {
	intvec nxt;
	int mark=-1;
};

int N,M;
Room rm[100001];

void input() {
	cin>>N>>M;
	for(int i=0; i<M; i++) {
		int A,B; cin>>A>>B;
		rm[A].nxt.pushb(B);
		rm[B].nxt.pushb(A);
	}
}

void solve() {
	queue<intpair> s;
	s.push({1,0});
	while(!s.empty()) {
		int pos=s.front().fi, prv=s.front().se;
		s.pop();
		if(rm[pos].mark>=0) continue;
		rm[pos].mark=prv;
		for(int i=0; i<rm[pos].nxt.size(); i++) {
			int npos=rm[pos].nxt[i];
			s.push({npos,pos});
		}
	}

	cout<<"Yes"<<endl;
	for(int i=2; i<=N; i++) {
		cout<<rm[i].mark<<endl;
	}
}

int main() {
	while(1) {
		input();
		solve();
		break;
	}
}


Measured memory_bytes: 12668
#include <cstdio>

main(){
	while(1){
		int h[5] = {0}, t[4] = {0}, w = 0;
		for(;w<5;w++){
			scanf("%d", h+w);t[h[w]]++;
			if(!*h)break;
		}
		if(!*h)break;

		if(t[1] && t[2] && t[3])
			w = -1;
		else if(t[1] && t[2])
			w = 1;
		else if(t[2] && t[3])
			w = 2;
		else if(t[1] && t[3])
			w = 3;
		else
			w = -1;

		while((*t)++<5)
			puts(w<0?"3":h[*t-1]-w?"2":"1");
	}
}

Measured memory_bytes: 0
// inputに入力データ全体が入る
function Main(input) {
  //const input = "3\nABZ";
  const stdin = input.split("\n");
  const n = ~~stdin[0];
  const s = [...stdin[1]];
 
  const alpha = [..."ABCDEFGHIJKLMNOPQRSTUVWXYZ"];

  const replaced = s.reduce((acc, letter) => {
    const index = (alpha.indexOf(letter) + n) % 26;
    return acc += alpha[index];
  }, "");
 
  //出力
  console.log(replaced);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

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

    int ans = (int)log10(n) + 1;

    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ans = min(ans, max((int)log10(i) + 1, (int)log10(n / i) + 1));
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    string s;
    cin >> s;
    int n = s.size();

    bool ans = true;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            if (s[i] == 'L') {
                ans = false;
                break;
            }

        } else {
            if (s[i] == 'R') {
                ans = false;
                break;
            }
        }
    }

    if (ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
using namespace std;
int main(){
	map<string, int>m;
	int q;
	cin>>q;
	while(q--){
		int c;
		string k;
		cin>>c>>k;
		if(c==0){
			int x;
			cin>>x;
			m[k]=x;
		}
		else if(c==1){
			if(m.find(k)==m.end())
				cout<<0<<endl;
			else
				cout<<m[k]<<endl;
		}
		else if(c==2){
			m.erase(k);
		}
	}
	return 0;
}


Measured memory_bytes: 27844
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
//const long long INF = 1LL << 60;
 int INF = 500000;
 int MAX = 1e5+10;
 ll mod = 998244353;

int main(){
  int n,total_w=0;
  cin >> n;
  vector<int> w(n,0);
  rep(i,n){
    cin >> w[i];
    total_w+=w[i];
  }
  int res = INF;
  for(int i=1;i<n;i++){
    int s1 = 0,s2 = 0;
    for(int j=0;j<n;j++){
      if(j<i) s1+=w[j];
      else s2+=w[j];
    }
    int tmp = abs(s1-s2);
    chmin(res,tmp);
  }
  
  cout << res << endl;
}

Measured memory_bytes: 256