akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

VI sum;

int count(int a) {
	int cnt = 0;
	REP(i , sum.size()) {
		//cout << i << endl;
		if ((sum[i]&a) == a) {
			cnt++;
		}
	}
	return cnt;
}
signed main(){
cin.tie(0);
ios::sync_with_stdio(false);

	int N, K;
	cin >> N >> K;
	VI A(N);
	REP(i, N) {
		cin >> A[i];
	}
	REP(i, N) {
		int cnt = 0;
		FOR(j, i, N) {
			 cnt += A[j];
			 sum.push_back(cnt);			
		}
	}
	int ans = 0;
	for (int i = 40; i >= 0; i--) {
		if (count(ans|(1LL<<i))>=K)
			ans |= (1LL << i);
	}

	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 6384
k = int(input())
if k%2==0 or k%5==0:
    print(-1)
    exit()
cnt=1
sup=1
if k%7==0:
    t = 9*k//7
else:
    t=9*k
while 1:
    sup*=10
    sup = sup%t
    if sup==1:
        print(cnt)
        exit()
    cnt+=1

Measured memory_bytes: 8992
#AtCorder Beginner Contest 088 B Card Game for Two

#number of cards
n = int(input())

#cards in the field
line = list(map(int,input().split()))
pointA = 0
pointB = 0

while len(line) > 0:
    pointA += max(line)
    line.remove(max(line))
    if len(line) == 0:
        break
    else:
        pointB += max(line)
        line.remove(max(line))

print(pointA-pointB)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6+7;
int tong[N];
int main()
{
    int n,x,y; scanf("%d%d%d",&n,&x,&y);
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            int res1=abs(i-j);
            int res2=abs(i-x)+abs(j-y)+1;
            tong[min(res1,res2)]++;
        }
    }
    for(int i=1;i<n;i++) printf("%d\n",tong[i]);
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
data=[[],[]]
flag=[[],[]]
for i in range(N):
    data[i%2].append(A[i])
    flag[0].append(i%2)
    flag[1].append((i+1)%2)

num0=0

for i in range(len(data[0])):
    u=data[0][i]
    if u>0:
        num0+=u
    else:
        flag[0][2*i]=1

if num0==0:
    num0=max(data[0])
    flag[0]=[1 for i in range(N)]
    for i in range(len(data[0])):
        u=data[0][i]
        if u==num0:
            flag[0][2*i]=0
            break
            
num1=0

for i in range(len(data[1])):
    u=data[1][i]
    if u>0:
        num1+=u
    else:
        flag[1][2*i+1]=1
        
if num1==0:
    num1=max(data[1])
    flag[1]=[1 for i in range(N)]
    for i in range(len(data[1])):
        u=data[1][i]
        if u==num1:
            flag[1][2*i+1]=0
            break

if num0>num1:
    print(num0)
    H=flag[0]
else:
    print(num1)
    H=flag[1]
ans=[]
ddd=0
for i in range(N):
    if H[i]==1:
        ans.append(1)
        ddd+=1
    else:
        H=H[i:]
        break   
H=[0]+H
kkk=N-ddd
while True:
    if H[kkk]==1:
        ans.append(kkk)
        kkk-=1
    else:
        break

while kkk>0:
    if H[kkk]==0:
        kkk-=1
    else:
        cnt=0
        while H[kkk]==1:
            kkk-=1
            cnt+=1
        for j in range((cnt+1)//2,0,-1):
            ans.append(kkk+j)

print(len(ans))
for u in ans:
    print(u)

Measured memory_bytes: 39024
#include <iostream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int a[5];
    rep(i,5) {
        cin >> a[i];
    }

    int ibuff;
    int min=10;
    int minpos=5;
    rep(i,5) {
        ibuff = a[i]%10;
        if (ibuff !=0 && min>ibuff) {
          min = ibuff;
          minpos=i;
        }
    }
    int totaltime=0;
    rep(i,5) {
        if (i!=minpos) {
            totaltime += (a[i]/10)*10;
            if (a[i]%10) totaltime += 10;
        }
    }
    if (min!=10) {
        totaltime += a[minpos];
    }

    cout << totaltime << endl;
    return 0;
}

Measured memory_bytes: 3536
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a, b;
    cin >> a >> b;
    if (a == 1 && b == 1)
        cout << 1;
    else if (a == 1)
        cout << b - 2;
    else if (b == 1)
        cout << a - 2;
    else
        cout << (a - 2) * (b - 2);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int judge(int n){
    if(n<=12 && n>0){
        return 1;
    }else{
        return 0;
    }
}
int main(){
    int Input;
    int f2=0,r2=0;
    cin >> Input;
    int N = judge(Input/100)*10+judge(Input%100);
    switch(N){
        case 0:
            cout << "NA";
            break;
        case 1:
            cout << "YYMM";
            break;
        case 10:
            cout << "MMYY";
            break;
        case 11:
            cout << "AMBIGUOUS";
            break;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
using namespace std;

int main()
{
  int H,W,cnt=0;
  cin>>H>>W;
  string ans="Impossible";
  string A;
  for(int i=0;i<H;i++){
    cin>>A;
    for(int j=0;j<W;j++){
      if(A[j]=='#') cnt++;
    }
  }
  if(cnt==H+W-1) ans="Possible";
  cout<< ans <<endl;
}


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

int main(){
  int N;
  int64_t a;
  cin >> N;
  vector<int64_t> L(2);
  L = {2, 1};
  for(int i = 0; i < N; i++){
    a = L.at(0) + L.at(1);
    L.at(0) = L.at(1);
    L.at(1) = a;
  }
  cout << L.at(0) << endl;
}

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

int main(){

	int a,b;
	cin >> a >> b;
	if( a < b ){
		cout << "a < b" << endl;
    }
    else if ( a > b ){
    	cout << "a > b"  << endl;
    }
    else if ( a == b ){
    	cout << "a == b" << endl;
    }
    return 0;
}

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

signed main(){
	int k,a,b,ans=0;
	cin>>k>>a>>b;

	if(b-1<=a){
		ans = 1+k;
	}else if(k<=a){
		ans = 1+k;
	}else{
		k=(k-a)+1;
		ans = a;
		while(1){
			ans += (b-a);
			k-=2;
			if(k<=0)break;
		}
		if(k==-1){
			ans -= (b-a);
			ans++;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
import collections
N = int(input())
A = list(map(int, input().split()))

cnt = collections.Counter(A)

ans = 1
if cnt[0] == 1:
    print(0)
    exit()
else:
    for i in A:
        ans = ans * i
        if ans > 10**18:
            print(-1)
            exit()
print(ans)


Measured memory_bytes: 24704
#include<stdio.h>
int main(void)
{
    int a,b,n;
    scanf("%d%d",&a,&b);
    n = (b-1)/(a-1);
    if(n*(a-1)==(b-1))
        printf("%d\n",n);
    else
        printf("%d\n",n+1);
}


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

int B[11]={0};
int C[11]={0};

bool DFS(int *a,int i=0,int b=1,int c=1)
{
	bool judge=true;

	if(i==10)
		return judge;

	judge=false;

	if(B[b-1]<a[i]){
		B[b]=a[i];
		judge=DFS(a,i+1,b+1,c);
		
	}
	if(C[c-1]<a[i]){
		C[c]=a[i];
		judge=DFS(a,i+1,b,c+1);
		
	}

	return judge;
}        

int main()
{
        int N;
	int i=0;
        cin>>N;

	while(i<N){
          int A[10];
          for(int i=0;i<10;i++){
           cin>>A[i];
          }

          if(DFS(A)==true){
           cout<<"YES"<<endl;
          }
          else{
           cout<<"NO"<<endl;
          }

          i++;
        }
                
        return 0;
} 

Measured memory_bytes: 3080
a = int(input())
flg = 0
b =[]
c = ""
for i in range(a):
    s = str(input())
    for j in b:
        if s == j:
            flg = 1
    if i != 0:
        if s[0:1] != c[-1:]:
            flg = 1
    c = s
    b.append(s)
if flg == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;
using LL = long long;

int A, B;

LL solve()
{
    if (A == B)
        return 2 * (A - 1);
    if (A > B)
        swap(A, B); //A < B

    LL M, left = 0, right = 1'000'000'000LL;
    while (left < right)
    {
        LL mid = (left + right + 1) / 2;
        if (mid * mid < 1LL * A * B)
            left = mid;
        else
            right = mid - 1;
    }
    M = left;

    if (M * (M + 1) < 1LL * A * B)
        return 2 * M - 1;
    else
        return 2 * M - 2;
}

int main()
{
    int Q;
    for (scanf("%d", &Q); Q; Q--)
    {
        scanf("%d%d", &A, &B);
        printf("%lld\n", solve());
    }
    return 0;
}

Measured memory_bytes: 128
n = int(input())
*x, = map(int, input().split())
x.sort()
ans = float('inf')

for i in range(x[0], x[n-1]+1):
    tmp = 0
    for j in x:
        tmp += (j - i)*(j - i)
    ans = min(ans, tmp)
print(ans)

Measured memory_bytes: 3060
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))};const gcd=(x,y)=>{while(y){[x,y]=[y,x%y]}return x};
const main=()=>{
  let sr=ts().split(''),c=0
  for(let i=0;i<sr.length-1;i++){
    while(sr[i]=='0'&&sr[i+1]=='1'||sr[i]=='1'&&sr[i+1]=='0'){
      c+=2
      sr.splice(i,2)
      i--
    }
  }
  to(c)
}
main()


Measured memory_bytes: 10956
ans,t=0,[]
n,d=gets.split.map &:to_i
n.times{t<<gets.split.map(&:to_i)}
t.combination(2).to_a.map{|a,b|
dist=0
d.times{|i|dist+=(b[i]-a[i]).abs**2}
ans+=1 if (dist**0.5).to_s=~/^[0-9]+\.0$/
}
p ans

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

using namespace std;

int main() {
    string c = "CODEFESTIVAL2016";
    string s;
    cin>>s;

    int co=0;
    for(int i=0;i<s.size();i++) {
        if(c[i] != s[i]) co++;
    }
    cout<<co;
    return 0;
}


Measured memory_bytes: 256
//shivamkr21
#include<bits/stdc++.h>
#define lli long long int
#define endl "\n"
using namespace std;
int main()
{
  lli a,b;
  cin>>a>>b;
  if((a+b)%2==0)
  {
    cout<<(a+b)/2<<endl;
  }
  else
  {
    cout<<"IMPOSSIBLE"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main (){
	 int x;
	 int y;
	 while (1){
	 scanf("%d %d",&x,&y);
	 if (x==0 && y==0) break;
	 if (x<y){
	 printf("%d %d\n",x,y);
	 }else{
	 printf("%d %d\n",y,x);
	 }
	 }
	 return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  vector<ll> P(N);
  rep(i, N) cin >> P[i];
  sort(all(P));
  cout << accumulate(P.begin(), P.begin()+K, 0LL) << endl;
  return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
#include <cctype>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
ll INF=1<<30;

int main(){
    ll n,m;
    cin >> n >> m;
    ll a[m],b[m];
    rep(i,m) cin >> a[i] >> b[i];
    vector<ll> v;
    rep(i,m){
        if(a[i]==1) v.push_back(b[i]);
        if(b[i]==n) v.push_back(a[i]);
    }
    sort(v.begin(),v.end());
    rep(i,v.size()-1){
        if(v.at(i) == v.at(i+1)){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}

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

#define INF (1<<29)
int dp[50001];
int n, m;



int main(){

  cin >> n >> m;
  vector<int> d(m);

  for(int i = 0; i < m; i++){
    cin >> d[i];
    dp[d[i]] = 1;
  }

  for(int i = 2; i <= n; i++){
    if(dp[i] == 0) dp[i] = INF;
    for(int j = 0; j < m; j++){
      if(i<d[j]) continue;
      if(dp[i-d[j]] != 0) dp[i] = min(dp[i], dp[i-d[j]] + 1);
    }
  }

  cout << dp[n] << endl;

}

Measured memory_bytes: 1388
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>

using namespace std;

#define ll long long

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

	vector<ll> arr(n);
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
		arr[i] %= m;
	}

	for (int i = 0; i < n; i++)
	{
		if (i)
		{
			arr[i] += arr[i - 1];
			arr[i] %= m;
		}
	}

	unordered_map<ll, ll> mp;
	mp[0]++;

	for (int i = 0; i < n; i++)
	{
		mp[arr[i]]++;
	}

	ll ans = 0;

	for (auto it : mp)
	{
		ans += it.second * (it.second - 1) / 2;
	}

	cout << ans << endl;
}


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

int main(){
	int n,m;
  cin >> n>>m;
  dsu d(n);
  int a,b;
  for(int i=0;i<m;i++){
    cin >> a >> b;
    d.merge(a-1,b-1);
  }
  auto g = d.groups();
  cout << g.size() - 1 << endl;
}

Measured memory_bytes: 8948
# 入力
n=int(input())

l=[]
for i in range(n):
  l.append(input())

# 重複がある場合はアウト
if len(set(l))!=n:
  print('No')
  exit()

for i in range(n-1):
  # しりとりのルールを満たしていない場合はアウト
  if l[i][-1]!=l[i+1][0]:
    print('No')
    exit()

# 全てのチェックを通過できればセーフ
print('Yes')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 2e5 + 10;
typedef long double ldb;

int fa[N];
int find(int x){
	if (fa[x] != x) return fa[x] = find(fa[x]);
	return fa[x];
}
void merge(int x,int y){
	x = find(x) , y = find(y);
	if (x ^ y) fa[x] = y;
}
int u[N] , v[N] , val[N] , col[N] , n , m;
vector <int> G[N];
vector <int> V[N];

void dfs(int x){
	for (int u : G[x])if (col[u] == -1){
		col[u] = col[x] ^ 1;
		dfs(u);
	}for (int u : V[x])if (col[u] == -1){
		col[u] = col[x];
		dfs(u);
	}
}
int cnt = 0;
int main(){
	scanf("%d%d",&n,&m);
//	printf("%d %d\n",n,m);
	for (int i = 1;i <= m;i++){
		scanf("%d%d%d",u+i,v+i,val+i);
//		printf("%d %d %d\n",u[i],v[i],val[i]);
		if (val[i] & 1){
			G[u[i]].push_back(v[i]);
			G[v[i]].push_back(u[i]);
		}else{
			V[u[i]].push_back(v[i]);
			V[v[i]].push_back(u[i]);
		}
	}
	
	memset(col , -1 , sizeof col);
	
	
	for (int i = 1;i <= n;i++){
		if (col[i] == -1) {
			col[i] = 0;
			dfs(i);
			cnt++;
		}
	}
	
	cout<<cnt;
	return 0;
}

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

ll dp1[5000][5000];
ll dp2[5000][5000];

int main() {
    int N, T;
    cin >> N >> T;
    int A[3000];
    int B[3000];
    for(int i=0;i<N;i++) {
        cin >> A[i] >> B[i];
    }
    for(int i=1;i<=N;i++) {
        for (int j=0;j<T;j++) {
            if (j>=A[i-1]) dp1[i][j] = max(dp1[i-1][j-A[i-1]]+B[i-1], dp1[i-1][j]);
            else dp1[i][j] = dp1[i-1][j];
        }
    }

    for (int l=0;l<T;l++) dp2[N+1][l] = 0;
    for (int k=N;k>0;k--) {
        for (int l=0;l<T;l++) {
            if (l>=A[k-1]) dp2[k][l] = max(dp2[k+1][l-A[k-1]]+B[k-1], dp2[k+1][l]);
            else dp2[k][l] = dp2[k+1][l];
        }
    }

    ll max_p = 0;
    ll max_p_arg = -1;
    for (int p=1;p<=N;p++) {
        ll max_t = 0;
        for (int t=0;t<T;t++) {
            max_t = max(max_t, dp1[p-1][t] + dp2[p+1][T-1-t]);
        }
        max_t += B[p-1];
        if (max_p <= max_t){
            max_p_arg = p;
            max_p = max_t;
        }
    }
    cout << max_p<< endl;
    return 0;
}

Measured memory_bytes: 237184
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    Int N; cin >> N;
    Int fours = 0, twos = 0, others = 0;
    rep(i, 0, N) {
        Int a; cin >> a;
        if (a%4 == 0) ++fours;
        else if (a%2 == 0) ++twos;
        else ++others;
    }

    if (twos > 0) ++others;

    if (fours+1 >= others) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
n, m = [int(x) for x in input().split()]
L = [ [int(x) for x in input().split()] for i in range(m) ]
P = [int(x) for x in input().split()]

# 全通り探索すれば良い
# 全スイッチパターンのリストの作成
S = []
def switch(x=[], y=0):
    if y == n:
        return S.append(x)
    for i in range(2):
        switch(x+[i], y+1)
switch()

# 全パターンの探索
ans = 0
for i in S:    # スイッチの状態
    s = 1
    for j in range(m):    # 全ての電球を探索
        # 電球につながるスイッチのon-offリストを作る
        Sk = []
        for k in L[j][1:]:
            Sk.append(i[k-1])
        # onになっているスイッチの個数を2で割った余りがpiに等しい時に点灯
        if Sk.count(1) % 2 == P[j]:
            s *= 1
        else:
            s *= 0
    ans += s

print(ans)


Measured memory_bytes: 3188
#include <stdio.h>

int main(int argc, const char * argv[])
{

    int i, j;
    int n;
    int num[7] = {0};
    double height;
    
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%lf", &height);
        if (height < 165.00) num[1]++;
        else if (height < 170.00) num[2]++;
        else if (height < 175) num[3]++;
        else if (height < 180) num[4]++;
        else if (height < 185) num[5]++;
        else num[6]++;
    }
    for (i = 1; i <= 6; i++) {
        printf("%d:",i);
        for (j = 0; j < num[i]; j++) {
            printf("*");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static void main( String[] args ){

        Scanner in = new Scanner(System.in);
        String param = in.nextLine();
        String[] splitParams = param.split(" ");
        int n = Integer.parseInt(splitParams[0]);
        int k = Integer.parseInt(splitParams[1]);

        double ans = 0;

        for( int i = 1 ; i <= n ; i++ ){
            int point = i;
            int count = 0;
            while( point < k ){
                point *= 2;
                count++;
            }
            ans += 1.0/n*Math.pow(0.5,count);
        }

        System.out.println(ans);

    }
}

Measured memory_bytes: 21588
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


/*
dp[i][j]=i番目まで見たときにj番目の状態になっているときの操作回数の最小値
*/

ll l,a[200010],dp[200010][5];

int main(void){
	cin>>l;
	reg(i,1,l)cin>>a[i];
	//初期化
	rep(j,5)dp[0][j]=0;
	//本体
	reg(i,1,l){
		dp[i][0]=dp[i-1][0]+a[i];
		dp[i][1]=min({dp[i-1][0]+a[i],dp[i-1][1]+(a[i]==0?2:a[i]%2)});
		dp[i][2]=min({dp[i-1][0]+a[i],dp[i-1][1]+(a[i]==0?2:a[i]%2),dp[i-1][2]+abs(a[i]-1)%2});
		dp[i][3]=min({dp[i-1][0]+a[i],dp[i-1][1]+(a[i]==0?2:a[i]%2),dp[i-1][2]+abs(a[i]-1)%2,dp[i-1][3]+(a[i]==0?2:a[i]%2)});
		dp[i][4]=min({dp[i-1][0]+a[i],dp[i-1][1]+(a[i]==0?2:a[i]%2),dp[i-1][2]+abs(a[i]-1)%2,dp[i-1][3]+(a[i]==0?2:a[i]%2),dp[i-1][4]+a[i]});
	}
	cout<<dp[l][4]<<endl;
	return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <vector>

using namespace std;

vector<int> v;

int main()
{
    int A, B, K;

    cin >> A >> B >> K;

    for (int i = 0; i < K;i++)
    {
        if(A + i <= B)
        {
            v.push_back(A + i);
        }
        if(B - i >= A)
        {
            v.push_back(B - i);
        }
    }

    sort(v.begin(), v.end());

    v.erase(std::unique(v.begin(), v.end()), v.end());

    for (auto i = v.begin(); i != v.end();i++)
    {
        cout << *i << endl;
    }

    return 0;
}

Measured memory_bytes: 888
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;

// Sieve of Eratosthenes
fn get_primes(input: i64) -> Vec<i64> {
    let N: usize = max(input, 100) as usize;

    let mut Alive = vec![true; N];
    Alive[0] = false;
    Alive[1] = false;

    // i番目の素数が分かる (0-origin)
    let mut Ps: Vec<i64> = Vec::new();

    for smallest in 2..=((N as f64).sqrt()) as usize + 1 {
        if !Alive[smallest] {
            continue;
        }

        for i in (smallest * 2..N).step_by(smallest) {
            Alive[i] = false;
        }
    }

    for i in 2..N {
        if Alive[i] {
            Ps.push(i as i64);
        }
    }

    return Ps;
}

fn main() {
    input! {
        N: usize,
    }

    const MOD: usize = 1000_000_000 + 7;

    // 下準備1: 2~1000までの素数を求めておく
    let primes = get_primes(1001);

    // 素数pがキー、肩の指数が値
    let mut cnt_map: HashMap<i64, usize> = HashMap::new();

    for n in 1..=(N as i64) {
        // ループの内側が10^4程度であればOK

        let mut res = n;
        let lim: i64 = (n as f64).sqrt() as i64 + 1;
        for &p in primes.iter() {
            if p > lim {
                break;
            }

            if res % p == 0 {
                let mut cnt: usize = 0;
                while res % p == 0 {
                    res /= p;
                    cnt += 1;
                }
                let orig_cnt: usize = *cnt_map.get(&p).or(Some(&0)).unwrap();
                cnt_map.insert(p, orig_cnt + cnt);
            }
        }

        // 割り切れなかったら、それは素数
        if res > 1 {
            let orig_cnt: usize = *cnt_map.get(&res).or(Some(&0)).unwrap();
            cnt_map.insert(res, orig_cnt + 1);
        }
    }

    let mut ans: usize = 1;
    for (_p, cnt) in cnt_map.iter() {
        ans = (ans * (cnt + 1)) % MOD;
    }

    println!("{}", ans);
}


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

using namespace std;

#define ll long long
constexpr ll inf = 1e9+7;

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

    ll N;
    string S1, S2;
    cin>>N>>S1>>S2;

    ll ans;
    bool prev;
    ll n = 0;
    if (S1[0] == S2[0]) {
        ans = 3;
        prev = false;
        n = 1;
    } else {
        ans = 6;
        prev = true;
        n = 2;
    }
    // prev == false
    // X
    // X
    //
    // prev == true
    // XX
    // YY
    while (n < N) {
        if (S1[n] == S2[n]) {
            n++;
            if (!prev) ans = ans * 2 % inf;
            prev = false;
        } else {
            n += 2;
            if (!prev) ans = ans * 2 % inf;
            else ans = ans * 3 % inf;
            prev = true;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		double r = Double.parseDouble(line);
		System.out.printf("%.6f %.6f%n", r*r*Math.PI, 2*r*Math.PI);
	}
}

Measured memory_bytes: 17076
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}

int main() {
  vi a(3);
  rep(i,3) cin>>a[i];
  sort(all(a));
  int sum=0;
  rep(i,2) sum+=a[i];
  cout<<sum<<endl;
}


Measured memory_bytes: 3596
#include <cstdio>
#include <algorithm>
#include <functional>
#include <vector>

using namespace std;

int main()
{
  int n;
  scanf("%d",&n);
  static int a[100000];
  for(int i=0;i<n;i++){
    scanf("%lld",a+i);
  }
  sort(a,a+n,greater<int>());
  int I=0;
  while(I+1<n&&I+1<a[I+1]){
    I++;
  }
  int t0=a[I]-I-1,t1=0;
  int J=I+1;
  while(J<n&&I==a[J]-1){
    t1++;
    J++;
  }
  puts(t0%2==1||t1%2==1?"First":"Second");
  return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int N;
vector<int> A;
int p_num, m_num;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  A.resize(N);
  for (ll i = 0; i < N; i++) {
    cin >> A[i];
    if (A[i] >= 0) {
      p_num++;
    } else {
      m_num++;
    }
  }
  sort(A.begin(), A.end());
  if (p_num == 0) {
    p_num++;
    m_num--;
  } else if (m_num == 0) {
    p_num--;
    m_num++;
  }

  int m = A[0];
  vector<int> x, y;
  for (int i = m_num; i < N - 1; i++) {
    x.push_back(m);
    y.push_back(A[i]);
    m -= A[i];
  }
  A[0] = m;
  m = A[N - 1];
  for (int i = 0; i < m_num; i++) {
    x.push_back(m);
    y.push_back(A[i]);
    m -= A[i];
  }

  cout << m << endl;
  for (int i = 0; i < N - 1; i++) {
    cout << x[i] << " " << y[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 3316
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np
import statistics
from statistics import mean, median,variance,stdev
import math

def main():
	s = input()
	
	tmp = 0
	for i in range(len(s)):
		if s[i] == "o":
			tmp += 1
			
	print(700 + (tmp * 100))
	
			
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 13260
#include <cstdio>
#define rg register
using namespace std;
typedef long long ll;
template <typename Tp> inline int getmin(Tp &x,Tp y){return y<x?x=y,1:0;}
template <typename Tp> inline int getmax(Tp &x,Tp y){return y>x?x=y,1:0;}
template <typename Tp> inline void read(Tp &x)
{
	x=0;int f=0;char ch=getchar();
	while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
	if(ch=='-') f=1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	if(f) x=-x;
}
int n,k;
ll tmp,ans;
int main()
{
	read(n);read(k);
	tmp=n/k;
	ans=tmp*tmp*tmp;
	if(k%2==0)
	{
		if(n%k>=(k/2)) ++tmp;
		ans+=tmp*tmp*tmp;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import permutations
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
import queue

N, M = map(int, input().split())
if M == 0:
    print(-1)
    exit()
adj = [[] for _ in range(N)]
for i in range(M):
    u, v = map(int, input().split())    
    u -= 1
    v -= 1
    adj[u].append(v)
S, T = map(int, input().split())
S -= 1
T -= 1

dist = [[INF,INF,INF] for _ in range(N+1)]
 
d = 0
q = [S]
while q:
  d += 1
  r = d % 3
  qq = []
  for u in q:
    for v in adj[u]:
      if dist[v][r] == INF:
        dist[v][r] = d
        qq.append(v)
  q = qq
 
d = dist[T][0]
answer = -1 if d == INF else d // 3
print(answer)




Measured memory_bytes: 42772
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn gcd(a: usize, b: usize) -> usize {
    if a % b == 0 {
        b
    } else {
        gcd(b, a % b)
    }
}

use std::collections::HashMap;

fn get_factors(n: usize) -> HashMap<usize, usize> {
    let mut factors = HashMap::new();
    let mut n = n;
    for i in 2.. {
        if i * i > n {
            break;
        }
        while n % i == 0 {
            *factors.entry(i).or_insert(0) += 1;
            n /= i;
        }

    }
    if n != 1 {
        factors.insert(n, 1);
    }
factors
}

fn main() {
    let input = read_vec::<usize>();
    let (a, b) = (input[0], input[1]);

    let g = gcd(a,b);

    let factors = get_factors(g);

    println!("{}", factors.len()+1);
}

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

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

int main() {
  int n;
  cin >> n;
  int ans;
  if (n <= 999) {
    cout << "ABC";
  } else {
    cout << "ABD";
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int a, b, c, ans;
	ans = 0;
	cin >> a >> b >> c;
	for(int i = a; i <= b; i++){
		if(c % i == 0){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3096
dict = {}
while True:
    try:
        word, page = raw_input().split()
        if dict.has_key(word):
            dict[word].append(int(page))
        else:
            dict[word] = [int(page)]
    except:
        break

for k, v in sorted(dict.items()):
    print k
    print " ".join(map(str, sorted(v)))

Measured memory_bytes: 4204
#include<stdio.h>
#include<stdlib.h>
#define N 500000
#define SENTINEL 1000000000

void Merge(int *, int, int, int);
void Sort(int *, int, int);
int count;

main(){
  int i, n, A[N];

  scanf("%d", &n);
  for(i = 0;i < n;i++){
    scanf("%d", &A[i]);
  }
  Sort(A, 0, n);
  for(i = 0;i < n - 1;i++){
    printf("%d ", A[i]);
  }
  printf("%d\n%d\n", A[n - 1], count);
  return 0;
}

void Merge(int *A, int left, int mid, int right){
  /*int i, j, k, l, n1, n2, *L, *R;
  n1 = mid - left;
  n2 = right - mid;
  L = malloc(n1 * sizeof(int));
  R = malloc(n2 * sizeof(int));*/
  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1], R[n2], i, j, k;
  for(i = 0;i < n1;i++){
    L[i] = A[left + i];
  }
  for(i = 0;i < n2;i++){
    R[i] = A[mid + i];
  }
  L[n1] = R[n2] = SENTINEL;
  i = j = 0;
  for(k = left;k < right;k++){    
    if(L[i] <= R[j]){
      A[k] = L[i++];
    }
    else{
      A[k] = R[j++];
    }
    count++;
  }
}

void Sort(int *A, int left, int right){
  int mid;
  if((left+1) < right){
    mid = (left + right) / 2;
    Sort(A, left, mid);
    Sort(A, mid, right);
    Merge(A, left, mid, right);
  }
}

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

int bubblesort(vector<int> a){
    int cnt = 0;
    for(int i=0; i<a.size()-1; i++){
        for(int j=a.size()-1; j>i; j--){
            if(a[j]<a[j-1]){
                int tmp = a[j];
                a[j] = a[j-1];
                a[j-1] = tmp;
                cnt++;
            }
        }
    }

    return cnt;
}

int main(){
    int n;

    while(cin >> n, n != 0){
        vector<int> a(n);
        for(int i=0; i<n; i++){
            cin >> a[i];
        }

        int result = bubblesort(a);

        cout << result << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main(void){
    int i,j;
    char pat[8][8];
    for(i=0;i<8;i++){
        for(j=0;j<8;j++){
            scanf("%c",&pat[i][j]);
        }
        getchar();
    }
    printf("90\n");
    for(i=0;i<8;i++){
        for(j=7;j>=0;j--){
            printf("%c",pat[j][i]);
        }
        printf("\n");
    }
    printf("180\n");
    for(i=7;i>=0;i--){
        for(j=7;j>=0;j--){
            printf("%c",pat[i][j]);
        }
        printf("\n");
    }
    printf("270\n");
    for(i=7;i>=0;i--){
        for(j=0;j<8;j++){
            printf("%c",pat[j][i]);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 524
#include <stdio.h>

int main(void)
{
int x,y;
scanf("%d %d",&x,&y);

while(x !=0 || y !=0){

if(x<y){
printf("%d %d\n",x,y);
}else{
printf("%d %d\n",y,x);
}


scanf("%d %d",&x,&y);
}
 return 0;
}

Measured memory_bytes: 600
def merge(A,left,mid,right):
    global cnt
    L = A[left:mid]
    R = A[mid:right]
    L.append(float("inf"))
    R.append(float("inf"))
    i = 0
    j = 0
    for k in range(left, right):
        cnt += 1
        if L[i] <=R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1


def mergeSort(A,left,right):
        if left+1 < right:
            mid = (left+right) // 2
            mergeSort(A,left,mid)
            mergeSort(A,mid,right)
            merge(A,left,mid,right)

n = int(input())
S = list(map(int,input().split()))
cnt=0

mergeSort(S,0,n)

print(" ".join(map(str,S)))
print(cnt)

Measured memory_bytes: 68804
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin>>n;
  vector<vector<int>> a(2,vector<int> (n));
  for(int i=0;i<2;i++){
    for(int j=0;j<n;j++){
      cin>>a[i][j];
    }
  }
  int ans=0;
  for(int i=0;i<n;i++){
    int x=0;
    int k=0;
    for(int j=0;j<n;j++){
      if(i==j){
        x+=a[k][j];
        k++;
        x+=a[k][j];
      }
      else{
        x+=a[k][j];
      }
    }
    if(x>ans){
      ans=x;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3552
#include <stdio.h>
#include <string.h>
int main(void){
	int a,b,q,i;
	char str[1001],o[10],p[1001],v[2];
	scanf("%s %d",str,&q);
	while(q--){
		scanf("%s %d %d",o,&a,&b);
		if(strcmp(o,"replace")==0){
			scanf("%s",p);
			for(i=0;i<b-a+1;i++){
				str[a+i]=p[i];
			}
		}
		if(strcmp(o,"reverse")==0){
			for(i=0;i<(b-a+1)/2;i++){
				v[0]=str[a+i];
				str[a+i]=str[b-i];
				str[b-i]=v[0];
			}
		}
		if(strcmp(o,"print")==0){
			for(i=a;i<=b;i++){
				printf("%c",str[i]);
			}
			putchar('\n');
		}
	}
	return 0;
}

Measured memory_bytes: 576
#include <bits/stdc++.h>
#define pb push_back
#define all(v) (v).begin() , (v).end()

using namespace std;

typedef vector<int> vi;
typedef long long   ll;

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

int main()
{
    int n , a , b;
    cin >> n >> a >> b;
    cout<<min(a*n,b)<<endl;
    return 0;
}


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

using namespace std;

#define X first
#define Y second
#define eps  1e-5
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;

const int maxn = 1e5+7;
const int INF  = 1<<30;
const int mod  = 1e9+7;

void solve(){
    int k,x;
    cin>>k>>x;
    int l = x-k+1,r = k+x-1;
    for(int i=l;i<=r;i++){
        printf("%d%c",i," \n"[i==r] );
    }
    return;
}

int main()
{
#ifndef ONLINE_JUDGE
    //freopen("in.txt","r",stdin);
#endif
//    freopen("out.txt","w",stdout);
//    ios::sync_with_stdio(false);
    int t = 1;
    //scanf("%d",&t);
    while(t--){
    //    printf("Case %d: ",cas++);
        solve();
    }
#ifndef ONLINE_JUDGE
  //  printf("%.10f\n",1.0*clock()/CLOCKS_PER_SEC);
#endif
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    typedef vector<int> vi;
    typedef vector<long long> vll;
    typedef vector<pair<int , int>> vpii;
    typedef pair<int , int> pii;
    typedef pair<long long  , long long> pll;
    typedef pair<double , double> pdd;
    #define eb emplace_back;
    #define mp make_pair;
     
    int main(){
        int n;
        cin>>n;
        int arr[n];
        ll b[200006];
        memset(b , 0 , sizeof(b));
        ll totalSum = 0;
        int mx = 0;
        for(int i = 0 ; i<n ; i++){
            cin>>arr[i];
            b[arr[i]]++;
            if(mx<arr[i]){
                mx = arr[i];
            }
        }
        for(int i = 1 ; i<=mx ; i++){
            if(b[i]){
                totalSum+= (b[i] * (b[i]-1))/2;
            }
        }
        ll csum = totalSum;
        for(int i = 0 ; i<n ; i++){
            csum -= (b[arr[i]] * (b[arr[i]]-1))/2;
            csum += ((b[arr[i]]-1) * ((b[arr[i]]-2)))/2;
            cout<<csum<<"\n";
            csum = totalSum;
        } 
        return 0;
    }

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()


int main(){
    int n,m; cin>>n>>m;
    int s[m],c[m];
    rep(i,0,m) cin>>s[i]>>c[i];

    bool f=true;
    rep(i,0,1000){
        V v;
        for(int j=i; j; j/=10) v.push_back(j%10);
        if(i==0) v.push_back(0);
        if(v.size()!=n) continue;
        reverse(v.begin(),v.end());
        bool f=true;
        rep(j,0,m){
            if(v[s[j]-1]!=c[j]) f=false;
        }
        if(f){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}


Measured memory_bytes: 256
while True:
    H,W=map(int,input().split())
    if W==0 and H==0:
        break
    for i in range(W):
        print('#',end='')
    print()
    for j in range(H-2):
        print('#',end='')
        for k in range(W-2):
            print('.',end='')
        print('#',end='')
        print()
    for i in range(W):
        print('#',end='')
    print()
    print()


Measured memory_bytes: 7000
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] in = sc.nextLine().split(" ");
		String s = in[0];
		String t = in[1];

		String[] in2 = sc.nextLine().split(" ");
		int a = Integer.valueOf(in2[0]);
		int b = Integer.valueOf(in2[1]);
		String u = sc.nextLine();
		if (s.equals(u)) {
			System.out.println((a - 1) + " " + b);
		} else {
			System.out.println(a + " " + (b - 1));
		}
	}
}


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

int main() {
  int N; cin >> N;
  int L[N]; for (int i = 0; i < N; i++) cin >> L[i];
  sort(L, L + N);
  int F[2001], S[2001]; for (int i = 0; i < 2001; i++) F[i] = 0;
  for (int i = 0; i < N; i++) F[L[i]]++;
  S[0] = 0; for (int i = 0; i < 2000; i++) S[i+1] = S[i]+F[i+1];
  int num = 0;
  for (int i = 0; i < N-1; i++) {
    for (int j = i+1; j < N; j++) {
      num += S[L[i] + L[j] - 1] - (j + 1);
    }
  }
  cout << num << endl;
}

Measured memory_bytes: 256
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
map<ll,ll> zip[2];
ll unzip[2][5000];

void compress(vector<ll> &x,int e) {
   sort(x.begin(), x.end());
   x.erase(unique(x.begin(),x.end()),x.end());
   for(int i = 0; i < x.size(); i++){
       zip[e][x[i]] = i;
       unzip[e][i] = x[i];
   }
}
int main(){
    ll n;
    vector<ll> x;
    vector<ll> y;
    std::cin >> n;
    
    for (int i = 0; i < n; i++) {
        ll tmpx,tmpy;
        std::cin >>tmpx>>tmpy;
        x.push_back(tmpx);
        y.push_back(tmpy);
    }
    
    // compress(x,0);
    // compress(y,1);
    
    ll d_c[5000][5000];
    
    vector<ll> xd;
    vector<ll> yd;
    Fill(d_c,0);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if(i==j)continue;
            xd.push_back(x[i]-x[j]);
            yd.push_back(y[i]-y[j]);
            // d_c[ zip[0][x[i]]-zip[0][x[j]]+100 ][zip[1][y[i]]-zip[1][y[j]]+100]++;
        }
    }
    compress(xd,0);
    compress(yd,1);
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if(i==j)continue;
            d_c[ zip[0][x[i]-x[j]] ][zip[1][y[i]-y[j]]]++;
        }
    }
    
    
    ll rm = 0;
    for (int i = 0; i < 5000; i++) {
        for (int j = 0; j < 5000; j++) {
            if(d_c[i][j]>rm){
                rm = d_c[i][j];
                // std::cout << rm<<" "<<i<<" "<<j << std::endl;
            }
        }
    }
    std::cout << n-rm << std::endl;
}


Measured memory_bytes: 195968
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define RFOR(i,s,e) for(int (i) = (s);(i) >= (e);(i)--)
#define rep(i,n) FOR(i,0,n-1)
#define MOD 1000000007
 
signed main(){
	int n;cin>>n;
	int originN = n;
	vector<int> soin;
	for(int i=2;i*i<=n;i++)
	{
		if(n%i==0)soin.push_back(i);
		while(n%i==0)n/=i;
	}
	if(n>1) soin.push_back(n);
	int kosuu = soin.size();
	int ans = 0;
	for(int i=1;i<(1<<kosuu);i++)
	{
		int popcnt = __builtin_popcount(i);
		int mul = 1;
		for(int j=0;j<kosuu;j++) if((i>>j)&1)mul*=soin[j];
		if(popcnt%2 == 1) ans += originN/mul;
		else ans -= originN/mul;
	}
	
	cout << originN - ans << endl;
	
}


Measured memory_bytes: 3172
n=int(input())
a=[list(map(int,input().split())) for _ in range(n)]
cost=[[0 for i in range(3)]for j in range(n+1)]
for i in range(n):
    for j in range(3):
        for k in range(3):
            if j==k:
                continue
            cost[i+1][k]=max(cost[i+1][k],cost[i][j]+a[i][k])
print(max(cost[n]))

Measured memory_bytes: 47332
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
    h, w = parseMap(split(readline()))
    board = zeros(Int, (h, w))
    for i in 1:h
            s = readline()
        for j in 1:w
            board[i, j] = s[j] == '.' ? 1 : 0
        end
    end
    ansrow = deepcopy(board)
    for i in 1:h
        for j in 2:w
            ansrow[i, j] = board[i, j] == 1 ? ansrow[i, j - 1] + 1 : 0
        end
        for j in w-1:-1:1
            ansrow[i, j] = board[i, j] == 1 && board[i, j + 1] == 1 ? ansrow[i, j + 1] : ansrow[i, j]
        end
    end
    anscol = deepcopy(board)
    for j in 1:w
        for i in 2:h
            anscol[i, j] = board[i, j] == 1 ? anscol[i - 1, j] + 1 : 0
        end
        for i in h-1:-1:1
            anscol[i, j] = board[i, j] == 1 && board[i + 1, j] == 1 ? anscol[i + 1, j] : anscol[i, j]
        end
    end
    print(maximum(ansrow + anscol) - 1)
end

main()


Measured memory_bytes: 239020
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

const string x = "-";

void chmax(string &a, string b){
  if ( a == x){ a = b;}
  else if( a.size() < b.size()){ a = b;}
  else if( a.size() == b.size()){
    a  = max( a , b);}

}

int match(int a){
  if( a == 1){ return 2;}
  else if( a == 2){ return 5;}
  else if( a == 3){ return 5;}
  else if( a == 4){ return 4;}
  else if( a == 5){ return 5;}
  else if( a == 6){ return 6;}
  else if( a == 7){ return 3;}
  else if( a == 8){ return 7;}
  else if( a == 9){ return 6;}
}
                   

int main(){
  int N,M; cin >> N >> M;
  vector<int> A(M);
  for(int i = 0; i < M; i++){ cin >> A[i];}
  
  string dp[10100];
  
  for(int i  =0; i < 10100; i++){ dp[i] = x;}
  
  dp[0] = ""; //配るDP "-"は未更新 ""は更新したが何も書けない
  
  for(int i = 0; i < 10100; i++){
    
   if( dp[i] == x){continue;} //未更新から配ってもしょうがない
   
    for(int j = 0; j < M; j++){
      if( i + match(A[j]) >= 10100){ continue;}
      chmax( dp[i+match(A[j])], dp[i] + (char)('0' + A[j]));}
  }
                                
                                cout << dp[N] << endl; return 0;}
                          


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

using namespace std;

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

    int a[n];

    for(int i =0; i < n;i++){
      cin >> a[i];
    }

    int max = a[0];
    int sum = 0;

    for(int i = 1; i < n;i++){
      if(a[i] >= max){
        sum += max;
        max = a[i];
      } else {
        sum += a[i];
      }
    }
  
    if(max >= sum){
      cout << "No" << endl;
    } else  {
      cout << "Yes" << endl;
    }
return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int MAX_N = 24;
int N;
int xs[MAX_N], ys[MAX_N], rs[MAX_N], cs[MAX_N];
int overs[MAX_N];
bool dp[1<<MAX_N];

int sq(int x){
	return x*x;
}

void init(){
	memset(overs, 0, sizeof(overs));
	for(int i=0; i<N; i++)for(int j=i+1; j<N; j++){
		int dist = sq(xs[i] - xs[j]) + sq(ys[i] - ys[j]);
		int r = sq(rs[i] + rs[j]);
		if(dist < r){
			overs[j] |= 1<<i;
		}
	}
}

int solve(){
	init();

	memset(dp, 0, sizeof(dp));
	dp[0] = true;
	for(int bit=0; bit<(1<<N); bit++)if(dp[bit]){
		for(int i=0; i<N; i++)if(!((bit>>i)&1) && (overs[i]&bit)==overs[i]){
			for(int j=i+1; j<N; j++)if(cs[i] == cs[j] && !((bit>>j)&1) && (overs[j]&bit)==overs[j]){
				dp[bit | (1<<i) | (1<<j)] = true;
			}
		}
	}

	int ret = 0;
	for(int i=0; i<(1<<N); i++)if(dp[i]){
		ret = max(ret, __builtin_popcount(i));
	}
	return ret;
}

int main(){
	while(scanf("%d",&N),N){
		for(int i=0; i<N; i++){
			scanf("%d%d%d%d",xs+i,ys+i,rs+i,cs+i);
		}
		printf("%d\n", solve());
	}
	return 0;
}

Measured memory_bytes: 0
from math import trunc
import sys
import copy
from collections import deque
import collections
import itertools
stdin = sys.stdin
import math

mod = 10**9+7

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

a = na()

ans = []

ans.append(a[0]*a[2])
ans.append(a[0]*a[3])
ans.append(a[1]*a[2])
ans.append(a[1]*a[3])

print(max(ans))

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 1001001001;

int main(){
	int a, b; cin >> a >> b;
	if(a>=13) cout << b << endl;
	else if(a >= 6) cout << b/2 << endl;
	else cout << 0 << endl; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(0),cin.tie(0);
	int k,x;
	while(cin>>k>>x){
		if((k*500)>=x) cout<<"Yes"<<'\n';
		else cout<<"No"<<'\n';
	}
	
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long
#define pb push_back

int main(){

	ll A, B, C;
	cin >> A >> B >> C;
	if(C > A + B + 1){
		cout << A + B + 1 + B << endl;
	}
	else{
		cout << C + B << endl;
	}

	return 0;
}


Measured memory_bytes: 256