akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i< (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
//long long ccw(const Point& A, const Point& B, const Point& C) {
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}

int main() {
	// 오늘 할 것!  종만북 보기! 
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	string a, b; cin >> a >> b;
	a += b;
	ll t = stoll(a);
	ll c = sqrt(t);
	if (c * c == t) {
		cout << "Yes" << '\n';
	}
	else {
		cout << "No" << '\n';
	}




}

Measured memory_bytes: 256
N,M,X =map(int,input().split())
A = list(map(int,input().split()))
countA=0
countB=0

for i in range(0,M):
    if A[int(i)] in range(0,X):
        countA += 1
for j in range(0,M):
    if A[int(j)] in range(X,N+1):
        countB += 1
if countA > countB:
    print(countB)
else:
    print(countA)


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

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

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int N=1005;

int n,m;
int ans[N*200],t[N][N],tt[N],b[N*200],a[N*200];

int D,del,clk,vis[N];
void dfs(int u)
{
	if (vis[u]) return;
	if (u==del) return;
	vis[u]=clk;
	for (int i=1;i<=tt[u];i++) dfs(b[t[u][i]]);
}

void work(int u)
{
	del=u;
	memset(vis,0,sizeof(vis));
	for (int v,i=1;i<=tt[u];i++)
	{
		clk=v=b[t[u][i]];
		dfs(v);
	}
	for (int v,i=1;i<=tt[u];i++) 
	{
		v=b[t[u][i]];
		if (v!=vis[v]) ans[t[u][i]]=1;
	}
}

int main()
{
	scanf("%d%d",&n,&m);
	for (int u,v,i=1;i<=m;i++)
	{
		scanf("%d%d",&u,&v);
		a[i]=u,b[i]=v;
		t[u][++tt[u]]=i;
	}
	
	for (int u=1;u<=n;u++)
	{
		work(u);
		for (int i=1;i<=tt[u]/2;i++) swap(t[u][i],t[u][ tt[u]-i+1 ]);
		work(u);
	}

	for (int u=1;u<=n;u++)
	{
		memset(vis,0,sizeof(vis));
		clk=1;
		del=0;
		dfs(u);
		for (int i=1;i<=m;i++) if (b[i]==u) ans[i]^=vis[a[i]];
	}

	for (int i=1;i<=m;i++) if (ans[i]) puts("diff");else puts("same");
	return 0;
}

Measured memory_bytes: 7552
//
//  main.cpp
//  usaco
//
//  Created by 김현수 on 2020/08/30.
//  Copyright © 2020 김현수. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <string>
int main()
{
    int a, b, c, d, e, k;
    scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &k);
    if(e-a<=k)
    {
        printf("Yay!");
    }
    else if(e-a>k)
    {
        printf(":(");
    }
}


Measured memory_bytes: 3700
//ABC111A
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	int n;
	cin >> n;
	int ans = 1110-n;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'


signed main() {
  fio();
  ll w, h, x, y;
  cin >> w >> h >> x >> y;
  double ans = (w * h) / 2.0;
  int res;
  if (2*x == w and 2*y == h) res = 1;
  else res = 0;
  cout << ans << " " << res << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<functional>
#include<algorithm>
#include<string>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<set>
#include<queue>
#include<cmath>

using namespace std;
#define LL long long

string s;

int main() {
	cin>>s;
	cout<<(s=="ABC"?"ARC":"ABC")<<endl;

	return 0;
}



Measured memory_bytes: 3612
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int height = sc.nextInt();
		int left = sc.nextInt();
		int right = sc.nextInt();
		int types = 0;
		for (int i = left; i <= right; i++) {
		    if (height % i == 0) {
		        types++;
		    }
		}
		System.out.println(types);
	}
}



Measured memory_bytes: 26248
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/arc059_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  vector<int> c(N);
  ll e = 0;
  rep(i, N) {
    cin >> c[i];
    e += c[i];
  }
  e = round((double)e / N);

  ll ans = 0;
  rep(i, N) { ans += pow(abs(c[i] - e), 2); }

  cout << ans << endl;
}

Measured memory_bytes: 3588
#include<iostream>
using namespace std;
typedef long long int ll;
int main(){
	ll K, A, B;
	cin >> K >> A >> B;
	if(A >= K) cout << 1 << endl;
	else if(B >= A) cout << -1 << endl;
	else if((K - A) % (B - A) == 0) cout << 1 + (K - A) / (A - B) * 2 << endl;
	else cout << 1 + ((K - A) / (A - B) + 1) * 2 << endl;
	return 0;
}

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

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

    int v[N], c[N];
    for(int i=0; i<N; i++) cin >> v[i];
    for(int i=0; i<N; i++) cin >> c[i];

    int total=0;

    for(int i=0; i<N; i++){
       if(v[i] - c[i] > 0) total += (v[i] - c[i]);
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 256
l = input().split()
th = int(l[0])
ta = int(l[1])
ah = int(l[2])
aa = int(l[3])
win = False

while True:
	ah -= ta
	if ah <= 0:
		win = True
		break
	th -= aa
	if th <= 0:
		break

if win:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 9188
n=int(input())
a=list(input())
b=list(input())
c=list(input())
co=0
for i in range(n):
  if a[i]!=b[i] and a[i]!=c[i] and b[i]!=c[i]:
    co+=2
  elif a[i]==b[i] and a[i]!=c[i] and b[i]!=c[i]:
    co+=1
  elif a[i]!=b[i] and a[i]==c[i] and b[i]!=c[i]:
    co+=1
  elif a[i]!=b[i] and a[i]!=c[i] and b[i]==c[i]:
    co+=1
print(co)

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

int main(){
  int n, res=0; cin>>n;
  bool ans=false;
  for(int i=1; i<=n; ++i){
    if(floor(i*108/100)==n){res=i; ans=true; break;}
  }

  if(ans)cout<<res<<endl;
  else cout<<":("<<endl;
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif

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

    string S; cin >> S;
    int SL = S.size();
    string T; cin >> T;
    int TL = T.size();

    string ans = "UNRESTORABLE";

    string RS = S;
    reverse(RS.begin(), RS.end());
    string RT = T;
    reverse(RT.begin(), RT.end());

    for(int i=0; i<=SL-TL; i++) {
        bool match = true;
        for(int j=0; j<TL; j++) {
            if (RS[i+j] != '?' && RS[i+j]!=RT[j]) {
                match = false;
                break;
            }
        }

        if (match) {            
            ans = RS.substr(0, i) + RT + RS.substr(i + TL);
            replace(ans.begin(), ans.end(), '?', 'a');
            reverse(ans.begin(), ans.end());
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
def modpow(m, n, mod):
    if n == 0:
        return 1

    return ((modpow(m, n//2, mod)**2 % mod) * m**(n & 1)) % mod

mod = 10**9 + 7

m, n = map(int, input().split())

print(modpow(m, n, mod))

Measured memory_bytes: 7736
#include<bits/stdc++.h>
#define N 500010
#define INF 1e9
#define int unsigned long long
//#define int __int128
#define rep(i, l, r) for(register int i = l;i <= r;++ i)
using namespace std;
inline int read()
{
	char cc = getchar(); int cn(0), flus(1);
	while(cc > '9' || cc < '0') {if(cc == '-') flus = -flus; cc = getchar();};
	while(cc >= '0' && cc <= '9') {cn = cn * 10 + cc - '0'; cc = getchar();};
	return flus * cn;
}
signed main()
{
	int n, a, b;
	n = read();
	a = read();
	b = read();
	int c;
	c = b - a;
	if(!(c - c / 2 * 2)) printf("%lld",c / 2);
	else printf("%lld",min((a + b - 1)>>1, ((n << 1) - a - b + 1) >> 1));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<utility>
#include<map>
typedef long long ll;
typedef unsigned long long ull;
typedef std::vector<long long > vi ;
#define F first
#define S second
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define PB push_back
#define MP make_pair
ll pow1(ll n,ll p)
{
	if(p==0)	return 1;
	ll x=pow1(n, p/2);
	x=(x*x)%mod;
	if(p%2==0)
		return x;
	else
		return (x*n)%mod;
}

using  namespace std;

int main()
{
    ll n;
    cin>>n;
    ll a[n],b[n],c[n],dp[n][3]={0},i,j;
    for(i=0;i<n;i++)
    {
        std::cin >> a[i]>>b[i]>>c[i];
        dp[i][0]=0;
        dp[i][1]=0;
        dp[i][2]=0;
        if(i==0)
        {
            dp[i][0]=a[i];
            dp[i][1]=b[i];
            dp[i][2]=c[i];
        }
        else
        {
            dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
            dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
            dp[i][2]=c[i]+max(dp[i-1][1],dp[i-1][0]);
        }
    }
    dp[n-1][0]=max(dp[n-1][1],dp[n-1][0]);
    std::cout << max(dp[n-1][2],dp[n-1][0]) << std::endl;
}

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

int main() {
    int n;
    cin>>n;
    int k;
    cin>>k;
    int arr[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
    }
    int dp[n+1];
    dp[1]=0;
    dp[2]=abs(arr[1]-arr[2]);
    for(int i=3;i<=n;i++)
    {
        dp[i]=INT_MAX;
        for(int j=1;j<=k&&i-j>=1;j++)
        {
            dp[i]=min(dp[i-j]+abs(arr[i-j]-arr[i]),dp[i]);
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 1024
from sys import stdin

def main():

    input = stdin.readline

    N = int(input())

    AC = 0
    WA = 0
    TLE = 0
    RE = 0


    for _ in range(N):
        s = str(input())[:-1]
        if s == "AC":
            AC += 1
        elif s == "WA":
            WA += 1
        elif s == "TLE":
            TLE += 1
        elif s == "RE":
            RE += 1



    print("AC x {}".format(AC))
    print("WA x {}".format(WA))
    print("TLE x {}".format(TLE))
    print("RE x {}".format(RE))


if __name__ == "__main__":
    main()

Measured memory_bytes: 9220
while gets
  w = $_.to_i
  n = gets.to_i
  a = Array.new

  for i in 1..w
    a.push(i)
  end

  for i in 1..n
    s = gets.split(",")
    x = s[0].to_i - 1
    y = s[1].to_i - 1
    a[x], a[y] = a[y], a[x]
  end

  for i in 0...w
    puts a[i]
  end
end

Measured memory_bytes: 2360
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using Enu = System.Linq.Enumerable;

public class Program
{
    public void Solve()
    {
        int N = Reader.Int(), K = Reader.Int();
        var A = Reader.IntArray(N);
        var sum = new long[N + 1];
        var positive = new long[N + 1];
        for (int i = 0; i < N; i++)
        {
            sum[i + 1] = sum[i] + A[i];
            positive[i + 1] = positive[i] + Math.Max(0, A[i]);
        }
        long ans = 0;
        for (int L = 0; L + K <= N; L++)
            ans = Math.Max(ans, Math.Max(0, sum[L + K] - sum[L]) +
                 positive[L] + positive[N] - positive[L + K]);

        Console.WriteLine(ans);
    }
}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    public static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    static string[] Split(string s) { return s.Split(separator, op); }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

Measured memory_bytes: 19408
#include <iostream>
#include<algorithm>
#include <stdio.h>
#include <string>
#include <string.h>
#include <map>
#include <math.h>
#include <vector>
#include <set>
#include <map>
#include <deque>
using namespace std;
typedef long long ll;
const int N=1e9+7;
const ll M=1e9+7;
struct sa
{
   char ch[100];
    int f;
    int x;
}p[200];
int main()
{
   int n;
   while(scanf("%d",&n)!=-1)
   {
       memset(p,0,sizeof(p));
       for(int i=1;i<=n;i++)
           scanf("%s %d",p[i].ch,&p[i].f),p[i].x=i;
       for(int i=1;i<n;i++)
           for(int j=0;j<=n-i;j++)
           {
               char str[100];
               int k,y;
               if(strcmp(p[j].ch,p[j+1].ch)>0)
               {
                   strcpy(str,p[j].ch);
                   strcpy(p[j].ch,p[j+1].ch);
                   strcpy(p[j+1].ch,str);
                   k=p[j].f,p[j].f=p[j+1].f,p[j+1].f=k;
                   y=p[j].x,p[j].x=p[j+1].x,p[j+1].x=y;
               }

           }
       for(int i=1;i<n;i++)
           for(int j=0;j<=n-i;j++)
           {
               char str[100];
               int k,y;
               if(strcmp(p[j].ch,p[j+1].ch)==0&&p[j].f<p[j+1].f)
               {
                   strcpy(str,p[j].ch);
                   strcpy(p[j].ch,p[j+1].ch);
                   strcpy(p[j+1].ch,str);
                   k=p[j].f,p[j].f=p[j+1].f,p[j+1].f=k;
                   y=p[j].x,p[j].x=p[j+1].x,p[j+1].x=y;
               }

           }
       for(int i=1;i<=n;i++)
          printf("%d\n",p[i].x);
   }
    return 0;
}


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

const int N=500005;
const int maxn=N*5;

int tot,a[maxn+5];
char str[N];

void mul(int x)
{
	int s,g=0;
	for (int i=maxn;i>=1;i--)
	{
		s=a[i]*x+g;
		a[i]=s%10;
		g=s/10;
	}
}

void add(int x)
{
	a[maxn]+=x;tot+=x;
	for (int i=maxn;i>=1&&a[i]>=10;i--)
	{
		tot-=a[i-1]+a[i];
		a[i-1]++;a[i]-=10;
		tot+=a[i-1]+a[i];
	}
}

int main()
{
	scanf("%s",str);
	int len=strlen(str);
	for (int i=0;i<len;i++) a[maxn-i]=str[len-i-1]-'0';
	mul(9);
	for (int i=1;i<=maxn;i++) tot+=a[i];
	for (int k=1;;k++)
	{
		add(9);
		if (k*9>=tot) {printf("%d",k);break;}
	}
	return 0;
}

Measured memory_bytes: 10496
#include <iostream>
#include <climits>
#include <cmath>

#define M 1000000007

using namespace std;

typedef struct {
  int l, r, u, d;
} D;

int d_r(char **map, D **d, int *ca, int *cb, int ch, int cw, int h, int w) {
  int end;
  
  if (cw >= w || map[ch][cw] == '#') {
    *cb = 0;
    return cw;
  }
    
  *ca += 1;
  end = d_r(map, d, ca, cb, ch, cw + 1, h, w);
  *ca -= 1;
  d[ch][cw].l = *ca;
  d[ch][cw].r = *cb;
  *cb += 1;
  return end;
}
  
int d_d(char **map, D **d, int *ca, int *cb, int ch, int cw, int h, int w) {
  int end;
  
  if (ch >= h || map[ch][cw] == '#') {
    *cb = 0;
    return ch;
  }
    
  *ca += 1;
  end = d_d(map, d, ca, cb, ch + 1, cw, h, w);
  *ca -= 1;
  d[ch][cw].u = *ca;
  d[ch][cw].d = *cb;
  *cb += 1;
  return end;
}
  

int main(void) {
  int h, w;
  int i, j, tmp1, tmp2;
  int ca, cb;
  char **map;
  D **d;
  int max = 0;
  
  cin >> h >> w;
  map = new char *[h];
  for (int i = 0; i < h; i++) map[i] = new char[w + 1];
  d = new D *[h];
  for (int i = 0; i < h; i++) d[i] = new D[w];

  for (int i = 0; i < h; i++)
    cin >> map[i];//, cout << map[i] << endl;

  for (int i = 0; i < h; i++) {
    j = 0;
    while (j < w) {
      ca = 0;
      //cout << "r :" << i << " , " << j << endl;
      if (map[i][j] != '#') {
        j = d_r(map, d, &ca, &cb, i, j, h, w) + 1;
      } else {
        j++;
      }
    }
  }
  
  for (int j = 0; j < w; j++) { 
    i = 0;
    while (i < h) {
      ca = 0;
      //cout << "d :" << i << " , " << j << endl;
      if (map[i][j] != '#') {
        tmp1 = d_d(map, d, &ca, &cb, i, j, h, w);
		/*tmp2 = 1 + d[i][j].l + d[i][j].r + d[i][j].u + d[i][j].d;
        cout << i << " , " << j << " :" << d[i][j].l << ","<< 
          d[i][j].r<<"<"<< d[i][j].u<<","<<d[i][j].d << endl;*/
        //max = max > tmp2 ? max : tmp2;
        //cout << tmp1 + 1 << endl;
        i = tmp1 + 1;
      } else {
        i++;
      }
    }
  }
  
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (map[i][j] == '.') {
        tmp1 = 1 + d[i][j].l + d[i][j].r + d[i][j].u + d[i][j].d;
        
        /*cout << i << " , " << j << " :" << d[i][j].l << ","<< 
          d[i][j].r<<"<"<< d[i][j].u<<","<<d[i][j].d << " : " << tmp1 << endl;*/
        max = max > tmp1 ? max : tmp1;
      }
    }
  }
  
  cout << max << endl;
  
  return 0;
}
  

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long
#define ALL(v) (v).begin(), (v).end()
typedef pair<int, int> P;
vector<P> hindo1(100000), hindo2(100000); /* マイナス1したやつにする */

int main(){
    int n;
    cin >> n;
    n /= 2;
    vector<int> gusu(n), kisu(n);


    REP(i, n) cin >> kisu[i] >> gusu[i];
    REP(i, n) {
        hindo1[gusu[i]-1].first++;
        hindo1[gusu[i]-1].second = gusu[i]-1;
    }
    REP(i, n) {
        hindo2[kisu[i]-1].first++;
        hindo2[kisu[i]-1].second = kisu[i]-1;
    }

    sort(hindo1.begin(), hindo1.end());
    reverse(hindo1.begin(), hindo1.end());
    sort(hindo2.begin(), hindo2.end());
    reverse(hindo2.begin(), hindo2.end());

    P ki, gu;
    ki.first = hindo1[0].first;
    ki.second = hindo1[0].second;
    gu.first = hindo2[0].first;
    gu.second = hindo2[0].second;

    P ki2, gu2;
    ki2.first = hindo1[1].first;
    ki2.second = hindo1[1].second;
    gu2.first = hindo2[1].first;
    gu2.second = hindo2[1].second;


    if(ki.second == gu.second) {
        int ans = INF;
        ans = min(ans, (n-ki.first)+(n-gu2.first));
        ans = min(ans, (n-ki2.first)+(n-gu.first));
        cout << ans << endl;
    } else {
        cout << (n - ki.first) + (n - gu.first) << endl;
    }

    return 0;
}


Measured memory_bytes: 2176
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

struct Solver {
	Solver() {
		ios::sync_with_stdio( false );
		cout << fixed << setprecision( 10 );
	}

	void solve() {
		int X;
		cin >> X;

		int a = X / 500;
		int b = (X - 500*a) / 5;
		int ans = 1000*a + 5*b;

		cout << ans << endl;
	}
};

int main() {
	Solver().solve();
	return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  string s;
  std::cin >> s;
  for(int i=0; i<s.size(); i++){
    if(i%2==0) std::cout << s[i];
  }
  std::cout  << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long int
#define ld long double
#define MOD 1000000007
#define N 1000006
#define INF 1000000000000000000
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define randright srand(chrono::steady_clock::now().time_since_epoch().count());

using namespace std;

ld sum=0;
ld num=0;
int n;
vector<pair<ld,ld>> coor;

ld dis(int i, int j){
    return sqrt( ((coor[j].first - coor[i].first)*(coor[j].first - coor[i].first)) + ((coor[j].second - coor[i].second)*(coor[j].second - coor[i].second)) );
}

void trav(vector<bool> visited, int curr, int don, ld curdis){
    //cout<<curr<<" "<<don<<"\n";
    if(don==n){
        sum += curdis;
        num++;
        return;
    }
    //cout<<"here"<<"\n";
    visited[curr]=true;
    //cout<<"here"<<"\n";
    for(int i=0;i<n;i++){
        if(!visited[i]){
            visited[i] = true;
            trav(visited, i, don+1, curdis + dis(curr,i) );
            visited[i] = false;
        }
    }
}

void solve(){
    cin>>n;
    coor.resize(n);
    for(int i=0;i<n;i++){
        cin>>coor[i].first>>coor[i].second;
    }
    vector<bool> visited(n,false);
    for(int i=0;i<n;i++){
        trav(visited, i, 1, 0);
    }
    cout<<(sum/num)<<"\n";
}

signed main(){
    cout<<setprecision(10)<<fixed;
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int n,m,a,b;
	scanf("%d %d",&n,&m);
	a=n>m?n:m;
	b=n>m?m:n;
	for(int i=0;i<a;i++)
		printf("%d",b);
	return 0;
}

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

using namespace std;

#define sz(v)           ((int)((v).size()))
#define clr(v, d)       memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0; i<sz(v); ++i)
#define lp(i, n)        for(int i=0; i<(int)(n); ++i)
#define lpi(i, j, n)    for(int i=(j); i<(int)(n); ++i)
#define lpd(i, j, n)    for(int i=(j); i>=(int)(n); --i)
#define INF             1000000000

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

void init(){
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

const int N = 1e5+5;
int nxt_idx[N][30];

int main()
{
	init();
	ll ans = 0;
	string s, t;
	cin >> s >> t;
	int s_siz = s.size(), t_siz = t.size();
	lp(i, 30){
		nxt_idx[s_siz-1][i] = -1;
	}
	lp(i, s_siz){
		if(nxt_idx[s_siz-1][s[i]-'a'] == -1)
			nxt_idx[s_siz-1][s[i]-'a'] = i;
	}
	lpd(i, s_siz-2, 0){
		lp(j, 26){
			nxt_idx[i][j] = nxt_idx[i+1][j];
		}
		nxt_idx[i][s[i+1] - 'a'] = i+1;
	}
	int cur = s_siz-1, nxt;
	lp(i, t_siz){
		nxt = nxt_idx[cur][t[i] - 'a'];
		if(nxt == -1){
			cout << -1;
			return 0;
		}
		if(nxt > cur)
			ans += nxt - cur;
		else
			ans += (s_siz - cur) + nxt;
		cur = nxt;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 12240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
#define REP(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for(ll (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); (i)++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define _GLIBCXX_DEBUG

template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<1000000007>;

const double PI = 3.14159265358979323846;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  ret[2] = 0;
  ret[3] = 0;
  ret[5] = 0;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main()
{	
    int k;
    cin >> k;
    queue<ll> q;

    REP(i, 9) q.push(i+1);
    //k-1回ループするとq.front()はk個目の値となる
    REP(i, k-1){
        ll s = q.front();
        q.pop();
        FOR(j, -1, 2){
            ll add = (s % 10) + j;
            if (add >= 0 && add <= 9) q.push(s * 10 + add);
        }
    }
    cout << q.front() << endl;
}


Measured memory_bytes: 5100
#include <bits/stdc++.h>
#include "atcoder/all"

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll K;
    cin >> K;
    REP(i, K) {
        cout << "ACL";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
 
int main()
{
	while (1){
		int steps = 1;
		int n, m;
		cin >> n >> m;
		if (!n and !m) return 0;
		int masu[n];
		int order[m];
		REP(i, n) cin >> masu[i];
		REP(i, m) cin >> order[i];
		int current = 0;
		REP(i, m){
			int tmp = order[i];
			current += tmp;
			if (current+1 >= n) break;

			current += masu[current];
			if (current+1 >= n) break;
			steps++;
		}

		cout << steps << endl;
	}


			
}



Measured memory_bytes: 3104
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  int n, m;
  cin >> n >> m;
  vector<vi> t(n);
  rep(i, m){
    int a, b;
    cin >> a >> b;
    a--;b--;
    t[a].push_back(b);
    t[b].push_back(a);
  }

  vi ans(n, -1);  
  ans[0] = 0;
  queue<int> q;
  rep(i, (int) t[0].size()){
    ans[t[0][i]] = 0;
    q.push(t[0][i]);
  }

  // cout << "ans: ";
  // rep(k, n) cout << ans[k] << " ";
  // cout << endl;
  while(!q.empty()){
    queue<int> nq;
    while(!q.empty()){
      int now = q.front();q.pop();
      rep(i, (int)t[now].size()){
        if(ans[t[now][i]] == -1){
          ans[t[now][i]] = now;
          nq.push(t[now][i]);
        }
      }
    }
    // cout << "ans: ";
    // rep(k, n) cout << ans[k] << " ";
    // cout << endl;
    q = nq;
  }

  for(int i=1;i<n;i++){
    if (ans[i] == -1){
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  for(int i=1;i<n;i++){
    cout << ans[i] + 1 << endl;
  }


  return 0;
}

Measured memory_bytes: 10308
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.LinkedList;
import java.util.Queue;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Spandan Mishra
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DLunlunNumber solver = new DLunlunNumber();
        solver.solve(1, in, out);
        out.close();
    }

    static class DLunlunNumber {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int k = in.readInt();
            Queue<Long> q = new LinkedList<>();
            for (int i = 1; i <= 9; i++)
                q.add(i * 1L);
            long x = 0;
            for (int i = 0; i < k; i++) {
                x = q.poll();
                long r = x % 10;

                if (r > 0)
                    q.add(10 * x + r - 1);
                q.add(10 * x + r);
                if (r < 9)
                    q.add(10 * x + r + 1);
            }

            System.out.println(x);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new RuntimeException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new RuntimeException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 36044
import java.util.Scanner;

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

    for (int i = 1; i <= n; ++i) {
      if (i % 3 == 0) System.out.print(" " + i);
      else {
        int temp = i;
        while (temp > 0) {
          if (temp % 10 == 3) { System.out.print(" " + i); break; }
          temp /= 10;
        }
      }
    }

    System.out.println();
  }
}


Measured memory_bytes: 28736
//@formatter:off
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define rrep(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = int(s); i < int(n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<P>
#define vvp vector<vector<P>>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==int(v.size()-1)?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << '\n'; }
void YES(bool b) { cout << (b ? "YES" : "NO") << '\n'; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;
//@formatter:on

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n,q;
    cin >> n >> q;
    vi c(n);
    cin >> c;
    rep(i,n) c[i]--;
    vi l(q),r(q);
    rep(i,q) cin >> l[i] >> r[i];
    rep(i,q) {
        l[i]--;
        r[i]--;
    }
    int d = sqrt(n)+1;
    auto cmp = [&](int a,int b) {
        if(l[a]/d < l[b]/d) return true;
        return l[a] / d == l[b] / d and r[a] < r[b];
    };
    vi ord(q);
    iota(all(ord),0);
    sort(all(ord),cmp);
    int nl = l[ord[0]],nr = r[ord[0]];
    vi ans(q);
    int sum = 0;
    vi v(n);
    auto erase = [&](int i) {
        if(--v[i] == 0) {
            sum--;
        }
    };
    auto add = [&](int i) {
        if(v[i]++ == 0) sum++;
    };
    for(int i = nl; i <= nr; i++) add(c[i]);
    ans[ord[0]] = sum;
    rep2(i,1,q) {
        if(nl <= l[ord[i]]) {
            while(nl < l[ord[i]]) {
                erase(c[nl++]);
            }
        } else {
            while(nl > l[ord[i]]) {
                add(c[--nl]);
            }
        }
        if(nr >= r[ord[i]]) {
            while(nr > r[ord[i]]) {
                erase(c[nr--]);
            }
        } else {
            while(nr < r[ord[i]]) {
                add(c[++nr]);
            }
        }
        ans[ord[i]] = sum;
    }
    rep(i,q) cout << ans[i] << '\n';
}


Measured memory_bytes: 15472
/* generated by esotope-bfc */
#include <stdio.h>
#include <stdint.h>
#define GETC() (fflush(stdout), fgetc(stdin))
#define PUTC(c) fputc(c, stdout)
#define PUTS(s) fwrite(s, 1, sizeof(s)-1, stdout)
static uint8_t m[30000], *p = m;
int main(void) {
        p[5] = GETC();
        p[5] -= 10;
        p[4] = 0;
        p[6] = 0;
        while (p[5]) {
                p[4] += 10;
                p[5] -= 10*p[4]+1;
                p[4] = 0;
                if (p[5]) {
                        ++p[6];
                        p[5] = 0;
                }
                p[5] = GETC();
                p[5] -= 10;
        }
        p[5] = 7;
        p[7] = 10;
        while (p[5]) {
                while (p[6]) {
                        --p[6];
                        p += 2;
                }
                while (p[7] != 0) p += 2;
                --p[3];
                p -= 2;
        }
        while (p[6]) {
                p[8] += 8*p[7]-2;
                p[7] = 0;
                PUTC(p[8]);
                ++p[8];
                PUTC(p[8]);
                p[8] = 0;
                p += 2;
        }
        while (p[7]) {
                p[8] += 9*p[7]-1;
                p[9] += 7*p[7]-1;
                p[7] = 0;
                PUTC(p[8]);
                PUTC(p[9]);
                p[8] -= 6;
                PUTC(p[8]);
                p[8] = 0;
                ++p;
        }
        PUTS("\n");
        return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

int main() {
  int N, P; cin >> N >> P;
  vector<int> A(N); cin >> A;
  int even = 0, odd = 0;
  for (int x : A) {
    if (x % 2 == 0) ++even;
    else            ++odd;
  }

  if (odd == 0) {
    if (P == 0) {
      cout << (1LL << N) << endl;
    } else {
      cout << 0 << endl;
    }
  } else {
    cout << (1LL << (N-1)) << endl;
  }
}


Measured memory_bytes: 3604
#include <iostream>

using namespace std;

int main(){
        int N, T, E;
        cin >> N >> T >> E;
        int answer = -1;
        for(int i = 0; i < N; ++i){
                int x;
                cin >> x;
                int m = T % x;
                if(m <= E || x - E <= m){ answer = i + 1; }
        }
        cout << answer << endl;
        return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < n; i++) 
using namespace std;
typedef long long ll;

int main() {
  
  int w, a, b;
  cin >> w >> a >> b;
  
  int c = abs(a-b);
  
  if (c <= w) cout << 0 << endl;
  else cout << c-w << endl;
  
}

Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <map>

#define mp make_pair

using namespace std;
typedef pair<int,int> pii;
 
int main() {
  int H, W;
  cin >> H >> W;
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  vector<pii> P;
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      P.push_back(mp(i, j));
    }
    i++;
    for(int j = W - 1; j >= 0; j--) {
      P.push_back(mp(i, j));
    }
  }

  int nowc = 0;
  vector<vector<int>> ans(H, vector<int>(W, 0));
  for (int i = 0; i < H * W; i++) {
    if (A[nowc] == 0) nowc++;
    A[nowc]--;
    ans[P[i].first][P[i].second] = nowc + 1;
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << ans[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 512
//AtCoder ABC092 B - Chocolate
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    ll N;
    cin>>N;
    ll D,X;
    cin>>D>>X;
    vector<ll> an(N);
    for(auto&& a:an){
        cin>>a;
    }
    ll ans=X;
    for(const auto& a:an){
        ans+=(D-1)/a+1;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<numeric>
#include<complex>
#define inf 0x3f3f3f3f3f3f3f3f
#define fi first
#define se second
#define pb push_back
#define ll long long
#define pii pair<int,int> 
const int N=1e6+10;
const int mod=998244353;
using namespace std;

pii p[N];
void solve(){
    int x,y,a,b,c; scanf("%d%d%d%d%d",&x,&y,&a,&b,&c);
    for(int i=1;i<=a;++i) scanf("%d",&p[i].fi),p[i].se=1;
    for(int i=1;i<=b;++i) scanf("%d",&p[i+a].fi),p[i+a].se=2;
    for(int i=1;i<=c;++i) scanf("%d",&p[i+a+b].fi);
    sort(p+1,p+1+a+b+c);
    int g=0,h=0,l=0;
    ll ans=0;
    for(int i=a+b+c;i>=1&&g<x+y;--i){
        if(p[i].se==1){
            if(h<x) g++,h++,ans+=p[i].fi;
        } else if(p[i].se==2){
            if(l<y) l++,g++, ans+=p[i].fi;
        } else {
            ans+=p[i].fi; g++;
        }
        //cout<<g<<" "<<p[i].fi<<endl;
    }
    printf("%lld\n",ans);
}
int main() 
{
    int _=1;  //scanf("%d",&_);
    while(_--) solve();
return 0;
}
/*
2 1
1 2
*/




Measured memory_bytes: 4352
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値

using namespace std;
using ll = long long int;

int main(void){
    string s;cin>>s;
    if(s[2]==s[3]&&s[4]==s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

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

  string A, B;
  cin >> A >> B;
  int N = A.size(), M = B.size();
  if (N > M) {
    cout << "GREATER" << endl;
  }
  else if (N < M) {
    cout << "LESS" << endl;
  }
  else if(A > B) {
    cout << "GREATER" << endl;
  }
  else if(A < B) {
    cout << "LESS" << endl;
  }
  else {
    cout << "EQUAL" << endl;
  }
  return 0;
}


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

#define PI 3.14159265358979323846264338327950L

int main() {
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  
  long double rad = PI * 2 * ((long double)H / 12.0 + ((long double)M / 60.0) /12.0 -(long double)M / 60.0);
  
  long double rsq = (long double)(A * A + B * B) - (long double)(2 * A * B) * cos(rad);

 
  printf("%20.20Lf\n", sqrtl(rsq));
}

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

using namespace std;

int main()
{
	int n, a, b;
	scanf("%d %d %d", &n, &a, &b);

	if(abs(n - a) <= abs(n - b))
		printf("A\n");
	else
		printf("B\n");

	return 0;
}


Measured memory_bytes: 256
from functools import reduce
import math
import itertools

def main():
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N,M = (int(_) for _ in input().split())
    a = []
    b = []
    for i in range(M):
        c, d = (int(_) for _ in input().split())
        a.append(c)
        b.append(d)
    l = list(_ for _ in range(2,N+1))
    d = []
    for elem in itertools.permutations(l,len(l)):
        elem = list(elem)
        elem.insert(0,1)
        d.append(elem)
    ans = 0
    for l1 in d:
        flag = True
        for i in range(len(l1)-1):
            for j in range(M):
                if(a[j]==l1[i] and b[j] ==l1[i+1]) or (b[j]==l1[i] and a[j] ==l1[i+1]):
                    flag = True
                    break
                flag = False
            if flag == False:
                break
        if flag:
            ans += 1

    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 4324
from collections import Counter
n=int(input())
a=[int(i) for i in input().split()]

o=[]
e=[]


for i in range(n):
    if i%2==1:
        o.append(a[i])
    else:
        e.append(a[i])

oc = Counter(o)
ec = Counter(e)

ok=[]
ek=[]
ol=[]
el=[]
for word, cnt in oc.most_common():
    ok.append(cnt)
    ol.append(word)
for word, cnt in ec.most_common():
    ek.append(cnt)
    el.append(word)

if len(ok)==1:
    ok.append(0)
if len(ek)==1:
    ek.append(0)
if el[0]!=ol[0]:
    print(n-ok[0]-ek[0])
else:
    print(min(n-ok[1]-ek[0],n-ok[0]-ek[1]))


Measured memory_bytes: 20568
n, m = map(int, input().split())
a = []
for i in range(m):
  a.append(int(input()))
# 0: 1, 1: 1, 2: 2(1+1, 2), 3: 3(1+1+1, 1+2, 2+1)
# dp[i] = dp[i-1] + dp[i-2]
dp = [0]*(n+1)
dp[0] = 1
for i in range(m):
  dp[a[i]] = -1
for i in range(n):
  if dp[i] == -1:
    continue
  if dp[i+1] != -1:
    dp[i+1] += dp[i]
    dp[i+1] %= 10**9+7
  if i+2 != n+1:
    if dp[i+2] != -1:
      dp[i+2] += dp[i]
      dp[i+2] %= 10**9+7
print(dp[n])

Measured memory_bytes: 7848
#include<bits/stdc++.h>
#define me(a,x) memset(a,x,sizeof(a))
#define sc scanf
#define itn int
using namespace std;
const int N=1e6;
const long long mod=1e9+7;
const int oo=0x7fffffff;
const int sup=0x80000000;
typedef long long ll;
typedef unsigned long long ull;
template <typename it>void db(it *begin,it *end){while(begin!=end)cout<<(*begin++)<<" ";puts("");}
template <typename it>
string to_str(it n){string s="";while(n)s+=n%10+'0',n/=10;reverse(s.begin(),s.end());return s;}
template <typename it>int o(it a){cout<<a<<endl;return 0;}
ll mul(ll a,ll b,ll c){ll ans=0;for(;b;b>>=1,a=(a+a)%c)if(b&1)ans=(ans+a)%c;return ans;}
ll ksm(ll a,ll b,ll c){ll ans=1;for(;b;b>>=1,a=mul(a,a,c))if(b&1)ans=mul(ans,a,c);return ans;}
int n,d[N];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>d[i];
	sort(d+1,d+n+1);
	o(d[n/2+1]-d[n/2]);
}

Measured memory_bytes: 768
# https://atcoder.jp/contests/abc099/tasks/abc099_c
# 典型的なコイン問題

# 引き出す金額の候補はNによって動的に決定する。
# dp[i] を i 円引き出すのに最小の操作回数とする
# dp[i] = min_{j \in 引き出し額}(dp[i - j]) +1 なので更新できる

# 今回は実装の都合上集めるdpではなく配るdpで実装する


def full(shape, full_value):
    if isinstance(shape, tuple):
        sha = shape[::-1]
        ret = [full_value] * sha[0]
        for s in sha[1:]:
            ret = [ret.copy() for i in range(s)]
        return ret

        if len(shape) == 2:
            return [[full_value] * shape[1] for _ in range(shape[0])]
    else:
        return [full_value] * shape


INF = 10**9

N = int(input())
candi = [1]
i = 1
while 6 ** i <= N:
    candi.append(6**i)
    i += 1

i = 1
while 9 ** i <= N:
    candi.append(9**i)
    i += 1

candi.sort()

dp = full(N + 1, INF)
dp[0] = 0  # 初期化

for i in range(N):
    for j in candi:
        if i + j > N:
            continue
        dp[i + j] = min(dp[i + j], dp[i] + 1)

print(dp[-1])


Measured memory_bytes: 3828